-
-
Save callmephil/ba6467fe1e8f2830809f to your computer and use it in GitHub Desktop.
[Merging - Mangos->TC] Talent Template learning.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt | |
index bf46c1f..a08b2e7 100644 | |
--- a/src/server/game/CMakeLists.txt | |
+++ b/src/server/game/CMakeLists.txt | |
@@ -48,6 +48,7 @@ file(GLOB_RECURSE sources_Tickets Tickets/*.cpp Tickets/*.h) | |
file(GLOB_RECURSE sources_Warden Warden/*.cpp Warden/*.h) | |
file(GLOB_RECURSE sources_Weather Weather/*.cpp Weather/*.h) | |
file(GLOB_RECURSE sources_World World/*.cpp World/*.h) | |
+file(GLOB_RECURSE sources_Custom Custom/*.cpp Custom/*.h) | |
# Create game-libary | |
@@ -98,6 +99,7 @@ set(game_STAT_SRCS | |
${sources_Warden} | |
${sources_Weather} | |
${sources_World} | |
+ ${sources_Custom} | |
) | |
include_directories( | |
@@ -194,6 +196,7 @@ include_directories( | |
${CMAKE_CURRENT_SOURCE_DIR}/Warden/Modules | |
${CMAKE_CURRENT_SOURCE_DIR}/Weather | |
${CMAKE_CURRENT_SOURCE_DIR}/World | |
+ ${CMAKE_CURRENT_SOURCE_DIR}/Custom | |
${CMAKE_SOURCE_DIR}/src/server/scripts/PrecompiledHeaders | |
${ACE_INCLUDE_DIR} | |
${MYSQL_INCLUDE_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Custom.h" | |
#include "Log.h" | |
#include "ObjectMgr.h" | |
#include "Database\DatabaseEnv.h" | |
#include "World.h" | |
#include "Log.h" | |
#include "SocialMgr.h" | |
#include "GossipDef.h" | |
#include "Player.cpp" | |
Custom::~Custom() | |
{ | |
for (TalentContainer::const_iterator itr = m_TalentContainer.begin(); itr != m_TalentContainer.end(); ++itr) | |
delete *itr; | |
} | |
void Custom::LoadTalentContainer() | |
{ | |
for (TalentContainer::const_iterator itr = m_TalentContainer.begin(); itr != m_TalentContainer.end(); ++itr) | |
delete *itr; | |
m_TalentContainer.clear(); | |
uint32 count = 0; | |
QueryResult result = WorldDatabase.PQuery("SELECT class, spec, id, rank FROM talenttemplates"); | |
if (result) | |
{ | |
do | |
{ | |
Field* fields = result->Fetch(); | |
TalentTemplate* pTalent = new TalentTemplate; | |
pTalent->ClassId = fields[0].GetUInt8(); | |
pTalent->SpecId = fields[1].GetUInt8(); | |
pTalent->TalentId = fields[2].GetUInt32(); | |
pTalent->TalentRank = fields[3].GetUInt8(); | |
m_TalentContainer.push_back(pTalent); | |
++count; | |
} while (result->NextRow()); | |
//delete result->Fetch; | |
} | |
TC_LOG_ERROR("TC_LOG_ERROR", "Loaded %u talents", count); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _CUSTOM_H | |
#define _CUSTOM_H | |
#include "Player.h" | |
#include "Creature.h" | |
#define MSG_COLOR_LIGHTRED "|cffff6060" | |
#define MSG_COLOR_LIGHTBLUE "|cff00ccff" | |
#define MSG_COLOR_ANN_GREEN "|c1f40af20" | |
#define MSG_COLOR_RED "|cffff0000" | |
#define MSG_COLOR_GOLD "|cffffcc00" | |
#define MSG_COLOR_SUBWHITE "|cffbbbbbb" | |
#define MSG_COLOR_MAGENTA "|cffff00ff" | |
#define MSG_COLOR_YELLOW "|cffffff00" | |
#define MSG_COLOR_CYAN "|cff00ffff" | |
#define MSG_COLOR_DARKBLUE "|cff0000ff" | |
#define MSG_COLOR_GREY "|cff9d9d9d" | |
#define MSG_COLOR_WHITE "|cffffffff" | |
#define MSG_COLOR_GREEN "|cff1eff00" | |
#define MSG_COLOR_BLUE "|cff0080ff" | |
#define MSG_COLOR_PURPLE "|cffb048f8" | |
#define MSG_COLOR_ORANGE "|cffff8000" | |
#define MSG_COLOR_DRUID "|cffff7d0a" | |
#define MSG_COLOR_HUNTER "|cffabd473" | |
#define MSG_COLOR_MAGE "|cff69ccf0" | |
#define MSG_COLOR_PALADIN "|cfff58cba" | |
#define MSG_COLOR_PRIEST "|cffffffff" | |
#define MSG_COLOR_ROGUE "|cfffff569" | |
#define MSG_COLOR_SHAMAN "|cff0070de" | |
#define MSG_COLOR_WARLOCK "|cff9482c9" | |
#define MSG_COLOR_WARRIOR "|cffc79c6e" | |
struct TalentTemplate | |
{ | |
uint8 ClassId; | |
uint8 SpecId; | |
uint32 TalentId; | |
uint8 TalentRank; | |
}; | |
typedef std::vector<TalentTemplate*> TalentContainer; | |
class Custom | |
{ | |
public: | |
Custom(); | |
~Custom(); | |
void LoadTalentContainer(); | |
TalentContainer::const_iterator GetTalentContainerBegin() { return m_TalentContainer.begin(); } | |
TalentContainer::const_iterator GetTalentContainerEnd() { return m_TalentContainer.end(); } | |
private: | |
TalentContainer m_TalentContainer; | |
}; | |
class Custom_UnitExtension { | |
public: | |
Custom_UnitExtension(Unit* unit); | |
~Custom_UnitExtension(); | |
private: | |
Unit* _unit; | |
}; | |
class Custom_PlayerExtension : public Custom_UnitExtension { | |
public: | |
Custom_PlayerExtension(Player* player); | |
~Custom_PlayerExtension(); | |
// Talent | |
// void LearnTalentTemplate(uint8 spec); | |
private: | |
Player* _player; | |
}; | |
#define sCustom ACE_Singleton<Custom, ACE_Null_Mutex>::instance() | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp | |
index d964397..0fd2239 100644 | |
--- a/src/server/game/Entities/Player/Player.cpp | |
+++ b/src/server/game/Entities/Player/Player.cpp | |
@@ -78,6 +78,7 @@ | |
#include "WorldPacket.h" | |
#include "WorldSession.h" | |
#include "GameObjectAI.h" | |
+#include "Custom.h" | |
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS) | |
@@ -26706,3 +26707,13 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy | |
return pet; | |
} | |
+ | |
+void Player::LearnTalentTemplate(uint8 spec) | |
+{ | |
+ for (TalentContainer::const_iterator itr = sCustom->GetTalentContainerBegin(); itr != sCustom->GetTalentContainerEnd(); ++itr) | |
+ { | |
+ if ((*itr)->ClassId == getClass() && (*itr)->SpecId == spec) | |
+ LearnTalent((*itr)->TalentId, (*itr)->TalentRank - 1); | |
+ } | |
+} | |
+ | |
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h | |
index 2eb740f..cecf564 100644 | |
--- a/src/server/game/Entities/Player/Player.h | |
+++ b/src/server/game/Entities/Player/Player.h | |
@@ -1590,6 +1590,10 @@ class Player : public Unit, public GridObject<Player> | |
void LearnTalent(uint32 talentId, uint32 talentRank); | |
void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank); | |
+ // Custom | |
+ void LearnTalentTemplate(uint8 spec); | |
+ // Custom | |
+ | |
bool AddTalent(uint32 spellId, uint8 spec, bool learning); | |
bool HasTalent(uint32 spell_id, uint8 spec) const; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment