diff options
Diffstat (limited to 'src')
395 files changed, 4746 insertions, 3925 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index 840cdc4be60..ad6bcf76c08 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -17,7 +17,8 @@ #endif _TRINITY_SCRIPT_CONFIG //*** Global data *** -int nrscripts; +int num_db_scripts; +int num_sc_scripts; Script *m_scripts[MAX_SCRIPTS]; DatabaseType TScriptDB; @@ -47,7 +48,6 @@ enum ChatType // Text Maps UNORDERED_MAP<int32, StringTextData> TextMap; - //*** End Global data *** //*** EventAI data *** @@ -1180,15 +1180,16 @@ struct TSpellSummary { TRINITY_DLL_EXPORT void ScriptsFree() -{ +{ // Free Spell Summary delete []SpellSummary; // Free resources before library unload - for(int i=0;i<nrscripts;i++) + for(int i=0;i<num_db_scripts;i++) delete m_scripts[i]; - nrscripts = 0; + num_db_scripts = 0; + num_sc_scripts = 0; } TRINITY_DLL_EXPORT @@ -1239,12 +1240,13 @@ void ScriptsInit() if (CanLoadDB) LoadDatabase(); + num_db_scripts = GetScriptNames().size(); + outstring_log("TSCR: Loading C++ scripts"); barGoLink bar(1); bar.step(); outstring_log(""); - nrscripts = 0; for(int i=0;i<MAX_SCRIPTS;i++) m_scripts[i]=NULL; @@ -1775,8 +1777,7 @@ void ScriptsInit() // ------------------- - outstring_log("TSCR: Loaded %u C++ Scripts", nrscripts); - outstring_log(""); + outstring_log(">> Loaded %i C++ Scripts (of %i ScriptNames defined in Mangos database)", num_sc_scripts, num_db_scripts); } //********************************* @@ -1848,32 +1849,29 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) //********************************* //*** Functions used internally *** -TRINITY_DLL_EXPORT -char const* ScriptsVersion() +void Script::RegisterSelf() { - return "Default Trinity scripting library"; -} - -Script* GetScriptByName(std::string Name) -{ - if (Name.empty()) - return NULL; - - for(int i=0;i<MAX_SCRIPTS;i++) + int id = GetScriptId(Name.c_str()); + if (id != 0) { - if (m_scripts[i] && m_scripts[i]->Name == Name) - return m_scripts[i]; - } - return NULL; + m_scripts[id] = this; + ++num_sc_scripts; + } else + debug_log("SD2: RegisterSelf, but script named %s does not have ScriptName assigned in database.",(this)->Name.c_str()); } //******************************** //*** Functions to be Exported *** TRINITY_DLL_EXPORT +char const* ScriptsVersion() +{ + return "Default Trinity scripting library"; +} +TRINITY_DLL_EXPORT bool GossipHello ( Player * player, Creature *_Creature ) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pGossipHello) return false; player->PlayerTalkClass->ClearMenus(); @@ -1885,7 +1883,7 @@ bool GossipSelect( Player *player, Creature *_Creature, uint32 sender, uint32 ac { debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action); - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pGossipSelect) return false; player->PlayerTalkClass->ClearMenus(); @@ -1897,7 +1895,7 @@ bool GossipSelectWithCode( Player *player, Creature *_Creature, uint32 sender, u { debug_log("TSCR: Gossip selection with code, sender: %d, action: %d",sender, action); - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false; player->PlayerTalkClass->ClearMenus(); @@ -1907,7 +1905,7 @@ bool GossipSelectWithCode( Player *player, Creature *_Creature, uint32 sender, u TRINITY_DLL_EXPORT bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest ) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pQuestAccept) return false; player->PlayerTalkClass->ClearMenus(); @@ -1917,7 +1915,7 @@ bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest ) TRINITY_DLL_EXPORT bool QuestSelect( Player *player, Creature *_Creature, Quest const *_Quest ) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pQuestSelect) return false; player->PlayerTalkClass->ClearMenus(); @@ -1927,7 +1925,7 @@ bool QuestSelect( Player *player, Creature *_Creature, Quest const *_Quest ) TRINITY_DLL_EXPORT bool QuestComplete( Player *player, Creature *_Creature, Quest const *_Quest ) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pQuestComplete) return false; player->PlayerTalkClass->ClearMenus(); @@ -1937,7 +1935,7 @@ bool QuestComplete( Player *player, Creature *_Creature, Quest const *_Quest ) TRINITY_DLL_EXPORT bool ChooseReward( Player *player, Creature *_Creature, Quest const *_Quest, uint32 opt ) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pChooseReward) return false; player->PlayerTalkClass->ClearMenus(); @@ -1947,7 +1945,7 @@ bool ChooseReward( Player *player, Creature *_Creature, Quest const *_Quest, uin TRINITY_DLL_EXPORT uint32 NPCDialogStatus( Player *player, Creature *_Creature ) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pNPCDialogStatus) return 100; player->PlayerTalkClass->ClearMenus(); @@ -1957,8 +1955,8 @@ uint32 NPCDialogStatus( Player *player, Creature *_Creature ) TRINITY_DLL_EXPORT uint32 GODialogStatus( Player *player, GameObject *_GO ) { - Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName); - if(!tmpscript || !tmpscript->pGODialogStatus) return 100; + Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId]; + if (!tmpscript || !tmpscript->pGODialogStatus) return 100; player->PlayerTalkClass->ClearMenus(); return tmpscript->pGODialogStatus(player,_GO); @@ -1967,7 +1965,7 @@ uint32 GODialogStatus( Player *player, GameObject *_GO ) TRINITY_DLL_EXPORT bool ItemHello( Player *player, Item *_Item, Quest const *_Quest ) { - Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName); + Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId]; if (!tmpscript || !tmpscript->pItemHello) return false; player->PlayerTalkClass->ClearMenus(); @@ -1977,7 +1975,7 @@ bool ItemHello( Player *player, Item *_Item, Quest const *_Quest ) TRINITY_DLL_EXPORT bool ItemQuestAccept( Player *player, Item *_Item, Quest const *_Quest ) { - Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName); + Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId]; if (!tmpscript || !tmpscript->pItemQuestAccept) return false; player->PlayerTalkClass->ClearMenus(); @@ -1987,7 +1985,7 @@ bool ItemQuestAccept( Player *player, Item *_Item, Quest const *_Quest ) TRINITY_DLL_EXPORT bool GOHello( Player *player, GameObject *_GO ) { - Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName); + Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId]; if (!tmpscript || !tmpscript->pGOHello) return false; player->PlayerTalkClass->ClearMenus(); @@ -1997,7 +1995,7 @@ bool GOHello( Player *player, GameObject *_GO ) TRINITY_DLL_EXPORT bool GOQuestAccept( Player *player, GameObject *_GO, Quest const *_Quest ) { - Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName); + Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId]; if (!tmpscript || !tmpscript->pGOQuestAccept) return false; player->PlayerTalkClass->ClearMenus(); @@ -2007,7 +2005,7 @@ bool GOQuestAccept( Player *player, GameObject *_GO, Quest const *_Quest ) TRINITY_DLL_EXPORT bool GOChooseReward( Player *player, GameObject *_GO, Quest const *_Quest, uint32 opt ) { - Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName); + Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId]; if (!tmpscript || !tmpscript->pGOChooseReward) return false; player->PlayerTalkClass->ClearMenus(); @@ -2017,9 +2015,7 @@ bool GOChooseReward( Player *player, GameObject *_GO, Quest const *_Quest, uint3 TRINITY_DLL_EXPORT bool AreaTrigger( Player *player, AreaTriggerEntry * atEntry) { - Script *tmpscript = NULL; - - tmpscript = GetScriptByName(GetAreaTriggerScriptNameById(atEntry->id)); + Script *tmpscript = m_scripts[GetAreaTriggerScriptId(atEntry->id)]; if (!tmpscript || !tmpscript->pAreaTrigger) return false; return tmpscript->pAreaTrigger(player, atEntry); @@ -2028,16 +2024,16 @@ bool AreaTrigger( Player *player, AreaTriggerEntry * atEntry) TRINITY_DLL_EXPORT CreatureAI* GetAI(Creature *_Creature) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); - + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->GetAI) return NULL; + return tmpscript->GetAI(_Creature); } TRINITY_DLL_EXPORT bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets) { - Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName); + Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId]; if (!tmpscript || !tmpscript->pItemUse) return false; return tmpscript->pItemUse(player,_Item,targets); @@ -2046,7 +2042,7 @@ bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets) TRINITY_DLL_EXPORT bool ReceiveEmote( Player *player, Creature *_Creature, uint32 emote ) { - Script *tmpscript = GetScriptByName(_Creature->GetScriptName()); + Script *tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pReceiveEmote) return false; return tmpscript->pReceiveEmote(player, _Creature, emote); @@ -2055,12 +2051,10 @@ bool ReceiveEmote( Player *player, Creature *_Creature, uint32 emote ) TRINITY_DLL_EXPORT InstanceData* CreateInstanceData(Map *map) { - Script *tmpscript = NULL; - - if (!map->IsDungeon()) return false; + if (!map->IsDungeon()) return NULL; - tmpscript = GetScriptByName(((InstanceMap*)map)->GetScript()); - if (!tmpscript || !tmpscript->GetInstanceData) return false; + Script *tmpscript = m_scripts[((InstanceMap*)map)->GetScriptId()]; + if (!tmpscript || !tmpscript->GetInstanceData) return NULL; return tmpscript->GetInstanceData(map); } diff --git a/src/bindings/scripts/ScriptMgr.h b/src/bindings/scripts/ScriptMgr.h index 83b2c0dd7a0..ef7bdfd3cce 100644 --- a/src/bindings/scripts/ScriptMgr.h +++ b/src/bindings/scripts/ScriptMgr.h @@ -24,46 +24,45 @@ class Map; class Unit; class WorldObject; -#define MAX_SCRIPTS 1000 //72 bytes each (approx 71kb) +#define MAX_SCRIPTS 5000 //72 bytes each (approx 351kb) #define VISIBLE_RANGE (166.0f) //MAX visible range (size of grid) #define DEFAULT_TEXT "<Trinity Script Text Entry Missing!>" struct Script { Script() : -pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL), -pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL), -pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL), -pGOChooseReward(NULL),pReceiveEmote(NULL),pItemUse(NULL), GetAI(NULL), GetInstanceData(NULL) -{} + pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL), + pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL), + pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL), + pGOChooseReward(NULL),pReceiveEmote(NULL),pItemUse(NULL), GetAI(NULL), GetInstanceData(NULL) + {} -std::string Name; + std::string Name; -// Quest/gossip Methods to be scripted -bool (*pGossipHello )(Player*, Creature*); -bool (*pQuestAccept )(Player*, Creature*, Quest const* ); -bool (*pGossipSelect )(Player*, Creature*, uint32 , uint32 ); -bool (*pGossipSelectWithCode)(Player*, Creature*, uint32 , uint32 , const char* ); -bool (*pQuestSelect )(Player*, Creature*, Quest const* ); -bool (*pQuestComplete )(Player*, Creature*, Quest const* ); -uint32 (*pNPCDialogStatus )(Player*, Creature* ); -uint32 (*pGODialogStatus )(Player *player, GameObject * _GO ); -bool (*pChooseReward )(Player*, Creature*, Quest const*, uint32 ); -bool (*pItemHello )(Player*, Item*, Quest const* ); -bool (*pGOHello )(Player*, GameObject* ); -bool (*pAreaTrigger )(Player*, AreaTriggerEntry* ); -bool (*pItemQuestAccept )(Player*, Item *, Quest const* ); -bool (*pGOQuestAccept )(Player*, GameObject*, Quest const* ); -bool (*pGOChooseReward )(Player*, GameObject*_GO, Quest const*, uint32 ); -bool (*pReceiveEmote )(Player*, Creature*, uint32 ); -bool (*pItemUse )(Player*, Item*, SpellCastTargets const& ); + //Methods to be scripted + bool (*pGossipHello )(Player*, Creature*); + bool (*pQuestAccept )(Player*, Creature*, Quest const* ); + bool (*pGossipSelect )(Player*, Creature*, uint32 , uint32 ); + bool (*pGossipSelectWithCode)(Player*, Creature*, uint32 , uint32 , const char* ); + bool (*pQuestSelect )(Player*, Creature*, Quest const* ); + bool (*pQuestComplete )(Player*, Creature*, Quest const* ); + uint32 (*pNPCDialogStatus )(Player*, Creature* ); + uint32 (*pGODialogStatus )(Player*, GameObject * _GO ); + bool (*pChooseReward )(Player*, Creature*, Quest const*, uint32 ); + bool (*pItemHello )(Player*, Item*, Quest const* ); + bool (*pGOHello )(Player*, GameObject* ); + bool (*pAreaTrigger )(Player*, AreaTriggerEntry* ); + bool (*pItemQuestAccept )(Player*, Item *, Quest const* ); + bool (*pGOQuestAccept )(Player*, GameObject*, Quest const* ); + bool (*pGOChooseReward )(Player*, GameObject*, Quest const*, uint32 ); + bool (*pReceiveEmote )(Player*, Creature*, uint32 ); + bool (*pItemUse )(Player*, Item*, SpellCastTargets const& ); -CreatureAI* (*GetAI)(Creature*); -InstanceData* (*GetInstanceData)(Map*); -}; + CreatureAI* (*GetAI)(Creature*); + InstanceData* (*GetInstanceData)(Map*); -extern int nrscripts; -extern Script *m_scripts[MAX_SCRIPTS]; + void RegisterSelf(); +}; //Generic scripting text function void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL); diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index 1ee90c41029..ca7dc435b09 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -73,17 +73,7 @@ bool ScriptedAI::IsVisible(Unit* who) const void ScriptedAI::MoveInLineOfSight(Unit *who) { - if(m_creature->getVictim() || !m_creature->IsHostileTo(who) || !who->isInAccessiblePlaceFor(m_creature)) - return; - - if(!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - if(!m_creature->IsWithinDistInMap(who, m_creature->GetAttackDistance(who)) || !m_creature->IsWithinLOSInMap(who)) - return; - - if(m_creature->canAttack(who)) - //who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + if(!m_creature->getVictim() && m_creature->canStartAttack(who)) AttackStart(who); } @@ -679,13 +669,11 @@ void ScriptedAI::DoZoneInCombat(Unit* pUnit) return; } - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; - for (i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if((*i)->isAlive()) - pUnit->AddThreat(*i, 0.0f); - } + Map::PlayerList const &PlayerList = map->GetPlayers(); + for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + if (Player* i_pl = i->getSource()) + if (!i_pl->isAlive()) + pUnit->AddThreat(i_pl, 0.0f); } void ScriptedAI::DoResetThreat() @@ -721,6 +709,20 @@ void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); } +void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) +{ + Map *map = m_creature->GetMap(); + if (!map->IsDungeon()) + return; + + Map::PlayerList const &PlayerList = map->GetPlayers(); + for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + if (Player* i_pl = i->getSource()) + if (!i_pl->isAlive()) + i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); +} + + Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) { CellPair p(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h index 99ca4672f65..c1d7f06f029 100644 --- a/src/bindings/scripts/include/sc_creature.h +++ b/src/bindings/scripts/include/sc_creature.h @@ -146,6 +146,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI //Teleports a player without dropping threat (only teleports to same map) void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o); + void DoTeleportAll(float x, float y, float z, float o); //Returns friendly unit with the most amount of hp missing from max hp Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff = 1); diff --git a/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp b/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp index 117121d8530..83dda669e1f 100644 --- a/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp +++ b/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp @@ -40,5 +40,5 @@ void AddSC_areatrigger_scripts() newscript = new Script; newscript->Name="at_test"; newscript->pAreaTrigger = ATtest; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/boss/boss_emeriss.cpp b/src/bindings/scripts/scripts/boss/boss_emeriss.cpp index 99b3a845f95..a8af2b43e41 100644 --- a/src/bindings/scripts/scripts/boss/boss_emeriss.cpp +++ b/src/bindings/scripts/scripts/boss/boss_emeriss.cpp @@ -152,5 +152,5 @@ void AddSC_boss_emeriss() newscript = new Script; newscript->Name="boss_emeriss"; newscript->GetAI = GetAI_boss_emeriss; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/boss/boss_taerar.cpp b/src/bindings/scripts/scripts/boss/boss_taerar.cpp index 67d3364dd66..faed723cb4d 100644 --- a/src/bindings/scripts/scripts/boss/boss_taerar.cpp +++ b/src/bindings/scripts/scripts/boss/boss_taerar.cpp @@ -297,10 +297,10 @@ void AddSC_boss_taerar() newscript = new Script; newscript->Name="boss_taerar"; newscript->GetAI = GetAI_boss_taerar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_shade_of_taerar"; newscript->GetAI = GetAI_boss_shadeoftaerar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/boss/boss_ysondre.cpp b/src/bindings/scripts/scripts/boss/boss_ysondre.cpp index 3df1746bd76..b9fad649d71 100644 --- a/src/bindings/scripts/scripts/boss/boss_ysondre.cpp +++ b/src/bindings/scripts/scripts/boss/boss_ysondre.cpp @@ -237,10 +237,10 @@ void AddSC_boss_ysondre() newscript = new Script; newscript->Name="boss_ysondre"; newscript->GetAI = GetAI_boss_ysondre; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_dementeddruids"; newscript->GetAI = GetAI_mob_dementeddruids; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index d7578731e91..af945282935 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -1400,5 +1400,5 @@ void AddSC_mob_event() newscript = new Script; newscript->Name="mob_eventai"; newscript->GetAI = GetAI_Mob_EventAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp b/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp index 0e03915df0e..02e34a8fa1e 100644 --- a/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp +++ b/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp @@ -168,5 +168,5 @@ void AddSC_generic_creature() newscript = new Script; newscript->Name="generic_creature"; newscript->GetAI = GetAI_generic_creature; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/custom/custom_example.cpp b/src/bindings/scripts/scripts/custom/custom_example.cpp index 133b2136a1c..d1a30fd06af 100644 --- a/src/bindings/scripts/scripts/custom/custom_example.cpp +++ b/src/bindings/scripts/scripts/custom/custom_example.cpp @@ -273,5 +273,5 @@ void AddSC_custom_example() newscript->pGossipHello = &GossipHello_custom_example; newscript->pGossipSelect = &GossipSelect_custom_example; newscript->pReceiveEmote = &ReceiveEmote_custom_example; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp b/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp index c8cfe711fc9..3963d31b98b 100644 --- a/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp +++ b/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp @@ -77,5 +77,5 @@ void AddSC_custom_gossip_codebox() newscript->pGossipHello = &GossipHello_custom_gossip_codebox; newscript->pGossipSelect = &GossipSelect_custom_gossip_codebox; newscript->pGossipSelectWithCode = &GossipSelectWithCode_custom_gossip_codebox; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/custom/test.cpp b/src/bindings/scripts/scripts/custom/test.cpp index 52d5c7d6f4f..e54716afcf0 100644 --- a/src/bindings/scripts/scripts/custom/test.cpp +++ b/src/bindings/scripts/scripts/custom/test.cpp @@ -196,5 +196,5 @@ void AddSC_test() newscript->GetAI = GetAI_test; newscript->pGossipHello = &GossipHello_npc_test; newscript->pGossipSelect = &GossipSelect_npc_test; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/go/go_scripts.cpp b/src/bindings/scripts/scripts/go/go_scripts.cpp index a06e588d916..511e283373a 100644 --- a/src/bindings/scripts/scripts/go/go_scripts.cpp +++ b/src/bindings/scripts/scripts/go/go_scripts.cpp @@ -165,45 +165,45 @@ void AddSC_go_scripts() newscript = new Script; newscript->Name="go_northern_crystal_pylon"; newscript->pGOHello = &GOHello_go_northern_crystal_pylon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_eastern_crystal_pylon"; newscript->pGOHello = &GOHello_go_eastern_crystal_pylon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_western_crystal_pylon"; newscript->pGOHello = &GOHello_go_western_crystal_pylon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_barov_journal"; newscript->pGOHello = &GOHello_go_barov_journal; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_field_repair_bot_74A"; newscript->pGOHello = &GOHello_go_field_repair_bot_74A; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_orb_of_command"; newscript->pGOHello = &GOHello_go_orb_of_command; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_tablet_of_madness"; newscript->pGOHello = &GOHello_go_tablet_of_madness; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_tablet_of_the_seven"; newscript->pGOHello = &GOHello_go_tablet_of_the_seven; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_teleporter"; newscript->pGOHello = &GOHello_go_teleporter; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/guard/guards.cpp b/src/bindings/scripts/scripts/guard/guards.cpp index fdc541665d1..a96ded0ac70 100644 --- a/src/bindings/scripts/scripts/guard/guards.cpp +++ b/src/bindings/scripts/scripts/guard/guards.cpp @@ -3980,75 +3980,75 @@ void AddSC_guards() newscript->pGossipHello = &GossipHello_guard_azuremyst; newscript->pGossipSelect = &GossipSelect_guard_azuremyst; newscript->GetAI = GetAI_guard_azuremyst; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_bluffwatcher"; newscript->pGossipHello = &GossipHello_guard_bluffwatcher; newscript->pGossipSelect = &GossipSelect_guard_bluffwatcher; newscript->GetAI = GetAI_guard_bluffwatcher; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_contested"; newscript->GetAI = GetAI_guard_contested; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_darnassus"; newscript->pGossipHello = &GossipHello_guard_darnassus; newscript->pGossipSelect = &GossipSelect_guard_darnassus; newscript->GetAI = GetAI_guard_darnassus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_dunmorogh"; newscript->pGossipHello = &GossipHello_guard_dunmorogh; newscript->pGossipSelect = &GossipSelect_guard_dunmorogh; newscript->GetAI = GetAI_guard_dunmorogh; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_durotar"; newscript->pGossipHello = &GossipHello_guard_durotar; newscript->pGossipSelect = &GossipSelect_guard_durotar; newscript->GetAI = GetAI_guard_durotar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_elwynnforest"; newscript->pGossipHello = &GossipHello_guard_elwynnforest; newscript->pGossipSelect = &GossipSelect_guard_elwynnforest; newscript->GetAI = GetAI_guard_elwynnforest; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_eversong"; newscript->pGossipHello = &GossipHello_guard_eversong; newscript->pGossipSelect = &GossipSelect_guard_eversong; newscript->GetAI = GetAI_guard_eversong; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_exodar"; newscript->pGossipHello = &GossipHello_guard_exodar; newscript->pGossipSelect = &GossipSelect_guard_exodar; newscript->GetAI = GetAI_guard_exodar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_ironforge"; newscript->pGossipHello = &GossipHello_guard_ironforge; newscript->pGossipSelect = &GossipSelect_guard_ironforge; newscript->GetAI = GetAI_guard_ironforge; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_mulgore"; newscript->pGossipHello = &GossipHello_guard_mulgore; newscript->pGossipSelect = &GossipSelect_guard_mulgore; newscript->GetAI = GetAI_guard_mulgore; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_orgrimmar"; @@ -4056,35 +4056,35 @@ void AddSC_guards() newscript->pGossipSelect = &GossipSelect_guard_orgrimmar; newscript->pReceiveEmote = &ReceiveEmote_guard_orgrimmar; newscript->GetAI = GetAI_guard_orgrimmar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_shattrath"; newscript->pGossipHello = &GossipHello_guard_shattrath; newscript->pGossipSelect = &GossipSelect_guard_shattrath; newscript->GetAI = GetAI_guard_shattrath; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_shattrath_aldor"; newscript->GetAI = GetAI_guard_shattrath_aldor; newscript->pGossipHello = &GossipHello_guard_shattrath_aldor; newscript->pGossipSelect = &GossipSelect_guard_shattrath_aldor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_shattrath_scryer"; newscript->GetAI = GetAI_guard_shattrath_scryer; newscript->pGossipHello = &GossipHello_guard_shattrath_scryer; newscript->pGossipSelect = &GossipSelect_guard_shattrath_scryer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_silvermoon"; newscript->pGossipHello = &GossipHello_guard_silvermoon; newscript->pGossipSelect = &GossipSelect_guard_silvermoon; newscript->GetAI = GetAI_guard_silvermoon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_stormwind"; @@ -4092,26 +4092,26 @@ void AddSC_guards() newscript->pGossipSelect = &GossipSelect_guard_stormwind; newscript->pReceiveEmote = &ReceiveEmote_guard_stormwind; newscript->GetAI = GetAI_guard_stormwind; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_teldrassil"; newscript->pGossipHello = &GossipHello_guard_teldrassil; newscript->pGossipSelect = &GossipSelect_guard_teldrassil; newscript->GetAI = GetAI_guard_teldrassil; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_tirisfal"; newscript->pGossipHello = &GossipHello_guard_tirisfal; newscript->pGossipSelect = &GossipSelect_guard_tirisfal; newscript->GetAI = GetAI_guard_tirisfal; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="guard_undercity"; newscript->pGossipHello = &GossipHello_guard_undercity; newscript->pGossipSelect = &GossipSelect_guard_undercity; newscript->GetAI = GetAI_guard_undercity; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/item/item_scripts.cpp b/src/bindings/scripts/scripts/item/item_scripts.cpp index 42ab5914262..372f438753c 100644 --- a/src/bindings/scripts/scripts/item/item_scripts.cpp +++ b/src/bindings/scripts/scripts/item/item_scripts.cpp @@ -455,95 +455,95 @@ void AddSC_item_scripts() newscript = new Script; newscript->Name="item_area_52_special"; newscript->pItemUse = ItemUse_item_area_52_special; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_arcane_charges"; newscript->pItemUse = ItemUse_item_arcane_charges; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_attuned_crystal_cores"; newscript->pItemUse = ItemUse_item_attuned_crystal_cores; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_blackwhelp_net"; newscript->pItemUse = ItemUse_item_blackwhelp_net; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_disciplinary_rod"; newscript->pItemUse = ItemUse_item_disciplinary_rod; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_draenei_fishing_net"; newscript->pItemUse = ItemUse_item_draenei_fishing_net; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_nether_wraith_beacon"; newscript->pItemUse = ItemUse_item_nether_wraith_beacon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_flying_machine"; newscript->pItemUse = ItemUse_item_flying_machine; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_gor_dreks_ointment"; newscript->pItemUse = ItemUse_item_gor_dreks_ointment; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_muiseks_vessel"; newscript->pItemUse = ItemUse_item_muiseks_vessel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_razorthorn_flayer_gland"; newscript->pItemUse = ItemUse_item_razorthorn_flayer_gland; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_tame_beast_rods"; newscript->pItemUse = ItemUse_item_tame_beast_rods; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_protovoltaic_magneto_collector"; newscript->pItemUse = ItemUse_item_protovoltaic_magneto_collector; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_soul_cannon"; newscript->pItemUse = ItemUse_item_soul_cannon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_sparrowhawk_net"; newscript->pItemUse = ItemUse_item_sparrowhawk_net; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_voodoo_charm"; newscript->pItemUse = ItemUse_item_voodoo_charm; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_vorenthals_presence"; newscript->pItemUse = ItemUse_item_vorenthals_presence; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_yehkinyas_bramble"; newscript->pItemUse = ItemUse_item_yehkinyas_bramble; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_zezzaks_shard"; newscript->pItemUse = ItemUse_item_zezzak_shard; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/item/item_test.cpp b/src/bindings/scripts/scripts/item/item_test.cpp index a1e3b6c13c1..1dce7157e21 100644 --- a/src/bindings/scripts/scripts/item/item_test.cpp +++ b/src/bindings/scripts/scripts/item/item_test.cpp @@ -38,5 +38,5 @@ void AddSC_item_test() newscript = new Script; newscript->Name="item_test"; newscript->pItemUse = ItemUse_item_test; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp b/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp index d0faf45c792..efc5e4b7b3a 100644 --- a/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp +++ b/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp @@ -140,5 +140,5 @@ void AddSC_npc_innkeeper() newscript->Name="npc_innkeeper"; newscript->pGossipHello = &GossipHello_npc_innkeeper; newscript->pGossipSelect = &GossipSelect_npc_innkeeper; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/npc/npc_professions.cpp b/src/bindings/scripts/scripts/npc/npc_professions.cpp index 30ecfc6788d..5061f195910 100644 --- a/src/bindings/scripts/scripts/npc/npc_professions.cpp +++ b/src/bindings/scripts/scripts/npc/npc_professions.cpp @@ -1177,29 +1177,29 @@ void AddSC_npc_professions() newscript->Name="npc_prof_alchemy"; newscript->pGossipHello = &GossipHello_npc_prof_alchemy; newscript->pGossipSelect = &GossipSelect_npc_prof_alchemy; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_prof_blacksmith"; newscript->pGossipHello = &GossipHello_npc_prof_blacksmith; newscript->pGossipSelect = &GossipSelect_npc_prof_blacksmith; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_prof_leather"; newscript->pGossipHello = &GossipHello_npc_prof_leather; newscript->pGossipSelect = &GossipSelect_npc_prof_leather; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_prof_tailor"; newscript->pGossipHello = &GossipHello_npc_prof_tailor; newscript->pGossipSelect = &GossipSelect_npc_prof_tailor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); /*newscript = new Script; newscript->Name="go_soothsaying_for_dummies"; newscript->pGOHello = &GOHello_go_soothsaying_for_dummies; //newscript->pGossipSelect = &GossipSelect_go_soothsaying_for_dummies; - m_scripts[nrscripts++] = newscript;*/ + newscript->RegisterSelf();*/ } diff --git a/src/bindings/scripts/scripts/npc/npcs_special.cpp b/src/bindings/scripts/scripts/npc/npcs_special.cpp index e0e53ab55b1..61091ab54e2 100644 --- a/src/bindings/scripts/scripts/npc/npcs_special.cpp +++ b/src/bindings/scripts/scripts/npc/npcs_special.cpp @@ -1,945 +1,945 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Npcs_Special -SD%Complete: 100 -SDComment: To be used for special NPCs that are located globally. Support for quest 3861 (Cluck!), 6622 and 6624 (Triage) -SDCategory: NPCs -EndScriptData -*/ - -/* ContentData -npc_chicken_cluck 100% support for quest 3861 (Cluck!) -npc_dancing_flames 100% midsummer event NPC -npc_guardian 100% guardianAI used to prevent players from accessing off-limits areas. Not in use by SD2 -npc_injured_patient 100% patients for triage-quests (6622 and 6624) -npc_doctor 100% Gustaf Vanhowzen and Gregory Victor, quest 6622 and 6624 (Triage) -npc_mount_vendor 100% Regular mount vendors all over the world. Display gossip if player doesn't meet the requirements to buy -npc_rogue_trainer 80% Scripted trainers, so they are able to offer item 17126 for class quest 6681 -npc_sayge 100% Darkmoon event fortune teller, buff player based on answers given -EndContentData */ - -#include "precompiled.h" - -/*######## -# npc_chicken_cluck -#########*/ - -#define QUEST_CLUCK 3861 -#define EMOTE_A_HELLO "looks up at you quizzically. Maybe you should inspect it?" -#define EMOTE_H_HELLO "looks at you unexpectadly." -#define CLUCK_TEXT2 "starts pecking at the feed." -#define FACTION_FRIENDLY 84 -#define FACTION_CHICKEN 31 - -struct TRINITY_DLL_DECL npc_chicken_cluckAI : public ScriptedAI -{ - npc_chicken_cluckAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ResetFlagTimer; - - void Reset() - { - ResetFlagTimer = 120000; - - m_creature->setFaction(FACTION_CHICKEN); - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - // Reset flags after a certain time has passed so that the next player has to start the 'event' again - if(m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) - { - if(ResetFlagTimer < diff) - EnterEvadeMode(); - else ResetFlagTimer -= diff; - } - - if(m_creature->SelectHostilTarget() && m_creature->getVictim()) - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_npc_chicken_cluck(Creature *_Creature) -{ - return new npc_chicken_cluckAI(_Creature); -} - -bool ReceiveEmote_npc_chicken_cluck( Player *player, Creature *_Creature, uint32 emote ) -{ - if( emote == TEXTEMOTE_CHICKEN ) - { - if( player->GetTeam() == ALLIANCE ) - { - if( rand()%30 == 1 ) - { - if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_NONE ) - { - _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - _Creature->setFaction(FACTION_FRIENDLY); - _Creature->MonsterTextEmote(EMOTE_A_HELLO, 0); - } - } - } else - _Creature->MonsterTextEmote(EMOTE_H_HELLO,0); - } - if( emote == TEXTEMOTE_CHEER && player->GetTeam() == ALLIANCE ) - if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_COMPLETE ) - { - _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - _Creature->setFaction(FACTION_FRIENDLY); - _Creature->MonsterTextEmote(CLUCK_TEXT2, 0); - } - - return true; -} - -bool QuestAccept_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest ) -{ - if(_Quest->GetQuestId() == QUEST_CLUCK) - ((npc_chicken_cluckAI*)_Creature->AI())->Reset(); - - return true; -} - -bool QuestComplete_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest) -{ - if(_Quest->GetQuestId() == QUEST_CLUCK) - ((npc_chicken_cluckAI*)_Creature->AI())->Reset(); - - return true; -} - -/*###### -## npc_dancing_flames -######*/ - -bool ReceiveEmote_npc_dancing_flames( Player *player, Creature *_Creature, uint32 emote ) -{ - if( emote == TEXTEMOTE_DANCE ) - _Creature->CastSpell(player,47057,false); - - return true; -} - -/*###### -## Triage quest -######*/ - -#define SAY_DOC1 "I'm saved! Thank you, doctor!" -#define SAY_DOC2 "HOORAY! I AM SAVED!" -#define SAY_DOC3 "Sweet, sweet embrace... take me..." - -struct Location -{ - float x, y, z, o; -}; - -#define DOCTOR_ALLIANCE 12939 - -static Location AllianceCoords[]= -{ - { // Top-far-right bunk as seen from entrance - -3757.38, -4533.05, 14.16, 3.62 - }, - { // Top-far-left bunk - -3754.36, -4539.13, 14.16, 5.13 - }, - { // Far-right bunk - -3749.54, -4540.25, 14.28, 3.34 - }, - { // Right bunk near entrance - -3742.10, -4536.85, 14.28, 3.64 - }, - { // Far-left bunk - -3755.89, -4529.07, 14.05, 0.57 - }, - { // Mid-left bunk - -3749.51, -4527.08, 14.07, 5.26 - }, - { // Left bunk near entrance - -3746.37, -4525.35, 14.16, 5.22 - }, -}; - -#define ALLIANCE_COORDS 7 - -//alliance run to where -#define A_RUNTOX -3742.96 -#define A_RUNTOY -4531.52 -#define A_RUNTOZ 11.91 - -#define DOCTOR_HORDE 12920 - -static Location HordeCoords[]= -{ - { // Left, Behind - -1013.75, -3492.59, 62.62, 4.34 - }, - { // Right, Behind - -1017.72, -3490.92, 62.62, 4.34 - }, - { // Left, Mid - -1015.77, -3497.15, 62.82, 4.34 - }, - { // Right, Mid - -1019.51, -3495.49, 62.82, 4.34 - }, - { // Left, front - -1017.25, -3500.85, 62.98, 4.34 - }, - { // Right, Front - -1020.95, -3499.21, 62.98, 4.34 - } -}; - -#define HORDE_COORDS 6 - -//horde run to where -#define H_RUNTOX -1016.44 -#define H_RUNTOY -3508.48 -#define H_RUNTOZ 62.96 - -const uint32 AllianceSoldierId[3] = -{ - 12938, // 12938 Injured Alliance Soldier - 12936, // 12936 Badly injured Alliance Soldier - 12937 // 12937 Critically injured Alliance Soldier -}; - -const uint32 HordeSoldierId[3] = -{ - 12923, //12923 Injured Soldier - 12924, //12924 Badly injured Soldier - 12925 //12925 Critically injured Soldier -}; - -/*###### -## npc_doctor (handles both Gustaf Vanhowzen and Gregory Victor) -######*/ - -struct TRINITY_DLL_DECL npc_doctorAI : public ScriptedAI -{ - uint64 Playerguid; - - uint32 SummonPatient_Timer; - uint32 SummonPatientCount; - uint32 PatientDiedCount; - uint32 PatientSavedCount; - - bool Event; - - std::list<uint64> Patients; - std::vector<Location*> Coordinates; - - npc_doctorAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset(){} - - void BeginEvent(Player* player); - void PatientDied(Location* Point); - void PatientSaved(Creature* soldier, Player* player, Location* Point); - void UpdateAI(const uint32 diff); - - void Aggro(Unit* who){} -}; - -/*##### -## npc_injured_patient (handles all the patients, no matter Horde or Alliance) -#####*/ - -struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI -{ - npc_injured_patientAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 Doctorguid; - - Location* Coord; - - void Reset() - { - Doctorguid = 0; - - Coord = NULL; - //no select - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //no regen health - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - //to make them lay with face down - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_DEAD); - - uint32 mobId = m_creature->GetEntry(); - - switch (mobId) - { //lower max health - case 12923: - case 12938: //Injured Soldier - m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.75)); - break; - case 12924: - case 12936: //Badly injured Soldier - m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.50)); - break; - case 12925: - case 12937: //Critically injured Soldier - m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.25)); - break; - } - } - - void Aggro(Unit* who){} - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if (caster->GetTypeId() == TYPEID_PLAYER && m_creature->isAlive() && spell->Id == 20804) - { - if( (((Player*)caster)->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (((Player*)caster)->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)) - { - if(Doctorguid) - { - Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid)); - if(Doctor) - ((npc_doctorAI*)Doctor->AI())->PatientSaved(m_creature, ((Player*)caster), Coord); - } - } - //make not selectable - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //regen health - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - //stand up - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); - DoSay(SAY_DOC1,LANG_UNIVERSAL,NULL); - - uint32 mobId = m_creature->GetEntry(); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - switch (mobId) - { - case 12923: - case 12924: - case 12925: - m_creature->GetMotionMaster()->MovePoint(0, H_RUNTOX, H_RUNTOY, H_RUNTOZ); - break; - case 12936: - case 12937: - case 12938: - m_creature->GetMotionMaster()->MovePoint(0, A_RUNTOX, A_RUNTOY, A_RUNTOZ); - break; - } - } - return; - } - - void UpdateAI(const uint32 diff) - { - if (m_creature->isAlive() && m_creature->GetHealth() > 6) - { //lower HP on every world tick makes it a useful counter, not officlone though - m_creature->SetHealth(uint32(m_creature->GetHealth()-5) ); - } - - if (m_creature->isAlive() && m_creature->GetHealth() <= 6) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setDeathState(JUST_DIED); - m_creature->SetFlag(UNIT_DYNAMIC_FLAGS, 32); - - if(Doctorguid) - { - Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid)); - if(Doctor) - ((npc_doctorAI*)Doctor->AI())->PatientDied(Coord); - } - } - } -}; - -CreatureAI* GetAI_npc_injured_patient(Creature *_Creature) -{ - return new npc_injured_patientAI (_Creature); -} - -/* -npc_doctor (continue) -*/ - -void npc_doctorAI::BeginEvent(Player* player) -{ - Playerguid = player->GetGUID(); - - SummonPatient_Timer = 10000; - SummonPatientCount = 0; - PatientDiedCount = 0; - PatientSavedCount = 0; - - switch(m_creature->GetEntry()) - { - case DOCTOR_ALLIANCE: - for(uint8 i = 0; i < ALLIANCE_COORDS; ++i) - Coordinates.push_back(&AllianceCoords[i]); - break; - - case DOCTOR_HORDE: - for(uint8 i = 0; i < HORDE_COORDS; ++i) - Coordinates.push_back(&HordeCoords[i]); - break; - } - - Event = true; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); -} - -void npc_doctorAI::PatientDied(Location* Point) -{ - Player* player = ((Player*)Unit::GetUnit((*m_creature), Playerguid)); - if(player && ((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))) - { - PatientDiedCount++; - if (PatientDiedCount > 5 && Event) - { - if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) - player->FailQuest(6624); - else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE) - player->FailQuest(6622); - - Event = false; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - Coordinates.push_back(Point); - } -} - -void npc_doctorAI::PatientSaved(Creature* soldier, Player* player, Location* Point) -{ - if(player && Playerguid == player->GetGUID()) - { - if((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)) - { - PatientSavedCount++; - if(PatientSavedCount == 15) - { - if(!Patients.empty()) - { - std::list<uint64>::iterator itr; - for(itr = Patients.begin(); itr != Patients.end(); ++itr) - { - Creature* Patient = ((Creature*)Unit::GetUnit((*m_creature), *itr)); - if( Patient ) - Patient->setDeathState(JUST_DIED); - } - } - - if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(6624); - else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(6622); - - Event = false; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - Coordinates.push_back(Point); - } - } -} - -void npc_doctorAI::UpdateAI(const uint32 diff) -{ - if(Event && SummonPatientCount >= 20) - { - Event = false; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - if(Event) - if(SummonPatient_Timer < diff) - { - Creature* Patient = NULL; - Location* Point = NULL; - - if(Coordinates.empty()) - return; - - std::vector<Location*>::iterator itr = Coordinates.begin()+rand()%Coordinates.size(); - uint32 patientEntry = 0; - - switch(m_creature->GetEntry()) - { - case DOCTOR_ALLIANCE: patientEntry = AllianceSoldierId[rand()%3]; break; - case DOCTOR_HORDE: patientEntry = HordeSoldierId[rand()%3]; break; - default: - error_log("SD2: Invalid entry for Triage doctor. Please check your database"); - return; - } - - Point = *itr; - - Patient = m_creature->SummonCreature(patientEntry, Point->x, Point->y, Point->z, Point->o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - - if(Patient) - { - Patients.push_back(Patient->GetGUID()); - ((npc_injured_patientAI*)Patient->AI())->Doctorguid = m_creature->GetGUID(); - if(Point) - ((npc_injured_patientAI*)Patient->AI())->Coord = Point; - Coordinates.erase(itr); - } - SummonPatient_Timer = 10000; - SummonPatientCount++; - }else SummonPatient_Timer -= diff; -} - -bool QuestAccept_npc_doctor(Player *player, Creature *creature, Quest const *quest ) -{ - if((quest->GetQuestId() == 6624) || (quest->GetQuestId() == 6622)) - ((npc_doctorAI*)creature->AI())->BeginEvent(player); - - return true; -} - -CreatureAI* GetAI_npc_doctor(Creature *_Creature) -{ - return new npc_doctorAI (_Creature); -} - -/*###### -## npc_guardian -######*/ - -#define SPELL_DEATHTOUCH 5 -#define SAY_AGGRO "This area is closed!" - -struct TRINITY_DLL_DECL npc_guardianAI : public ScriptedAI -{ - npc_guardianAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (m_creature->isAttackReady()) - { - m_creature->CastSpell(m_creature->getVictim(),SPELL_DEATHTOUCH, true); - m_creature->resetAttackTimer(); - } - } -}; - -CreatureAI* GetAI_npc_guardian(Creature *_Creature) -{ - return new npc_guardianAI (_Creature); -} - -/*###### -## npc_mount_vendor -######*/ - -bool GossipHello_npc_mount_vendor(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - bool canBuy; - canBuy = false; - uint32 vendor = _Creature->GetEntry(); - uint8 race = player->getRace(); - - switch (vendor) - { - case 384: //Katie Hunter - case 1460: //Unger Statforth - case 2357: //Merideth Carlson - case 4885: //Gregor MacVince - if (player->GetReputationRank(72) != REP_EXALTED && race != RACE_HUMAN) - player->SEND_GOSSIP_MENU(5855, _Creature->GetGUID()); - else canBuy = true; - break; - case 1261: //Veron Amberstill - if (player->GetReputationRank(47) != REP_EXALTED && race != RACE_DWARF) - player->SEND_GOSSIP_MENU(5856, _Creature->GetGUID()); - else canBuy = true; - break; - case 3362: //Ogunaro Wolfrunner - if (player->GetReputationRank(76) != REP_EXALTED && race != RACE_ORC) - player->SEND_GOSSIP_MENU(5841, _Creature->GetGUID()); - else canBuy = true; - break; - case 3685: //Harb Clawhoof - if (player->GetReputationRank(81) != REP_EXALTED && race != RACE_TAUREN) - player->SEND_GOSSIP_MENU(5843, _Creature->GetGUID()); - else canBuy = true; - break; - case 4730: //Lelanai - if (player->GetReputationRank(69) != REP_EXALTED && race != RACE_NIGHTELF) - player->SEND_GOSSIP_MENU(5844, _Creature->GetGUID()); - else canBuy = true; - break; - case 4731: //Zachariah Post - if (player->GetReputationRank(68) != REP_EXALTED && race != RACE_UNDEAD_PLAYER) - player->SEND_GOSSIP_MENU(5840, _Creature->GetGUID()); - else canBuy = true; - break; - case 7952: //Zjolnir - if (player->GetReputationRank(530) != REP_EXALTED && race != RACE_TROLL) - player->SEND_GOSSIP_MENU(5842, _Creature->GetGUID()); - else canBuy = true; - break; - case 7955: //Milli Featherwhistle - if (player->GetReputationRank(54) != REP_EXALTED && race != RACE_GNOME) - player->SEND_GOSSIP_MENU(5857, _Creature->GetGUID()); - else canBuy = true; - break; - case 16264: //Winaestra - if (player->GetReputationRank(911) != REP_EXALTED && race != RACE_BLOODELF) - player->SEND_GOSSIP_MENU(10305, _Creature->GetGUID()); - else canBuy = true; - break; - case 17584: //Torallius the Pack Handler - if (player->GetReputationRank(930) != REP_EXALTED && race != RACE_DRAENEI) - player->SEND_GOSSIP_MENU(10239, _Creature->GetGUID()); - else canBuy = true; - break; - } - - if (canBuy) - { - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM( 1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - } - return true; -} - -bool GossipSelect_npc_mount_vendor(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_TRADE) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -/*###### -## npc_rogue_trainer -######*/ - -bool GossipHello_npc_rogue_trainer(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( _Creature->isTrainer() ) - player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); - - if( _Creature->isCanTrainingAndResetTalentsOf(player) ) - player->ADD_GOSSIP_ITEM(2, "I wish to unlearn my talents", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_UNLEARNTALENTS); - - if( player->getClass() == CLASS_ROGUE && player->getLevel() >= 24 && !player->HasItemCount(17126,1) && !player->GetQuestRewardStatus(6681) ) - { - player->ADD_GOSSIP_ITEM(0, "<Take the letter>", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(5996, _Creature->GetGUID()); - } else - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_rogue_trainer(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch( action ) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,21100,false); - break; - case GOSSIP_ACTION_TRAIN: - player->SEND_TRAINERLIST( _Creature->GetGUID() ); - break; - case GOSSIP_OPTION_UNLEARNTALENTS: - player->CLOSE_GOSSIP_MENU(); - player->SendTalentWipeConfirm( _Creature->GetGUID() ); - break; - } - return true; -} - -/*###### -## npc_sayge -######*/ - -#define SPELL_DMG 23768 //dmg -#define SPELL_RES 23769 //res -#define SPELL_ARM 23767 //arm -#define SPELL_SPI 23738 //spi -#define SPELL_INT 23766 //int -#define SPELL_STM 23737 //stm -#define SPELL_STR 23735 //str -#define SPELL_AGI 23736 //agi -#define SPELL_FORTUNE 23765 //faire fortune - -bool GossipHello_npc_sayge(Player *player, Creature *_Creature) -{ - if(_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->HasSpellCooldown(SPELL_INT) || - player->HasSpellCooldown(SPELL_ARM) || - player->HasSpellCooldown(SPELL_DMG) || - player->HasSpellCooldown(SPELL_RES) || - player->HasSpellCooldown(SPELL_STR) || - player->HasSpellCooldown(SPELL_AGI) || - player->HasSpellCooldown(SPELL_STM) || - player->HasSpellCooldown(SPELL_SPI) ) - player->SEND_GOSSIP_MENU(7393, _Creature->GetGUID()); - else - { - player->ADD_GOSSIP_ITEM(0, "Yes", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(7339, _Creature->GetGUID()); - } - - return true; -} - -void SendAction_npc_sayge(Player *player, Creature *_Creature, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, "Slay the Man", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->ADD_GOSSIP_ITEM(0, "Turn him over to liege", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->ADD_GOSSIP_ITEM(0, "Confiscate the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->ADD_GOSSIP_ITEM(0, "Let him go and have the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(7340, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, "Execute your friend painfully", GOSSIP_SENDER_MAIN+1, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Execute your friend painlessly", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Let your friend go", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7341, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, "Confront the diplomat", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Show not so quiet defiance", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Remain quiet", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7361, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(0, "Speak against your brother openly", GOSSIP_SENDER_MAIN+6, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Help your brother in", GOSSIP_SENDER_MAIN+7, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Keep your brother out without letting him know", GOSSIP_SENDER_MAIN+8, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7362, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM(0, "Take credit, keep gold", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Take credit, share the gold", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Let the knight take credit", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7363, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM(0, "Thanks", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(7364, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - _Creature->CastSpell(player, SPELL_FORTUNE, false); - player->SEND_GOSSIP_MENU(7365, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_npc_sayge(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(sender) - { - case GOSSIP_SENDER_MAIN: - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+1: - _Creature->CastSpell(player, SPELL_DMG, false); - player->AddSpellCooldown(SPELL_DMG,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+2: - _Creature->CastSpell(player, SPELL_RES, false); - player->AddSpellCooldown(SPELL_RES,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+3: - _Creature->CastSpell(player, SPELL_ARM, false); - player->AddSpellCooldown(SPELL_ARM,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+4: - _Creature->CastSpell(player, SPELL_SPI, false); - player->AddSpellCooldown(SPELL_SPI,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+5: - _Creature->CastSpell(player, SPELL_INT, false); - player->AddSpellCooldown(SPELL_INT,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+6: - _Creature->CastSpell(player, SPELL_STM, false); - player->AddSpellCooldown(SPELL_STM,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+7: - _Creature->CastSpell(player, SPELL_STR, false); - player->AddSpellCooldown(SPELL_STR,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+8: - _Creature->CastSpell(player, SPELL_AGI, false); - player->AddSpellCooldown(SPELL_AGI,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - } - return true; -} - -struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI -{ - npc_steam_tonkAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() {} - void Aggro(Unit *who) {} - - void OnPossess(bool apply) - { - if (apply) - { - // Initialize the action bar without the melee attack command - m_creature->InitCharmInfo(m_creature); - m_creature->GetCharmInfo()->InitEmptyActionBar(false); - } - } - -}; - -CreatureAI* GetAI_npc_steam_tonk(Creature *_Creature) -{ - return new npc_steam_tonkAI(_Creature); -} - -#define SPELL_TONK_MINE_DETONATE 25099 - -struct TRINITY_DLL_DECL npc_tonk_mineAI : public ScriptedAI -{ - npc_tonk_mineAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ExplosionTimer; - - void Reset() - { - ExplosionTimer = 3000; - } - - void Aggro(Unit *who) {} - void AttackStart(Unit *who) {} - void MoveInLineOfSight(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if (ExplosionTimer < diff) - { - m_creature->CastSpell(m_creature, SPELL_TONK_MINE_DETONATE, true); - m_creature->setDeathState(DEAD); // unsummon it - } else - ExplosionTimer -= diff; - } -}; - -CreatureAI* GetAI_npc_tonk_mine(Creature *_Creature) -{ - return new npc_tonk_mineAI(_Creature); -} - -void AddSC_npcs_special() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_chicken_cluck"; - newscript->GetAI = GetAI_npc_chicken_cluck; - newscript->pReceiveEmote = &ReceiveEmote_npc_chicken_cluck; - newscript->pQuestAccept = &QuestAccept_npc_chicken_cluck; - newscript->pQuestComplete = &QuestComplete_npc_chicken_cluck; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_dancing_flames"; - newscript->pReceiveEmote = &ReceiveEmote_npc_dancing_flames; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_injured_patient"; - newscript->GetAI = GetAI_npc_injured_patient; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_doctor"; - newscript->GetAI = GetAI_npc_doctor; - newscript->pQuestAccept = &QuestAccept_npc_doctor; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_guardian"; - newscript->GetAI = GetAI_npc_guardian; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_mount_vendor"; - newscript->pGossipHello = &GossipHello_npc_mount_vendor; - newscript->pGossipSelect = &GossipSelect_npc_mount_vendor; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_rogue_trainer"; - newscript->pGossipHello = &GossipHello_npc_rogue_trainer; - newscript->pGossipSelect = &GossipSelect_npc_rogue_trainer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_sayge"; - newscript->pGossipHello = &GossipHello_npc_sayge; - newscript->pGossipSelect = &GossipSelect_npc_sayge; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_steam_tonk"; - newscript->GetAI = &GetAI_npc_steam_tonk; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_tonk_mine"; - newscript->GetAI = &GetAI_npc_tonk_mine; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* ScriptData
+SDName: Npcs_Special
+SD%Complete: 100
+SDComment: To be used for special NPCs that are located globally. Support for quest 3861 (Cluck!), 6622 and 6624 (Triage)
+SDCategory: NPCs
+EndScriptData
+*/
+
+/* ContentData
+npc_chicken_cluck 100% support for quest 3861 (Cluck!)
+npc_dancing_flames 100% midsummer event NPC
+npc_guardian 100% guardianAI used to prevent players from accessing off-limits areas. Not in use by SD2
+npc_injured_patient 100% patients for triage-quests (6622 and 6624)
+npc_doctor 100% Gustaf Vanhowzen and Gregory Victor, quest 6622 and 6624 (Triage)
+npc_mount_vendor 100% Regular mount vendors all over the world. Display gossip if player doesn't meet the requirements to buy
+npc_rogue_trainer 80% Scripted trainers, so they are able to offer item 17126 for class quest 6681
+npc_sayge 100% Darkmoon event fortune teller, buff player based on answers given
+EndContentData */
+
+#include "precompiled.h"
+
+/*########
+# npc_chicken_cluck
+#########*/
+
+#define QUEST_CLUCK 3861
+#define EMOTE_A_HELLO "looks up at you quizzically. Maybe you should inspect it?"
+#define EMOTE_H_HELLO "looks at you unexpectadly."
+#define CLUCK_TEXT2 "starts pecking at the feed."
+#define FACTION_FRIENDLY 84
+#define FACTION_CHICKEN 31
+
+struct TRINITY_DLL_DECL npc_chicken_cluckAI : public ScriptedAI
+{
+ npc_chicken_cluckAI(Creature *c) : ScriptedAI(c) {Reset();}
+
+ uint32 ResetFlagTimer;
+
+ void Reset()
+ {
+ ResetFlagTimer = 120000;
+
+ m_creature->setFaction(FACTION_CHICKEN);
+ m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
+ }
+
+ void Aggro(Unit *who) {}
+
+ void UpdateAI(const uint32 diff)
+ {
+ // Reset flags after a certain time has passed so that the next player has to start the 'event' again
+ if(m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
+ {
+ if(ResetFlagTimer < diff)
+ EnterEvadeMode();
+ else ResetFlagTimer -= diff;
+ }
+
+ if(m_creature->SelectHostilTarget() && m_creature->getVictim())
+ DoMeleeAttackIfReady();
+ }
+};
+
+CreatureAI* GetAI_npc_chicken_cluck(Creature *_Creature)
+{
+ return new npc_chicken_cluckAI(_Creature);
+}
+
+bool ReceiveEmote_npc_chicken_cluck( Player *player, Creature *_Creature, uint32 emote )
+{
+ if( emote == TEXTEMOTE_CHICKEN )
+ {
+ if( player->GetTeam() == ALLIANCE )
+ {
+ if( rand()%30 == 1 )
+ {
+ if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_NONE )
+ {
+ _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
+ _Creature->setFaction(FACTION_FRIENDLY);
+ _Creature->MonsterTextEmote(EMOTE_A_HELLO, 0);
+ }
+ }
+ } else
+ _Creature->MonsterTextEmote(EMOTE_H_HELLO,0);
+ }
+ if( emote == TEXTEMOTE_CHEER && player->GetTeam() == ALLIANCE )
+ if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_COMPLETE )
+ {
+ _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
+ _Creature->setFaction(FACTION_FRIENDLY);
+ _Creature->MonsterTextEmote(CLUCK_TEXT2, 0);
+ }
+
+ return true;
+}
+
+bool QuestAccept_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest )
+{
+ if(_Quest->GetQuestId() == QUEST_CLUCK)
+ ((npc_chicken_cluckAI*)_Creature->AI())->Reset();
+
+ return true;
+}
+
+bool QuestComplete_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest)
+{
+ if(_Quest->GetQuestId() == QUEST_CLUCK)
+ ((npc_chicken_cluckAI*)_Creature->AI())->Reset();
+
+ return true;
+}
+
+/*######
+## npc_dancing_flames
+######*/
+
+bool ReceiveEmote_npc_dancing_flames( Player *player, Creature *_Creature, uint32 emote )
+{
+ if( emote == TEXTEMOTE_DANCE )
+ _Creature->CastSpell(player,47057,false);
+
+ return true;
+}
+
+/*######
+## Triage quest
+######*/
+
+#define SAY_DOC1 "I'm saved! Thank you, doctor!"
+#define SAY_DOC2 "HOORAY! I AM SAVED!"
+#define SAY_DOC3 "Sweet, sweet embrace... take me..."
+
+struct Location
+{
+ float x, y, z, o;
+};
+
+#define DOCTOR_ALLIANCE 12939
+
+static Location AllianceCoords[]=
+{
+ { // Top-far-right bunk as seen from entrance
+ -3757.38, -4533.05, 14.16, 3.62
+ },
+ { // Top-far-left bunk
+ -3754.36, -4539.13, 14.16, 5.13
+ },
+ { // Far-right bunk
+ -3749.54, -4540.25, 14.28, 3.34
+ },
+ { // Right bunk near entrance
+ -3742.10, -4536.85, 14.28, 3.64
+ },
+ { // Far-left bunk
+ -3755.89, -4529.07, 14.05, 0.57
+ },
+ { // Mid-left bunk
+ -3749.51, -4527.08, 14.07, 5.26
+ },
+ { // Left bunk near entrance
+ -3746.37, -4525.35, 14.16, 5.22
+ },
+};
+
+#define ALLIANCE_COORDS 7
+
+//alliance run to where
+#define A_RUNTOX -3742.96
+#define A_RUNTOY -4531.52
+#define A_RUNTOZ 11.91
+
+#define DOCTOR_HORDE 12920
+
+static Location HordeCoords[]=
+{
+ { // Left, Behind
+ -1013.75, -3492.59, 62.62, 4.34
+ },
+ { // Right, Behind
+ -1017.72, -3490.92, 62.62, 4.34
+ },
+ { // Left, Mid
+ -1015.77, -3497.15, 62.82, 4.34
+ },
+ { // Right, Mid
+ -1019.51, -3495.49, 62.82, 4.34
+ },
+ { // Left, front
+ -1017.25, -3500.85, 62.98, 4.34
+ },
+ { // Right, Front
+ -1020.95, -3499.21, 62.98, 4.34
+ }
+};
+
+#define HORDE_COORDS 6
+
+//horde run to where
+#define H_RUNTOX -1016.44
+#define H_RUNTOY -3508.48
+#define H_RUNTOZ 62.96
+
+const uint32 AllianceSoldierId[3] =
+{
+ 12938, // 12938 Injured Alliance Soldier
+ 12936, // 12936 Badly injured Alliance Soldier
+ 12937 // 12937 Critically injured Alliance Soldier
+};
+
+const uint32 HordeSoldierId[3] =
+{
+ 12923, //12923 Injured Soldier
+ 12924, //12924 Badly injured Soldier
+ 12925 //12925 Critically injured Soldier
+};
+
+/*######
+## npc_doctor (handles both Gustaf Vanhowzen and Gregory Victor)
+######*/
+
+struct TRINITY_DLL_DECL npc_doctorAI : public ScriptedAI
+{
+ uint64 Playerguid;
+
+ uint32 SummonPatient_Timer;
+ uint32 SummonPatientCount;
+ uint32 PatientDiedCount;
+ uint32 PatientSavedCount;
+
+ bool Event;
+
+ std::list<uint64> Patients;
+ std::vector<Location*> Coordinates;
+
+ npc_doctorAI(Creature *c) : ScriptedAI(c) {Reset();}
+
+ void Reset(){}
+
+ void BeginEvent(Player* player);
+ void PatientDied(Location* Point);
+ void PatientSaved(Creature* soldier, Player* player, Location* Point);
+ void UpdateAI(const uint32 diff);
+
+ void Aggro(Unit* who){}
+};
+
+/*#####
+## npc_injured_patient (handles all the patients, no matter Horde or Alliance)
+#####*/
+
+struct TRINITY_DLL_DECL npc_injured_patientAI : public ScriptedAI
+{
+ npc_injured_patientAI(Creature *c) : ScriptedAI(c) {Reset();}
+
+ uint64 Doctorguid;
+
+ Location* Coord;
+
+ void Reset()
+ {
+ Doctorguid = 0;
+
+ Coord = NULL;
+ //no select
+ m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ //no regen health
+ m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+ //to make them lay with face down
+ m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_DEAD);
+
+ uint32 mobId = m_creature->GetEntry();
+
+ switch (mobId)
+ { //lower max health
+ case 12923:
+ case 12938: //Injured Soldier
+ m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.75));
+ break;
+ case 12924:
+ case 12936: //Badly injured Soldier
+ m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.50));
+ break;
+ case 12925:
+ case 12937: //Critically injured Soldier
+ m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.25));
+ break;
+ }
+ }
+
+ void Aggro(Unit* who){}
+
+ void SpellHit(Unit *caster, const SpellEntry *spell)
+ {
+ if (caster->GetTypeId() == TYPEID_PLAYER && m_creature->isAlive() && spell->Id == 20804)
+ {
+ if( (((Player*)caster)->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (((Player*)caster)->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))
+ {
+ if(Doctorguid)
+ {
+ Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid));
+ if(Doctor)
+ ((npc_doctorAI*)Doctor->AI())->PatientSaved(m_creature, ((Player*)caster), Coord);
+ }
+ }
+ //make not selectable
+ m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ //regen health
+ m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+ //stand up
+ m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE);
+ DoSay(SAY_DOC1,LANG_UNIVERSAL,NULL);
+
+ uint32 mobId = m_creature->GetEntry();
+ m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+ switch (mobId)
+ {
+ case 12923:
+ case 12924:
+ case 12925:
+ m_creature->GetMotionMaster()->MovePoint(0, H_RUNTOX, H_RUNTOY, H_RUNTOZ);
+ break;
+ case 12936:
+ case 12937:
+ case 12938:
+ m_creature->GetMotionMaster()->MovePoint(0, A_RUNTOX, A_RUNTOY, A_RUNTOZ);
+ break;
+ }
+ }
+ return;
+ }
+
+ void UpdateAI(const uint32 diff)
+ {
+ if (m_creature->isAlive() && m_creature->GetHealth() > 6)
+ { //lower HP on every world tick makes it a useful counter, not officlone though
+ m_creature->SetHealth(uint32(m_creature->GetHealth()-5) );
+ }
+
+ if (m_creature->isAlive() && m_creature->GetHealth() <= 6)
+ {
+ m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+ m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ m_creature->setDeathState(JUST_DIED);
+ m_creature->SetFlag(UNIT_DYNAMIC_FLAGS, 32);
+
+ if(Doctorguid)
+ {
+ Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid));
+ if(Doctor)
+ ((npc_doctorAI*)Doctor->AI())->PatientDied(Coord);
+ }
+ }
+ }
+};
+
+CreatureAI* GetAI_npc_injured_patient(Creature *_Creature)
+{
+ return new npc_injured_patientAI (_Creature);
+}
+
+/*
+npc_doctor (continue)
+*/
+
+void npc_doctorAI::BeginEvent(Player* player)
+{
+ Playerguid = player->GetGUID();
+
+ SummonPatient_Timer = 10000;
+ SummonPatientCount = 0;
+ PatientDiedCount = 0;
+ PatientSavedCount = 0;
+
+ switch(m_creature->GetEntry())
+ {
+ case DOCTOR_ALLIANCE:
+ for(uint8 i = 0; i < ALLIANCE_COORDS; ++i)
+ Coordinates.push_back(&AllianceCoords[i]);
+ break;
+
+ case DOCTOR_HORDE:
+ for(uint8 i = 0; i < HORDE_COORDS; ++i)
+ Coordinates.push_back(&HordeCoords[i]);
+ break;
+ }
+
+ Event = true;
+
+ m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+}
+
+void npc_doctorAI::PatientDied(Location* Point)
+{
+ Player* player = ((Player*)Unit::GetUnit((*m_creature), Playerguid));
+ if(player && ((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)))
+ {
+ PatientDiedCount++;
+ if (PatientDiedCount > 5 && Event)
+ {
+ if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE)
+ player->FailQuest(6624);
+ else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)
+ player->FailQuest(6622);
+
+ Event = false;
+ m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ }
+
+ Coordinates.push_back(Point);
+ }
+}
+
+void npc_doctorAI::PatientSaved(Creature* soldier, Player* player, Location* Point)
+{
+ if(player && Playerguid == player->GetGUID())
+ {
+ if((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))
+ {
+ PatientSavedCount++;
+ if(PatientSavedCount == 15)
+ {
+ if(!Patients.empty())
+ {
+ std::list<uint64>::iterator itr;
+ for(itr = Patients.begin(); itr != Patients.end(); ++itr)
+ {
+ Creature* Patient = ((Creature*)Unit::GetUnit((*m_creature), *itr));
+ if( Patient )
+ Patient->setDeathState(JUST_DIED);
+ }
+ }
+
+ if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE)
+ player->AreaExploredOrEventHappens(6624);
+ else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)
+ player->AreaExploredOrEventHappens(6622);
+
+ Event = false;
+ m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ }
+
+ Coordinates.push_back(Point);
+ }
+ }
+}
+
+void npc_doctorAI::UpdateAI(const uint32 diff)
+{
+ if(Event && SummonPatientCount >= 20)
+ {
+ Event = false;
+ m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ }
+
+ if(Event)
+ if(SummonPatient_Timer < diff)
+ {
+ Creature* Patient = NULL;
+ Location* Point = NULL;
+
+ if(Coordinates.empty())
+ return;
+
+ std::vector<Location*>::iterator itr = Coordinates.begin()+rand()%Coordinates.size();
+ uint32 patientEntry = 0;
+
+ switch(m_creature->GetEntry())
+ {
+ case DOCTOR_ALLIANCE: patientEntry = AllianceSoldierId[rand()%3]; break;
+ case DOCTOR_HORDE: patientEntry = HordeSoldierId[rand()%3]; break;
+ default:
+ error_log("SD2: Invalid entry for Triage doctor. Please check your database");
+ return;
+ }
+
+ Point = *itr;
+
+ Patient = m_creature->SummonCreature(patientEntry, Point->x, Point->y, Point->z, Point->o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
+
+ if(Patient)
+ {
+ Patients.push_back(Patient->GetGUID());
+ ((npc_injured_patientAI*)Patient->AI())->Doctorguid = m_creature->GetGUID();
+ if(Point)
+ ((npc_injured_patientAI*)Patient->AI())->Coord = Point;
+ Coordinates.erase(itr);
+ }
+ SummonPatient_Timer = 10000;
+ SummonPatientCount++;
+ }else SummonPatient_Timer -= diff;
+}
+
+bool QuestAccept_npc_doctor(Player *player, Creature *creature, Quest const *quest )
+{
+ if((quest->GetQuestId() == 6624) || (quest->GetQuestId() == 6622))
+ ((npc_doctorAI*)creature->AI())->BeginEvent(player);
+
+ return true;
+}
+
+CreatureAI* GetAI_npc_doctor(Creature *_Creature)
+{
+ return new npc_doctorAI (_Creature);
+}
+
+/*######
+## npc_guardian
+######*/
+
+#define SPELL_DEATHTOUCH 5
+#define SAY_AGGRO "This area is closed!"
+
+struct TRINITY_DLL_DECL npc_guardianAI : public ScriptedAI
+{
+ npc_guardianAI(Creature *c) : ScriptedAI(c) {Reset();}
+
+ void Reset()
+ {
+ m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ }
+
+ void Aggro(Unit *who)
+ {
+ DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL);
+ }
+
+ void UpdateAI(const uint32 diff)
+ {
+ if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
+ return;
+
+ if (m_creature->isAttackReady())
+ {
+ m_creature->CastSpell(m_creature->getVictim(),SPELL_DEATHTOUCH, true);
+ m_creature->resetAttackTimer();
+ }
+ }
+};
+
+CreatureAI* GetAI_npc_guardian(Creature *_Creature)
+{
+ return new npc_guardianAI (_Creature);
+}
+
+/*######
+## npc_mount_vendor
+######*/
+
+bool GossipHello_npc_mount_vendor(Player *player, Creature *_Creature)
+{
+ if (_Creature->isQuestGiver())
+ player->PrepareQuestMenu( _Creature->GetGUID() );
+
+ bool canBuy;
+ canBuy = false;
+ uint32 vendor = _Creature->GetEntry();
+ uint8 race = player->getRace();
+
+ switch (vendor)
+ {
+ case 384: //Katie Hunter
+ case 1460: //Unger Statforth
+ case 2357: //Merideth Carlson
+ case 4885: //Gregor MacVince
+ if (player->GetReputationRank(72) != REP_EXALTED && race != RACE_HUMAN)
+ player->SEND_GOSSIP_MENU(5855, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 1261: //Veron Amberstill
+ if (player->GetReputationRank(47) != REP_EXALTED && race != RACE_DWARF)
+ player->SEND_GOSSIP_MENU(5856, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 3362: //Ogunaro Wolfrunner
+ if (player->GetReputationRank(76) != REP_EXALTED && race != RACE_ORC)
+ player->SEND_GOSSIP_MENU(5841, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 3685: //Harb Clawhoof
+ if (player->GetReputationRank(81) != REP_EXALTED && race != RACE_TAUREN)
+ player->SEND_GOSSIP_MENU(5843, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 4730: //Lelanai
+ if (player->GetReputationRank(69) != REP_EXALTED && race != RACE_NIGHTELF)
+ player->SEND_GOSSIP_MENU(5844, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 4731: //Zachariah Post
+ if (player->GetReputationRank(68) != REP_EXALTED && race != RACE_UNDEAD_PLAYER)
+ player->SEND_GOSSIP_MENU(5840, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 7952: //Zjolnir
+ if (player->GetReputationRank(530) != REP_EXALTED && race != RACE_TROLL)
+ player->SEND_GOSSIP_MENU(5842, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 7955: //Milli Featherwhistle
+ if (player->GetReputationRank(54) != REP_EXALTED && race != RACE_GNOME)
+ player->SEND_GOSSIP_MENU(5857, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 16264: //Winaestra
+ if (player->GetReputationRank(911) != REP_EXALTED && race != RACE_BLOODELF)
+ player->SEND_GOSSIP_MENU(10305, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ case 17584: //Torallius the Pack Handler
+ if (player->GetReputationRank(930) != REP_EXALTED && race != RACE_DRAENEI)
+ player->SEND_GOSSIP_MENU(10239, _Creature->GetGUID());
+ else canBuy = true;
+ break;
+ }
+
+ if (canBuy)
+ {
+ if (_Creature->isVendor())
+ player->ADD_GOSSIP_ITEM( 1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+ player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID());
+ }
+ return true;
+}
+
+bool GossipSelect_npc_mount_vendor(Player *player, Creature *_Creature, uint32 sender, uint32 action)
+{
+ if (action == GOSSIP_ACTION_TRADE)
+ player->SEND_VENDORLIST( _Creature->GetGUID() );
+
+ return true;
+}
+
+/*######
+## npc_rogue_trainer
+######*/
+
+bool GossipHello_npc_rogue_trainer(Player *player, Creature *_Creature)
+{
+ if( _Creature->isQuestGiver() )
+ player->PrepareQuestMenu( _Creature->GetGUID() );
+
+ if( _Creature->isTrainer() )
+ player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
+
+ if( _Creature->isCanTrainingAndResetTalentsOf(player) )
+ player->ADD_GOSSIP_ITEM(2, "I wish to unlearn my talents", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_UNLEARNTALENTS);
+
+ if( player->getClass() == CLASS_ROGUE && player->getLevel() >= 24 && !player->HasItemCount(17126,1) && !player->GetQuestRewardStatus(6681) )
+ {
+ player->ADD_GOSSIP_ITEM(0, "<Take the letter>", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+ player->SEND_GOSSIP_MENU(5996, _Creature->GetGUID());
+ } else
+ player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID());
+
+ return true;
+}
+
+bool GossipSelect_npc_rogue_trainer(Player *player, Creature *_Creature, uint32 sender, uint32 action)
+{
+ switch( action )
+ {
+ case GOSSIP_ACTION_INFO_DEF+1:
+ player->CLOSE_GOSSIP_MENU();
+ player->CastSpell(player,21100,false);
+ break;
+ case GOSSIP_ACTION_TRAIN:
+ player->SEND_TRAINERLIST( _Creature->GetGUID() );
+ break;
+ case GOSSIP_OPTION_UNLEARNTALENTS:
+ player->CLOSE_GOSSIP_MENU();
+ player->SendTalentWipeConfirm( _Creature->GetGUID() );
+ break;
+ }
+ return true;
+}
+
+/*######
+## npc_sayge
+######*/
+
+#define SPELL_DMG 23768 //dmg
+#define SPELL_RES 23769 //res
+#define SPELL_ARM 23767 //arm
+#define SPELL_SPI 23738 //spi
+#define SPELL_INT 23766 //int
+#define SPELL_STM 23737 //stm
+#define SPELL_STR 23735 //str
+#define SPELL_AGI 23736 //agi
+#define SPELL_FORTUNE 23765 //faire fortune
+
+bool GossipHello_npc_sayge(Player *player, Creature *_Creature)
+{
+ if(_Creature->isQuestGiver())
+ player->PrepareQuestMenu( _Creature->GetGUID() );
+
+ if( player->HasSpellCooldown(SPELL_INT) ||
+ player->HasSpellCooldown(SPELL_ARM) ||
+ player->HasSpellCooldown(SPELL_DMG) ||
+ player->HasSpellCooldown(SPELL_RES) ||
+ player->HasSpellCooldown(SPELL_STR) ||
+ player->HasSpellCooldown(SPELL_AGI) ||
+ player->HasSpellCooldown(SPELL_STM) ||
+ player->HasSpellCooldown(SPELL_SPI) )
+ player->SEND_GOSSIP_MENU(7393, _Creature->GetGUID());
+ else
+ {
+ player->ADD_GOSSIP_ITEM(0, "Yes", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+ player->SEND_GOSSIP_MENU(7339, _Creature->GetGUID());
+ }
+
+ return true;
+}
+
+void SendAction_npc_sayge(Player *player, Creature *_Creature, uint32 action)
+{
+ switch(action)
+ {
+ case GOSSIP_ACTION_INFO_DEF+1:
+ player->ADD_GOSSIP_ITEM(0, "Slay the Man", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
+ player->ADD_GOSSIP_ITEM(0, "Turn him over to liege", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
+ player->ADD_GOSSIP_ITEM(0, "Confiscate the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
+ player->ADD_GOSSIP_ITEM(0, "Let him go and have the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5);
+ player->SEND_GOSSIP_MENU(7340, _Creature->GetGUID());
+ break;
+ case GOSSIP_ACTION_INFO_DEF+2:
+ player->ADD_GOSSIP_ITEM(0, "Execute your friend painfully", GOSSIP_SENDER_MAIN+1, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Execute your friend painlessly", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Let your friend go", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF);
+ player->SEND_GOSSIP_MENU(7341, _Creature->GetGUID());
+ break;
+ case GOSSIP_ACTION_INFO_DEF+3:
+ player->ADD_GOSSIP_ITEM(0, "Confront the diplomat", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Show not so quiet defiance", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Remain quiet", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF);
+ player->SEND_GOSSIP_MENU(7361, _Creature->GetGUID());
+ break;
+ case GOSSIP_ACTION_INFO_DEF+4:
+ player->ADD_GOSSIP_ITEM(0, "Speak against your brother openly", GOSSIP_SENDER_MAIN+6, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Help your brother in", GOSSIP_SENDER_MAIN+7, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Keep your brother out without letting him know", GOSSIP_SENDER_MAIN+8, GOSSIP_ACTION_INFO_DEF);
+ player->SEND_GOSSIP_MENU(7362, _Creature->GetGUID());
+ break;
+ case GOSSIP_ACTION_INFO_DEF+5:
+ player->ADD_GOSSIP_ITEM(0, "Take credit, keep gold", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Take credit, share the gold", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF);
+ player->ADD_GOSSIP_ITEM(0, "Let the knight take credit", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF);
+ player->SEND_GOSSIP_MENU(7363, _Creature->GetGUID());
+ break;
+ case GOSSIP_ACTION_INFO_DEF:
+ player->ADD_GOSSIP_ITEM(0, "Thanks", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6);
+ player->SEND_GOSSIP_MENU(7364, _Creature->GetGUID());
+ break;
+ case GOSSIP_ACTION_INFO_DEF+6:
+ _Creature->CastSpell(player, SPELL_FORTUNE, false);
+ player->SEND_GOSSIP_MENU(7365, _Creature->GetGUID());
+ break;
+ }
+}
+
+bool GossipSelect_npc_sayge(Player *player, Creature *_Creature, uint32 sender, uint32 action )
+{
+ switch(sender)
+ {
+ case GOSSIP_SENDER_MAIN:
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+1:
+ _Creature->CastSpell(player, SPELL_DMG, false);
+ player->AddSpellCooldown(SPELL_DMG,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+2:
+ _Creature->CastSpell(player, SPELL_RES, false);
+ player->AddSpellCooldown(SPELL_RES,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+3:
+ _Creature->CastSpell(player, SPELL_ARM, false);
+ player->AddSpellCooldown(SPELL_ARM,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+4:
+ _Creature->CastSpell(player, SPELL_SPI, false);
+ player->AddSpellCooldown(SPELL_SPI,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+5:
+ _Creature->CastSpell(player, SPELL_INT, false);
+ player->AddSpellCooldown(SPELL_INT,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+6:
+ _Creature->CastSpell(player, SPELL_STM, false);
+ player->AddSpellCooldown(SPELL_STM,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+7:
+ _Creature->CastSpell(player, SPELL_STR, false);
+ player->AddSpellCooldown(SPELL_STR,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ case GOSSIP_SENDER_MAIN+8:
+ _Creature->CastSpell(player, SPELL_AGI, false);
+ player->AddSpellCooldown(SPELL_AGI,0,time(NULL) + 7200);
+ SendAction_npc_sayge(player, _Creature, action);
+ break;
+ }
+ return true;
+}
+
+struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI
+{
+ npc_steam_tonkAI(Creature *c) : ScriptedAI(c) {Reset();}
+
+ void Reset() {}
+ void Aggro(Unit *who) {}
+
+ void OnPossess(bool apply)
+ {
+ if (apply)
+ {
+ // Initialize the action bar without the melee attack command
+ m_creature->InitCharmInfo(m_creature);
+ m_creature->GetCharmInfo()->InitEmptyActionBar(false);
+ }
+ }
+
+};
+
+CreatureAI* GetAI_npc_steam_tonk(Creature *_Creature)
+{
+ return new npc_steam_tonkAI(_Creature);
+}
+
+#define SPELL_TONK_MINE_DETONATE 25099
+
+struct TRINITY_DLL_DECL npc_tonk_mineAI : public ScriptedAI
+{
+ npc_tonk_mineAI(Creature *c) : ScriptedAI(c) {Reset();}
+
+ uint32 ExplosionTimer;
+
+ void Reset()
+ {
+ ExplosionTimer = 3000;
+ }
+
+ void Aggro(Unit *who) {}
+ void AttackStart(Unit *who) {}
+ void MoveInLineOfSight(Unit *who) {}
+
+ void UpdateAI(const uint32 diff)
+ {
+ if (ExplosionTimer < diff)
+ {
+ m_creature->CastSpell(m_creature, SPELL_TONK_MINE_DETONATE, true);
+ m_creature->setDeathState(DEAD); // unsummon it
+ } else
+ ExplosionTimer -= diff;
+ }
+};
+
+CreatureAI* GetAI_npc_tonk_mine(Creature *_Creature)
+{
+ return new npc_tonk_mineAI(_Creature);
+}
+
+void AddSC_npcs_special()
+{
+ Script *newscript;
+
+ newscript = new Script;
+ newscript->Name="npc_chicken_cluck";
+ newscript->GetAI = GetAI_npc_chicken_cluck;
+ newscript->pReceiveEmote = &ReceiveEmote_npc_chicken_cluck;
+ newscript->pQuestAccept = &QuestAccept_npc_chicken_cluck;
+ newscript->pQuestComplete = &QuestComplete_npc_chicken_cluck;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_dancing_flames";
+ newscript->pReceiveEmote = &ReceiveEmote_npc_dancing_flames;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_injured_patient";
+ newscript->GetAI = GetAI_npc_injured_patient;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_doctor";
+ newscript->GetAI = GetAI_npc_doctor;
+ newscript->pQuestAccept = &QuestAccept_npc_doctor;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_guardian";
+ newscript->GetAI = GetAI_npc_guardian;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_mount_vendor";
+ newscript->pGossipHello = &GossipHello_npc_mount_vendor;
+ newscript->pGossipSelect = &GossipSelect_npc_mount_vendor;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_rogue_trainer";
+ newscript->pGossipHello = &GossipHello_npc_rogue_trainer;
+ newscript->pGossipSelect = &GossipSelect_npc_rogue_trainer;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_sayge";
+ newscript->pGossipHello = &GossipHello_npc_sayge;
+ newscript->pGossipSelect = &GossipSelect_npc_sayge;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_steam_tonk";
+ newscript->GetAI = &GetAI_npc_steam_tonk;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name="npc_tonk_mine";
+ newscript->GetAI = &GetAI_npc_tonk_mine;
+ newscript->RegisterSelf();
+}
diff --git a/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp b/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp index 98597afae3a..bb43a989a6b 100644 --- a/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp +++ b/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp @@ -58,5 +58,5 @@ void AddSC_alterac_mountains() newscript = new Script; newscript->Name="npc_ravenholdt"; newscript->GetAI = GetAI_npc_ravenholdt; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp index 055e0cbdbb9..810486aede7 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp @@ -348,15 +348,15 @@ void AddSC_boss_exarch_maladaar() newscript = new Script; newscript->Name="boss_exarch_maladaar"; newscript->GetAI = GetAI_boss_exarch_maladaar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_avatar_of_martyred"; newscript->GetAI = GetAI_mob_avatar_of_martyred; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_stolen_soul"; newscript->GetAI = GetAI_mob_stolen_soul; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp index 3db39e4f477..a9589736784 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp @@ -271,10 +271,10 @@ void AddSC_boss_nexusprince_shaffar() newscript = new Script; newscript->Name="boss_nexusprince_shaffar"; newscript->GetAI = GetAI_boss_nexusprince_shaffar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_ethereal_beacon"; newscript->GetAI = GetAI_mob_ethereal_beacon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp index d4c950c754b..3542c3e484a 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp @@ -134,5 +134,5 @@ void AddSC_boss_pandemonius() newscript = new Script; newscript->Name="boss_pandemonius"; newscript->GetAI = GetAI_boss_pandemonius; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp index 1b77d81a908..0581e9ac3af 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp @@ -392,25 +392,25 @@ void AddSC_boss_darkweaver_syth() newscript = new Script; newscript->Name="boss_darkweaver_syth"; newscript->GetAI = GetAI_boss_darkweaver_syth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_syth_fire"; newscript->GetAI = GetAI_mob_syth_arcane; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_syth_arcane"; newscript->GetAI = GetAI_mob_syth_arcane; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_syth_frost"; newscript->GetAI = GetAI_mob_syth_frost; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_syth_shadow"; newscript->GetAI = GetAI_mob_syth_shadow; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp index ab9cd0f083b..be69ee79844 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp @@ -219,5 +219,5 @@ void AddSC_boss_talon_king_ikiss() newscript = new Script; newscript->Name="boss_talon_king_ikiss"; newscript->GetAI = GetAI_boss_talon_king_ikiss; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp index b49d18445c2..4ae6ad5c7a4 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp @@ -70,5 +70,5 @@ void AddSC_instance_sethekk_halls() newscript = new Script; newscript->Name = "instance_sethekk_halls"; newscript->GetInstanceData = GetInstanceData_instance_sethekk_halls; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp index e565becfaba..20bf7c2d95e 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp @@ -194,5 +194,5 @@ void AddSC_boss_ambassador_hellmaw() newscript = new Script; newscript->Name="boss_ambassador_hellmaw"; newscript->GetAI = GetAI_boss_ambassador_hellmaw; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp index ed2784471b3..8dd0a5f7060 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp @@ -173,5 +173,5 @@ void AddSC_boss_blackheart_the_inciter() newscript = new Script; newscript->Name="boss_blackheart_the_inciter"; newscript->GetAI = GetAI_boss_blackheart_the_inciter; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp index 16bd012e576..ed7108ad3e7 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp @@ -220,18 +220,7 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI if ( DrawnShadows_Timer < diff) { - Map *map = m_creature->GetMap(); - if(map->IsDungeon()) - { - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if((*i)->isAlive()) - { - (*i)->TeleportTo(555,VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); - } - } - } + DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); DoCast(m_creature,SPELL_DRAWN_SHADOWS,true); @@ -374,10 +363,10 @@ void AddSC_boss_grandmaster_vorpil() newscript = new Script; newscript->Name="boss_grandmaster_vorpil"; newscript->GetAI = GetAI_boss_grandmaster_vorpil; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_voidtraveler"; newscript->GetAI = GetAI_mob_voidtraveler; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp index 5b223b8d5ad..a5c387dc317 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp @@ -148,5 +148,5 @@ void AddSC_boss_murmur() newscript = new Script; newscript->Name="boss_murmur"; newscript->GetAI = GetAI_boss_murmur; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp index 1d482754cbc..ff5afc179e2 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp @@ -174,5 +174,5 @@ void AddSC_instance_shadow_labyrinth() newscript = new Script; newscript->Name = "instance_shadow_labyrinth"; newscript->GetInstanceData = GetInstanceData_instance_shadow_labyrinth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp index 92c522fba60..5a62f5ee6c5 100644 --- a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp +++ b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp @@ -492,23 +492,23 @@ void AddSC_azshara() newscript = new Script; newscript->Name="mobs_spitelashes"; newscript->GetAI = GetAI_mobs_spitelashes; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_loramus_thalipedes"; newscript->pGossipHello = &GossipHello_npc_loramus_thalipedes; newscript->pGossipSelect = &GossipSelect_npc_loramus_thalipedes; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_rizzle_sprysprocket"; newscript->GetAI = GetAI_mob_rizzle_sprysprocket; newscript->pGossipHello = &GossipHello_mob_rizzle_sprysprocket; newscript->pGossipSelect = &GossipSelect_mob_rizzle_sprysprocket; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_depth_charge"; newscript->GetAI = GetAI_mob_depth_charge; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp b/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp index 2908dc04285..f688892d709 100644 --- a/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp +++ b/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp @@ -149,5 +149,5 @@ void AddSC_boss_azuregos() newscript = new Script; newscript->Name="boss_azuregos"; newscript->GetAI = GetAI_boss_azuregos; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp b/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp index 43209b64ba8..03e26504228 100644 --- a/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp +++ b/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp @@ -350,23 +350,23 @@ void AddSC_azuremyst_isle() newscript = new Script; newscript->Name="npc_draenei_survivor"; newscript->GetAI = GetAI_npc_draenei_survivor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_engineer_spark_overgrind"; newscript->GetAI = GetAI_npc_engineer_spark_overgrind; newscript->pGossipHello = &GossipHello_npc_engineer_spark_overgrind; newscript->pGossipSelect = &GossipSelect_npc_engineer_spark_overgrind; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_injured_draenei"; newscript->GetAI = GetAI_npc_injured_draenei; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_susurrus"; newscript->pGossipHello = &GossipHello_npc_susurrus; newscript->pGossipSelect = &GossipSelect_npc_susurrus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp b/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp index 788f4e2b8ce..468efc4d6a3 100644 --- a/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp +++ b/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp @@ -369,22 +369,22 @@ void AddSC_the_barrens() newscript->Name="npc_beaten_corpse"; newscript->pGossipHello = &GossipHello_npc_beaten_corpse; newscript->pGossipSelect = &GossipSelect_npc_beaten_corpse; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_sputtervalve"; newscript->pGossipHello = &GossipHello_npc_sputtervalve; newscript->pGossipSelect = &GossipSelect_npc_sputtervalve; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_taskmaster_fizzule"; newscript->GetAI = GetAI_npc_taskmaster_fizzule; newscript->pReceiveEmote = &ReciveEmote_npc_taskmaster_fizzule; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_twiggy_flathead"; newscript->GetAI = GetAI_npc_twiggy_flathead; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp b/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp index 757f6acef06..68b581bae1c 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp @@ -64,5 +64,5 @@ void AddSC_black_temple() newscript->Name = "npc_spirit_of_olum"; newscript->pGossipHello = GossipHello_npc_spirit_of_olum; newscript->pGossipSelect = GossipSelect_npc_spirit_of_olum; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp index 44bf36cad93..3f56e3cd59b 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp @@ -361,5 +361,5 @@ void AddSC_boss_gurtogg_bloodboil() newscript = new Script; newscript->Name="boss_gurtogg_bloodboil"; newscript->GetAI = GetAI_boss_gurtogg_bloodboil; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp index ce03d8eac3a..c7f2ec460d9 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp @@ -2247,52 +2247,52 @@ void AddSC_boss_illidan() newscript = new Script; newscript->Name = "boss_illidan_stormrage"; newscript->GetAI = GetAI_boss_illidan_stormrage; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_akama_illidan"; newscript->GetAI = GetAI_npc_akama_at_illidan; newscript->pGossipHello = GossipHello_npc_akama_at_illidan; newscript->pGossipSelect = GossipSelect_npc_akama_at_illidan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "boss_maiev_shadowsong"; newscript->GetAI = GetAI_boss_maiev; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_flame_of_azzinoth"; newscript->GetAI = GetAI_mob_flame_of_azzinoth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_blade_of_azzinoth"; newscript->GetAI = GetAI_blade_of_azzinoth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "gameobject_cage_trap"; newscript->pGOHello = GOHello_cage_trap; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_cage_trap_trigger"; newscript->GetAI = &GetAI_cage_trap_trigger; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_shadow_demon"; newscript->GetAI = GetAI_shadow_demon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_demon_fire"; newscript->GetAI = GetAI_demonfire; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_parasitic_shadowfiend"; newscript->GetAI = GetAI_parasitic_shadowfiend; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp index 0f5d2af3c22..ee8a2c8348e 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp @@ -357,5 +357,5 @@ void AddSC_boss_mother_shahraz() newscript = new Script; newscript->Name="boss_mother_shahraz"; newscript->GetAI = GetAI_boss_shahraz; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp index 3d6233ca3f7..8c5bdbc4a4a 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp @@ -723,25 +723,25 @@ void AddSC_boss_reliquary_of_souls() newscript = new Script; newscript->Name="boss_reliquary_of_souls"; newscript->GetAI = GetAI_boss_reliquary_of_souls; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_essence_of_suffering"; newscript->GetAI = GetAI_boss_essence_of_suffering; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_essence_of_desire"; newscript->GetAI = GetAI_boss_essence_of_desire; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_essence_of_anger"; newscript->GetAI = GetAI_boss_essence_of_anger; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_enslaved_soul"; newscript->GetAI = GetAI_npc_enslaved_soul; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp index 9c1d50950dc..3cd73df1bc7 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp @@ -796,22 +796,22 @@ void AddSC_boss_shade_of_akama() newscript = new Script; newscript->Name="boss_shade_of_akama"; newscript->GetAI = GetAI_boss_shade_of_akama; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_ashtongue_channeler"; newscript->GetAI = GetAI_mob_ashtongue_channeler; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_ashtongue_sorcerer"; newscript->GetAI = GetAI_mob_ashtongue_sorcerer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_akama_shade"; newscript->GetAI = GetAI_npc_akama_shade; newscript->pGossipHello = &GossipHello_npc_akama; newscript->pGossipSelect = &GossipSelect_npc_akama; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp index d6b2e08fac0..640977d0eb9 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp @@ -236,10 +236,10 @@ void AddSC_boss_supremus() newscript = new Script; newscript->Name="boss_supremus"; newscript->GetAI = GetAI_boss_supremus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="molten_flame"; newscript->GetAI = GetAI_molten_flame; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp index e2ab402c7ff..97fcde9265f 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp @@ -575,15 +575,15 @@ void AddSC_boss_teron_gorefiend() newscript = new Script; newscript->Name = "mob_doom_blossom"; newscript->GetAI = GetAI_mob_doom_blossom; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_shadowy_construct"; newscript->GetAI = GetAI_mob_shadowy_construct; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_teron_gorefiend"; newscript->GetAI = GetAI_boss_teron_gorefiend; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp index f49c2ef17c7..f2fe6f64f2f 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp @@ -258,10 +258,10 @@ void AddSC_boss_najentus() newscript = new Script; newscript->Name="boss_najentus"; newscript->GetAI = GetAI_boss_najentus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_najentus_spine"; newscript->pGOHello = &GOHello_go_najentus_spine; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp b/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp index 6e5cabc034c..42197029a89 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp @@ -855,30 +855,30 @@ void AddSC_boss_illidari_council() newscript = new Script; newscript->Name="mob_illidari_council"; newscript->GetAI = GetAI_mob_illidari_council; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_blood_elf_council_voice_trigger"; newscript->GetAI = GetAI_mob_blood_elf_council_voice_trigger; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_gathios_the_shatterer"; newscript->GetAI = GetAI_boss_gathios_the_shatterer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lady_malande"; newscript->GetAI = GetAI_boss_lady_malande; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_veras_darkshadow"; newscript->GetAI = GetAI_boss_veras_darkshadow; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_high_nethermancer_zerevor"; newscript->GetAI = GetAI_boss_high_nethermancer_zerevor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp b/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp index cfeb700282b..0ff92762389 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp @@ -332,5 +332,5 @@ void AddSC_instance_black_temple() newscript = new Script; newscript->Name = "instance_black_temple"; newscript->GetInstanceData = GetInstanceData_instance_black_temple; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp index 95a920d39a3..c6e1cbcafe9 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp @@ -221,17 +221,17 @@ void AddSC_blackrock_depths() newscript = new Script; newscript->Name="phalanx"; newscript->GetAI = GetAI_mob_phalanx; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_kharan_mighthammer"; newscript->pGossipHello = &GossipHello_npc_kharan_mighthammer; newscript->pGossipSelect = &GossipSelect_npc_kharan_mighthammer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_lokhtos_darkbargainer"; newscript->pGossipHello = &GossipHello_npc_lokhtos_darkbargainer; newscript->pGossipSelect = &GossipSelect_npc_lokhtos_darkbargainer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp index b63691a3b6e..2bb2a2ae004 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp @@ -102,5 +102,5 @@ void AddSC_boss_ambassador_flamelash() newscript = new Script; newscript->Name="boss_ambassador_flamelash"; newscript->GetAI = GetAI_boss_ambassador_flamelash; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp index 13b9f31e734..cbf895cc3e4 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp @@ -87,5 +87,5 @@ void AddSC_boss_angerrel() newscript = new Script; newscript->Name="boss_angerrel"; newscript->GetAI = GetAI_boss_angerrel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp index 50cf2af8169..091863de655 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp @@ -111,5 +111,5 @@ void AddSC_boss_anubshiah() newscript = new Script; newscript->Name="boss_anubshiah"; newscript->GetAI = GetAI_boss_anubshiah; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp index b58ebc7b97a..867afe417cd 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp @@ -135,5 +135,5 @@ void AddSC_boss_doomrel() newscript = new Script; newscript->Name="boss_doomrel"; newscript->GetAI = GetAI_boss_doomrel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp index f9da16dd2fd..3c394476106 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp @@ -87,5 +87,5 @@ void AddSC_boss_doperel() newscript = new Script; newscript->Name="boss_doperel"; newscript->GetAI = GetAI_boss_doperel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp index e8b1fb791ee..d463ed7f38f 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp @@ -100,5 +100,5 @@ void AddSC_boss_draganthaurissan() newscript = new Script; newscript->Name="boss_emperor_dagran_thaurissan"; newscript->GetAI = GetAI_boss_draganthaurissan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp index 0760bc65733..7e3b8d9fba7 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp @@ -163,5 +163,5 @@ void AddSC_boss_general_angerforge() newscript = new Script; newscript->Name="boss_general_angerforge"; newscript->GetAI = GetAI_boss_general_angerforge; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp index 30caa104b31..966fe4b8c22 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp @@ -138,5 +138,5 @@ void AddSC_boss_gloomrel() newscript->GetAI = GetAI_boss_gloomrel; newscript->pGossipHello = &GossipHello_boss_gloomrel; newscript->pGossipSelect = &GossipSelect_boss_gloomrel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp index 91770069779..f2b617b73f0 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp @@ -77,5 +77,5 @@ void AddSC_boss_gorosh_the_dervish() newscript = new Script; newscript->Name="boss_gorosh_the_dervish"; newscript->GetAI = GetAI_boss_gorosh_the_dervish; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp index 7e489cca5a7..5005bb3935a 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp @@ -82,5 +82,5 @@ void AddSC_boss_grizzle() newscript = new Script; newscript->Name="boss_grizzle"; newscript->GetAI = GetAI_boss_grizzle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp index 778c68f73d3..53a94865002 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp @@ -101,5 +101,5 @@ void AddSC_boss_haterel() newscript = new Script; newscript->Name="boss_haterel"; newscript->GetAI = GetAI_boss_haterel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp index 8ee1a00c85b..43aa38ba4d4 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp @@ -101,5 +101,5 @@ void AddSC_boss_high_interrogator_gerstahn() newscript = new Script; newscript->Name="boss_high_interrogator_gerstahn"; newscript->GetAI = GetAI_boss_high_interrogator_gerstahn; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp index 0d163d31775..7703d6b2b31 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp @@ -80,5 +80,5 @@ void AddSC_boss_magmus() newscript = new Script; newscript->Name="boss_magmus"; newscript->GetAI = GetAI_boss_magmus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp index 208353e66f3..68923722380 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp @@ -95,5 +95,5 @@ void AddSC_boss_moira_bronzebeard() newscript = new Script; newscript->Name="boss_moira_bronzebeard"; newscript->GetAI = GetAI_boss_moira_bronzebeard; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp index 93f3c124f29..e8753971898 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp @@ -111,5 +111,5 @@ void AddSC_boss_seethrel() newscript = new Script; newscript->Name="boss_seethrel"; newscript->GetAI = GetAI_boss_seethrel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp index 0ecf70148fe..db1b0923f4c 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp @@ -97,5 +97,5 @@ void AddSC_boss_vilerel() newscript = new Script; newscript->Name="boss_vilerel"; newscript->GetAI = GetAI_boss_vilerel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp index c26ba2ed6b9..56f4b3f385f 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp @@ -97,5 +97,5 @@ void AddSC_boss_drakkisath() newscript = new Script; newscript->Name="boss_drakkisath"; newscript->GetAI = GetAI_boss_drakkisath; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp index 68107e820bf..d6089c269e7 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp @@ -201,5 +201,5 @@ void AddSC_boss_gyth() newscript = new Script; newscript->Name="boss_gyth"; newscript->GetAI = GetAI_boss_gyth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp index 0b2c09acccf..e0c5d69d631 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp @@ -91,5 +91,5 @@ void AddSC_boss_halycon() newscript = new Script; newscript->Name="boss_halycon"; newscript->GetAI = GetAI_boss_halycon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp index afaedcc4ad8..0ee0a9df7f8 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp @@ -127,5 +127,5 @@ void AddSC_boss_highlordomokk() newscript = new Script; newscript->Name="boss_highlord_omokk"; newscript->GetAI = GetAI_boss_highlordomokk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp index 8c1d3096597..c9686346057 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp @@ -82,5 +82,5 @@ void AddSC_boss_mothersmolderweb() newscript = new Script; newscript->Name="boss_mother_smolderweb"; newscript->GetAI = GetAI_boss_mothersmolderweb; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp index 5ab5847e38a..5852a12302e 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp @@ -123,5 +123,5 @@ void AddSC_boss_overlordwyrmthalak() newscript = new Script; newscript->Name="boss_overlord_wyrmthalak"; newscript->GetAI = GetAI_boss_overlordwyrmthalak; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp index f7705c647af..cbabb24d752 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp @@ -89,5 +89,5 @@ void AddSC_boss_pyroguard_emberseer() newscript = new Script; newscript->Name="boss_pyroguard_emberseer"; newscript->GetAI = GetAI_boss_pyroguard_emberseer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp index 7c0901e1f40..82561cb954f 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp @@ -81,5 +81,5 @@ void AddSC_boss_quatermasterzigris() newscript = new Script; newscript->Name="quartermaster_zigris"; newscript->GetAI = GetAI_boss_quatermasterzigris; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp index 7ca84b3c429..b80a941ad17 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp @@ -87,5 +87,5 @@ void AddSC_boss_rend_blackhand() newscript = new Script; newscript->Name="boss_rend_blackhand"; newscript->GetAI = GetAI_boss_rend_blackhand; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp index 17c73e43c82..83a324a2c38 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp @@ -91,5 +91,5 @@ void AddSC_boss_shadowvosh() newscript = new Script; newscript->Name="boss_shadow_hunter_voshgajin"; newscript->GetAI = GetAI_boss_shadowvosh; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp index d7e403d0e72..586addd9d76 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp @@ -89,5 +89,5 @@ void AddSC_boss_thebeast() newscript = new Script; newscript->Name="boss_the_beast"; newscript->GetAI = GetAI_boss_thebeast; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp index 7377b46526f..bcc1469ccd9 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp @@ -117,5 +117,5 @@ void AddSC_boss_warmastervoone() newscript = new Script; newscript->Name="boss_warmaster_voone"; newscript->GetAI = GetAI_boss_warmastervoone; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp index 0e40276903a..2c69e8ff599 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp @@ -124,5 +124,5 @@ void AddSC_boss_broodlord() newscript = new Script; newscript->Name="boss_broodlord"; newscript->GetAI = GetAI_boss_broodlord; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp index ea683bd1a13..920a50d4e49 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp @@ -310,5 +310,5 @@ void AddSC_boss_chromaggus() newscript = new Script; newscript->Name="boss_chromaggus"; newscript->GetAI = GetAI_boss_chromaggus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp index 703dec09536..0dd8095a94b 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp @@ -99,5 +99,5 @@ void AddSC_boss_ebonroc() newscript = new Script; newscript->Name="boss_ebonroc"; newscript->GetAI = GetAI_boss_ebonroc; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp index 05a3e36948b..c1915d45a15 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp @@ -90,5 +90,5 @@ void AddSC_boss_firemaw() newscript = new Script; newscript->Name="boss_firemaw"; newscript->GetAI = GetAI_boss_firemaw; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp index fa34406b1fe..fbc8f4fa51a 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp @@ -90,5 +90,5 @@ void AddSC_boss_flamegor() newscript = new Script; newscript->Name="boss_flamegor"; newscript->GetAI = GetAI_boss_flamegor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp index b819fde0bd5..741e61ba4de 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp @@ -223,5 +223,5 @@ void AddSC_boss_nefarian() newscript = new Script; newscript->Name="boss_nefarian"; newscript->GetAI = GetAI_boss_nefarian; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp index bf76a08897f..98615b47758 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp @@ -127,5 +127,5 @@ void AddSC_boss_razorgore() newscript = new Script; newscript->Name="boss_razorgore"; newscript->GetAI = GetAI_boss_razorgore; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp index 05e4b39af7d..a708a7de195 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp @@ -257,5 +257,5 @@ void AddSC_boss_vael() newscript->GetAI = GetAI_boss_vael; newscript->pGossipHello = &GossipHello_boss_vael; newscript->pGossipSelect = &GossipSelect_boss_vael; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp index c9e92c7b75f..70bb6c15113 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp @@ -390,5 +390,5 @@ void AddSC_boss_victor_nefarius() newscript->GetAI = GetAI_boss_victor_nefarius; newscript->pGossipHello = &GossipHello_boss_victor_nefarius; newscript->pGossipSelect = &GossipSelect_boss_victor_nefarius; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp b/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp index 99dc4dbc82c..c47153aed7a 100644 --- a/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp +++ b/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp @@ -406,33 +406,33 @@ void AddSC_blades_edge_mountains() newscript = new Script; newscript->Name="mobs_bladespire_ogre"; newscript->GetAI = GetAI_mobs_bladespire_ogre; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mobs_nether_drake"; newscript->GetAI = GetAI_mobs_nether_drake; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_daranelle"; newscript->GetAI = GetAI_npc_daranelle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_overseer_nuaar"; newscript->pGossipHello = &GossipHello_npc_overseer_nuaar; newscript->pGossipSelect = &GossipSelect_npc_overseer_nuaar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_saikkal_the_elder"; newscript->pGossipHello = &GossipHello_npc_saikkal_the_elder; newscript->pGossipSelect = &GossipSelect_npc_saikkal_the_elder; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_skyguard_handler_irena"; newscript->pGossipHello = &GossipHello_npc_skyguard_handler_irena; newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_irena; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp b/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp index 9212f13946a..b47abcb4c15 100644 --- a/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp +++ b/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp @@ -149,11 +149,11 @@ void AddSC_blasted_lands() newscript->Name="npc_deathly_usher"; newscript->pGossipHello = &GossipHello_npc_deathly_usher; newscript->pGossipSelect = &GossipSelect_npc_deathly_usher; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_fallen_hero_of_horde"; newscript->pGossipHello = &GossipHello_npc_fallen_hero_of_horde; newscript->pGossipSelect = &GossipSelect_npc_fallen_hero_of_horde; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp b/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp index 9de7b6d6085..250c382f028 100644 --- a/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp +++ b/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp @@ -178,5 +178,5 @@ void AddSC_boss_kruul() newscript = new Script; newscript->Name="boss_kruul"; newscript->GetAI = GetAI_boss_kruul; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp b/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp index e52386fc020..3705d195ca3 100644 --- a/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp +++ b/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp @@ -131,11 +131,11 @@ void AddSC_bloodmyst_isle() newscript = new Script; newscript->Name="mob_webbed_creature"; newscript->GetAI = GetAI_mob_webbed_creature; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_captured_sunhawk_agent"; newscript->pGossipHello = &GossipHello_npc_captured_sunhawk_agent; newscript->pGossipSelect = &GossipSelect_npc_captured_sunhawk_agent; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp b/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp index bd926a2e7cc..7f0c2f45118 100644 --- a/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp +++ b/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp @@ -147,5 +147,5 @@ void AddSC_burning_steppes() newscript->GetAI = GetAI_npc_ragged_john; newscript->pGossipHello = &GossipHello_npc_ragged_john; newscript->pGossipSelect = &GossipSelect_npc_ragged_john; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp index f6dd7a167ff..db167ff5ab9 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp @@ -117,5 +117,5 @@ void AddSC_boss_aeonus() newscript = new Script; newscript->Name="boss_aeonus"; newscript->GetAI = GetAI_boss_aeonus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp index b6d00be0889..fcaade46067 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp @@ -105,5 +105,5 @@ void AddSC_boss_chrono_lord_deja() newscript = new Script; newscript->Name="boss_chrono_lord_deja"; newscript->GetAI = GetAI_boss_chrono_lord_deja; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp index a59ecc8e4b6..2dad8913576 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp @@ -139,5 +139,5 @@ void AddSC_boss_temporus() newscript = new Script; newscript->Name="boss_temporus"; newscript->GetAI = GetAI_boss_temporus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp index 7e25c0c9b15..ab208aafba9 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp @@ -769,20 +769,20 @@ void AddSC_boss_archimonde() newscript = new Script; newscript->Name="boss_archimonde"; newscript->GetAI = GetAI_boss_archimonde; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_doomfire"; newscript->GetAI = GetAI_mob_doomfire; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_doomfire_targetting"; newscript->GetAI = GetAI_mob_doomfire_targetting; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_ancient_wisp"; newscript->GetAI = GetAI_mob_ancient_wisp; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp index 837f1f09872..51f147badc2 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp @@ -200,18 +200,18 @@ void AddSC_hyjal() newscript->GetAI = GetAI_npc_jaina_proudmoore; newscript->pGossipHello = &GossipHello_npc_jaina_proudmoore; newscript->pGossipSelect = &GossipSelect_npc_jaina_proudmoore; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_thrall"; newscript->GetAI = GetAI_npc_thrall; newscript->pGossipHello = &GossipHello_npc_thrall; newscript->pGossipSelect = &GossipSelect_npc_thrall; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_tyrande_whisperwind"; newscript->pGossipHello = &GossipHello_npc_tyrande_whisperwind; newscript->pGossipSelect = &GossipSelect_npc_tyrande_whisperwind; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp index a6f8e3a7305..3c3971d6036 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp @@ -199,5 +199,5 @@ void AddSC_instance_mount_hyjal() newscript = new Script; newscript->Name = "instance_hyjal"; newscript->GetInstanceData = GetInstanceData_instance_mount_hyjal; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp index 19aff777b23..c43f5c2471c 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp @@ -152,5 +152,5 @@ void AddSC_boss_captain_skarloc() newscript = new Script; newscript->Name="boss_captain_skarloc"; newscript->GetAI = GetAI_boss_captain_skarloc; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp index 734ea93ffbe..510ef7a039f 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp @@ -146,5 +146,5 @@ void AddSC_boss_epoch_hunter() newscript = new Script; newscript->Name="boss_epoch_hunter"; newscript->GetAI = GetAI_boss_epoch_hunter; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp index 6733e4b8d41..76d96775056 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp @@ -194,10 +194,10 @@ void AddSC_boss_lieutenant_drake() newscript = new Script; newscript->Name="go_barrel_old_hillsbrad"; newscript->pGOHello = &GOHello_go_barrel_old_hillsbrad; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lieutenant_drake"; newscript->GetAI = GetAI_boss_lieutenant_drake; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp index a6e4b377358..38a20c8adaf 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp @@ -174,5 +174,5 @@ void AddSC_instance_old_hillsbrad() newscript = new Script; newscript->Name = "instance_old_hillsbrad"; newscript->GetInstanceData = GetInstanceData_instance_old_hillsbrad; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp index 659636e1d35..596d327bc42 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp @@ -893,24 +893,24 @@ void AddSC_old_hillsbrad() newscript->Name="npc_brazen"; newscript->pGossipHello = &GossipHello_npc_brazen; newscript->pGossipSelect = &GossipSelect_npc_brazen; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_erozion"; newscript->pGossipHello = &GossipHello_npc_erozion; newscript->pGossipSelect = &GossipSelect_npc_erozion; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_thrall_old_hillsbrad"; newscript->pGossipHello = &GossipHello_npc_thrall_old_hillsbrad; newscript->pGossipSelect = &GossipSelect_npc_thrall_old_hillsbrad; newscript->GetAI = GetAI_npc_thrall_old_hillsbrad; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_taretha"; newscript->pGossipHello = &GossipHello_npc_taretha; newscript->pGossipSelect = &GossipSelect_npc_taretha; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp index 9199bcadaf1..42a707ff930 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp @@ -744,20 +744,20 @@ void AddSC_boss_fathomlord_karathress() newscript = new Script; newscript->Name="boss_fathomlord_karathress"; newscript->GetAI = GetAI_boss_fathomlord_karathress; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_fathomguard_sharkkis"; newscript->GetAI = GetAI_boss_fathomguard_sharkkis; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_fathomguard_tidalvess"; newscript->GetAI = GetAI_boss_fathomguard_tidalvess; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_fathomguard_caribdis"; newscript->GetAI = GetAI_boss_fathomguard_caribdis; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp index 13b8ebbf312..07adcf4b225 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp @@ -382,5 +382,5 @@ void AddSC_boss_hydross_the_unstable() newscript = new Script; newscript->Name="boss_hydross_the_unstable"; newscript->GetAI = GetAI_boss_hydross_the_unstable; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp index 6adc833e8a8..232a828150c 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp @@ -250,12 +250,12 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI { //remove old tainted cores to prevent cheating in phase 2 Map *map = m_creature->GetMap(); - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) + Map::PlayerList const &PlayerList = map->GetPlayers(); + for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) { - if((*i)) + if(Player* i_pl = i->getSource()) { - (*i)->DestroyItemCount(31088, 1, true); + i_pl->DestroyItemCount(31088, 1, true); } } } @@ -1029,42 +1029,42 @@ void AddSC_boss_lady_vashj() newscript = new Script; newscript->Name="boss_lady_vashj"; newscript->GetAI = GetAI_boss_lady_vashj; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_enchanted_elemental"; newscript->GetAI = GetAI_mob_enchanted_elemental; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_tainted_elemental"; newscript->GetAI = GetAI_mob_tainted_elemental; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_toxic_sporebat"; newscript->GetAI = GetAI_mob_toxic_sporebat; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_coilfang_elite"; newscript->GetAI = GetAI_mob_coilfang_elite; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_coilfang_strider"; newscript->GetAI = GetAI_mob_coilfang_strider; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_shield_generator_channel"; newscript->GetAI = GetAI_mob_shield_generator_channel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="item_tainted_core"; newscript->pItemUse = ItemUse_item_tainted_core; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp index 53aa7c48d35..70d4d6d2c56 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp @@ -754,19 +754,22 @@ struct TRINITY_DLL_DECL mob_greyheart_spellbinderAI : public ScriptedAI if(Earthshock_Timer < diff) { Map *map = m_creature->GetMap(); - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - for(InstanceMap::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr) + Map::PlayerList const &PlayerList = map->GetPlayers(); + for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr) { - bool isCasting = false; - for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) - if((*itr)->m_currentSpells[i]) - isCasting = true; - - if(isCasting) - { - DoCast((*itr), SPELL_EARTHSHOCK); - break; - } + if (Player* i_pl = itr->getSource()) + { + bool isCasting = false; + for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) + if(i_pl->m_currentSpells[i]) + isCasting = true; + + if(isCasting) + { + DoCast(i_pl, SPELL_EARTHSHOCK); + break; + } + } } Earthshock_Timer = 8000 + rand()%7000; }else Earthshock_Timer -= diff; @@ -801,20 +804,20 @@ void AddSC_boss_leotheras_the_blind() newscript = new Script; newscript->Name="boss_leotheras_the_blind"; newscript->GetAI = GetAI_boss_leotheras_the_blind; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_leotheras_the_blind_demonform"; newscript->GetAI = GetAI_boss_leotheras_the_blind_demonform; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_greyheart_spellbinder"; newscript->GetAI = GetAI_mob_greyheart_spellbinder; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_inner_demon"; newscript->GetAI = GetAI_mob_inner_demon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp index 924b15397ed..509eadc2006 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp @@ -167,16 +167,16 @@ void AddSC_boss_the_lurker_below() newscript = new Script; newscript->Name="boss_the_lurker_below"; newscript->GetAI = GetAI_boss_the_lurker_below; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_coilfang_guardian"; newscript->GetAI = GetAI_mob_coilfang_guardian; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_coilfang_ambusher"; newscript->GetAI = GetAI_mob_coilfang_ambusher; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp index fa6a57a7fe4..900c3aad6d9 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp @@ -350,10 +350,10 @@ void AddSC_boss_morogrim_tidewalker() newscript = new Script; newscript->Name="boss_morogrim_tidewalker"; newscript->GetAI = GetAI_boss_morogrim_tidewalker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_water_globule"; newscript->GetAI = GetAI_mob_water_globule; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp index de0f829c3d1..25b6a1a54d5 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp @@ -215,5 +215,5 @@ void AddSC_instance_serpentshrine_cavern() newscript = new Script; newscript->Name = "instance_serpent_shrine"; newscript->GetInstanceData = GetInstanceData_instance_serpentshrine_cavern; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp index f51a28d61b3..cb09a94044f 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp @@ -188,10 +188,10 @@ void AddSC_boss_hydromancer_thespia() newscript = new Script; newscript->Name="boss_hydromancer_thespia"; newscript->GetAI = GetAI_boss_thespiaAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_coilfang_waterelemental"; newscript->GetAI = GetAI_mob_coilfang_waterelementalAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp index d769b44d9cf..6f839359d0a 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp @@ -271,10 +271,10 @@ void AddSC_boss_mekgineer_steamrigger() newscript = new Script; newscript->Name="boss_mekgineer_steamrigger"; newscript->GetAI = GetAI_boss_mekgineer_steamrigger; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_steamrigger_mechanic"; newscript->GetAI = GetAI_mob_steamrigger_mechanic; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp index 85c6657bebb..a3b3c68ba82 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp @@ -226,10 +226,10 @@ void AddSC_boss_warlord_kalithresh() newscript = new Script; newscript->Name="mob_naga_distiller"; newscript->GetAI = GetAI_mob_naga_distiller; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_warlord_kalithresh"; newscript->GetAI = GetAI_boss_warlord_kalithresh; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp index 798d04d6cfb..dc082244846 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp @@ -166,5 +166,5 @@ void AddSC_instance_steam_vault() newscript = new Script; newscript->Name = "instance_steam_vault"; newscript->GetInstanceData = GetInstanceData_instance_steam_vault; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp index 13ac880295b..34c854ad8bf 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp @@ -147,10 +147,10 @@ void AddSC_boss_hungarfen() newscript = new Script; newscript->Name="boss_hungarfen"; newscript->GetAI = GetAI_boss_hungarfen; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_underbog_mushroom"; newscript->GetAI = GetAI_mob_underbog_mushroom; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp b/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp index c5f7bf6fc07..ee8c531593b 100644 --- a/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp +++ b/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp @@ -94,5 +94,5 @@ void AddSC_dun_morogh() newscript = new Script; newscript->Name="npc_narm_faulk"; newscript->GetAI = GetAI_npc_narm_faulk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp b/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp index 7a8c1329b36..16e5d3fc62e 100644 --- a/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp +++ b/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp @@ -204,28 +204,28 @@ void AddSC_dustwallow_marsh() newscript = new Script; newscript->Name="mobs_risen_husk_spirit"; newscript->GetAI = GetAI_mobs_risen_husk_spirit; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_restless_apparition"; newscript->pGossipHello = &GossipHello_npc_restless_apparition; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_deserter_agitator"; newscript->GetAI = GetAI_npc_deserter_agitator; newscript->pGossipHello = &GossipHello_npc_deserter_agitator; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_lady_jaina_proudmoore"; newscript->pGossipHello = &GossipHello_npc_lady_jaina_proudmoore; newscript->pGossipSelect = &GossipSelect_npc_lady_jaina_proudmoore; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_nat_pagle"; newscript->pGossipHello = &GossipHello_npc_nat_pagle; newscript->pGossipSelect = &GossipSelect_npc_nat_pagle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp b/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp index e8d44931f11..125fdf44817 100644 --- a/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp +++ b/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp @@ -158,23 +158,23 @@ void AddSC_eastern_plaguelands() newscript = new Script; newscript->Name="mobs_ghoul_flayer"; newscript->GetAI = GetAI_mobs_ghoul_flayer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_augustus_the_touched"; newscript->pGossipHello = &GossipHello_npc_augustus_the_touched; newscript->pGossipSelect = &GossipSelect_npc_augustus_the_touched; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_darrowshire_spirit"; newscript->GetAI = GetAI_npc_darrowshire_spirit; newscript->pGossipHello = &GossipHello_npc_darrowshire_spirit; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_tirion_fordring"; newscript->pGossipHello = &GossipHello_npc_tirion_fordring; newscript->pGossipSelect = &GossipSelect_npc_tirion_fordring; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp b/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp index d91b4533de2..b1061213649 100644 --- a/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp +++ b/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp @@ -94,5 +94,5 @@ void AddSC_elwynn_forest() newscript = new Script; newscript->Name="npc_henze_faulk"; newscript->GetAI = GetAI_npc_henze_faulk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp index 932dea11a60..4f9c2a775af 100644 --- a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp +++ b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp @@ -152,12 +152,12 @@ void AddSC_eversong_woods() newscript = new Script; newscript->Name="mobs_mana_tapped"; newscript->GetAI = GetAI_mobs_mana_tapped; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name= "npc_prospector_anvilward"; newscript->GetAI = GetAI_npc_prospector_anvilward; newscript->pGossipHello = &GossipHello_npc_prospector_anvilward; newscript->pGossipSelect = &GossipSelect_npc_prospector_anvilward; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/felwood/felwood.cpp b/src/bindings/scripts/scripts/zone/felwood/felwood.cpp index 59dc03456a4..2cd6d05579e 100644 --- a/src/bindings/scripts/scripts/zone/felwood/felwood.cpp +++ b/src/bindings/scripts/scripts/zone/felwood/felwood.cpp @@ -85,5 +85,5 @@ void AddSC_felwood() newscript->Name="npcs_riverbreeze_and_silversky"; newscript->pGossipHello = &GossipHello_npcs_riverbreeze_and_silversky; newscript->pGossipSelect = &GossipSelect_npcs_riverbreeze_and_silversky; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/feralas/feralas.cpp b/src/bindings/scripts/scripts/zone/feralas/feralas.cpp index ca8c5d0a02d..e0a89fe5905 100644 --- a/src/bindings/scripts/scripts/zone/feralas/feralas.cpp +++ b/src/bindings/scripts/scripts/zone/feralas/feralas.cpp @@ -76,10 +76,10 @@ void AddSC_feralas() newscript->Name="npc_gregan_brewspewer"; newscript->pGossipHello = &GossipHello_npc_gregan_brewspewer; newscript->pGossipSelect = &GossipSelect_npc_gregan_brewspewer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_screecher_spirit"; newscript->pGossipHello = &GossipHello_npc_screecher_spirit; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp b/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp index 35c7213d033..ade3931c75d 100644 --- a/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp +++ b/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp @@ -133,22 +133,22 @@ void AddSC_ghostlands() newscript->Name="npc_blood_knight_dawnstar"; newscript->pGossipHello = &GossipHello_npc_blood_knight_dawnstar; newscript->pGossipSelect = &GossipSelect_npc_blood_knight_dawnstar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_budd_nedreck"; newscript->pGossipHello = &GossipHello_npc_budd_nedreck; newscript->pGossipSelect = &GossipSelect_npc_budd_nedreck; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_rathis_tomber"; newscript->pGossipHello = &GossipHello_npc_rathis_tomber; newscript->pGossipSelect = &GossipSelect_npc_rathis_tomber; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "go_gilded_brazier"; newscript->pGOHello = &GOHello_gilded_brazier; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp index bb2487b892e..1616d75e376 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp @@ -300,5 +300,5 @@ void AddSC_boss_gruul() newscript = new Script; newscript->Name="boss_gruul"; newscript->GetAI = GetAI_boss_gruul; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp index 3c77b1a0acf..b0e53373a2f 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp @@ -817,25 +817,25 @@ void AddSC_boss_high_king_maulgar() newscript = new Script; newscript->Name="boss_high_king_maulgar"; newscript->GetAI = GetAI_boss_high_king_maulgar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_kiggler_the_crazed"; newscript->GetAI = GetAI_boss_kiggler_the_crazed; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_blindeye_the_seer"; newscript->GetAI = GetAI_boss_blindeye_the_seer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_olm_the_summoner"; newscript->GetAI = GetAI_boss_olm_the_summoner; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_krosh_firehand"; newscript->GetAI = GetAI_boss_krosh_firehand; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp index 062800da3f6..3d058060722 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp @@ -184,5 +184,5 @@ void AddSC_instance_gruuls_lair() newscript = new Script; newscript->Name = "instance_gruuls_lair"; newscript->GetInstanceData = GetInstanceData_instance_gruuls_lair; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp index 2237a85077a..1431be7dd51 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp @@ -123,10 +123,10 @@ void AddSC_boss_broggok() newscript = new Script; newscript->Name="boss_broggok"; newscript->GetAI = GetAI_boss_broggokAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_broggok_poisoncloud"; newscript->GetAI = GetAI_mob_broggok_poisoncloudAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp index bc5799ffe7e..092dfcd17be 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp @@ -225,10 +225,10 @@ void AddSC_boss_kelidan_the_breaker() newscript = new Script; newscript->Name="boss_kelidan_the_breaker"; newscript->GetAI = GetAI_boss_kelidan_the_breaker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_shadowmoon_channeler"; newscript->GetAI = GetAI_mob_shadowmoon_channeler; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp index ec85747032d..0c30651c9d5 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp @@ -127,5 +127,5 @@ void AddSC_boss_the_maker() newscript = new Script; newscript->Name="boss_the_maker"; newscript->GetAI = GetAI_boss_the_makerAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp index 676fbddf48c..1d8b1ec2c22 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp @@ -209,5 +209,5 @@ void AddSC_boss_omor_the_unscarred() newscript = new Script; newscript->Name="boss_omor_the_unscarred"; newscript->GetAI = GetAI_boss_omor_the_unscarredAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp index 21e9362a762..0d9e200c6e7 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp @@ -164,5 +164,5 @@ void AddSC_boss_watchkeeper_gargolmar() newscript = new Script; newscript->Name="boss_watchkeeper_gargolmar"; newscript->GetAI = GetAI_boss_watchkeeper_gargolmarAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp index 4d7fe35891d..4d819b3537b 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp @@ -545,21 +545,21 @@ void AddSC_boss_magtheridon() newscript = new Script; newscript->Name="boss_magtheridon"; newscript->GetAI = GetAI_boss_magtheridon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_hellfire_channeler"; newscript->GetAI = GetAI_mob_hellfire_channeler; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_manticron_cube"; newscript->pGOHello = &GOHello_go_Manticron_Cube; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_abyssal"; newscript->GetAI = GetAI_mob_abyssalAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); }
\ No newline at end of file diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp index 8a6815e068a..51f22a1ff54 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp @@ -118,9 +118,6 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance void SetData(uint32 type, uint32 data) { - Player *player = GetPlayer(); - if(!player) return; - switch(type) { case DATA_MAGTHERIDON_EVENT: @@ -129,7 +126,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance RespawnTimer = 10000; if(data != IN_PROGRESS) { - if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) + if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) Door->SetGoState(0); } break; @@ -142,7 +139,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance Encounters[1] = NOT_STARTED; for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) { - if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i)) + if(Creature *Channeler = instance->GetCreatureInMap(*i)) { if(Channeler->isAlive()) Channeler->AI()->EnterEvadeMode(); @@ -151,7 +148,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance } } CageTimer = 0; - if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) + if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) Door->SetGoState(0); }break; case IN_PROGRESS: // Event start. @@ -161,7 +158,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance // Let all five channelers aggro. for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) { - Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i); + Creature *Channeler = instance->GetCreatureInMap(*i); if(Channeler && Channeler->isAlive()) { //if(Unit *target = Channeler->SelectNearbyTarget()) @@ -170,19 +167,19 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance } } // Release Magtheridon after two minutes. - Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID); + Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); if(Magtheridon && Magtheridon->isAlive()) { Magtheridon->TextEmote("'s bonds begin to weaken!", 0); CageTimer = 120000; } - if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) + if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) Door->SetGoState(1); }break; case DONE: // Add buff and check if all channelers are dead. for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) { - Unit *Channeler = Unit::GetUnit(*player, *i); + Creature *Channeler = instance->GetCreatureInMap(*i); if(Channeler && Channeler->isAlive()) { //Channeler->CastSpell(Channeler, SPELL_SOUL_TRANSFER, true); @@ -197,7 +194,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance // true - collapse / false - reset for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i) { - if(GameObject *Column = GameObject::GetGameObject(*player, *i)) + if(GameObject *Column = instance->GetGameObjectInMap(*i)) Column->SetGoState(!data); } break; @@ -213,30 +210,26 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance return 0; } - Player* GetPlayer() - { - if(((InstanceMap*)instance)->GetPlayers().size()) - return ((InstanceMap*)instance)->GetPlayers().front(); - return NULL; - } - void AttackNearestTarget(Creature *creature) { float minRange = 999.0f; float range; Player* target = NULL; - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)instance)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; + Map::PlayerList const &PlayerList = instance->GetPlayers(); + Map::PlayerList::const_iterator i; for(i = PlayerList.begin(); i != PlayerList.end(); ++i) { - if((*i)->isTargetableForAttack()) + if(Player* i_pl = i->getSource()) { - range = (*i)->GetDistance(creature); - if(range < minRange) + if(i_pl->isTargetableForAttack()) { - minRange = range; - target = *i; - } + range = i_pl->GetDistance(creature); + if(range < minRange) + { + minRange = range; + target = i_pl; + } + } } } creature->AI()->AttackStart(target); @@ -248,14 +241,11 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance { if(CageTimer <= diff) { - if(Player *player = GetPlayer()) + Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); + if(Magtheridon && Magtheridon->isAlive()) { - Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID); - if(Magtheridon && Magtheridon->isAlive()) - { - Magtheridon->clearUnitState(UNIT_STAT_STUNNED); - AttackNearestTarget(Magtheridon); - } + Magtheridon->clearUnitState(UNIT_STAT_STUNNED); + AttackNearestTarget(Magtheridon); } CageTimer = 0; }else CageTimer -= diff; @@ -265,17 +255,14 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance { if(RespawnTimer <= diff) { - if(Player *player = GetPlayer()) + for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) { - for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) + if(Creature *Channeler = instance->GetCreatureInMap(*i)) { - if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i)) - { - if(Channeler->isAlive()) - Channeler->AI()->EnterEvadeMode(); - else - Channeler->Respawn(); - } + if(Channeler->isAlive()) + Channeler->AI()->EnterEvadeMode(); + else + Channeler->Respawn(); } } RespawnTimer = 0; @@ -295,5 +282,5 @@ void AddSC_instance_magtheridons_lair() newscript = new Script; newscript->Name = "instance_magtheridons_lair"; newscript->GetInstanceData = GetInstanceData_instance_magtheridons_lair; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp index 9d8335c527b..299f72a041b 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp @@ -444,15 +444,15 @@ void AddSC_boss_grand_warlock_nethekurse() newscript = new Script; newscript->Name="boss_grand_warlock_nethekurse"; newscript->GetAI = GetAI_boss_grand_warlock_nethekurse; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_fel_orc_convert"; newscript->GetAI = GetAI_mob_fel_orc_convert; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_lesser_shadow_fissure"; newscript->GetAI = GetAI_mob_lesser_shadow_fissure; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp index 092e82df0ed..2c128b3c047 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp @@ -394,10 +394,10 @@ void AddSC_boss_warbringer_omrogg() newscript = new Script; newscript->Name="boss_warbringer_omrogg"; newscript->GetAI = GetAI_boss_warbringer_omrogg; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_omrogg_heads"; newscript->GetAI = GetAI_mob_omrogg_heads; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp index 9dc78cb82cb..bee90392fe3 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp @@ -110,5 +110,5 @@ void AddSC_instance_shattered_halls() newscript = new Script; newscript->Name = "instance_shattered_halls"; newscript->GetInstanceData = GetInstanceData_instance_shattered_halls; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp b/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp index 51b4017b707..9b1822226a7 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp @@ -137,5 +137,5 @@ void AddSC_boss_doomlordkazzak() newscript = new Script; newscript->Name="boss_doomlord_kazzak"; newscript->GetAI = GetAI_boss_doomlordkazzak; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp b/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp index 1c3a4c71725..81d23457aab 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp @@ -171,17 +171,17 @@ void AddSC_hellfire_peninsula() newscript->Name="npc_wing_commander_dabiree"; newscript->pGossipHello = &GossipHello_npc_wing_commander_dabiree; newscript->pGossipSelect = &GossipSelect_npc_wing_commander_dabiree; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_gryphoneer_windbellow"; newscript->pGossipHello = &GossipHello_npc_gryphoneer_windbellow; newscript->pGossipSelect = &GossipSelect_npc_gryphoneer_windbellow; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_wing_commander_brack"; newscript->pGossipHello = &GossipHello_npc_wing_commander_brack; newscript->pGossipSelect = &GossipSelect_npc_wing_commander_brack; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp b/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp index 7bb51ad499c..701f208f2a3 100644 --- a/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp +++ b/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp @@ -89,5 +89,5 @@ void AddSC_ironforge() newscript->Name="npc_royal_historian_archesonus"; newscript->pGossipHello = &GossipHello_npc_royal_historian_archesonus; newscript->pGossipSelect = &GossipSelect_npc_royal_historian_archesonus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp b/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp index 9b2c1cda518..2690ecfa0ac 100644 --- a/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp +++ b/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp @@ -140,16 +140,16 @@ void AddSC_isle_of_queldanas() newscript->Name="npc_ayren_cloudbreaker"; newscript->pGossipHello = &GossipHello_npc_ayren_cloudbreaker; newscript->pGossipSelect = &GossipSelect_npc_ayren_cloudbreaker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_converted_sentry"; newscript->GetAI = GetAI_npc_converted_sentry; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_unrestrained_dragonhawk"; newscript->pGossipHello = &GossipHello_npc_unrestrained_dragonhawk; newscript->pGossipSelect = &GossipSelect_npc_unrestrained_dragonhawk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp index b560caad0d1..3c83b618604 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp @@ -196,5 +196,5 @@ void AddSC_boss_curator() newscript = new Script; newscript->Name="boss_curator"; newscript->GetAI = GetAI_boss_curator; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp index e0bbadf5650..b4075e72b73 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp @@ -179,5 +179,5 @@ void AddSC_boss_maiden_of_virtue() newscript = new Script; newscript->Name="boss_maiden_of_virtue"; newscript->GetAI = GetAI_boss_maiden_of_virtue; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp index 1be1a2df16f..1331e59c2f2 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp @@ -362,10 +362,10 @@ void AddSC_boss_attumen() newscript = new Script; newscript->Name="boss_attumen"; newscript->GetAI = GetAI_boss_attumen; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_midnight"; newscript->GetAI = GetAI_boss_midnight; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp index 06a47787fa0..ce8f26ff0e5 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp @@ -835,35 +835,35 @@ void AddSC_boss_moroes() newscript = new Script; newscript->Name="boss_moroes"; newscript->GetAI = GetAI_boss_moroes; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_baroness_dorothea_millstipe"; newscript->GetAI = GetAI_baroness_dorothea_millstipe; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_baron_rafe_dreuger"; newscript->GetAI = GetAI_baron_rafe_dreuger; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lady_catriona_von_indi"; newscript->GetAI = GetAI_lady_catriona_von_indi; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lady_keira_berrybuck"; newscript->GetAI = GetAI_lady_keira_berrybuck; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lord_robin_daris"; newscript->GetAI = GetAI_lord_robin_daris; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lord_crispin_ference"; newscript->GetAI = GetAI_lord_crispin_ference; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp index 6dfa4cb01b7..6d4e75afdb9 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp @@ -666,10 +666,10 @@ void AddSC_boss_malchezaar() newscript = new Script; newscript->Name="boss_malchezaar"; newscript->GetAI = GetAI_boss_malchezaar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="netherspite_infernal"; newscript->GetAI = GetAI_netherspite_infernal; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp index 20cdb5b2d7d..71325d21f22 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp @@ -654,20 +654,20 @@ void AddSC_boss_shade_of_aran() newscript = new Script; newscript->Name="boss_shade_of_aran"; newscript->GetAI = GetAI_boss_aran; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_shadow_of_aran"; newscript->GetAI = GetAI_shadow_of_aran; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_aran_elemental"; newscript->GetAI = GetAI_water_elemental; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); //newscript = new Script; //newscript->Name="mob_aran_blizzard"; //newscript->GetAI = GetAI_boss_aran; - //m_scripts[nrscripts++] = newscript; + //newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp index ddf6e9cb451..00a8cd46281 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp @@ -436,20 +436,20 @@ void AddSC_boss_terestian_illhoof() newscript = new Script; newscript->Name="boss_terestian_illhoof"; newscript->GetAI = GetAI_boss_terestian_illhoof; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_karazhan_imp"; newscript->GetAI = GetAI_mob_karazhan_imp; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_kilrek"; newscript->GetAI = GetAI_mob_kilrek; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_demon_chain"; newscript->GetAI = GetAI_mob_demon_chain; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp index 91dab811d00..2509445f3d0 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp @@ -1414,58 +1414,58 @@ void AddSC_bosses_opera() newscript = new Script; newscript->GetAI = GetAI_boss_dorothee; newscript->Name = "boss_dorothee"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_boss_strawman; newscript->Name = "boss_strawman"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_boss_tinhead; newscript->Name = "boss_tinhead"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_boss_roar; newscript->Name = "boss_roar"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_boss_crone; newscript->Name = "boss_crone"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_mob_tito; newscript->Name = "mob_tito"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_mob_cyclone; newscript->Name = "mob_cyclone"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); // Hood newscript = new Script; newscript->pGossipHello = GossipHello_npc_grandmother; newscript->pGossipSelect = GossipSelect_npc_grandmother; newscript->Name = "npc_grandmother"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_boss_bigbadwolf; newscript->Name = "boss_bigbadwolf"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); // Romeo And Juliet newscript = new Script; newscript->GetAI = GetAI_boss_julianne; newscript->Name = "boss_julianne"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->GetAI = GetAI_boss_romulo; newscript->Name = "boss_romulo"; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp index f683eea5336..29e07fe254f 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp @@ -249,5 +249,5 @@ void AddSC_instance_karazhan() newscript = new Script; newscript->Name = "instance_karazhan"; newscript->GetInstanceData = GetInstanceData_instance_karazhan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp b/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp index b0ab0d86db5..404014565e6 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp @@ -285,14 +285,14 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI Map *map = m_creature->GetMap(); if(!map->IsDungeon()) return; - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - if(PlayerList.empty()) + Map::PlayerList const &PlayerList = map->GetPlayers(); + if(PlayerList.isEmpty()) return; RaidWiped = true; - for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) + for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) { - if((*i)->isAlive() && !(*i)->isGameMaster()) + if (i->getSource()->isAlive() && !i->getSource()->isGameMaster()) { RaidWiped = false; break; @@ -460,11 +460,11 @@ void AddSC_karazhan() newscript->Name = "npc_barnes"; newscript->pGossipHello = GossipHello_npc_barnes; newscript->pGossipSelect = GossipSelect_npc_barnes; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_berthold"; newscript->pGossipHello = GossipHello_npc_berthold; newscript->pGossipSelect = GossipSelect_npc_berthold; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp b/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp index 966bf7c40a3..0e48a72535f 100644 --- a/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp +++ b/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp @@ -87,5 +87,5 @@ void AddSC_loch_modan() newscript->Name="npc_mountaineer_pebblebitty"; newscript->pGossipHello = &GossipHello_npc_mountaineer_pebblebitty; newscript->pGossipSelect = &GossipSelect_npc_mountaineer_pebblebitty; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp index 7a44e04dd6d..f08ff848237 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp @@ -231,17 +231,17 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI float x,y,z; m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0); Map *map = m_creature->GetMap(); - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; + Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList::const_iterator i; for (i = PlayerList.begin(); i != PlayerList.end(); ++i) { - //if(!(*i)->isGameMaster()) - if((*i) && (*i)->isAlive()) - { - (*i)->CastSpell((*i), SPELL_TELEPORT_CENTER, true); - m_creature->GetNearPoint(m_creature,x,y,z,5,5,0); - (*i)->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,(*i)->GetOrientation()); - } + if (Player* i_pl = i->getSource()) + if(i_pl->isAlive()) + { + i_pl->CastSpell(i_pl, SPELL_TELEPORT_CENTER, true); + m_creature->GetNearPoint(m_creature,x,y,z,5,5,0); + i_pl->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,i_pl->GetOrientation()); + } } DoCast(m_creature, SPELL_TELEPORT_CENTER, true); } @@ -249,34 +249,38 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI void CastGravityLapseKnockUp() { Map *map = m_creature->GetMap(); - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; + Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList::const_iterator i; for (i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if((*i) && (*i)->isAlive()) + { + if (Player* i_pl = i->getSource()) + if(i_pl->isAlive()) // Knockback into the air - (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); + i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); } } void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air... { Map *map = m_creature->GetMap(); - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; + Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList::const_iterator i; for (i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if((*i) && (*i)->isAlive()) + { + if (Player* i_pl = i->getSource()) { - // Also needs an exception in spell system. - (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); - // Use packet hack - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); - data.append((*i)->GetPackGUID()); - data << uint32(0); - (*i)->SendMessageToSet(&data, true); - (*i)->SetSpeed(MOVE_FLY, 2.0f); + if(i_pl->isAlive()) + { + // Also needs an exception in spell system. + i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); + // Use packet hack + WorldPacket data(12); + data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); + data.append(i_pl->GetPackGUID()); + data << uint32(0); + i_pl->SendMessageToSet(&data, true); + i_pl->SetSpeed(MOVE_FLY, 2.0f); + } } } } @@ -284,19 +288,19 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI void RemoveGravityLapse() { Map *map = m_creature->GetMap(); - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; + Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList::const_iterator i; for (i = PlayerList.begin(); i != PlayerList.end(); ++i) { - if((*i)) + if(Player* i_pl = i->getSource()) { - (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); - (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); + i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); + i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); WorldPacket data(12); data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); - data.append((*i)->GetPackGUID()); + data.append(i_pl->GetPackGUID()); data << uint32(0); - (*i)->SendMessageToSet(&data, true); + i_pl->SendMessageToSet(&data, true); } } } @@ -757,35 +761,35 @@ void AddSC_boss_felblood_kaelthas() newscript = new Script; newscript->Name = "boss_felblood_kaelthas"; newscript->GetAI = GetAI_boss_felblood_kaelthas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_arcane_sphere"; newscript->GetAI = GetAI_mob_arcane_sphere; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_felkael_phoenix"; newscript->GetAI = GetAI_mob_felkael_phoenix; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_felkael_phoenix_egg"; newscript->GetAI = GetAI_mob_felkael_phoenix_egg; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_felkael_flamestrike"; newscript->GetAI = GetAI_mob_felkael_flamestrike; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_kael_orb"; newscript->pGOHello = &GOHello_go_kael_orb; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="go_movie_orb"; newscript->pGOHello = &GOHello_go_movie_orb; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp index bd4a336eff4..afae183a4ec 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp @@ -1355,60 +1355,60 @@ void AddSC_boss_priestess_delrissa() newscript = new Script; newscript->Name="boss_priestess_delrissa"; newscript->GetAI = GetAI_boss_priestess_delrissa; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_kagani_nightstrike"; newscript->GetAI = GetAI_boss_kagani_nightstrike; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_ellris_duskhallow"; newscript->GetAI = GetAI_ellris_duskhallow; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_eramas_brightblaze"; newscript->GetAI = GetAI_eramas_brightblaze; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_yazzai"; newscript->GetAI = GetAI_yazzai; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_warlord_salaris"; newscript->GetAI = GetAI_warlord_salaris; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_garaxxas"; newscript->GetAI = GetAI_garaxxas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_apoko"; newscript->GetAI = GetAI_apoko; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_zelfan"; newscript->GetAI = GetAI_zelfan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); /*newscript = new Script; newscript->Name="mob_high_explosive_sheep"; newscript->GetAI = GetAI_mob_high_explosive_sheep; - m_scripts[nrscripts++] = newscript;*/ + newscript->RegisterSelf();*/ /*newscript = new Script; newscript->Name="mob_fizzle"; newscript->GetAI = GetAI_mob_fizzle; - m_scripts[nrscripts++] = newscript;*/ + newscript->RegisterSelf();*/ /*newscript = new Script; newscript->Name="mob_sliver"; newscript->GetAI = GetAI_mob_sliver; - m_scripts[nrscripts++] = newscript;*/ + newscript->RegisterSelf();*/ } diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp index 24526dac185..83174dd5a4c 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp @@ -403,10 +403,10 @@ void AddSC_boss_selin_fireheart() newscript = new Script; newscript->Name="boss_selin_fireheart"; newscript->GetAI = GetAI_boss_selin_fireheart; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_fel_crystal"; newscript->GetAI = GetAI_mob_fel_crystal; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp index ff11b425bd2..4f073cb884d 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp @@ -238,10 +238,10 @@ void AddSC_boss_vexallus() newscript = new Script; newscript->Name="boss_vexallus"; newscript->GetAI = GetAI_boss_vexallus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_pure_energy"; newscript->GetAI = GetAI_mob_pure_energy; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp index 8afecdc32e9..70d12865158 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp @@ -249,5 +249,5 @@ void AddSC_instance_magisters_terrace() newscript = new Script; newscript->Name = "instance_magisters_terrace"; newscript->GetInstanceData = GetInstanceData_instance_magisters_terrace; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp index 543686e2648..8830b7f3e4b 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp @@ -93,5 +93,5 @@ void AddSC_boss_celebras_the_cursed() newscript = new Script; newscript->Name="celebras_the_cursed"; newscript->GetAI = GetAI_celebras_the_cursed; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp index 20b93fe64b3..ab68f68c6e3 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp @@ -90,5 +90,5 @@ void AddSC_boss_landslide() newscript = new Script; newscript->Name="boss_landslide"; newscript->GetAI = GetAI_boss_landslide; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp index c5d5a51ffb9..0ffe9cd7f56 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp @@ -145,5 +145,5 @@ void AddSC_boss_noxxion() newscript = new Script; newscript->Name="boss_noxxion"; newscript->GetAI = GetAI_boss_noxxion; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp index 1920109f3d8..01cfb86a372 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp @@ -104,5 +104,5 @@ void AddSC_boss_ptheradras() newscript = new Script; newscript->Name="boss_princess_theradras"; newscript->GetAI = GetAI_boss_ptheradras; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp index 163926881f6..75cf6cb0a45 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp @@ -101,5 +101,5 @@ void AddSC_boss_baron_geddon() newscript = new Script; newscript->Name="boss_baron_geddon"; newscript->GetAI = GetAI_boss_baron_geddon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp index 70e98d648ee..830af78c430 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp @@ -140,10 +140,10 @@ void AddSC_boss_garr() newscript = new Script; newscript->Name="boss_garr"; newscript->GetAI = GetAI_boss_garr; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_firesworn"; newscript->GetAI = GetAI_mob_firesworn; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp index f15c66f26af..dc8bd9a5d9c 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp @@ -87,5 +87,5 @@ void AddSC_boss_gehennas() newscript = new Script; newscript->Name="boss_gehennas"; newscript->GetAI = GetAI_boss_gehennas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp index 6d17621ceb2..ebefd0185fc 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp @@ -192,10 +192,10 @@ void AddSC_boss_golemagg() newscript = new Script; newscript->Name="boss_golemagg"; newscript->GetAI = GetAI_boss_golemagg; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_core_rager"; newscript->GetAI = GetAI_mob_core_rager; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp index 6e8938bc542..f45657c8dae 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp @@ -86,5 +86,5 @@ void AddSC_boss_lucifron() newscript = new Script; newscript->Name="boss_lucifron"; newscript->GetAI = GetAI_boss_lucifron; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp index a892c83f175..d08f393fbee 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp @@ -93,5 +93,5 @@ void AddSC_boss_magmadar() newscript = new Script; newscript->Name="boss_magmadar"; newscript->GetAI = GetAI_boss_magmadar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp index d61f08ee7e7..43be23046ea 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp @@ -129,5 +129,5 @@ void AddSC_boss_majordomo() newscript = new Script; newscript->Name="boss_majordomo"; newscript->GetAI = GetAI_boss_majordomo; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp index 723fba0edf7..d357d9580e9 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp @@ -313,5 +313,5 @@ void AddSC_boss_ragnaros() newscript = new Script; newscript->Name="boss_ragnaros"; newscript->GetAI = GetAI_boss_ragnaros; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp index c9d4f4f3eec..c78b9ac3c91 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp @@ -117,5 +117,5 @@ void AddSC_boss_shazzrah() newscript = new Script; newscript->Name="boss_shazzrah"; newscript->GetAI = GetAI_boss_shazzrah; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp index 8a2a7764daa..0bc0e8e729e 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp @@ -206,10 +206,10 @@ void AddSC_boss_sulfuron() newscript = new Script; newscript->Name="boss_sulfuron"; newscript->GetAI = GetAI_boss_sulfuron; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_flamewaker_priest"; newscript->GetAI = GetAI_mob_flamewaker_priest; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp b/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp index 42a2ec35678..efba77f41f0 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp @@ -253,5 +253,5 @@ void AddSC_instance_molten_core() newscript = new Script; newscript->Name="instance_molten_core"; newscript->GetInstanceData = &GetInstance_instance_molten_core; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp b/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp index e36f56c7817..9446fb54a12 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp @@ -84,5 +84,5 @@ void AddSC_molten_core() newscript = new Script; newscript->Name="mob_ancient_core_hound"; newscript->GetAI = GetAI_mob_ancient_core_hound; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp b/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp index 7ac2326327b..1b0afbaaf94 100644 --- a/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp +++ b/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp @@ -545,27 +545,27 @@ void AddSC_moonglade() newscript->Name="npc_bunthen_plainswind"; newscript->pGossipHello = &GossipHello_npc_bunthen_plainswind; newscript->pGossipSelect = &GossipSelect_npc_bunthen_plainswind; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_great_bear_spirit"; newscript->pGossipHello = &GossipHello_npc_great_bear_spirit; newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_silva_filnaveth"; newscript->pGossipHello = &GossipHello_npc_silva_filnaveth; newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_clintar_dreamwalker"; newscript->pQuestAccept = &QuestAccept_npc_clintar_dreamwalker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_clintar_spirit"; newscript->GetAI = GetAI_npc_clintar_spirit; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp b/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp index d2fb6643423..44de5eab777 100644 --- a/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp +++ b/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp @@ -60,5 +60,5 @@ void AddSC_mulgore() newscript->Name="npc_skorn_whitecloud"; newscript->pGossipHello = &GossipHello_npc_skorn_whitecloud; newscript->pGossipSelect = &GossipSelect_npc_skorn_whitecloud; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp b/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp index dcd3f57bef3..f662fe4c2c4 100644 --- a/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp +++ b/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp @@ -631,46 +631,46 @@ void AddSC_nagrand() newscript = new Script; newscript->Name="mob_shattered_rumbler"; newscript->GetAI = GetAI_mob_shattered_rumbler; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_lump"; newscript->GetAI = GetAI_mob_lump; newscript->pGossipHello = &GossipHello_mob_lump; newscript->pGossipSelect = &GossipSelect_mob_lump; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_sunspring_villager"; newscript->GetAI = GetAI_mob_sunspring_villager; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_altruis_the_sufferer"; newscript->pGossipHello = &GossipHello_npc_altruis_the_sufferer; newscript->pGossipSelect = &GossipSelect_npc_altruis_the_sufferer; newscript->pQuestAccept = &QuestAccept_npc_altruis_the_sufferer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_greatmother_geyah"; newscript->pGossipHello = &GossipHello_npc_greatmother_geyah; newscript->pGossipSelect = &GossipSelect_npc_greatmother_geyah; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_lantresor_of_the_blade"; newscript->pGossipHello = &GossipHello_npc_lantresor_of_the_blade; newscript->pGossipSelect = &GossipSelect_npc_lantresor_of_the_blade; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_creditmarker_visit_with_ancestors"; newscript->GetAI = GetAI_npc_creditmarker_visit_with_ancestors; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_sparrowhawk"; newscript->GetAI = GetAI_mob_sparrowhawk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp index 50a4f867b4c..2b93e7828f9 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp @@ -208,5 +208,5 @@ void AddSC_boss_anubrekhan() newscript = new Script; newscript->Name="boss_anubrekhan"; newscript->GetAI = GetAI_boss_anubrekhan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp index 4add49e17b4..dbcf72510aa 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp @@ -197,5 +197,5 @@ void AddSC_boss_faerlina() newscript = new Script; newscript->Name="boss_faerlina"; newscript->GetAI = GetAI_boss_faerlina; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp index 09e3c1ecf25..b5b40a4b245 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp @@ -170,5 +170,5 @@ void AddSC_boss_gluth() newscript = new Script; newscript->Name="boss_gluth"; newscript->GetAI = GetAI_boss_gluth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp index 96d94ad51ad..d21e2a2119f 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp @@ -174,5 +174,5 @@ void AddSC_boss_highlord_mograine() newscript = new Script; newscript->Name="boss_highlord_mograine"; newscript->GetAI = GetAI_boss_highlord_mograine; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp index 3a47f6f5c27..e65bfb62fdd 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp @@ -537,6 +537,6 @@ void AddSC_boss_kelthuzad() newscript = new Script; newscript->Name="boss_kelthuzad"; newscript->GetAI = GetAI_boss_kelthuzadAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); */ } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp index ee3b47e478d..770f880557d 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp @@ -143,5 +143,5 @@ void AddSC_boss_lady_blaumeux() newscript = new Script; newscript->Name="boss_lady_blaumeux"; newscript->GetAI = GetAI_boss_lady_blaumeux; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp index 56fe786e6c8..4da5c6626cb 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp @@ -212,5 +212,5 @@ void AddSC_boss_loatheb() newscript = new Script; newscript->Name="boss_loatheb"; newscript->GetAI = GetAI_boss_loatheb; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp index 4c65feb9c7b..821ca832e65 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp @@ -237,10 +237,10 @@ void AddSC_boss_maexxna() newscript = new Script; newscript->Name="boss_maexxna"; newscript->GetAI = GetAI_boss_maexxna; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_webwrap"; newscript->GetAI = GetAI_mob_webwrap; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp index cda01c57e40..43616311bb4 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp @@ -176,5 +176,5 @@ void AddSC_boss_noth() newscript = new Script; newscript->Name="boss_noth"; newscript->GetAI = GetAI_boss_noth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp index d0edc7f46b3..2f51c9c3064 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp @@ -156,5 +156,5 @@ void AddSC_boss_patchwerk() newscript = new Script; newscript->Name="boss_patchwerk"; newscript->GetAI = GetAI_boss_patchwerk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp index d83f99bda43..ac7de1db7eb 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp @@ -163,5 +163,5 @@ void AddSC_boss_razuvious() newscript = new Script; newscript->Name="boss_razuvious"; newscript->GetAI = GetAI_boss_razuvious; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp index 0be1619ad74..75a2f20db14 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp @@ -195,5 +195,5 @@ void AddSC_boss_sapphiron() newscript = new Script; newscript->Name="boss_sapphiron"; newscript->GetAI = GetAI_boss_sapphiron; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp index 0a3ca7a951b..8dead488208 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp @@ -142,5 +142,5 @@ void AddSC_boss_sir_zeliek() newscript = new Script; newscript->Name="boss_sir_zeliek"; newscript->GetAI = GetAI_boss_sir_zeliek; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp index a040626258d..500f0955316 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp @@ -143,5 +143,5 @@ void AddSC_boss_thane_korthazz() newscript = new Script; newscript->Name="boss_thane_korthazz"; newscript->GetAI = GetAI_boss_thane_korthazz; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp b/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp index 2d35802338e..4125c4e888e 100644 --- a/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp +++ b/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp @@ -400,22 +400,22 @@ void AddSC_netherstorm() newscript = new Script; newscript->Name="go_manaforge_control_console"; newscript->pGOHello = &GOHello_go_manaforge_control_console; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_manaforge_control_console"; newscript->GetAI = GetAI_npc_manaforge_control_console; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_protectorate_nether_drake"; newscript->pGossipHello = &GossipHello_npc_protectorate_nether_drake; newscript->pGossipSelect = &GossipSelect_npc_protectorate_nether_drake; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_veronia"; newscript->pGossipHello = &GossipHello_npc_veronia; newscript->pGossipSelect = &GossipSelect_npc_veronia; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp b/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp index 7774f65411d..eb73f8bfb3a 100644 --- a/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp +++ b/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp @@ -229,5 +229,5 @@ void AddSC_boss_onyxia() newscript = new Script; newscript->Name="boss_onyxia"; newscript->GetAI = GetAI_boss_onyxiaAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp b/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp index cb4be0499fc..76c7a5f3416 100644 --- a/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp +++ b/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp @@ -247,19 +247,19 @@ void AddSC_orgrimmar() newscript->Name="npc_neeru_fireblade"; newscript->pGossipHello = &GossipHello_npc_neeru_fireblade; newscript->pGossipSelect = &GossipSelect_npc_neeru_fireblade; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_shenthul"; newscript->GetAI = GetAI_npc_shenthul; newscript->pQuestAccept = &QuestAccept_npc_shenthul; newscript->pReceiveEmote = &ReciveEmote_npc_shenthul; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_thrall_warchief"; newscript->GetAI = GetAI_npc_thrall_warchief; newscript->pGossipHello = &GossipHello_npc_thrall_warchief; newscript->pGossipSelect = &GossipSelect_npc_thrall_warchief; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp b/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp index 163db1c2756..e7f3184a60e 100644 --- a/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp +++ b/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp @@ -136,5 +136,5 @@ void AddSC_boss_amnennar_the_coldbringer() newscript = new Script; newscript->Name="boss_amnennar_the_coldbringer"; newscript->GetAI = GetAI_boss_amnennar_the_coldbringer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp index 03a53d50297..374daab3344 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp @@ -103,5 +103,5 @@ void AddSC_boss_ayamiss() newscript = new Script; newscript->Name="boss_ayamiss"; newscript->GetAI = GetAI_boss_ayamiss; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp index 3a287d8b6ae..124ebccbcbb 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp @@ -89,5 +89,5 @@ void AddSC_boss_kurinnaxx() newscript = new Script; newscript->Name="boss_kurinnaxx"; newscript->GetAI = GetAI_boss_kurinnaxx; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp index 836dd3f8065..12e58066456 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp @@ -113,5 +113,5 @@ void AddSC_boss_moam() newscript = new Script; newscript->Name="boss_moam"; newscript->GetAI = GetAI_boss_moam; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp index 50764c4d022..aaa156b8092 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp @@ -167,5 +167,5 @@ void AddSC_boss_arcanist_doan() newscript = new Script; newscript->Name="boss_arcanist_doan"; newscript->GetAI = GetAI_boss_arcanist_doan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp index 4ea395a8038..10d340eae91 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp @@ -93,5 +93,5 @@ void AddSC_boss_azshir_the_sleepless() newscript = new Script; newscript->Name="boss_azshir_the_sleepless"; newscript->GetAI = GetAI_boss_azshir_the_sleepless; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp index 9fa5bee9714..ae2324d8615 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp @@ -132,5 +132,5 @@ void AddSC_boss_bloodmage_thalnos() newscript = new Script; newscript->Name="boss_bloodmage_thalnos"; newscript->GetAI = GetAI_boss_bloodmage_thalnos; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp index de1fd991c33..494def37c11 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp @@ -193,5 +193,5 @@ void AddSC_boss_herod() newscript = new Script; newscript->Name="boss_herod"; newscript->GetAI = GetAI_boss_herod; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp index 5742214e31d..a230629b871 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp @@ -128,5 +128,5 @@ void AddSC_boss_high_inquisitor_fairbanks() newscript = new Script; newscript->Name="boss_high_inquisitor_fairbanks"; newscript->GetAI = GetAI_boss_high_inquisitor_fairbanks; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp index 97fbce31b01..c10da64c4e9 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp @@ -173,5 +173,5 @@ void AddSC_boss_high_inquisitor_whitemane() newscript = new Script; newscript->Name="boss_high_inquisitor_whitemane"; newscript->GetAI = GetAI_boss_high_inquisitor_whitemane; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp index 6353f600460..e268d25c9d7 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp @@ -74,5 +74,5 @@ void AddSC_boss_houndmaster_loksey() newscript = new Script; newscript->Name="boss_houndmaster_loksey"; newscript->GetAI = GetAI_boss_houndmaster_loksey; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp index ede58d0997e..98cb742eb01 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp @@ -109,5 +109,5 @@ void AddSC_boss_interrogator_vishas() newscript = new Script; newscript->Name="boss_interrogator_vishas"; newscript->GetAI = GetAI_boss_interrogator_vishas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp index 5e87b1a2b77..1d8587d9f78 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp @@ -156,5 +156,5 @@ void AddSC_boss_scarlet_commander_mograine() newscript = new Script; newscript->Name="boss_scarlet_commander_mograine"; newscript->GetAI = GetAI_boss_scarlet_commander_mograine; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp index 1f9e3fb2487..95a206d1657 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp @@ -96,5 +96,5 @@ void AddSC_boss_scorn() newscript = new Script; newscript->Name="boss_scorn"; newscript->GetAI = GetAI_boss_scorn; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp index f67bf9fe594..38e6ad85d8c 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp @@ -188,5 +188,5 @@ void AddSC_boss_darkmaster_gandling() newscript = new Script; newscript->Name="boss_darkmaster_gandling"; newscript->GetAI = GetAI_boss_darkmaster_gandling; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp index 747ec039363..fa410af2734 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp @@ -55,5 +55,5 @@ void AddSC_boss_death_knight_darkreaver() newscript = new Script; newscript->Name="boss_death_knight_darkreaver"; newscript->GetAI = GetAI_boss_death_knight_darkreaver; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp index 484a27dca98..3993a58f1cd 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp @@ -104,5 +104,5 @@ void AddSC_boss_theolenkrastinov() newscript = new Script; newscript->Name="boss_doctor_theolen_krastinov"; newscript->GetAI = GetAI_boss_theolenkrastinov; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp index 1edae02fcf3..4b871f8e173 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp @@ -112,5 +112,5 @@ void AddSC_boss_illuciabarov() newscript = new Script; newscript->Name="boss_illucia_barov"; newscript->GetAI = GetAI_boss_illuciabarov; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp index 705b2835843..15e5c93a982 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp @@ -148,5 +148,5 @@ void AddSC_boss_instructormalicia() newscript = new Script; newscript->Name="boss_instructor_malicia"; newscript->GetAI = GetAI_boss_instructormalicia; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp index dfae0432d12..e27dc31879e 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp @@ -212,10 +212,10 @@ void AddSC_boss_jandicebarov() newscript = new Script; newscript->Name="boss_jandice_barov"; newscript->GetAI = GetAI_boss_jandicebarov; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_illusionofjandicebarov"; newscript->GetAI = GetAI_mob_illusionofjandicebarov; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp index b3cc6fd0530..1e1fb1ef685 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp @@ -151,5 +151,5 @@ void AddSC_boss_kormok() newscript = new Script; newscript->Name="boss_kormok"; newscript->GetAI = GetAI_boss_kormok; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp index 49f3f733949..8d8f248aede 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp @@ -94,5 +94,5 @@ void AddSC_boss_lordalexeibarov() newscript = new Script; newscript->Name="boss_lord_alexei_barov"; newscript->GetAI = GetAI_boss_lordalexeibarov; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp index d17d2036d91..c05e4d64d1d 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp @@ -109,5 +109,5 @@ void AddSC_boss_lorekeeperpolkelt() newscript = new Script; newscript->Name="boss_lorekeeper_polkelt"; newscript->GetAI = GetAI_boss_lorekeeperpolkelt; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp index 0ea243c2d08..afe7eb8716a 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp @@ -121,5 +121,5 @@ void AddSC_boss_rasfrost() newscript = new Script; newscript->Name="boss_boss_ras_frostwhisper"; newscript->GetAI = GetAI_boss_rasfrost; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp index f27e8aa458f..d16b0f917ce 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp @@ -114,5 +114,5 @@ void AddSC_boss_theravenian() newscript = new Script; newscript->Name="boss_the_ravenian"; newscript->GetAI = GetAI_boss_theravenian; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp index 954ee3b4eba..f92ae0732e1 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp @@ -91,5 +91,5 @@ void AddSC_boss_vectus() newscript = new Script; newscript->Name="boss_vectus"; newscript->GetAI = GetAI_boss_vectus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp b/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp index a48537068f8..036a34cd8fa 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp @@ -98,5 +98,5 @@ void AddSC_instance_scholomance() newscript = new Script; newscript->Name = "instance_scholomance"; newscript->GetInstanceData = GetInstanceData_instance_scholomance; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp b/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp index 7a9ef1a5449..23281eb9050 100644 --- a/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp +++ b/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp @@ -143,17 +143,17 @@ void AddSC_searing_gorge() newscript->Name="npc_kalaran_windblade"; newscript->pGossipHello = &GossipHello_npc_kalaran_windblade; newscript->pGossipSelect = &GossipSelect_npc_kalaran_windblade; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_lothos_riftwaker"; newscript->pGossipHello = &GossipHello_npc_lothos_riftwaker; newscript->pGossipSelect = &GossipSelect_npc_lothos_riftwaker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_zamael_lunthistle"; newscript->pGossipHello = &GossipHello_npc_zamael_lunthistle; newscript->pGossipSelect = &GossipSelect_npc_zamael_lunthistle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp b/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp index dfae8457abc..a854cc96989 100644 --- a/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp +++ b/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp @@ -148,5 +148,5 @@ void AddSC_instance_shadowfang_keep() newscript = new Script; newscript->Name = "instance_shadowfang_keep"; newscript->GetInstanceData = GetInstanceData_instance_shadowfang_keep; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp b/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp index 65e1eaea8ba..d297ccbcdeb 100644 --- a/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp +++ b/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp @@ -113,5 +113,5 @@ void AddSC_shadowfang_keep() newscript->pGossipHello = &GossipHello_npc_shadowfang_prisoner; newscript->pGossipSelect = &GossipSelect_npc_shadowfang_prisoner; newscript->GetAI = GetAI_npc_shadowfang_prisoner; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp b/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp index 89536b15ac2..a67318bc41c 100644 --- a/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp +++ b/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp @@ -212,5 +212,5 @@ void AddSC_boss_doomwalker() newscript = new Script; newscript->Name="boss_doomwalker"; newscript->GetAI = GetAI_boss_doomwalker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp b/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp index 7bc1ad312a9..534a853302d 100644 --- a/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp +++ b/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp @@ -1106,73 +1106,73 @@ void AddSC_shadowmoon_valley() newscript = new Script; newscript->Name = "mob_mature_netherwing_drake"; newscript->GetAI = GetAI_mob_mature_netherwing_drake; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_enslaved_netherwing_drake"; newscript->GetAI = GetAI_mob_enslaved_netherwing_drake; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "mob_dragonmaw_peon"; newscript->GetAI = GetAI_mob_dragonmaw_peon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_drake_dealer_hurlunk"; newscript->pGossipHello = &GossipHello_npc_drake_dealer_hurlunk; newscript->pGossipSelect = &GossipSelect_npc_drake_dealer_hurlunk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_invis_legion_teleporter"; newscript->GetAI = GetAI_npc_invis_legion_teleporter; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npcs_flanis_swiftwing_and_kagrosh"; newscript->pGossipHello = &GossipHello_npcs_flanis_swiftwing_and_kagrosh; newscript->pGossipSelect = &GossipSelect_npcs_flanis_swiftwing_and_kagrosh; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_murkblood_overseer"; newscript->pGossipHello = &GossipHello_npc_murkblood_overseer; newscript->pGossipSelect = &GossipSelect_npc_murkblood_overseer; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_neltharaku"; newscript->pGossipHello = &GossipHello_npc_neltharaku; newscript->pGossipSelect = &GossipSelect_npc_neltharaku; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_karynaku"; newscript->pQuestAccept = &QuestAccept_npc_karynaku; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_oronok_tornheart"; newscript->pGossipHello = &GossipHello_npc_oronok_tornheart; newscript->pGossipSelect = &GossipSelect_npc_oronok_tornheart; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_overlord_morghor"; newscript->GetAI = GetAI_Overlord_Morghor; newscript->pQuestAccept = &QuestAccept_Overlord_Morghor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_lord_illidan_stormrage"; newscript->GetAI = GetAI_Lord_Illidan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_yarzill_the_merc"; newscript->GetAI = GetAI_Yarzill_The_Merc; newscript->pGossipHello = &GossipHello_npc_yarzill_fly; newscript->pGossipSelect = &GossipSelect_npc_yarzill_fly; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp b/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp index 41cb56585ef..f974e0ec16d 100644 --- a/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp +++ b/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp @@ -414,28 +414,28 @@ void AddSC_shattrath_city() newscript->Name="npc_raliq_the_drunk"; newscript->pGossipHello = &GossipHello_npc_raliq_the_drunk; newscript->pGossipSelect = &GossipSelect_npc_raliq_the_drunk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_salsalabim"; newscript->GetAI = GetAI_npc_salsalabim; newscript->pGossipHello = &GossipHello_npc_salsalabim; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_shattrathflaskvendors"; newscript->pGossipHello = &GossipHello_npc_shattrathflaskvendors; newscript->pGossipSelect = &GossipSelect_npc_shattrathflaskvendors; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_zephyr"; newscript->pGossipHello = &GossipHello_npc_zephyr; newscript->pGossipSelect = &GossipSelect_npc_zephyr; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_kservant"; newscript->GetAI = GetAI_npc_kservantAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/silithus/silithus.cpp b/src/bindings/scripts/scripts/zone/silithus/silithus.cpp index 5e05fa60630..bf868318342 100644 --- a/src/bindings/scripts/scripts/zone/silithus/silithus.cpp +++ b/src/bindings/scripts/scripts/zone/silithus/silithus.cpp @@ -145,5 +145,5 @@ void AddSC_silithus() newscript->Name="npcs_rutgar_and_frankal"; newscript->pGossipHello = &GossipHello_npcs_rutgar_and_frankal; newscript->pGossipSelect = &GossipSelect_npcs_rutgar_and_frankal; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp b/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp index 077c078b64a..d50a1fcbdf8 100644 --- a/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp +++ b/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp @@ -99,5 +99,5 @@ void AddSC_silvermoon_city() newscript = new Script; newscript->Name="npc_blood_knight_stillblade"; newscript->GetAI = GetAI_npc_blood_knight_stillblade; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp b/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp index 597ab1ccb8d..b511ccbba4e 100644 --- a/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp +++ b/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp @@ -96,5 +96,5 @@ void AddSC_silverpine_forest() newscript->pGossipHello = &GossipHello_npc_astor_hadren; newscript->pGossipSelect = &GossipSelect_npc_astor_hadren; newscript->GetAI = GetAI_npc_astor_hadren; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp b/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp index 40cb6367379..28f0c644726 100644 --- a/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp +++ b/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp @@ -76,5 +76,5 @@ void AddSC_stonetalon_mountains() newscript->Name="npc_braug_dimspirit"; newscript->pGossipHello = &GossipHello_npc_braug_dimspirit; newscript->pGossipSelect = &GossipSelect_npc_braug_dimspirit; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp b/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp index b84b1d98cb6..9c34ec3d926 100644 --- a/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp +++ b/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp @@ -245,28 +245,28 @@ void AddSC_stormwind_city() newscript->Name="npc_archmage_malin"; newscript->pGossipHello = &GossipHello_npc_archmage_malin; newscript->pGossipSelect = &GossipSelect_npc_archmage_malin; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_bartleby"; newscript->GetAI = GetAI_npc_bartleby; newscript->pQuestAccept = &QuestAccept_npc_bartleby; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_dashel_stonefist"; newscript->GetAI = GetAI_npc_dashel_stonefist; newscript->pQuestAccept = &QuestAccept_npc_dashel_stonefist; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_general_marcus_jonathan"; newscript->pReceiveEmote = &ReceiveEmote_npc_general_marcus_jonathan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_lady_katrana_prestor"; newscript->pGossipHello = &GossipHello_npc_lady_katrana_prestor; newscript->pGossipSelect = &GossipSelect_npc_lady_katrana_prestor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp b/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp index 40ff438cbd1..426c56c679d 100644 --- a/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp +++ b/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp @@ -103,5 +103,5 @@ void AddSC_stranglethorn_vale() newscript = new Script; newscript->Name = "mob_yenniku"; newscript->GetAI = GetAI_mob_yenniku; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp index d3cfa97be75..aac9c590c97 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp @@ -211,5 +211,5 @@ void AddSC_boss_baron_rivendare() newscript = new Script; newscript->Name="boss_baron_rivendare"; newscript->GetAI = GetAI_boss_baron_rivendare; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp index f1315e66b83..8c88353878c 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp @@ -120,5 +120,5 @@ void AddSC_boss_baroness_anastari() newscript = new Script; newscript->Name="boss_baroness_anastari"; newscript->GetAI = GetAI_boss_baroness_anastari; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp index 4c1bd05b432..d3e1c4e2a3a 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp @@ -217,5 +217,5 @@ void AddSC_boss_cannon_master_willey() newscript = new Script; newscript->Name="boss_cannon_master_willey"; newscript->GetAI = GetAI_boss_cannon_master_willey; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp index 3d084fe0736..67503358d9d 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp @@ -312,5 +312,5 @@ void AddSC_boss_dathrohan_balnazzar() newscript = new Script; newscript->Name="boss_dathrohan_balnazzar"; newscript->GetAI = GetAI_boss_dathrohan_balnazzar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp index cbea76cf205..daa8da39a67 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp @@ -110,5 +110,5 @@ void AddSC_boss_magistrate_barthilas() newscript = new Script; newscript->Name="boss_magistrate_barthilas"; newscript->GetAI = GetAI_boss_magistrate_barthilas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp index e0f9c43cba7..d3d60121a87 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp @@ -115,5 +115,5 @@ void AddSC_boss_maleki_the_pallid() newscript = new Script; newscript->Name="boss_maleki_the_pallid"; newscript->GetAI = GetAI_boss_maleki_the_pallid; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp index 3929f2513dd..b56e643bdb2 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp @@ -134,5 +134,5 @@ void AddSC_boss_nerubenkan() newscript = new Script; newscript->Name="boss_nerubenkan"; newscript->GetAI = GetAI_boss_nerubenkan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp index a76913b658c..ee92be7737d 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp @@ -157,5 +157,5 @@ void AddSC_boss_order_of_silver_hand() newscript = new Script; newscript->Name="boss_silver_hand_bosses"; newscript->GetAI = GetAI_boss_silver_hand_bossesAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp index a4eddd46b5e..d0514bd2eb8 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp @@ -140,5 +140,5 @@ void AddSC_boss_postmaster_malown() newscript = new Script; newscript->Name="boss_postmaster_malown"; newscript->GetAI = GetAI_boss_postmaster_malown; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp index 674d4403266..b2965f09edf 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp @@ -88,5 +88,5 @@ void AddSC_boss_ramstein_the_gorger() newscript = new Script; newscript->Name="boss_ramstein_the_gorger"; newscript->GetAI = GetAI_boss_ramstein_the_gorger; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp index 2256c064e11..4f526041e35 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp @@ -96,5 +96,5 @@ void AddSC_boss_timmy_the_cruel() newscript = new Script; newscript->Name="boss_timmy_the_cruel"; newscript->GetAI = GetAI_boss_timmy_the_cruel; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp b/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp index eff4edf91a8..74181d6a15e 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp @@ -73,5 +73,5 @@ void AddSC_instance_stratholme() newscript = new Script; newscript->Name = "instance_stratholme"; newscript->GetInstanceData = GetInstanceData_instance_stratholme; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp b/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp index 5097648a04a..2a38abe9311 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp @@ -310,26 +310,26 @@ void AddSC_stratholme() newscript = new Script; newscript->Name="mob_freed_soul"; newscript->GetAI = GetAI_mob_freed_soul; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_restless_soul"; newscript->GetAI = GetAI_mob_restless_soul; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mobs_spectral_ghostly_citizen"; newscript->GetAI = GetAI_mobs_spectral_ghostly_citizen; newscript->pReceiveEmote = &ReciveEmote_mobs_spectral_ghostly_citizen; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_mindless_skeleton"; newscript->GetAI = GetAI_mob_mindless_skeleton; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_thuzadin_acolyte"; newscript->GetAI = GetAI_mob_thuzadin_acolyte; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp index fc1bca5233f..24ce8dc4a91 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp @@ -178,5 +178,5 @@ void AddSC_boss_brutallus() newscript = new Script; newscript->Name="boss_brutallus"; newscript->GetAI = GetAI_boss_brutallus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp index b49f0e391f3..b7e076b85d3 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp @@ -761,15 +761,15 @@ void AddSC_boss_eredar_twins() newscript = new Script; newscript->Name="boss_sacrolash"; newscript->GetAI = GetAI_boss_sacrolash; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_alythess"; newscript->GetAI = GetAI_boss_alythess; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_shadow_image"; newscript->GetAI = GetAI_mob_shadow_image; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp index e703b4b6c26..9f2b89b44f2 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp @@ -295,7 +295,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI Timer[EVENT_FLIGHT_SEQUENCE] = 0; break; case 2: - if(Player* target = SelectRandomPlayer(150)) + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) { Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000); if(Vapor) @@ -311,7 +311,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI case 3: DespawnSummons(MOB_VAPOR_TRAIL); //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support - if(Player* target = SelectRandomPlayer(150)) + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) { //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000); @@ -330,7 +330,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI Timer[EVENT_FLIGHT_SEQUENCE] = 1; break; case 5: - if(Player* target = SelectRandomPlayer(150)) + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) { BreathX = target->GetPositionX(); BreathY = target->GetPositionY(); @@ -433,7 +433,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI Timer[EVENT_GAS_NOVA] = 20000 + rand()%5 * 1000; break; case EVENT_ENCAPSULATE: - if(Unit* target = SelectRandomPlayer(150)) + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) { m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false); target->CastSpell(target, SPELL_ENCAPSULATE_EFFECT, true);// linked aura, need core patch to remove this hack @@ -515,26 +515,6 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI (*i)->RemoveCorpse(); } } - - Player* SelectRandomPlayer(float range = 0.0f) - { - Map *map = m_creature->GetMap(); - if (!map->IsDungeon()) return NULL; - - InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::iterator i; - while(PlayerList.size()) - { - i = PlayerList.begin(); - advance(i, rand()%PlayerList.size()); - if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range)) - && (*i)->isTargetableForAttack()) - return *i; - else - PlayerList.erase(i); - } - return NULL; - } }; struct TRINITY_DLL_DECL mob_felmyst_vaporAI : public ScriptedAI @@ -594,15 +574,15 @@ void AddSC_boss_felmyst() newscript = new Script; newscript->Name="boss_felmyst"; newscript->GetAI = GetAI_boss_felmyst; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_felmyst_vapor"; newscript->GetAI = GetAI_mob_felmyst_vapor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_felmyst_trail"; newscript->GetAI = GetAI_mob_felmyst_trail; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp index f3911b9b865..79d0d3766b8 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp @@ -368,13 +368,12 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI { Map *map = m_creature->GetMap(); if(!map->IsDungeon()) return; - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; - for (i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if((*i)->HasAura(AURA_SPECTRAL_REALM,0)) - (*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); - } + Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList::const_iterator i; + for(i = PlayerList.begin(); i != PlayerList.end(); ++i) + if(Player* i_pl = i->getSource()) + if(i_pl->HasAura(AURA_SPECTRAL_REALM,0)) + i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); } void Enrage(); // demon and dragon should enrage at the same time @@ -681,20 +680,20 @@ void AddSC_boss_kalecgos() newscript = new Script; newscript->Name="boss_kalecgos"; newscript->GetAI = GetAI_boss_kalecgos; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_sathrovarr"; newscript->GetAI = GetAI_boss_Sathrovarr; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_kalec"; newscript->GetAI = GetAI_boss_kalec; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="kalocegos_teleporter"; newscript->pGOHello = &GOkalocegos_teleporter; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); }
\ No newline at end of file diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp index a94cf460a83..98b0bd443b1 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp @@ -192,5 +192,5 @@ void AddSC_instance_sunwell_plateau() newscript = new Script; newscript->Name = "instance_sunwell_plateau"; newscript->GetInstanceData = GetInstanceData_instance_sunwell_plateau; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp b/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp index 2eb6ab80335..c6700af3e67 100644 --- a/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp +++ b/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp @@ -374,29 +374,29 @@ void AddSC_tanaris() newscript = new Script; newscript->Name="mob_aquementas"; newscript->GetAI = GetAI_mob_aquementas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_custodian_of_time"; newscript->GetAI = GetAI_npc_custodian_of_time; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_marin_noggenfogger"; newscript->pGossipHello = &GossipHello_npc_marin_noggenfogger; newscript->pGossipSelect = &GossipSelect_npc_marin_noggenfogger; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_steward_of_time"; newscript->pGossipHello = &GossipHello_npc_steward_of_time; newscript->pGossipSelect = &GossipSelect_npc_steward_of_time; newscript->pQuestAccept = &QuestAccept_npc_steward_of_time; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_stone_watcher_of_norgannon"; newscript->pGossipHello = &GossipHello_npc_stone_watcher_of_norgannon; newscript->pGossipSelect = &GossipSelect_npc_stone_watcher_of_norgannon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp index f928a41e1e0..624ad419243 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp @@ -575,15 +575,15 @@ void AddSC_arcatraz() newscript = new Script; newscript->Name="npc_millhouse_manastorm"; newscript->GetAI = GetAI_npc_millhouse_manastorm; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_warden_mellichar"; newscript->GetAI = GetAI_npc_warden_mellichar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_zerekethvoidzone"; newscript->GetAI = GetAI_mob_zerekethvoidzoneAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp index fcd8cf2c607..808604d2375 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp @@ -367,10 +367,10 @@ void AddSC_boss_harbinger_skyriss() newscript = new Script; newscript->Name="boss_harbinger_skyriss"; newscript->GetAI = GetAI_boss_harbinger_skyriss; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_harbinger_skyriss_illusion"; newscript->GetAI = GetAI_boss_harbinger_skyriss_illusion; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp index 93f21f2a72f..2325680d53b 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp @@ -220,5 +220,5 @@ void AddSC_instance_arcatraz() newscript = new Script; newscript->Name = "instance_arcatraz"; newscript->GetInstanceData = GetInstanceData_instance_arcatraz; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp index 201b5936ee9..334fdf07b98 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp @@ -211,5 +211,5 @@ void AddSC_boss_high_botanist_freywinn() newscript = new Script; newscript->Name="boss_high_botanist_freywinn"; newscript->GetAI = GetAI_boss_high_botanist_freywinn; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp index c714c470c55..09a237f53cf 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp @@ -194,5 +194,5 @@ void AddSC_boss_laj() newscript = new Script; newscript->Name="boss_laj"; newscript->GetAI = GetAI_boss_laj; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp index 5f7c87adff4..f0dc111e896 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp @@ -293,10 +293,10 @@ void AddSC_boss_warp_splinter() newscript = new Script; newscript->Name="boss_warp_splinter"; newscript->GetAI = GetAI_boss_warp_splinter; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_warp_splinter_treant"; newscript->GetAI = GetAI_mob_treant; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp index 617fd29dbc2..138d3d19f99 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp @@ -505,15 +505,15 @@ void AddSC_boss_alar() newscript = new Script; newscript->Name="boss_alar"; newscript->GetAI = GetAI_boss_alar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_ember_of_alar"; newscript->GetAI = GetAI_mob_ember_of_alar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_flame_patch_alar"; newscript->GetAI = GetAI_mob_flame_patch_alar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp index 477aab20241..9e93eac4693 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp @@ -536,10 +536,10 @@ void AddSC_boss_high_astromancer_solarian() newscript = new Script; newscript->Name="boss_high_astromancer_solarian"; newscript->GetAI = GetAI_boss_high_astromancer_solarian; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_solarium_priest"; newscript->GetAI = GetAI_mob_solarium_priest; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp index ddbfbb65bf2..ca5d8dcf7dd 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp @@ -1581,35 +1581,35 @@ void AddSC_boss_kaelthas() newscript = new Script; newscript->Name="boss_kaelthas"; newscript->GetAI = GetAI_boss_kaelthas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_thaladred_the_darkener"; newscript->GetAI = GetAI_boss_thaladred_the_darkener; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lord_sanguinar"; newscript->GetAI = GetAI_boss_lord_sanguinar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_grand_astromancer_capernian"; newscript->GetAI = GetAI_boss_grand_astromancer_capernian; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_master_engineer_telonicus"; newscript->GetAI = GetAI_boss_master_engineer_telonicus; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name= "mob_kael_flamestrike"; newscript->GetAI = GetAI_mob_kael_flamestrike; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_phoenix"; newscript->GetAI = GetAI_mob_phoenix; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp index 406e7e4d9ab..de6335e79e3 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp @@ -195,5 +195,5 @@ void AddSC_boss_void_reaver() newscript = new Script; newscript->Name="boss_void_reaver"; newscript->GetAI = GetAI_boss_void_reaver; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp index 3f1316d45e8..1fa1030a991 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp @@ -172,5 +172,5 @@ void AddSC_instance_the_eye() newscript = new Script; newscript->Name = "instance_the_eye"; newscript->GetInstanceData = GetInstanceData_instance_the_eye; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp index cd2962b509a..18d37e88bdc 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp @@ -94,5 +94,5 @@ void AddSC_the_eye() newscript = new Script; newscript->Name="mob_crystalcore_devastator"; newscript->GetAI = GetAI_mob_crystalcore_devastator; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp index 90ec4076d21..dfc5d70bb42 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp @@ -157,5 +157,5 @@ void AddSC_boss_gatewatcher_iron_hand() newscript = new Script; newscript->Name="boss_gatewatcher_iron_hand"; newscript->GetAI = GetAI_boss_gatewatcher_iron_hand; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp index 866f641922c..d077f5b8c0c 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp @@ -277,10 +277,10 @@ void AddSC_boss_nethermancer_sepethrea() newscript = new Script; newscript->Name="boss_nethermancer_sepethrea"; newscript->GetAI = GetAI_boss_nethermancer_sepethrea; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_ragin_flames"; newscript->GetAI = GetAI_mob_ragin_flames; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp index 06c57082357..842da61d9bf 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp @@ -1,306 +1,306 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-/* ScriptData
-SDName: Boss Pathaleon the Calculator
-SD%Complete: 50
-SDComment: Event missing. Script for himself 99% blizzlike.
-SDCategory: Tempest Keep, The Mechanar
-EndScriptData */
-
-#include "precompiled.h"
-
-// Spells to be casted
-#define SPELL_SUMMON_NETHER_WRAITH 35287 //Spell not working. Summon is working but Pets dont attack and wrong HP.
-#define SPELL_MANA_TAP 36021
-#define SPELL_ARCANE_TORRENT 36022
-#define SPELL_DOMINATION 35280
-#define H_SPELL_ARCANE_EXPLOSION 34791 //Spell not right.
-#define SPELL_ENRAGE 36992
-
-// Add Spells
-#define SPELL_DETONATION 35058
-#define SPELL_ARCANE_MISSILES 35034
-
-// On Domination
-#define SAY_SPELL_DOMINATION_1 "I'm looking for a team player... "
-#define SOUND_SPELL_DOMINATION_1 11197
-#define SAY_SPELL_DOMINATION_2 "You work for me now!"
-#define SOUND_SPELL_DOMINATION_2 11198
-
-// On Summon
-#define SAY_SUMMON_1 "Time to supplement my work force."
-#define SOUND_SAY_SUMMON_1 11196
-
-// On Enrage
-#define SAY_ENRAGE_1 "A minor inconvenience."
-#define SOUND_SAY_ENRAGE_1 11199
-
-// On Aggro
-#define SAY_AGGRO_1 "We are on a strict timetable. You will not interfere!"
-#define SOUND_SAY_AGGRO_1 11193
-
-//On Kill Unit
-#define SAY_SLAY_1 "Looks like you lose"
-#define SOUND_SLAY_1 11195
-
-// On Death
-#define SAY_DEATH_1 "The project will... continue."
-#define SOUND_DEATH_1 11200
-
-
-struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
-{
- boss_pathaleon_the_calculatorAI(Creature *c) : ScriptedAI(c)
- {
- HeroicMode = m_creature->GetMap()->IsHeroic();
- Reset();
- }
-
- uint32 Summon_Timer;
- uint32 ManaTap_Timer;
- uint32 ArcaneTorrent_Timer;
- uint32 Domination_Timer;
- uint32 ArcaneExplosion_Timer;
- bool HeroicMode;
- bool Enraged;
-
- uint32 Counter;
- Creature* Wraith;
-
- void Reset()
- {
- Summon_Timer = 30000;
- ManaTap_Timer = 12000 + rand()%8000;
- ArcaneTorrent_Timer = 16000 + rand()%9000;
- Domination_Timer = 25000 + rand()%15000;
- ArcaneExplosion_Timer = 8000 + rand()%5000;
-
- Enraged = false;
-
- Counter = 0;
-
- }
- void Aggro(Unit *who)
- {
- DoYell(SAY_AGGRO_1,LANG_UNIVERSAL,NULL);
- DoPlaySoundToSet(m_creature, SOUND_SAY_AGGRO_1);
- }
-
- // On Killed Unit
- void KilledUnit(Unit* victim)
- {
-
- DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL);
- DoPlaySoundToSet(m_creature,SOUND_SLAY_1);
-
- }
-
- // On Death
- void JustDied(Unit* Killer)
- {
- DoYell(SAY_DEATH_1,LANG_UNIVERSAL,NULL);
- DoPlaySoundToSet(m_creature, SOUND_DEATH_1);
- }
-
- void UpdateAI(const uint32 diff)
- {
- //Return since we have no target
- if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() )
- return;
-
- if(Summon_Timer < diff)
- {
-
- Unit* target = NULL;
-
- for(int i = 0; i < 3;i++)
- {
- target = SelectUnit(SELECT_TARGET_RANDOM,0);
- Wraith = m_creature->SummonCreature(21062,m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
- if (target)
- Wraith->AI()->AttackStart(target);
- }
-
- DoYell(SAY_SUMMON_1,LANG_UNIVERSAL,NULL);
- DoPlaySoundToSet(m_creature, SOUND_SAY_SUMMON_1);
-
- Summon_Timer = 30000 + rand()%15000;
- }else Summon_Timer -= diff;
-
- if(ManaTap_Timer < diff)
- {
- //time to cast
- DoCast(m_creature->getVictim(),SPELL_MANA_TAP);
-
- //Cast again on time
- ManaTap_Timer = 14000 + rand()%8000;
- }else ManaTap_Timer -= diff;
-
- if(ArcaneTorrent_Timer < diff)
- {
- //time to cast
- DoCast(m_creature->getVictim(),SPELL_ARCANE_TORRENT);
-
- //Cast again on time
- ArcaneTorrent_Timer = 12000 + rand()%6000;
- }else ArcaneTorrent_Timer -= diff;
-
- if(Domination_Timer < diff)
- {
- //time to cast
- switch(rand()%2)
- {
- case 0:
- DoYell(SAY_SPELL_DOMINATION_1, LANG_UNIVERSAL, NULL);
- DoPlaySoundToSet(m_creature, SOUND_SPELL_DOMINATION_1);
- break;
-
- case 1:
- DoYell(SAY_SPELL_DOMINATION_2, LANG_UNIVERSAL, NULL);
- DoPlaySoundToSet(m_creature, SOUND_SPELL_DOMINATION_2);
- break;
- }
-
- Unit* target = NULL;
- target = SelectUnit(SELECT_TARGET_RANDOM,1);
- if (target) DoCast(target,SPELL_DOMINATION);
-
- //Cast again on time
- Domination_Timer = 25000 + rand()%5000;
- }else Domination_Timer -= diff;
-
- //Only casting if Heroic Mode is used
- if (HeroicMode)
- {
- if(ArcaneExplosion_Timer < diff)
- {
- //time to cast
- DoCast(m_creature->getVictim(),H_SPELL_ARCANE_EXPLOSION);
-
- //Cast again on time
- ArcaneExplosion_Timer = 10000 + rand()%4000;
- }else ArcaneExplosion_Timer -= diff;
- }
-
- if (!Enraged && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21)
- {
-
- DoCast(m_creature, SPELL_ENRAGE);
- DoYell(SAY_ENRAGE_1, LANG_UNIVERSAL, NULL);
- DoPlaySoundToSet(m_creature,SOUND_SAY_ENRAGE_1);
- Enraged = true;
-
- }
-
- DoMeleeAttackIfReady();
- }
-};
-CreatureAI* GetAI_boss_pathaleon_the_calculator(Creature *_Creature)
-{
- return new boss_pathaleon_the_calculatorAI (_Creature);
-}
-
-struct TRINITY_DLL_DECL mob_nether_wraithAI : public ScriptedAI
-{
- mob_nether_wraithAI(Creature *c) : ScriptedAI(c) {Reset();}
-
- ScriptedInstance *pInstance;
-
- uint32 ArcaneMissiles_Timer;
- uint32 Detonation_Timer;
- uint32 Die_Timer;
- bool Detonation;
-
- void Reset()
- {
- ArcaneMissiles_Timer = 1000 + rand()%3000;
- Detonation_Timer = 20000;
- Die_Timer = 2200;
- Detonation = false;
-
- }
-
- void Aggro(Unit* who)
- {
- }
-
- void UpdateAI(const uint32 diff)
- {
- Unit* target = NULL;
-
- if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
- return;
-
- if(ArcaneMissiles_Timer < diff)
- {
-
- Unit* target = NULL;
- target = SelectUnit(SELECT_TARGET_RANDOM,1);
- if (!target)
- target = m_creature->getVictim();
- if (target)
- {
- DoCast(target,SPELL_ARCANE_MISSILES);
- }
-
- ArcaneMissiles_Timer = 5000 + rand()%5000;
- }else ArcaneMissiles_Timer -=diff;
-
- if (!Detonation)
- {
- if(Detonation_Timer < diff)
- {
- //time to cast
- DoCast(m_creature,SPELL_DETONATION);
- Detonation = true;
-
- }else Detonation_Timer -= diff;
-
- }
-
- if (Detonation)
- {
- if (Die_Timer < diff)
- {
- m_creature->setDeathState(JUST_DIED);
- m_creature->RemoveCorpse();
- }else Die_Timer -= diff;
- }
-
-
- DoMeleeAttackIfReady();
- }
-
-};
-CreatureAI* GetAI_mob_nether_wraith(Creature *_Creature)
-{
- return new mob_nether_wraithAI (_Creature);
-}
-
-void AddSC_boss_pathaleon_the_calculator()
-{
- Script *newscript;
- newscript = new Script;
- newscript->Name="boss_pathaleon_the_calculator";
- newscript->GetAI = GetAI_boss_pathaleon_the_calculator;
- m_scripts[nrscripts++] = newscript;
-
- newscript = new Script;
- newscript->Name="mob_nether_wraith";
- newscript->GetAI = GetAI_mob_nether_wraith;
- m_scripts[nrscripts++] = newscript;
-}
+/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: Boss Pathaleon the Calculator +SD%Complete: 50 +SDComment: Event missing. Script for himself 99% blizzlike. +SDCategory: Tempest Keep, The Mechanar +EndScriptData */ + +#include "precompiled.h" + +// Spells to be casted +#define SPELL_SUMMON_NETHER_WRAITH 35287 //Spell not working. Summon is working but Pets dont attack and wrong HP. +#define SPELL_MANA_TAP 36021 +#define SPELL_ARCANE_TORRENT 36022 +#define SPELL_DOMINATION 35280 +#define H_SPELL_ARCANE_EXPLOSION 34791 //Spell not right. +#define SPELL_ENRAGE 36992 + +// Add Spells +#define SPELL_DETONATION 35058 +#define SPELL_ARCANE_MISSILES 35034 + +// On Domination +#define SAY_SPELL_DOMINATION_1 "I'm looking for a team player... " +#define SOUND_SPELL_DOMINATION_1 11197 +#define SAY_SPELL_DOMINATION_2 "You work for me now!" +#define SOUND_SPELL_DOMINATION_2 11198 + +// On Summon +#define SAY_SUMMON_1 "Time to supplement my work force." +#define SOUND_SAY_SUMMON_1 11196 + +// On Enrage +#define SAY_ENRAGE_1 "A minor inconvenience." +#define SOUND_SAY_ENRAGE_1 11199 + +// On Aggro +#define SAY_AGGRO_1 "We are on a strict timetable. You will not interfere!" +#define SOUND_SAY_AGGRO_1 11193 + +//On Kill Unit +#define SAY_SLAY_1 "Looks like you lose" +#define SOUND_SLAY_1 11195 + +// On Death +#define SAY_DEATH_1 "The project will... continue." +#define SOUND_DEATH_1 11200 + + +struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI +{ + boss_pathaleon_the_calculatorAI(Creature *c) : ScriptedAI(c) + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + uint32 Summon_Timer; + uint32 ManaTap_Timer; + uint32 ArcaneTorrent_Timer; + uint32 Domination_Timer; + uint32 ArcaneExplosion_Timer; + bool HeroicMode; + bool Enraged; + + uint32 Counter; + Creature* Wraith; + + void Reset() + { + Summon_Timer = 30000; + ManaTap_Timer = 12000 + rand()%8000; + ArcaneTorrent_Timer = 16000 + rand()%9000; + Domination_Timer = 25000 + rand()%15000; + ArcaneExplosion_Timer = 8000 + rand()%5000; + + Enraged = false; + + Counter = 0; + + } + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SAY_AGGRO_1); + } + + // On Killed Unit + void KilledUnit(Unit* victim) + { + + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + + } + + // On Death + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH_1); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(Summon_Timer < diff) + { + + Unit* target = NULL; + + for(int i = 0; i < 3;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + Wraith = m_creature->SummonCreature(21062,m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000); + if (target) + Wraith->AI()->AttackStart(target); + } + + DoYell(SAY_SUMMON_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SAY_SUMMON_1); + + Summon_Timer = 30000 + rand()%15000; + }else Summon_Timer -= diff; + + if(ManaTap_Timer < diff) + { + //time to cast + DoCast(m_creature->getVictim(),SPELL_MANA_TAP); + + //Cast again on time + ManaTap_Timer = 14000 + rand()%8000; + }else ManaTap_Timer -= diff; + + if(ArcaneTorrent_Timer < diff) + { + //time to cast + DoCast(m_creature->getVictim(),SPELL_ARCANE_TORRENT); + + //Cast again on time + ArcaneTorrent_Timer = 12000 + rand()%6000; + }else ArcaneTorrent_Timer -= diff; + + if(Domination_Timer < diff) + { + //time to cast + switch(rand()%2) + { + case 0: + DoYell(SAY_SPELL_DOMINATION_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SPELL_DOMINATION_1); + break; + + case 1: + DoYell(SAY_SPELL_DOMINATION_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SPELL_DOMINATION_2); + break; + } + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (target) DoCast(target,SPELL_DOMINATION); + + //Cast again on time + Domination_Timer = 25000 + rand()%5000; + }else Domination_Timer -= diff; + + //Only casting if Heroic Mode is used + if (HeroicMode) + { + if(ArcaneExplosion_Timer < diff) + { + //time to cast + DoCast(m_creature->getVictim(),H_SPELL_ARCANE_EXPLOSION); + + //Cast again on time + ArcaneExplosion_Timer = 10000 + rand()%4000; + }else ArcaneExplosion_Timer -= diff; + } + + if (!Enraged && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21) + { + + DoCast(m_creature, SPELL_ENRAGE); + DoYell(SAY_ENRAGE_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SAY_ENRAGE_1); + Enraged = true; + + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_pathaleon_the_calculator(Creature *_Creature) +{ + return new boss_pathaleon_the_calculatorAI (_Creature); +} + +struct TRINITY_DLL_DECL mob_nether_wraithAI : public ScriptedAI +{ + mob_nether_wraithAI(Creature *c) : ScriptedAI(c) {Reset();} + + ScriptedInstance *pInstance; + + uint32 ArcaneMissiles_Timer; + uint32 Detonation_Timer; + uint32 Die_Timer; + bool Detonation; + + void Reset() + { + ArcaneMissiles_Timer = 1000 + rand()%3000; + Detonation_Timer = 20000; + Die_Timer = 2200; + Detonation = false; + + } + + void Aggro(Unit* who) + { + } + + void UpdateAI(const uint32 diff) + { + Unit* target = NULL; + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(ArcaneMissiles_Timer < diff) + { + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (!target) + target = m_creature->getVictim(); + if (target) + { + DoCast(target,SPELL_ARCANE_MISSILES); + } + + ArcaneMissiles_Timer = 5000 + rand()%5000; + }else ArcaneMissiles_Timer -=diff; + + if (!Detonation) + { + if(Detonation_Timer < diff) + { + //time to cast + DoCast(m_creature,SPELL_DETONATION); + Detonation = true; + + }else Detonation_Timer -= diff; + + } + + if (Detonation) + { + if (Die_Timer < diff) + { + m_creature->setDeathState(JUST_DIED); + m_creature->RemoveCorpse(); + }else Die_Timer -= diff; + } + + + DoMeleeAttackIfReady(); + } + +}; +CreatureAI* GetAI_mob_nether_wraith(Creature *_Creature) +{ + return new mob_nether_wraithAI (_Creature); +} + +void AddSC_boss_pathaleon_the_calculator() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_pathaleon_the_calculator"; + newscript->GetAI = GetAI_boss_pathaleon_the_calculator; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_nether_wraith"; + newscript->GetAI = GetAI_mob_nether_wraith; + newscript->RegisterSelf(); +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp index c58ab523b90..d25b9d05470 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp @@ -1,90 +1,90 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* ScriptData
-SDName: Instance_Mechanar
-SD%Complete: 100
-SDComment:
-SDCategory: Mechanar
-EndScriptData */
-
-#include "precompiled.h"
-#include "def_mechanar.h"
-
-struct TRINITY_DLL_DECL instance_mechanar : public ScriptedInstance
-{
- instance_mechanar(Map *Map) : ScriptedInstance(Map) {Initialize();};
-
-
- bool IsBossDied[1];
-
- void OnCreatureCreate (Creature *creature, uint32 creature_entry)
- {
- }
-
- void Initialize()
- {
- IsBossDied[0] = false;
- }
-
- bool IsEncounterInProgress() const
- {
- //not active
- return false;
- }
-
- uint32 GetData(uint32 type)
- {
- switch(type)
- {
- case DATA_SEPETHREAISDEAD:
- if(IsBossDied[0])
- return 1;
- break;
- }
-
- return 0;
- }
-
- uint64 GetData64 (uint32 identifier)
- {
- return 0;
- }
-
- void SetData(uint32 type, uint32 data)
- {
- switch(type)
- {
- case DATA_SEPETHREA_DEATH:
- IsBossDied[0] = true;
- break;
- }
- }
-};
-
-InstanceData* GetInstanceData_instance_mechanar(Map* map)
-{
- return new instance_mechanar(map);
-}
-
-void AddSC_instance_mechanar()
-{
- Script *newscript;
- newscript = new Script;
- newscript->Name = "instance_mechanar";
- newscript->GetInstanceData = GetInstanceData_instance_mechanar;
- m_scripts[nrscripts++] = newscript;
-}
+/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Mechanar +SD%Complete: 100 +SDComment: +SDCategory: Mechanar +EndScriptData */ + +#include "precompiled.h" +#include "def_mechanar.h" + +struct TRINITY_DLL_DECL instance_mechanar : public ScriptedInstance +{ + instance_mechanar(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + + bool IsBossDied[1]; + + void OnCreatureCreate (Creature *creature, uint32 creature_entry) + { + } + + void Initialize() + { + IsBossDied[0] = false; + } + + bool IsEncounterInProgress() const + { + //not active + return false; + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_SEPETHREAISDEAD: + if(IsBossDied[0]) + return 1; + break; + } + + return 0; + } + + uint64 GetData64 (uint32 identifier) + { + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_SEPETHREA_DEATH: + IsBossDied[0] = true; + break; + } + } +}; + +InstanceData* GetInstanceData_instance_mechanar(Map* map) +{ + return new instance_mechanar(map); +} + +void AddSC_instance_mechanar() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_mechanar"; + newscript->GetInstanceData = GetInstanceData_instance_mechanar; + newscript->RegisterSelf(); +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp index 1dba25cd132..8f2f025f7f1 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp @@ -334,15 +334,15 @@ void AddSC_bug_trio() newscript = new Script; newscript->Name="boss_kri"; newscript->GetAI = GetAI_boss_kri; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_vem"; newscript->GetAI = GetAI_boss_vem; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_yauj"; newscript->GetAI = GetAI_boss_yauj; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp index 0116947e390..b789f68e9aa 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp @@ -577,20 +577,23 @@ struct TRINITY_DLL_DECL cthunAI : public Scripted_NoMovementAI Map *map = m_creature->GetMap(); if(!map->IsDungeon()) return; - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + Map::PlayerList const &PlayerList = map->GetPlayers(); + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - //Play random sound to the zone - switch (rand()%8) + if (Player* i_pl = i->getSource()) { - case 0: (*i)->SendPlaySound(RND_WISPER_1, true); break; - case 1: (*i)->SendPlaySound(RND_WISPER_2, true); break; - case 2: (*i)->SendPlaySound(RND_WISPER_3, true); break; - case 3: (*i)->SendPlaySound(RND_WISPER_4, true); break; - case 4: (*i)->SendPlaySound(RND_WISPER_5, true); break; - case 5: (*i)->SendPlaySound(RND_WISPER_6, true); break; - case 6: (*i)->SendPlaySound(RND_WISPER_7, true); break; - case 7: (*i)->SendPlaySound(RND_WISPER_8, true); break; + //Play random sound to the zone + switch (rand()%8) + { + case 0: i_pl->SendPlaySound(RND_WISPER_1, true); break; + case 1: i_pl->SendPlaySound(RND_WISPER_2, true); break; + case 2: i_pl->SendPlaySound(RND_WISPER_3, true); break; + case 3: i_pl->SendPlaySound(RND_WISPER_4, true); break; + case 4: i_pl->SendPlaySound(RND_WISPER_5, true); break; + case 5: i_pl->SendPlaySound(RND_WISPER_6, true); break; + case 6: i_pl->SendPlaySound(RND_WISPER_7, true); break; + case 7: i_pl->SendPlaySound(RND_WISPER_8, true); break; + } } } @@ -1326,35 +1329,35 @@ void AddSC_boss_cthun() newscript = new Script; newscript->Name="boss_eye_of_cthun"; newscript->GetAI = GetAI_eye_of_cthun; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_cthun"; newscript->GetAI = GetAI_cthun; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_eye_tentacle"; newscript->GetAI = GetAI_eye_tentacle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_claw_tentacle"; newscript->GetAI = GetAI_claw_tentacle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_giant_claw_tentacle"; newscript->GetAI = GetAI_giant_claw_tentacle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_giant_eye_tentacle"; newscript->GetAI = GetAI_giant_eye_tentacle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_giant_flesh_tentacle"; newscript->GetAI = GetAI_flesh_tentacle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp index 331e43d83ef..babd0ebf7c2 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp @@ -186,5 +186,5 @@ void AddSC_boss_fankriss() newscript = new Script; newscript->Name="boss_fankriss"; newscript->GetAI = GetAI_boss_fankriss; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp index 7fb10528dff..51e030fa49d 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp @@ -139,5 +139,5 @@ void AddSC_boss_huhuran() newscript = new Script; newscript->Name="boss_huhuran"; newscript->GetAI = GetAI_boss_huhuran; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp index df7efb8f123..1e0e8fbca6d 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp @@ -136,5 +136,5 @@ void AddSC_boss_ouro() newscript = new Script; newscript->Name="boss_ouro"; newscript->GetAI = GetAI_boss_ouro; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp index 3315e49732c..c9a732493f7 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp @@ -259,10 +259,10 @@ void AddSC_boss_sartura() newscript = new Script; newscript->Name="boss_sartura"; newscript->GetAI = GetAI_boss_sartura; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_sartura_royal_guard"; newscript->GetAI = GetAI_mob_sartura_royal_guard; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp index 9d383ef0d61..9194354ddc0 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp @@ -310,5 +310,5 @@ void AddSC_boss_skeram() newscript = new Script; newscript->Name="boss_skeram"; newscript->GetAI = GetAI_boss_skeram; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp index 2ddb8be73c7..93525ad7246 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp @@ -689,10 +689,10 @@ void AddSC_boss_twinemperors() newscript = new Script; newscript->Name="boss_veknilash"; newscript->GetAI = GetAI_boss_veknilash; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_veklor"; newscript->GetAI = GetAI_boss_veklor; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp index f502b2aa23d..84713b190cf 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp @@ -161,5 +161,5 @@ void AddSC_instance_temple_of_ahnqiraj() newscript = new Script; newscript->Name = "instance_temple_of_ahnqiraj"; newscript->GetInstanceData = GetInstanceData_instance_temple_of_ahnqiraj; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp index 1c009721428..f5a55d711b7 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp @@ -309,7 +309,7 @@ void AddSC_mob_anubisath_sentinel() newscript = new Script; newscript->Name="mob_anubisath_sentinel"; newscript->GetAI = GetAI_mob_anubisath_sentinelAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } SentinelAbilityAura::~SentinelAbilityAura() {} diff --git a/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp b/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp index d38b7186172..d84c3c58133 100644 --- a/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp +++ b/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp @@ -368,32 +368,32 @@ void AddSC_terokkar_forest() newscript = new Script; newscript->Name="mob_unkor_the_ruthless"; newscript->GetAI = GetAI_mob_unkor_the_ruthless; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_infested_root_walker"; newscript->GetAI = GetAI_mob_infested_root_walker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_rotting_forest_rager"; newscript->GetAI = GetAI_mob_rotting_forest_rager; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_netherweb_victim"; newscript->GetAI = GetAI_mob_netherweb_victim; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_floon"; newscript->pGossipHello = &GossipHello_npc_floon; newscript->pGossipSelect = &GossipSelect_npc_floon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_skyguard_handler_deesak"; newscript->pGossipHello = &GossipHello_npc_skyguard_handler_deesak; newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_deesak; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp b/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp index ae65bd9d232..4b7dcd5a84a 100644 --- a/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp +++ b/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp @@ -132,5 +132,5 @@ void AddSC_thunder_bluff() newscript->GetAI = GetAI_npc_cairne_bloodhoof; newscript->pGossipHello = &GossipHello_npc_cairne_bloodhoof; newscript->pGossipSelect = &GossipSelect_npc_cairne_bloodhoof; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp b/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp index f95bc029752..d037b2b7e14 100644 --- a/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp +++ b/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp @@ -84,5 +84,5 @@ void AddSC_tirisfal_glades() newscript->Name="npc_calvin_montague"; newscript->GetAI = GetAI_npc_calvin_montague; newscript->pQuestAccept = &QuestAccept_npc_calvin_montague; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp b/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp index 34f8fda78cf..db4b7c22df3 100644 --- a/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp +++ b/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp @@ -103,5 +103,5 @@ void AddSC_boss_ironaya() newscript = new Script; newscript->Name="boss_ironaya"; newscript->GetAI = GetAI_boss_ironaya; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp b/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp index 1e1a6eb8462..e8453db9f65 100644 --- a/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp +++ b/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp @@ -177,11 +177,11 @@ void AddSC_uldaman() newscript = new Script; newscript->Name="mob_jadespine_basilisk"; newscript->GetAI = GetAI_mob_jadespine_basilisk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_lore_keeper_of_norgannon"; newscript->pGossipHello = &GossipHello_npc_lore_keeper_of_norgannon; newscript->pGossipSelect = &GossipSelect_npc_lore_keeper_of_norgannon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/undercity/undercity.cpp b/src/bindings/scripts/scripts/zone/undercity/undercity.cpp index b395121c73c..89ded786ce5 100644 --- a/src/bindings/scripts/scripts/zone/undercity/undercity.cpp +++ b/src/bindings/scripts/scripts/zone/undercity/undercity.cpp @@ -245,16 +245,16 @@ void AddSC_undercity() newscript->Name="npc_lady_sylvanas_windrunner"; newscript->GetAI = GetAI_npc_lady_sylvanas_windrunner; newscript->pChooseReward = &ChooseReward_npc_lady_sylvanas_windrunner; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_highborne_lamenter"; newscript->GetAI = GetAI_npc_highborne_lamenter; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_parqual_fintallas"; newscript->pGossipHello = &GossipHello_npc_parqual_fintallas; newscript->pGossipSelect = &GossipSelect_npc_parqual_fintallas; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp b/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp index c3725b0afc9..3f8dee012f4 100644 --- a/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp +++ b/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp @@ -167,10 +167,10 @@ void AddSC_western_plaguelands() newscript->Name="npcs_dithers_and_arbington"; newscript->pGossipHello = &GossipHello_npcs_dithers_and_arbington; newscript->pGossipSelect = &GossipSelect_npcs_dithers_and_arbington; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_the_scourge_cauldron"; newscript->GetAI = GetAI_npc_the_scourge_cauldron; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/westfall/westfall.cpp b/src/bindings/scripts/scripts/zone/westfall/westfall.cpp index 446f71f1c56..40faa01a9f0 100644 --- a/src/bindings/scripts/scripts/zone/westfall/westfall.cpp +++ b/src/bindings/scripts/scripts/zone/westfall/westfall.cpp @@ -1,179 +1,179 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* ScriptData
-SDName: Westfall
-SD%Complete: 90
-SDComment: Quest support: 155
-SDCategory: Westfall
-EndScriptData */
-
-/* ContentData
-npc_defias_traitor
-EndContentData */
-
-#include "precompiled.h"
-#include "../../npc/npc_escortAI.h"
-
-#define SAY_START -1000101
-#define SAY_PROGRESS -1000102
-#define SAY_END -1000103
-#define SAY_AGGRO_1 -1000104
-#define SAY_AGGRO_2 -1000105
-
-#define QUEST_DEFIAS_BROTHERHOOD 155
-
-struct TRINITY_DLL_DECL npc_defias_traitorAI : public npc_escortAI
-{
- npc_defias_traitorAI(Creature *c) : npc_escortAI(c) {Reset();}
-
- bool IsWalking;
-
- void WaypointReached(uint32 i)
- {
- Unit* player = Unit::GetUnit((*m_creature), PlayerGUID);
-
- if (!player)
- return;
-
- if (IsWalking && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
- m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
-
- switch (i)
- {
- case 35:
- IsWalking = true;
- break;
- case 36:
- DoScriptText(SAY_PROGRESS, m_creature, player);
- break;
- case 44:
- DoScriptText(SAY_END, m_creature, player);
- {
- if (player && player->GetTypeId() == TYPEID_PLAYER)
- ((Player*)player)->GroupEventHappens(QUEST_DEFIAS_BROTHERHOOD,m_creature);
- }
- break;
- }
- }
- void Aggro(Unit* who)
- {
- switch(rand()%2)
- {
- case 0: DoScriptText(SAY_AGGRO_1, m_creature, who); break;
- case 1: DoScriptText(SAY_AGGRO_2, m_creature, who); break;
- }
- }
-
- void Reset()
- {
- if (IsWalking && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
- {
- m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
- return;
- }
- IsWalking = false;
- }
-
- void JustDied(Unit* killer)
- {
- if (PlayerGUID)
- {
- if (Unit* player = Unit::GetUnit((*m_creature), PlayerGUID))
- ((Player*)player)->FailQuest(QUEST_DEFIAS_BROTHERHOOD);
- }
- }
-
- void UpdateAI(const uint32 diff)
- {
- npc_escortAI::UpdateAI(diff);
- }
-};
-
-bool QuestAccept_npc_defias_traitor(Player* player, Creature* creature, Quest const* quest)
-{
- if (quest->GetQuestId() == QUEST_DEFIAS_BROTHERHOOD)
- {
- ((npc_escortAI*)(creature->AI()))->Start(true, true, true, player->GetGUID());
- DoScriptText(SAY_START, creature, player);
- }
-
- return true;
-}
-
-CreatureAI* GetAI_npc_defias_traitor(Creature *_Creature)
-{
- npc_defias_traitorAI* thisAI = new npc_defias_traitorAI(_Creature);
-
- thisAI->AddWaypoint(0, -10508.40, 1068.00, 55.21);
- thisAI->AddWaypoint(1, -10518.30, 1074.84, 53.96);
- thisAI->AddWaypoint(2, -10534.82, 1081.92, 49.88);
- thisAI->AddWaypoint(3, -10546.51, 1084.88, 50.13);
- thisAI->AddWaypoint(4, -10555.29, 1084.45, 45.75);
- thisAI->AddWaypoint(5, -10566.57, 1083.53, 42.10);
- thisAI->AddWaypoint(6, -10575.83, 1082.34, 39.46);
- thisAI->AddWaypoint(7, -10585.67, 1081.08, 37.77);
- thisAI->AddWaypoint(8, -10600.08, 1078.19, 36.23);
- thisAI->AddWaypoint(9, -10608.69, 1076.08, 35.88);
- thisAI->AddWaypoint(10, -10621.26, 1073.00, 35.40);
- thisAI->AddWaypoint(11, -10638.12, 1060.18, 33.61);
- thisAI->AddWaypoint(12, -10655.87, 1038.99, 33.48);
- thisAI->AddWaypoint(13, -10664.68, 1030.54, 32.70);
- thisAI->AddWaypoint(14, -10708.68, 1033.86, 33.32);
- thisAI->AddWaypoint(15, -10754.43, 1017.93, 32.79);
- thisAI->AddWaypoint(16, -10802.26, 1018.01, 32.16);
- thisAI->AddWaypoint(17, -10832.60, 1009.04, 32.71);
- thisAI->AddWaypoint(18, -10866.56, 1006.51, 31.71); // Fix waypoints from roughly this point, test first to get proper one
- thisAI->AddWaypoint(19, -10879.98, 1005.10, 32.84);
- thisAI->AddWaypoint(20, -10892.45, 1001.32, 34.46);
- thisAI->AddWaypoint(21, -10906.14, 997.11, 36.15);
- thisAI->AddWaypoint(22, -10922.26, 1002.23, 35.74);
- thisAI->AddWaypoint(23, -10936.32, 1023.38, 36.52);
- thisAI->AddWaypoint(24, -10933.35, 1052.61, 35.85);
- thisAI->AddWaypoint(25, -10940.25, 1077.66, 36.49);
- thisAI->AddWaypoint(26, -10957.09, 1099.33, 36.83);
- thisAI->AddWaypoint(27, -10956.53, 1119.90, 36.73);
- thisAI->AddWaypoint(28, -10939.30, 1150.75, 37.42);
- thisAI->AddWaypoint(29, -10915.14, 1202.09, 36.55);
- thisAI->AddWaypoint(30, -10892.59, 1257.03, 33.37);
- thisAI->AddWaypoint(31, -10891.93, 1306.66, 35.45);
- thisAI->AddWaypoint(32, -10896.17, 1327.86, 37.77);
- thisAI->AddWaypoint(33, -10906.03, 1368.05, 40.91);
- thisAI->AddWaypoint(34, -10910.18, 1389.33, 42.62);
- thisAI->AddWaypoint(35, -10915.42, 1417.72, 42.93);
- thisAI->AddWaypoint(36, -10926.37, 1421.18, 43.04); // walk here and say
- thisAI->AddWaypoint(37, -10952.31, 1421.74, 43.40);
- thisAI->AddWaypoint(38, -10980.04, 1411.38, 42.79);
- thisAI->AddWaypoint(39, -11006.06, 1420.47, 43.26);
- thisAI->AddWaypoint(40, -11021.98, 1450.59, 43.09);
- thisAI->AddWaypoint(41, -11025.36, 1491.59, 43.15);
- thisAI->AddWaypoint(42, -11036.09, 1508.32, 43.28);
- thisAI->AddWaypoint(43, -11060.68, 1526.72, 43.19);
- thisAI->AddWaypoint(44, -11072.75, 1527.77, 43.20, 5000);// say and quest credit
-
- return (CreatureAI*)thisAI;
-}
-
-void AddSC_westfall()
-{
- Script *newscript;
-
- newscript = new Script;
- newscript->Name="npc_defias_traitor";
- newscript->GetAI = &GetAI_npc_defias_traitor;
- newscript->pQuestAccept = &QuestAccept_npc_defias_traitor;
- m_scripts[nrscripts++] = newscript;
-}
+/* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Westfall +SD%Complete: 90 +SDComment: Quest support: 155 +SDCategory: Westfall +EndScriptData */ + +/* ContentData +npc_defias_traitor +EndContentData */ + +#include "precompiled.h" +#include "../../npc/npc_escortAI.h" + +#define SAY_START -1000101 +#define SAY_PROGRESS -1000102 +#define SAY_END -1000103 +#define SAY_AGGRO_1 -1000104 +#define SAY_AGGRO_2 -1000105 + +#define QUEST_DEFIAS_BROTHERHOOD 155 + +struct TRINITY_DLL_DECL npc_defias_traitorAI : public npc_escortAI +{ + npc_defias_traitorAI(Creature *c) : npc_escortAI(c) {Reset();} + + bool IsWalking; + + void WaypointReached(uint32 i) + { + Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); + + if (!player) + return; + + if (IsWalking && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + + switch (i) + { + case 35: + IsWalking = true; + break; + case 36: + DoScriptText(SAY_PROGRESS, m_creature, player); + break; + case 44: + DoScriptText(SAY_END, m_creature, player); + { + if (player && player->GetTypeId() == TYPEID_PLAYER) + ((Player*)player)->GroupEventHappens(QUEST_DEFIAS_BROTHERHOOD,m_creature); + } + break; + } + } + void Aggro(Unit* who) + { + switch(rand()%2) + { + case 0: DoScriptText(SAY_AGGRO_1, m_creature, who); break; + case 1: DoScriptText(SAY_AGGRO_2, m_creature, who); break; + } + } + + void Reset() + { + if (IsWalking && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) + { + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + return; + } + IsWalking = false; + } + + void JustDied(Unit* killer) + { + if (PlayerGUID) + { + if (Unit* player = Unit::GetUnit((*m_creature), PlayerGUID)) + ((Player*)player)->FailQuest(QUEST_DEFIAS_BROTHERHOOD); + } + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + } +}; + +bool QuestAccept_npc_defias_traitor(Player* player, Creature* creature, Quest const* quest) +{ + if (quest->GetQuestId() == QUEST_DEFIAS_BROTHERHOOD) + { + ((npc_escortAI*)(creature->AI()))->Start(true, true, true, player->GetGUID()); + DoScriptText(SAY_START, creature, player); + } + + return true; +} + +CreatureAI* GetAI_npc_defias_traitor(Creature *_Creature) +{ + npc_defias_traitorAI* thisAI = new npc_defias_traitorAI(_Creature); + + thisAI->AddWaypoint(0, -10508.40, 1068.00, 55.21); + thisAI->AddWaypoint(1, -10518.30, 1074.84, 53.96); + thisAI->AddWaypoint(2, -10534.82, 1081.92, 49.88); + thisAI->AddWaypoint(3, -10546.51, 1084.88, 50.13); + thisAI->AddWaypoint(4, -10555.29, 1084.45, 45.75); + thisAI->AddWaypoint(5, -10566.57, 1083.53, 42.10); + thisAI->AddWaypoint(6, -10575.83, 1082.34, 39.46); + thisAI->AddWaypoint(7, -10585.67, 1081.08, 37.77); + thisAI->AddWaypoint(8, -10600.08, 1078.19, 36.23); + thisAI->AddWaypoint(9, -10608.69, 1076.08, 35.88); + thisAI->AddWaypoint(10, -10621.26, 1073.00, 35.40); + thisAI->AddWaypoint(11, -10638.12, 1060.18, 33.61); + thisAI->AddWaypoint(12, -10655.87, 1038.99, 33.48); + thisAI->AddWaypoint(13, -10664.68, 1030.54, 32.70); + thisAI->AddWaypoint(14, -10708.68, 1033.86, 33.32); + thisAI->AddWaypoint(15, -10754.43, 1017.93, 32.79); + thisAI->AddWaypoint(16, -10802.26, 1018.01, 32.16); + thisAI->AddWaypoint(17, -10832.60, 1009.04, 32.71); + thisAI->AddWaypoint(18, -10866.56, 1006.51, 31.71); // Fix waypoints from roughly this point, test first to get proper one + thisAI->AddWaypoint(19, -10879.98, 1005.10, 32.84); + thisAI->AddWaypoint(20, -10892.45, 1001.32, 34.46); + thisAI->AddWaypoint(21, -10906.14, 997.11, 36.15); + thisAI->AddWaypoint(22, -10922.26, 1002.23, 35.74); + thisAI->AddWaypoint(23, -10936.32, 1023.38, 36.52); + thisAI->AddWaypoint(24, -10933.35, 1052.61, 35.85); + thisAI->AddWaypoint(25, -10940.25, 1077.66, 36.49); + thisAI->AddWaypoint(26, -10957.09, 1099.33, 36.83); + thisAI->AddWaypoint(27, -10956.53, 1119.90, 36.73); + thisAI->AddWaypoint(28, -10939.30, 1150.75, 37.42); + thisAI->AddWaypoint(29, -10915.14, 1202.09, 36.55); + thisAI->AddWaypoint(30, -10892.59, 1257.03, 33.37); + thisAI->AddWaypoint(31, -10891.93, 1306.66, 35.45); + thisAI->AddWaypoint(32, -10896.17, 1327.86, 37.77); + thisAI->AddWaypoint(33, -10906.03, 1368.05, 40.91); + thisAI->AddWaypoint(34, -10910.18, 1389.33, 42.62); + thisAI->AddWaypoint(35, -10915.42, 1417.72, 42.93); + thisAI->AddWaypoint(36, -10926.37, 1421.18, 43.04); // walk here and say + thisAI->AddWaypoint(37, -10952.31, 1421.74, 43.40); + thisAI->AddWaypoint(38, -10980.04, 1411.38, 42.79); + thisAI->AddWaypoint(39, -11006.06, 1420.47, 43.26); + thisAI->AddWaypoint(40, -11021.98, 1450.59, 43.09); + thisAI->AddWaypoint(41, -11025.36, 1491.59, 43.15); + thisAI->AddWaypoint(42, -11036.09, 1508.32, 43.28); + thisAI->AddWaypoint(43, -11060.68, 1526.72, 43.19); + thisAI->AddWaypoint(44, -11072.75, 1527.77, 43.20, 5000);// say and quest credit + + return (CreatureAI*)thisAI; +} + +void AddSC_westfall() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_defias_traitor"; + newscript->GetAI = &GetAI_npc_defias_traitor; + newscript->pQuestAccept = &QuestAccept_npc_defias_traitor; + newscript->RegisterSelf(); +} diff --git a/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp b/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp index 7d6f8ea30fb..08ead2eb1de 100644 --- a/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp +++ b/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp @@ -141,17 +141,17 @@ void AddSC_winterspring() newscript->Name="npc_lorax"; newscript->pGossipHello = &GossipHello_npc_lorax; newscript->pGossipSelect = &GossipSelect_npc_lorax; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_rivern_frostwind"; newscript->pGossipHello = &GossipHello_npc_rivern_frostwind; newscript->pGossipSelect = &GossipSelect_npc_rivern_frostwind; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_witch_doctor_mauari"; newscript->pGossipHello = &GossipHello_npc_witch_doctor_mauari; newscript->pGossipSelect = &GossipSelect_npc_witch_doctor_mauari; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp b/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp index 621d3e5da49..fdce0029e9d 100644 --- a/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp +++ b/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp @@ -261,23 +261,23 @@ void AddSC_zangarmarsh() newscript->Name="npcs_ashyen_and_keleth"; newscript->pGossipHello = &GossipHello_npcs_ashyen_and_keleth; newscript->pGossipSelect = &GossipSelect_npcs_ashyen_and_keleth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_cooshcoosh"; newscript->pGossipHello = &GossipHello_npc_cooshcoosh; newscript->pGossipSelect = &GossipSelect_npc_cooshcoosh; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_elder_kuruti"; newscript->pGossipHello = &GossipHello_npc_elder_kuruti; newscript->pGossipSelect = &GossipSelect_npc_elder_kuruti; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_mortog_steamhead"; newscript->pGossipHello = &GossipHello_npc_mortog_steamhead; newscript->pGossipSelect = &GossipSelect_npc_mortog_steamhead; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp index c7327376ae1..4b9eb2afa88 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp @@ -461,10 +461,10 @@ void AddSC_boss_akilzon() newscript = new Script; newscript->Name="boss_akilzon"; newscript->GetAI = GetAI_boss_akilzon; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_akilzon_eagle"; newscript->GetAI = GetAI_mob_soaring_eagle; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp index 8daab23c6b2..19235677831 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp @@ -394,10 +394,10 @@ void AddSC_boss_halazzi() newscript = new Script; newscript->Name="boss_halazzi"; newscript->GetAI = GetAI_boss_halazziAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_halazzi_lynx"; newscript->GetAI = GetAI_boss_spiritlynxAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp index d0a78f3c848..4d36a138765 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp @@ -371,7 +371,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI if(SiphonSoul_Timer < diff) { - Player* target = SelectRandomPlayer(50); + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true); Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); if(!target || !trigger) EnterEvadeMode(); else @@ -435,26 +435,6 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI } m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false); } - - Player* SelectRandomPlayer(float range = 0.0f, bool alive = true) - { - Map *map = m_creature->GetMap(); - if (!map->IsDungeon()) return NULL; - - InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::iterator i; - while(PlayerList.size()) - { - i = PlayerList.begin(); - advance(i, rand()%PlayerList.size()); - if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range)) - && (!alive || (*i)->isAlive())) - return *i; - else - PlayerList.erase(i); - } - return NULL; - } }; #define SPELL_BLOODLUST 43578 @@ -888,45 +868,45 @@ void AddSC_boss_hex_lord_malacrass() newscript = new Script; newscript->Name="boss_hexlord_malacrass"; newscript->GetAI = GetAI_boss_hex_lord_malacrass; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_thurg"; newscript->GetAI = GetAI_boss_thurg; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_gazakroth"; newscript->GetAI = GetAI_boss_gazakroth; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_lord_raadan"; newscript->GetAI = GetAI_boss_lord_raadan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_darkheart"; newscript->GetAI = GetAI_boss_darkheart; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_slither"; newscript->GetAI = GetAI_boss_slither; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_fenstalker"; newscript->GetAI = GetAI_boss_fenstalker; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_koragg"; newscript->GetAI = GetAI_boss_koragg; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="boss_alyson_antille"; newscript->GetAI = GetAI_boss_alyson_antille; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); }
\ No newline at end of file diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp index 0b460404f92..463425a5ef3 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp @@ -397,11 +397,12 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI //Teleport every Player into the middle Map *map = m_creature->GetMap(); if(!map->IsDungeon()) return; - InstanceMap::PlayerList const &PlayerList =((InstanceMap*)map)->GetPlayers(); - for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + Map::PlayerList const &PlayerList = map->GetPlayers(); + for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - if((*i)->isAlive()) - DoTeleportPlayer(*i, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); + if (Player* i_pl = i->getSource()) + if(i_pl->isAlive()) + DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); } //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far return; @@ -705,25 +706,25 @@ void AddSC_boss_janalai() newscript = new Script; newscript->Name="boss_janalai"; newscript->GetAI = GetAI_boss_janalaiAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_janalai_firebomb"; newscript->GetAI = GetAI_mob_jandalai_firebombAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_janalai_hatcher"; newscript->GetAI = GetAI_mob_amanishi_hatcherAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_janalai_hatchling"; newscript->GetAI = GetAI_mob_hatchlingAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_janalai_egg"; newscript->GetAI = GetAI_mob_eggAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp index d51e1cdfa00..359bf496043 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp @@ -300,5 +300,5 @@ void AddSC_boss_nalorakk() newscript = new Script; newscript->Name="boss_nalorakk"; newscript->GetAI = GetAI_boss_nalorakk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp index 0b41f591d06..2fa0b83432a 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp @@ -629,15 +629,15 @@ void AddSC_boss_zuljin() newscript = new Script; newscript->Name="boss_zuljin"; newscript->GetAI = GetAI_boss_zuljin; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="do_nothing"; newscript->GetAI = GetAI_do_nothing; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_zuljin_vortex"; newscript->GetAI = GetAI_feather_vortexAI; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp index 2e9e481236f..c0c68c1a2e4 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp @@ -139,21 +139,28 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance void OpenDoor(uint64 DoorGUID, bool open) { - if(((InstanceMap*)instance)->GetPlayers().size()) - if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) - if(GameObject *Door = GameObject::GetGameObject(*first, DoorGUID)) - Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); + if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) + Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); } void SummonHostage(uint8 num) { - if(QuestMinute && ((InstanceMap*)instance)->GetPlayers().size()) - if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) - if(Unit* Hostage = first->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) - { - Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } + if(!QuestMinute) + return; + + Map::PlayerList const &PlayerList = instance->GetPlayers(); + if (PlayerList.isEmpty()) + return; + + Map::PlayerList::const_iterator i = PlayerList.begin(); + if(Player* i_pl = i->getSource()) + { + if(Unit* Hostage = i_pl->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) + { + Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + } } void CheckInstanceStatus() @@ -321,5 +328,5 @@ void AddSC_instance_zulaman() newscript = new Script; newscript->Name = "instance_zulaman"; newscript->GetInstanceData = GetInstanceData_instance_zulaman; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp b/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp index 4927ff4869a..b28b8a9bd06 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp @@ -171,12 +171,12 @@ void AddSC_zulaman() newscript = new Script; newscript->Name="npc_forest_frog"; newscript->GetAI = GetAI_npc_forest_frog; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name = "npc_zulaman_hostage"; newscript->GetAI = GetAI_npc_zulaman_hostage; newscript->pGossipHello = GossipHello_npc_zulaman_hostage; newscript->pGossipSelect = GossipSelect_npc_zulaman_hostage; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp b/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp index 6145f640634..a385314a12d 100644 --- a/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp +++ b/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp @@ -213,12 +213,12 @@ void AddSC_zulfarrak() newscript->GetAI = GetAI_npc_sergeant_bly; newscript->pGossipHello = &GossipHello_npc_sergeant_bly; newscript->pGossipSelect = &GossipSelect_npc_sergeant_bly; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="npc_weegli_blastfuse"; newscript->GetAI = GetAI_npc_weegli_blastfuse; newscript->pGossipHello = &GossipHello_npc_weegli_blastfuse; newscript->pGossipSelect = &GossipSelect_npc_weegli_blastfuse; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp index e32538616f6..0d08f35c6a1 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp @@ -207,5 +207,5 @@ void AddSC_boss_arlokk() newscript = new Script; newscript->Name="boss_arlokk"; newscript->GetAI = GetAI_boss_arlokk; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp index 7168d647d49..bcbd8287c46 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp @@ -88,5 +88,5 @@ void AddSC_boss_gahzranka() newscript = new Script; newscript->Name="boss_gahzranka"; newscript->GetAI = GetAI_boss_gahzranka; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp index c882aa3ae6f..d9ab005a8d5 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp @@ -88,5 +88,5 @@ void AddSC_boss_grilek() newscript = new Script; newscript->Name="boss_grilek"; newscript->GetAI = GetAI_boss_grilek; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp index cdd4c42128b..93db797e25f 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp @@ -252,5 +252,5 @@ void AddSC_boss_hakkar() newscript = new Script; newscript->Name="boss_hakkar"; newscript->GetAI = GetAI_boss_hakkar; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp index 62140f5303d..166e5bb0467 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp @@ -96,5 +96,5 @@ void AddSC_boss_hazzarah() newscript = new Script; newscript->Name="boss_hazzarah"; newscript->GetAI = GetAI_boss_hazzarah; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp index 86b6068cb3a..ce63d6f1587 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp @@ -288,10 +288,10 @@ void AddSC_boss_jeklik() newscript = new Script; newscript->Name="boss_jeklik"; newscript->GetAI = GetAI_boss_jeklik; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_batrider"; newscript->GetAI = GetAI_mob_batrider; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp index a5752845b92..f133cc6bceb 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp @@ -258,15 +258,15 @@ void AddSC_boss_jindo() newscript = new Script; newscript->Name="boss_jindo"; newscript->GetAI = GetAI_boss_jindo; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_healing_ward"; newscript->GetAI = GetAI_mob_healing_ward; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_shade_of_jindo"; newscript->GetAI = GetAI_mob_shade_of_jindo; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp index 9781fae1f2d..a70f39e2210 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp @@ -302,10 +302,10 @@ void AddSC_boss_mandokir() newscript = new Script; newscript->Name="boss_mandokir"; newscript->GetAI = GetAI_boss_mandokir; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_ohgan"; newscript->GetAI = GetAI_mob_ohgan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp index de9a440ba38..5f276a6c3f8 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp @@ -244,10 +244,10 @@ void AddSC_boss_marli() newscript = new Script; newscript->Name="boss_marli"; newscript->GetAI = GetAI_boss_marli; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_spawn_of_marli"; newscript->GetAI = GetAI_mob_spawn_of_marli; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp index ada5cc6cdbc..7febe276dc1 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp @@ -147,5 +147,5 @@ void AddSC_boss_renataki() newscript = new Script; newscript->Name="boss_renataki"; newscript->GetAI = GetAI_boss_renataki; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp index b1b44f9b94d..0eebbc1dda6 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp @@ -531,15 +531,15 @@ void AddSC_boss_thekal() newscript = new Script; newscript->Name="boss_thekal"; newscript->GetAI = GetAI_boss_thekal; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_zealot_lorkhan"; newscript->GetAI = GetAI_mob_zealot_lorkhan; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); newscript = new Script; newscript->Name="mob_zealot_zath"; newscript->GetAI = GetAI_mob_zealot_zath; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp index 771b61c372f..3d8657d1b67 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp @@ -196,5 +196,5 @@ void AddSC_boss_venoxis() newscript = new Script; newscript->Name="boss_venoxis"; newscript->GetAI = GetAI_boss_venoxis; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp index 3ac05c97b04..83e682917ae 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp @@ -80,5 +80,5 @@ void AddSC_boss_wushoolay() newscript = new Script; newscript->Name="boss_wushoolay"; newscript->GetAI = GetAI_boss_wushoolay; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp b/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp index 501c200fa5c..0e9a14a05b9 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp @@ -234,5 +234,5 @@ void AddSC_instance_zulgurub() newscript = new Script; newscript->Name = "instance_zulgurub"; newscript->GetInstanceData = GetInstanceData_instance_zulgurub; - m_scripts[nrscripts++] = newscript; + newscript->RegisterSelf(); } diff --git a/src/framework/Utilities/LinkedReference/RefManager.h b/src/framework/Utilities/LinkedReference/RefManager.h index 40b7cade914..599c4efab39 100644 --- a/src/framework/Utilities/LinkedReference/RefManager.h +++ b/src/framework/Utilities/LinkedReference/RefManager.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _REFMANAGER_H @@ -33,7 +33,9 @@ template <class TO, class FROM> class RefManager : public LinkedListHead virtual ~RefManager() { clearReferences(); } Reference<TO, FROM>* getFirst() { return ((Reference<TO, FROM>*) LinkedListHead::getFirst()); } + Reference<TO, FROM> const* getFirst() const { return ((Reference<TO, FROM> const*) LinkedListHead::getFirst()); } Reference<TO, FROM>* getLast() { return ((Reference<TO, FROM>*) LinkedListHead::getLast()); } + Reference<TO, FROM> const* getLast() const { return ((Reference<TO, FROM> const*) LinkedListHead::getLast()); } iterator begin() { return iterator(getFirst()); } iterator end() { return iterator(NULL); } diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h index 8e969669b99..ca837c81f91 100644 --- a/src/framework/Utilities/LinkedReference/Reference.h +++ b/src/framework/Utilities/LinkedReference/Reference.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _REFERENCE_H @@ -74,6 +74,7 @@ template <class TO, class FROM> class Reference : public LinkedListElement } Reference<TO,FROM>* next() { return((Reference<TO,FROM>*)LinkedListElement::next()); } + Reference<TO,FROM>const* next() const { return((Reference<TO,FROM> const*)LinkedListElement::next()); } Reference<TO,FROM>* prev() { return((Reference<TO,FROM>*)LinkedListElement::prev()); } inline TO* operator ->() const { return iRefTo; } diff --git a/src/game/AuctionHouse.cpp b/src/game/AuctionHouse.cpp index ca549f4d404..5526240528b 100644 --- a/src/game/AuctionHouse.cpp +++ b/src/game/AuctionHouse.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "WorldPacket.h" @@ -89,8 +89,8 @@ bool WorldSession::SendAuctionInfo(WorldPacket & data, AuctionEntry* auction) sLog.outError("auction to item, that doesn't exist !!!!"); return false; } - data << auction->Id; - data << pItem->GetUInt32Value(OBJECT_FIELD_ENTRY); + data << (uint32) auction->Id; + data << (uint32) pItem->GetEntry(); for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++) { @@ -245,7 +245,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR); return; } - // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction) + // prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction) if(!it) { SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND); @@ -716,7 +716,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId); if (il) { - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) name = il->Name[loc_idx]; } } diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp index 4b8284c7c37..765d40f3962 100644 --- a/src/game/Bag.cpp +++ b/src/game/Bag.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -41,7 +41,7 @@ Bag::~Bag() { for(int i = 0; i < MAX_BAG_SIZE; ++i) if (m_bagslot[i]) - delete m_bagslot[i]; + delete m_bagslot[i]; } void Bag::AddToWorld() @@ -71,7 +71,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) Object::_Create( guidlow, 0, HIGHGUID_CONTAINER ); - SetUInt32Value(OBJECT_FIELD_ENTRY, itemid); + SetEntry(itemid); SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0); @@ -85,7 +85,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) // Setting the number of Slots the Container has SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots); - // Cleanning 20 slots + // Cleaning 20 slots for (uint8 i = 0; i < MAX_BAG_SIZE; i++) { SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0); @@ -213,6 +213,7 @@ uint8 Bag::GetSlotByItemGUID(uint64 guid) const if(m_bagslot[i] != 0) if(m_bagslot[i]->GetGUID() == guid) return i; + return NULL_SLOT; } @@ -220,6 +221,6 @@ Item* Bag::GetItemByPos( uint8 slot ) const { if( slot < GetBagSize() ) return m_bagslot[slot]; - + return NULL; } diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index 80bd52a14fe..e53ed1d21e6 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __BATTLEGROUND_H @@ -95,7 +95,8 @@ enum BattleGroundTimeIntervals START_DELAY3 = 15000, // ms used only in arena RESPAWN_ONE_DAY = 86400, // secs RESPAWN_IMMEDIATELY = 0, // secs - BUFF_RESPAWN_TIME = 180 // secs + BUFF_RESPAWN_TIME = 180, // secs + BG_HONOR_SCORE_TICKS = 330 // points }; enum BattleGroundBuffObjects @@ -433,7 +434,6 @@ class BattleGround virtual WorldSafeLocsEntry const* GetClosestGraveYard(float /*x*/, float /*y*/, float /*z*/, uint32 /*team*/) { return NULL; } virtual void AddPlayer(Player *plr); // must be implemented in BG subclass - virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); // can be extended in in BG subclass diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 7a61a33fd4f..42732a17d2b 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -64,7 +64,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,slot,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GUID_LOPART(m_guid)); @@ -180,6 +180,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) std::string name; uint8 race_,class_; + recv_data >> name; // recheck with known string size @@ -214,6 +215,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_); ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_); + if( !classEntry || !raceEntry ) { data << (uint8)CHAR_CREATE_FAILED; @@ -607,7 +609,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) pCurrChar->SetRank(0); } - if (!MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Add(pCurrChar)) + if (!pCurrChar->GetMap()->Add(pCurrChar)) { AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId()); if(at) @@ -999,35 +1001,35 @@ void WorldSession::HandleDeclinedPlayerNameOpcode(WorldPacket& recv_data) { uint64 guid; - CHECK_PACKET_SIZE(recv_data, 8+6); + CHECK_PACKET_SIZE(recv_data, 8); recv_data >> guid; // not accept declined names for unsupported languages std::string name; - if(!objmgr.GetPlayerNameByGUID(guid,name)) + if(!objmgr.GetPlayerNameByGUID(guid, name)) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); - data << (uint32)1; - data << guid; + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + data << uint32(1); + data << uint64(guid); SendPacket(&data); return; } std::wstring wname; - if(!Utf8toWStr(name,wname)) + if(!Utf8toWStr(name, wname)) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); - data << (uint32)1; - data << guid; + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + data << uint32(1); + data << uint64(guid); SendPacket(&data); return; } if(!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); - data << (uint32)1; - data << guid; + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + data << uint32(1); + data << uint64(guid); SendPacket(&data); return; } @@ -1035,35 +1037,37 @@ void WorldSession::HandleDeclinedPlayerNameOpcode(WorldPacket& recv_data) std::string name2; DeclinedName declinedname; + CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> name2; - if(name2!=name) // character have different name + if(name2 != name) // character have different name { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); - data << (uint32)1; - data << guid; + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + data << uint32(1); + data << uint64(guid); SendPacket(&data); return; } for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { + CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> declinedname.name[i]; if(!normalizePlayerName(declinedname.name[i])) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); - data << (uint32)1; - data << guid; + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + data << uint32(1); + data << uint64(guid); SendPacket(&data); return; } } - if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname)) + if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname)) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); - data << (uint32)1; - data << guid; + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + data << uint32(1); + data << uint64(guid); SendPacket(&data); return; } @@ -1074,11 +1078,11 @@ void WorldSession::HandleDeclinedPlayerNameOpcode(WorldPacket& recv_data) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid)); CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')", - GUID_LOPART(guid), declinedname.name[0].c_str(),declinedname.name[1].c_str(),declinedname.name[2].c_str(),declinedname.name[3].c_str(),declinedname.name[4].c_str()); + GUID_LOPART(guid), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str()); CharacterDatabase.CommitTransaction(); - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); - data << (uint32)0; // OK - data << guid; + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + data << uint32(0); // OK + data << uint64(guid); SendPacket(&data); } diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index bff970be3b7..862cfc638ca 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -63,16 +63,44 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; + static ChatCommand serverIdleRestartCommandTable[] = + { + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleRestartCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + + static ChatCommand serverIdleShutdownCommandTable[] = + { + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleShutDownCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + + static ChatCommand serverRestartCommandTable[] = + { + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerRestartCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + + static ChatCommand serverShutdownCommandTable[] = + { + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand serverCommandTable[] = { { "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL }, { "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL }, - { "idlerestart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleRestartCommand, "", NULL }, - { "idleshutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleShutDownCommand, "", NULL }, + { "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable }, + { "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, { "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL }, { "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL }, - { "restart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleRestartCommand, "", NULL }, - { "shutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleShutDownCommand, "", NULL }, + { "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable }, + { "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, { "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable }, { NULL, 0, false, NULL, "", NULL } }; diff --git a/src/game/Chat.h b/src/game/Chat.h index 0ba253defd9..b62bae39d17 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -175,6 +175,7 @@ class ChatHandler bool HandleModifyHonorCommand (const char* args); bool HandleModifyRepCommand(const char* args); bool HandleModifyArenaCommand(const char* args); + bool HandleModifyGenderCommand(const char* args); bool HandleNpcAddCommand(const char* args); bool HandleNpcAddMoveCommand(const char* args); @@ -191,6 +192,7 @@ class ChatHandler bool HandleNpcSetMoveTypeCommand(const char* args); bool HandleNpcSpawnDistCommand(const char* args); bool HandleNpcSpawnTimeCommand(const char* args); + bool HandleNpcTameCommand(const char* args); bool HandleNpcTextEmoteCommand(const char* args); bool HandleNpcUnFollowCommand(const char* args); bool HandleNpcWhisperCommand(const char* args); @@ -215,6 +217,7 @@ class ChatHandler bool HandleReloadCommandCommand(const char* args); bool HandleReloadCreatureQuestRelationsCommand(const char* args); bool HandleReloadCreatureQuestInvRelationsCommand(const char* args); + bool HandleReloadDbScriptStringCommand(const char* args); bool HandleReloadGameGraveyardZoneCommand(const char* args); bool HandleReloadGameObjectScriptsCommand(const char* args); bool HandleReloadGameTeleCommand(const char* args); @@ -270,10 +273,15 @@ class ChatHandler bool HandleServerCorpsesCommand(const char* args); bool HandleServerExitCommand(const char* args); + bool HandleServerIdleRestartCommand(const char* args); + bool HandleServerIdleShutDownCommand(const char* args); bool HandleServerInfoCommand(const char* args); bool HandleServerMotdCommand(const char* args); + bool HandleServerRestartCommand(const char* args); bool HandleServerSetMotdCommand(const char* args); bool HandleServerSetLogLevelCommand(const char* args); + bool HandleServerShutDownCommand(const char* args); + bool HandleServerShutDownCancelCommand(const char* args); bool HandleAddHonorCommand(const char* args); bool HandleHonorAddKillCommand(const char* args); @@ -327,11 +335,6 @@ class ChatHandler bool HandleBanListAccountCommand(const char* args); bool HandleBanListCharacterCommand(const char* args); bool HandleBanListIPCommand(const char* args); - bool HandleIdleRestartCommand(const char* args); - bool HandleIdleShutDownCommand(const char* args); - bool HandleShutDownCommand(const char* args); - bool HandleRestartCommand(const char* args); - bool HandleSecurityCommand(const char* args); bool HandleGoXYCommand(const char* args); bool HandleGoXYZCommand(const char* args); bool HandleGoZoneXYCommand(const char* args); @@ -365,7 +368,6 @@ class ChatHandler bool HandleHideAreaCommand(const char* args); bool HandleAddItemCommand(const char* args); bool HandleAddItemSetCommand(const char* args); - bool HandleModifyGenderCommand(const char* args); bool HandlePetTpCommand(const char* args); bool HandlePetUnlearnCommand(const char* args); bool HandlePetLearnCommand(const char* args); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 646feb4951f..cb6a7640d16 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -122,7 +122,7 @@ Unit(), i_AI(NULL), i_AI_possessed(NULL), lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), m_lootMoney(0), m_lootRecipient(0), m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), -m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), +m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true), m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTableGuid(0) @@ -181,7 +181,7 @@ void Creature::RemoveCorpse() float x,y,z,o; GetRespawnCoord(x, y, z, &o); - MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o); + GetMap()->CreatureRelocation(this,x,y,z,o); } /** @@ -213,7 +213,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) } } - SetUInt32Value(OBJECT_FIELD_ENTRY, Entry); // normal entry always + SetEntry(Entry); // normal entry always m_creatureInfo = cinfo; // map mode related always // Cancel load if no model defined @@ -297,6 +297,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data ) SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->unit_flags); SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); + SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(GetCreatureInfo()->resistance2)); @@ -327,6 +328,12 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data ) if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER + || GetCreatureType() == CREATURE_TYPE_CRITTER) + m_isAggressive = false; + else + m_isAggressive = true; + return true; } @@ -356,7 +363,7 @@ void Creature::Update(uint32 diff) lootForPickPocketed = false; lootForBody = false; - if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY)) + if(m_originalEntry != GetEntry()) UpdateEntry(m_originalEntry); CreatureInfo const *cinfo = GetCreatureInfo(); @@ -375,9 +382,9 @@ void Creature::Update(uint32 diff) setDeathState( JUST_ALIVED ); //Call AI respawn virtual function - AI()->JustRespawned(); + i_AI->JustRespawned(); - MapManager::Instance().GetMap(GetMapId(), this)->Add(this); + GetMap()->Add(this); } break; } @@ -439,7 +446,7 @@ void Creature::Update(uint32 diff) { // do not allow the AI to be changed during update m_AI_locked = true; - AI()->UpdateAI(diff); + i_AI->UpdateAI(diff); m_AI_locked = false; } @@ -1411,8 +1418,6 @@ bool Creature::LoadFromDB(uint32 guid, Map *map) SetHealth(m_deathState == ALIVE ? curhealth : 0); SetPower(POWER_MANA,data->curmana); - SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); - // checked at creature_template loading m_defaultMovementType = MovementGeneratorType(data->movementType); @@ -1539,6 +1544,19 @@ bool Creature::IsWithinSightDist(Unit const* u) const return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); } +bool Creature::canStartAttack(Unit const* who) const +{ + if(!who->isInAccessiblePlaceFor(this) + || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE + || !IsWithinDistInMap(who, GetAttackDistance(who))) + return false; + + if(!canAttack(who)) + return false; + + return IsWithinLOSInMap(who); +} + float Creature::GetAttackDistance(Unit const* pl) const { float aggroRate = sWorld.getRate(RATE_CREATURE_AGGRO); @@ -1818,6 +1836,30 @@ void Creature::DoFleeToGetAssistance(float radius) // Optional parameter } } +Unit* Creature::SelectNearestTarget(float dist) const +{ + CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + Unit *target = NULL; + + { + Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist); + Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(target, u_check); + + TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); + TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); + + CellLock<GridReadGuard> cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap()); + cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap()); + } + + return target; +} + void Creature::CallAssistence() { if( !m_AlreadyCallAssistence && getVictim() && !isPet() && !isCharmed()) @@ -2097,9 +2139,14 @@ uint32 Creature::getLevelForTarget( Unit const* target ) const return level; } -char const* Creature::GetScriptName() const +std::string Creature::GetScriptName() +{ + return objmgr.GetScriptName(GetScriptId()); +} + +uint32 Creature::GetScriptId() { - return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; + return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; } VendorItemData const* Creature::GetVendorItems() const diff --git a/src/game/Creature.h b/src/game/Creature.h index fbebcb1e06e..da62a9834ca 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITYCORE_CREATURE_H @@ -205,10 +205,11 @@ struct CreatureInfo uint32 equipmentId; uint32 MechanicImmuneMask; uint32 flags_extra; - char const* ScriptName; + uint32 ScriptID; uint32 GetRandomValidModelId() const; uint32 GetFirstValidModelId() const; - + + // helpers SkillType GetRequiredLootSkill() const { if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT) @@ -218,7 +219,7 @@ struct CreatureInfo else return SKILL_SKINNING; // normal case } - + bool isTameable() const { return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEBLE); @@ -425,6 +426,8 @@ class TRINITY_DLL_SPEC Creature : public Unit bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } + bool isAggressive() const { return m_isAggressive; } + void SetAggressive(bool agg) { m_isAggressive = agg; } ///// TODO RENAME THIS!!!!! bool isCanTrainingOf(Player* player, bool msg) const; bool isCanIneractWithBattleMaster(Player* player, bool msg) const; @@ -498,7 +501,9 @@ class TRINITY_DLL_SPEC Creature : public Unit CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } CreatureDataAddon const* GetCreatureAddon() const; - char const* GetScriptName() const; + + std::string GetScriptName(); + uint32 GetScriptId(); void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 ); void sendPreparedGossip( Player* player ); @@ -524,7 +529,7 @@ class TRINITY_DLL_SPEC Creature : public Unit // overwrite WorldObject function for proper name localization const char* GetNameForLocaleIdx(int32 locale_idx) const; - + void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState bool LoadFromDB(uint32 guid, Map *map); @@ -552,8 +557,10 @@ class TRINITY_DLL_SPEC Creature : public Unit bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const; bool IsWithinSightDist(Unit const* u) const; + bool canStartAttack(Unit const* u) const; float GetAttackDistance(Unit const* pl) const; + Unit* SelectNearestTarget(float dist = 0) const; void CallAssistence(); void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; } void DoFleeToGetAssistance(float radius = 50); @@ -633,6 +640,7 @@ class TRINITY_DLL_SPEC Creature : public Unit uint8 m_emoteState; bool m_isPet; // set only in Pet::Pet bool m_isTotem; // set only in Totem::Totem + bool m_isAggressive; void RegenerateMana(); void RegenerateHealth(); uint32 m_regenTimer; diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 3cb8db202fa..ad663d13b38 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "CreatureAI.h" diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h index 877ed885152..76ba93a3cb5 100644 --- a/src/game/CreatureAIImpl.h +++ b/src/game/CreatureAIImpl.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef CREATUREAIIMPL_H #define CREATUREAIIMPL_H diff --git a/src/game/CreatureAIRegistry.cpp b/src/game/CreatureAIRegistry.cpp index 7219f71cd81..a4ee030c34e 100644 --- a/src/game/CreatureAIRegistry.cpp +++ b/src/game/CreatureAIRegistry.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "CreatureAIRegistry.h" diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index 2e0d297305c..5e15efafe6f 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Creature.h" diff --git a/src/game/Formulas.h b/src/game/Formulas.h index cef4fab9c7b..f9915a2001c 100644 --- a/src/game/Formulas.h +++ b/src/game/Formulas.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITY_FORMULAS_H @@ -29,7 +29,7 @@ namespace Trinity { inline uint32 hk_honor_at_level(uint32 level, uint32 count=1) { - return (uint32) ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); + return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); } } namespace XP @@ -80,6 +80,7 @@ namespace Trinity inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content) { + //TODO: need modifier for CONTENT_71_80 different from CONTENT_61_70? const uint32 nBaseExp = content == CONTENT_1_60 ? 45 : 235; if( mob_level >= pl_level ) { diff --git a/src/game/GMTicketHandler.cpp b/src/game/GMTicketHandler.cpp index 6d005c2806a..448730bd3ea 100644 --- a/src/game/GMTicketHandler.cpp +++ b/src/game/GMTicketHandler.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -66,8 +66,6 @@ void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data ) std::string ticketText; recv_data >> ticketText; - CharacterDatabase.escape_string(ticketText); - if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) ticket->SetText(ticketText.c_str()); else @@ -105,9 +103,7 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2); - CharacterDatabase.escape_string(ticketText); - - if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) + if(ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) { WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); data << uint32(1); diff --git a/src/game/GMTicketMgr.h b/src/game/GMTicketMgr.h index a7b7a02ea17..1fd4e4c3a8f 100644 --- a/src/game/GMTicketMgr.h +++ b/src/game/GMTicketMgr.h @@ -50,7 +50,10 @@ class GMTicket { m_text = text ? text : ""; m_lastUpdate = time(NULL); - CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid); + + std::string escapedString = m_text; + CharacterDatabase.escape_string(escapedString); + CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", escapedString.c_str(), m_guid); } void DeleteFromDB() const @@ -62,7 +65,11 @@ class GMTicket { CharacterDatabase.BeginTransaction(); DeleteFromDB(); - CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText()); + + std::string escapedString = m_text; + CharacterDatabase.escape_string(escapedString); + + CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, escapedString.c_str()); CharacterDatabase.CommitTransaction(); } private: @@ -115,4 +122,4 @@ class GMTicketMgr }; #define ticketmgr Trinity::Singleton<GMTicketMgr>::Instance() -#endif
\ No newline at end of file +#endif diff --git a/src/game/GameEvent.cpp b/src/game/GameEvent.cpp index 88028290dba..67d895cfc89 100644 --- a/src/game/GameEvent.cpp +++ b/src/game/GameEvent.cpp @@ -1503,7 +1503,7 @@ void GameEvent::SaveWorldEventStateToDB(uint16 event_id) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("DELETE FROM game_event_save WHERE event_id = '%u'",event_id); if(mGameEvent[event_id].nextstart) - CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("I64FMTD"))",event_id,mGameEvent[event_id].state,mGameEvent[event_id].nextstart); + CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("I64FMTD"))",event_id,mGameEvent[event_id].state,(uint64)(mGameEvent[event_id].nextstart)); else CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u','0000-00-00 00:00:00')",event_id,mGameEvent[event_id].state); CharacterDatabase.CommitTransaction(); diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 75a1f9be985..f6f89f482e5 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -1280,7 +1280,7 @@ void GameObject::CastSpell(Unit* target, uint32 spell) else { trigger->setFaction(14); - trigger->CastSpell(target, spell, true); + trigger->CastSpell(target, spell, true, 0, 0, target->GetGUID()); } //trigger->setDeathState(JUST_DIED); //trigger->RemoveCorpse(); diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 7dc5a879913..afeaba98cc9 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITYCORE_GAMEOBJECT_H @@ -357,7 +357,7 @@ struct GameObjectInfo uint32 data[24]; } raw; }; - char *ScriptName; + uint32 ScriptId; }; struct GameObjectLocale diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 972c209964c..3561f30861c 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -698,19 +698,40 @@ namespace Trinity // Creature checks - class InAttackDistanceFromAnyHostileCreatureCheck + class NearestHostileUnitInAttackDistanceCheck { public: - explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {} - bool operator()(Creature* u) + explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0) : m_creature(creature) { - if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) - return true; + m_range = (dist == 0 ? 9999 : dist); + m_force = (dist == 0 ? false : true); + } + bool operator()(Unit* u) + { + // TODO: addthreat for every enemy in range? + if(!m_creature->IsWithinDistInMap(u, m_range)) + return false; - return false; + if(m_force) + { + if(!m_creature->canAttack(u)) + return false; + } + else + { + if(!m_creature->canStartAttack(u)) + return false; + } + + m_range = m_creature->GetDistance(u); + return true; } + float GetLastRange() const { return m_range; } private: - Unit* const i_funit; + Creature const *m_creature; + float m_range; + bool m_force; + NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&); }; class NearestAssistCreatureInCreatureRangeCheck diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 80ab442bcd6..41f7cc6c068 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -72,7 +72,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c) pl->UpdateVisibilityOf(c); // Creature AI reaction - if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) + if(c->isAggressive() && !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() ) c->AI()->MoveInLineOfSight(pl); @@ -81,13 +81,13 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c) inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) { - if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) + if(c1->isAggressive() && !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() ) c1->AI()->MoveInLineOfSight(c2); } - if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) + if(c2->isAggressive() && !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() ) c2->AI()->MoveInLineOfSight(c1); diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 2c4ebfb0a3e..0c264a76d8b 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -179,7 +179,7 @@ bool ItemCanGoIntoBag(ItemPrototype const *pProto, ItemPrototype const *pBagProt case ITEM_SUBCLASS_CONTAINER: return true; case ITEM_SUBCLASS_SOUL_CONTAINER: - if(!(pProto->BagFamily & BAG_FAMILY_MASK_SHARDS)) + if(!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS)) return false; return true; case ITEM_SUBCLASS_HERB_CONTAINER: @@ -247,7 +247,7 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner) { Object::_Create( guidlow, 0, HIGHGUID_ITEM ); - SetUInt32Value(OBJECT_FIELD_ENTRY, itemid); + SetEntry(itemid); SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0); @@ -429,7 +429,7 @@ void Item::DeleteFromInventoryDB() ItemPrototype const *Item::GetProto() const { - return objmgr.GetItemPrototype(GetUInt32Value(OBJECT_FIELD_ENTRY)); + return objmgr.GetItemPrototype(GetEntry()); } Player* Item::GetOwner()const @@ -762,9 +762,7 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges) { // Better lost small time at check in comparison lost time at item save to DB. - if( GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET)==id && - GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration && - GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET)==charges ) + if((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges)) return; SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET,id); @@ -775,7 +773,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration) { - if(GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration) + if(GetEnchantmentDuration(slot) == duration) return; SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET,duration); @@ -784,17 +782,20 @@ void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration) void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges) { + if(GetEnchantmentCharges(slot) == charges) + return; + SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges); SetState(ITEM_CHANGED); } void Item::ClearEnchantment(EnchantmentSlot slot) { - if(!GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET)) + if(!GetEnchantmentId(slot)) return; - for(int x=0;x<3;x++) - SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x,0); + for(uint8 x = 0; x < 3; ++x) + SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0); SetState(ITEM_CHANGED); } diff --git a/src/game/Item.h b/src/game/Item.h index 7b265b9cbf2..72c09b0c1da 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITYCORE_ITEM_H @@ -228,7 +228,6 @@ class TRINITY_DLL_SPEC Item : public Object bool IsLimitedToAnotherMapOrZone( uint32 cur_mapId, uint32 cur_zoneId) const; bool GemsFitSockets() const; - uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); } void SetCount(uint32 value) { SetUInt32Value (ITEM_FIELD_STACK_COUNT, value); } uint32 GetMaxStackCount() const { return GetProto()->Stackable; } diff --git a/src/game/ItemEnchantmentMgr.cpp b/src/game/ItemEnchantmentMgr.cpp index 6d4197b0335..52a2e5dc1eb 100644 --- a/src/game/ItemEnchantmentMgr.cpp +++ b/src/game/ItemEnchantmentMgr.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdlib.h> diff --git a/src/game/ItemEnchantmentMgr.h b/src/game/ItemEnchantmentMgr.h index a6b84c17418..97053c1ec36 100644 --- a/src/game/ItemEnchantmentMgr.h +++ b/src/game/ItemEnchantmentMgr.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _ITEM_ENCHANTMENT_MGR_H diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 5f9daa44336..c074ac98d77 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -313,9 +313,9 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); if (il) { - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) Name = il->Name[loc_idx]; - if (il->Description.size() > loc_idx && !il->Description[loc_idx].empty()) + if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty()) Description = il->Description[loc_idx]; } } @@ -360,6 +360,8 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) data << pProto->Damage[i].DamageMax; data << pProto->Damage[i].DamageType; } + + // resistances (7) data << pProto->Armor; data << pProto->HolyRes; data << pProto->FireRes; @@ -367,10 +369,11 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) data << pProto->FrostRes; data << pProto->ShadowRes; data << pProto->ArcaneRes; + data << pProto->Delay; data << pProto->Ammo_type; + data << pProto->RangedModRange; - data << (float)pProto->RangedModRange; for(int s = 0; s < 5; s++) { // send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown @@ -976,7 +979,7 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); if (il) { - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) Name = il->Name[loc_idx]; } } @@ -1027,7 +1030,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) return; } - if(item==gift) // not possible with pacjket from real client + if(item==gift) // not possable with pacjket from real client { _player->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, NULL ); return; @@ -1072,16 +1075,16 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS)); - item->SetUInt32Value(OBJECT_FIELD_ENTRY, gift->GetUInt32Value(OBJECT_FIELD_ENTRY)); + item->SetEntry(gift->GetEntry()); switch (item->GetEntry()) { - case 5042: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 5043); break; - case 5048: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 5044); break; - case 17303: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17302); break; - case 17304: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17305); break; - case 17307: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17308); break; - case 21830: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 21831); break; + case 5042: item->SetEntry( 5043); break; + case 5048: item->SetEntry( 5044); break; + case 17303: item->SetEntry(17302); break; + case 17304: item->SetEntry(17305); break; + case 17307: item->SetEntry(17308); break; + case 21830: item->SetEntry(21831); break; } item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); item->SetUInt32Value(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED); diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index 42607095e65..8a90ad49adb 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _ITEMPROTOTYPE_H @@ -78,7 +78,7 @@ enum ItemBondingType { NO_BIND = 0, BIND_WHEN_PICKED_UP = 1, - BIND_WHEN_EQUIPPED = 2, + BIND_WHEN_EQUIPED = 2, BIND_WHEN_USE = 3, BIND_QUEST_ITEM = 4, BIND_QUEST_ITEM1 = 5 // not used in game @@ -99,16 +99,18 @@ enum ITEM_FLAGS ITEM_FLAGS_UNIQUE_EQUIPPED = 0x00080000, ITEM_FLAGS_USEABLE_IN_ARENA = 0x00200000, ITEM_FLAGS_THROWABLE = 0x00400000, // not used in game for check trow possibility, only for item in game tooltip - ITEM_FLAGS_SPECIALUSE = 0x00800000 // last used flag in 2.3.0 + ITEM_FLAGS_SPECIALUSE = 0x00800000, // last used flag in 2.3.0 + ITEM_FLAGS_BOA = 0x08000000, // bind on account + ITEM_FLAGS_MILLABLE = 0x20000000 }; enum BAG_FAMILY_MASK { BAG_FAMILY_MASK_ARROWS = 0x00000001, BAG_FAMILY_MASK_BULLETS = 0x00000002, - BAG_FAMILY_MASK_SHARDS = 0x00000004, + BAG_FAMILY_MASK_SOUL_SHARDS = 0x00000004, BAG_FAMILY_MASK_LEATHERWORKING_SUPP = 0x00000008, - BAG_FAMILY_MASK_UNUSED = 0x00000010, // not used currently + BAG_FAMILY_MASK_INSCRIPTION_SUPP = 0x00000010, BAG_FAMILY_MASK_HERBS = 0x00000020, BAG_FAMILY_MASK_ENCHANTING_SUPP = 0x00000040, BAG_FAMILY_MASK_ENGINEERING_SUPP = 0x00000080, @@ -116,13 +118,11 @@ enum BAG_FAMILY_MASK BAG_FAMILY_MASK_GEMS = 0x00000200, BAG_FAMILY_MASK_MINING_SUPP = 0x00000400, BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT = 0x00000800, - BAG_FAMILY_MASK_VANITY_PETS = 0x00001000 + BAG_FAMILY_MASK_VANITY_PETS = 0x00001000, + BAG_FAMILY_MASK_CURRENCY_TOKENS = 0x00002000, + BAG_FAMILY_MASK_QUEST_ITEMS = 0x00004000 }; -/* TODO: Not entirely positive on need for this?? -enum SOCKET_CONTENT (); -*/ - enum SocketColor { SOCKET_COLOR_META = 1, @@ -275,7 +275,7 @@ enum ItemSubclassArmor ITEM_SUBCLASS_ARMOR_TOTEM = 9 }; -#define MAX_ITEM_SUBCLASS_ARMOR 10 +#define MAX_ITEM_SUBCLASS_ARMOR 10 enum ItemSubclassReagent { @@ -390,6 +390,22 @@ enum ItemSubclassJunk #define MAX_ITEM_SUBCLASS_JUNK 6 +enum ItemSubclassGlyph +{ + ITEM_SUBCLASS_GLYPH_WARRIOR = 1, + ITEM_SUBCLASS_GLYPH_PALADIN = 2, + ITEM_SUBCLASS_GLYPH_HUNTER = 3, + ITEM_SUBCLASS_GLYPH_ROGUE = 4, + ITEM_SUBCLASS_GLYPH_PRIEST = 5, + ITEM_SUBCLASS_GLYPH_DEATH_KNIGHT = 6, + ITEM_SUBCLASS_GLYPH_SHAMAN = 7, + ITEM_SUBCLASS_GLYPH_MAGE = 8, + ITEM_SUBCLASS_GLYPH_WARLOCK = 9, + ITEM_SUBCLASS_GLYPH_DRUID = 11 +}; + +#define MAX_ITEM_SUBCLASS_GLYPH 12 + const uint32 MaxItemSubclassValues[MAX_ITEM_CLASS] = { MAX_ITEM_SUBCLASS_CONSUMABLE, @@ -524,7 +540,7 @@ struct ItemPrototype uint32 GemProperties; // id from GemProperties.dbc uint32 RequiredDisenchantSkill; float ArmorDamageModifier; - char* ScriptName; + uint32 ScriptId; uint32 DisenchantID; uint32 FoodType; uint32 MinMoneyLoot; diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 643a5b6f819..bb6a4473e0b 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -2361,8 +2361,8 @@ bool ChatHandler::HandleWpModifyCommand(const char* args) std::string show = show_str; // Check // Remember: "show" must also be the name of a column! - if( (show != "emote") && (show != "spell") && (show != "text1") && (show != "text2") - && (show != "text3") && (show != "text4") && (show != "text5") + if( (show != "emote") && (show != "spell") && (show != "textid1") && (show != "textid2") + && (show != "textid3") && (show != "textid4") && (show != "textid5") && (show != "waittime") && (show != "del") && (show != "move") && (show != "add") && (show != "model1") && (show != "model2") && (show != "orientation")) { @@ -2705,6 +2705,13 @@ bool ChatHandler::HandleWpModifyCommand(const char* args) return false; } + // set in game textids not supported + if( show == "textid1" || show == "textid2" || show == "textid3" || + show == "textid4" || show == "textid5" ) + { + return false; + } + WaypointMgr.SetNodeText(lowguid, point, show_str, arg_str); Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); @@ -2842,7 +2849,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) //pCreature->GetPositionX(); QueryResult *result = - WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u", + WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u", target->GetGUIDLow() ); if(!result) { @@ -2854,7 +2861,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) const char* maxDIFF = "0.01"; PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID()); - result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", + result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); if(!result) { @@ -2871,11 +2878,9 @@ bool ChatHandler::HandleWpShowCommand(const char* args) int waittime = fields[2].GetUInt32(); uint32 emote = fields[3].GetUInt32(); uint32 spell = fields[4].GetUInt32(); - const char * text1 = fields[5].GetString(); - const char * text2 = fields[6].GetString(); - const char * text3 = fields[7].GetString(); - const char * text4 = fields[8].GetString(); - const char * text5 = fields[9].GetString(); + uint32 textid[MAX_WAYPOINT_TEXT]; + for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + textid[i] = fields[5+i].GetUInt32(); uint32 model1 = fields[10].GetUInt32(); uint32 model2 = fields[11].GetUInt32(); @@ -2888,11 +2893,8 @@ bool ChatHandler::HandleWpShowCommand(const char* args) PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 2, model2); PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 1, text1); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 2, text2); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 3, text3); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 4, text4); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 5, text5); + for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetTrinityString(textid[i]) : "")); }while( result->NextRow() ); // Cleanup memory @@ -3213,8 +3215,8 @@ bool ChatHandler::HandleWpExportCommand(const char *args) PSendSysMessage("DEBUG: wp export, GUID: %u", lowguid); QueryResult *result = WorldDatabase.PQuery( - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid ); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid ); if (!result) { @@ -3231,7 +3233,7 @@ bool ChatHandler::HandleWpExportCommand(const char *args) Field *fields = result->Fetch(); outfile << "INSERT INTO creature_movement "; - outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5 ) VALUES "; + outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5 ) VALUES "; outfile << "( "; outfile << fields[15].GetUInt32(); // id @@ -3256,65 +3258,15 @@ bool ChatHandler::HandleWpExportCommand(const char *args) outfile << ", "; outfile << fields[9].GetUInt32(); // spell outfile << ", "; - const char *tmpChar = fields[10].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text1 - } - else - { - outfile << "'"; - outfile << tmpChar; // text1 - outfile << "'"; - } + outfile << fields[10].GetUInt32(); // textid1 outfile << ", "; - tmpChar = fields[11].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text2 - } - else - { - outfile << "'"; - outfile << tmpChar; // text2 - outfile << "'"; - } + outfile << fields[11].GetUInt32(); // textid2 outfile << ", "; - tmpChar = fields[12].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text3 - } - else - { - outfile << "'"; - outfile << tmpChar; // text3 - outfile << "'"; - } + outfile << fields[12].GetUInt32(); // textid3 outfile << ", "; - tmpChar = fields[13].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text4 - } - else - { - outfile << "'"; - outfile << tmpChar; // text4 - outfile << "'"; - } + outfile << fields[13].GetUInt32(); // textid4 outfile << ", "; - tmpChar = fields[14].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text5 - } - else - { - outfile << "'"; - outfile << tmpChar; // text5 - outfile << "'"; - } + outfile << fields[14].GetUInt32(); // textid5 outfile << ");\n "; } while( result->NextRow() ); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index a2f68a4ce58..1fb799cde6b 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -135,6 +135,7 @@ bool ChatHandler::HandleReloadAllScriptsCommand(const char*) HandleReloadQuestStartScriptsCommand("a"); HandleReloadSpellScriptsCommand("a"); SendGlobalSysMessage("DB tables `*_scripts` reloaded."); + HandleReloadDbScriptStringCommand("a"); return true; } @@ -601,6 +602,14 @@ bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg) return true; } +bool ChatHandler::HandleReloadDbScriptStringCommand(const char* arg) +{ + sLog.outString( "Re-Loading Script strings from `db_script_string`..."); + objmgr.LoadDbScriptStrings(); + SendGlobalSysMessage("DB table `db_script_string` reloaded."); + return true; +} + bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/) { sLog.outString( "Re-Loading Graveyard-zone links..."); @@ -1767,7 +1776,8 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) // search highest talent rank uint32 spellid = 0; - for(int rank = 4; rank >= 0; --rank) + int rank = 4; + for(; rank >= 0; --rank) { if(talentInfo->RankID[rank]!=0) { @@ -4645,91 +4655,149 @@ bool ChatHandler::HandleResetAllCommand(const char * args) return true; } -bool ChatHandler::HandleShutDownCommand(const char* args) +bool ChatHandler::HandleServerShutDownCancelCommand(const char* args) +{ + sWorld.ShutdownCancel(); + return true; +} + +bool ChatHandler::HandleServerShutDownCommand(const char* args) { if(!*args) return false; - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else + char* time_str = strtok ((char*) args, " "); + char* exitcode_str = strtok (NULL, ""); + + int32 time = atoi (time_str); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) + return false; + + if (exitcode_str) { - int32 time = atoi(args); + int32 exitcode = atoi (exitcode_str); - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + // Handle atoi() errors + if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) return false; - sWorld.ShutdownServ(time); + // Exit code should be in range of 0-125, 126-255 is used + // in many shells for their own return codes and code > 255 + // is not supported in many others + if (exitcode < 0 || exitcode > 125) + return false; + + sWorld.ShutdownServ (time, 0, exitcode); } + else + sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE); return true; } -bool ChatHandler::HandleRestartCommand(const char* args) +bool ChatHandler::HandleServerRestartCommand(const char* args) { if(!*args) return false; - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else + char* time_str = strtok ((char*) args, " "); + char* exitcode_str = strtok (NULL, ""); + + int32 time = atoi (time_str); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) + return false; + + if (exitcode_str) { - int32 time = atoi(args); + int32 exitcode = atoi (exitcode_str); + + // Handle atoi() errors + if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) + return false; - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + // Exit code should be in range of 0-125, 126-255 is used + // in many shells for their own return codes and code > 255 + // is not supported in many others + if (exitcode < 0 || exitcode > 125) return false; - sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); + sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART, exitcode); } + else + sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE); return true; } -bool ChatHandler::HandleIdleRestartCommand(const char* args) +bool ChatHandler::HandleServerIdleRestartCommand(const char* args) { if(!*args) return false; - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else + char* time_str = strtok ((char*) args, " "); + char* exitcode_str = strtok (NULL, ""); + + int32 time = atoi (time_str); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) + return false; + + if (exitcode_str) { - int32 time = atoi(args); + int32 exitcode = atoi (exitcode_str); + + // Handle atoi() errors + if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) + return false; - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + // Exit code should be in range of 0-125, 126-255 is used + // in many shells for their own return codes and code > 255 + // is not supported in many others + if (exitcode < 0 || exitcode > 125) return false; - sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); + sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode); } + else + sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE,RESTART_EXIT_CODE); return true; } -bool ChatHandler::HandleIdleShutDownCommand(const char* args) +bool ChatHandler::HandleServerIdleShutDownCommand(const char* args) { if(!*args) return false; - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else + char* time_str = strtok ((char*) args, " "); + char* exitcode_str = strtok (NULL, ""); + + int32 time = atoi (time_str); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) + return false; + + if (exitcode_str) { - int32 time = atoi(args); + int32 exitcode = atoi (exitcode_str); - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + // Handle atoi() errors + if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) return false; - sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); + // Exit code should be in range of 0-125, 126-255 is used + // in many shells for their own return codes and code > 255 + // is not supported in many others + if (exitcode < 0 || exitcode > 125) + return false; + + sWorld.ShutdownServ (time, SHUTDOWN_MASK_IDLE, exitcode); } + else + sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE); return true; } diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index d91206bf6d9..6605cc78057 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Mail.h" @@ -187,18 +187,17 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) pl->SendMailResult(0, 0, MAIL_ERR_INTERNAL_ERROR); return; } - if (mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || mailItem.item->GetUInt32Value(ITEM_FIELD_DURATION)) { pl->SendMailResult(0, 0, MAIL_ERR_INTERNAL_ERROR); return; } - if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) - { - pl->SendMailResult(0, 0, MAIL_ERR_CANT_SEND_WRAPPED_COD); - return; - } + if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) + { + pl->SendMailResult(0, 0, MAIL_ERR_CANT_SEND_WRAPPED_COD); + return; + } } } pl->SendMailResult(0, 0, MAIL_OK); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 7b3e40c00b3..39006c932c6 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -35,6 +35,7 @@ #include "World.h" #include "ScriptCalls.h" #include "Group.h" +#include "MapRefManager.h" #include "MapInstanced.h" #include "InstanceSaveMgr.h" @@ -449,6 +450,8 @@ Map::LoadGrid(const Cell& cell, bool no_unload) bool Map::Add(Player *player) { + player->GetMapRef().link(this, player); + player->SetInstanceId(GetInstanceId()); // update player state for other player and visa-versa @@ -593,6 +596,56 @@ bool Map::loaded(const GridPair &p) const void Map::Update(const uint32 &t_diff) { + // TODO: need have an active object list for every map + + /*resetMarkedCells(); + + Trinity::ObjectUpdater updater(t_diff); + // for creature + TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater); + // for pets + TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater); + + for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) + { + Player* plr = iter->getSource(); + if(!plr->IsInWorld()) + continue; + + CellPair standing_cell(Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY())); + + // Check for correctness of standing_cell, it also avoids problems with update_cell + if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + continue; + + // the overloaded operators handle range checking + // so ther's no need for range checking inside the loop + CellPair begin_cell(standing_cell), end_cell(standing_cell); + begin_cell << 1; begin_cell -= 1; // upper left + end_cell >> 1; end_cell += 1; // lower right + + for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) + { + for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) + { + // marked cells are those that have been visited + // don't visit the same cell twice + uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; + if(!isCellMarked(cell_id)) + { + markCell(cell_id); + CellPair pair(x,y); + Cell cell(pair); + cell.data.Part.reserved = CENTER_DISTRICT; + cell.SetNoCreate(); + CellLock<NullGuard> cell_lock(cell, pair); + cell_lock->Visit(cell_lock, grid_object_update, *this); + cell_lock->Visit(cell_lock, world_object_update, *this); + } + } + } + }*/ + // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended if (IsBattleGroundOrArena()) @@ -610,6 +663,7 @@ void Map::Update(const uint32 &t_diff) void Map::Remove(Player *player, bool remove) { + player->GetMapRef().unlink(); CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) { @@ -909,7 +963,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce) assert( grid != NULL); { - if(!pForce && ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, i_id, i_InstanceId) ) + if(!pForce && PlayersNearGrid(x, y) ) return false; DEBUG_LOG("Unloading grid[%u,%u] for map %u", x,y, i_id); @@ -1418,6 +1472,43 @@ bool Map::CanUnload(const uint32 &diff) return false; } +uint32 Map::GetPlayersCountExceptGMs() const +{ + uint32 count = 0; + for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + if(!itr->getSource()->isGameMaster()) + ++count; + return count; +} + +void Map::SendToPlayers(WorldPacket const* data) const +{ + for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + itr->getSource()->GetSession()->SendPacket(data); +} + +bool Map::PlayersNearGrid(uint32 x, uint32 y) const +{ + CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); + CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); + cell_min << 2; + cell_min -= 2; + cell_max >> 2; + cell_max += 2; + + for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) + { + Player* plr = iter->getSource(); + + CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); + if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && + (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) + return true; + } + + return false; +} + template void Map::Add(Corpse *); template void Map::Add(Creature *); template void Map::Add(GameObject *); @@ -1453,7 +1544,7 @@ InstanceMap::~InstanceMap() */ bool InstanceMap::CanEnter(Player *player) { - if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) + if(player->GetMapRef().getTarget() == this) { sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); assert(false); @@ -1570,7 +1661,6 @@ bool InstanceMap::Add(Player *player) if(i_data) i_data->OnPlayerEnter(player); SetResetSchedule(false); - i_Players.push_back(player); player->SendInitWorldStates(); sLog.outDetail("MAP: Player '%s' entered the instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); // initialize unload state @@ -1595,9 +1685,9 @@ void InstanceMap::Update(const uint32& t_diff) void InstanceMap::Remove(Player *player, bool remove) { sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); - i_Players.remove(player); SetResetSchedule(true); - if(!m_unloadTimer && i_Players.empty()) + //if last player set unload timer + if(!m_unloadTimer && m_mapRefManager.getSize() == 1) m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); Map::Remove(player, remove); } @@ -1624,7 +1714,7 @@ void InstanceMap::CreateInstanceData(bool load) InstanceTemplate const* mInstance = objmgr.GetInstanceTemplate(GetId()); if (mInstance) { - i_script = mInstance->script; + i_script_id = mInstance->script_id; i_data = Script->CreateInstanceData(this); } @@ -1641,7 +1731,7 @@ void InstanceMap::CreateInstanceData(bool load) const char* data = fields[0].GetString(); if(data) { - sLog.outDebug("Loading instance data for `%s` with id %u", i_script.c_str(), i_InstanceId); + sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId); i_data->Load(data); } delete result; @@ -1649,7 +1739,7 @@ void InstanceMap::CreateInstanceData(bool load) } else { - sLog.outDebug("New instance data, \"%s\" ,initialized!",i_script.c_str()); + sLog.outDebug("New instance data, \"%s\" ,initialized!", objmgr.GetScriptName(i_script_id)); i_data->Initialize(); } } @@ -1662,21 +1752,21 @@ bool InstanceMap::Reset(uint8 method) // note: since the map may not be loaded when the instance needs to be reset // the instance must be deleted from the DB by InstanceSaveManager - if(!i_Players.empty()) + if(HavePlayers()) { if(method == INSTANCE_RESET_ALL) { // notify the players to leave the instance so it can be reset - for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) - (*itr)->SendResetFailedNotify(GetId()); + for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + itr->getSource()->SendResetFailedNotify(GetId()); } else { if(method == INSTANCE_RESET_GLOBAL) { // set the homebind timer for players inside (1 minute) - for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) - (*itr)->m_InstanceValid = false; + for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + itr->getSource()->m_InstanceValid = false; } // the unload timer is not started @@ -1692,16 +1782,7 @@ bool InstanceMap::Reset(uint8 method) m_resetAfterUnload = true; } - return i_Players.empty(); -} - -uint32 InstanceMap::GetPlayersCountExceptGMs() const -{ - uint32 count = 0; - for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) - if(!(*itr)->isGameMaster()) - ++count; - return count; + return m_mapRefManager.isEmpty(); } void InstanceMap::PermBindAllPlayers(Player *player) @@ -1715,25 +1796,23 @@ void InstanceMap::PermBindAllPlayers(Player *player) Group *group = player->GetGroup(); // group members outside the instance group don't get bound - for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) + for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { - if(*itr) + Player* plr = itr->getSource(); + // players inside an instance cannot be bound to other instances + // some players may already be permanently bound, in this case nothing happens + InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); + if(!bind || !bind->perm) { - // players inside an instance cannot be bound to other instances - // some players may already be permanently bound, in this case nothing happens - InstancePlayerBind *bind = (*itr)->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); - if(!bind || !bind->perm) - { - (*itr)->BindToInstance(save, true); - WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); - data << uint32(0); - (*itr)->GetSession()->SendPacket(&data); - } - - // if the leader is not in the instance the group will not get a perm bind - if(group && group->GetLeaderGUID() == (*itr)->GetGUID()) - group->BindToInstance(save, true); + plr->BindToInstance(save, true); + WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); + data << uint32(0); + plr->GetSession()->SendPacket(&data); } + + // if the leader is not in the instance the group will not get a perm bind + if(group && group->GetLeaderGUID() == plr->GetGUID()) + group->BindToInstance(save, true); } } @@ -1745,11 +1824,14 @@ time_t InstanceMap::GetResetTime() void InstanceMap::UnloadAll(bool pForce) { - if(!i_Players.empty()) + if(HavePlayers()) { sLog.outError("InstanceMap::UnloadAll: there are still players in the instance at unload, should not happen!"); - for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) - if(*itr) (*itr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); + for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + { + Player* plr = itr->getSource(); + plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); + } } if(m_resetAfterUnload == true) @@ -1758,10 +1840,10 @@ void InstanceMap::UnloadAll(bool pForce) Map::UnloadAll(pForce); } -void InstanceMap::SendResetWarnings(uint32 timeLeft) +void InstanceMap::SendResetWarnings(uint32 timeLeft) const { - for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) - (*itr)->SendInstanceResetWarning(GetId(), timeLeft); + for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + itr->getSource()->SendInstanceResetWarning(GetId(), timeLeft); } void InstanceMap::SetResetSchedule(bool on) @@ -1769,7 +1851,7 @@ void InstanceMap::SetResetSchedule(bool on) // only for normal instances // the reset time is only scheduled when there are no payers inside // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled - if(i_Players.empty() && !IsRaid() && !IsHeroic()) + if(!HavePlayers() && !IsRaid() && !IsHeroic()) { InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId()); if(!save) sLog.outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, no save available for instance %d of %d", on ? "on" : "off", GetInstanceId(), GetId()); @@ -1777,12 +1859,6 @@ void InstanceMap::SetResetSchedule(bool on) } } -void InstanceMap::SendToPlayers(WorldPacket const* data) const -{ - for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) - (*itr)->GetSession()->SendPacket(data); -} - /* ******* Battleground Instance Maps ******* */ BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId) @@ -1796,7 +1872,7 @@ BattleGroundMap::~BattleGroundMap() bool BattleGroundMap::CanEnter(Player * player) { - if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) + if(player->GetMapRef().getTarget() == this) { sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow()); assert(false); @@ -1817,7 +1893,6 @@ bool BattleGroundMap::Add(Player * player) Guard guard(*this); if(!CanEnter(player)) return false; - i_Players.push_back(player); // reset instance validity, battleground maps do not homebind player->m_InstanceValid = true; } @@ -1827,7 +1902,6 @@ bool BattleGroundMap::Add(Player * player) void BattleGroundMap::Remove(Player *player, bool remove) { sLog.outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); - i_Players.remove(player); Map::Remove(player, remove); } @@ -1838,15 +1912,14 @@ void BattleGroundMap::SetUnload() void BattleGroundMap::UnloadAll(bool pForce) { - while(!i_Players.empty()) + while(HavePlayers()) { - PlayerList::iterator itr = i_Players.begin(); - Player * plr = *itr; - if(plr) (plr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); + Player * plr = m_mapRefManager.getFirst()->getSource(); + if(plr) (plr)->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); // TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator. // just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop // note that this remove is not needed if the code works well in other places - i_Players.remove(plr); + plr->GetMapRef().unlink(); } Map::UnloadAll(pForce); diff --git a/src/game/Map.h b/src/game/Map.h index 2ded7cf0975..6e0e9cb37a9 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITY_MAP_H @@ -33,6 +33,7 @@ #include "Timer.h" #include "SharedDefines.h" #include "GameSystem/GridRefManager.h" +#include "MapRefManager.h" #include <bitset> #include <list> @@ -104,7 +105,7 @@ struct InstanceTemplate float startLocY; float startLocZ; float startLocO; - char const* script; + uint32 script_id; }; enum LevelRequirementVsMode @@ -126,6 +127,7 @@ typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList; class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ZThread::Mutex> { + friend class MapReference; public: Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); virtual ~Map(); @@ -237,6 +239,14 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O Creature* GetCreatureInMap(uint64 guid); GameObject* GetGameObjectInMap(uint64 guid); + bool HavePlayers() const { return !m_mapRefManager.isEmpty(); } + uint32 GetPlayersCountExceptGMs() const; + bool PlayersNearGrid(uint32 x,uint32 y) const; + + void SendToPlayers(WorldPacket const* data) const; + + typedef MapRefManager PlayerList; + PlayerList const& GetPlayers() const { return m_mapRefManager; } template<class T> void SwitchGridContainers(T* obj, bool active); private: void LoadVMap(int pX, int pY); @@ -286,6 +296,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O uint32 i_InstanceId; uint32 m_unloadTimer; + MapRefManager m_mapRefManager; private: typedef GridReadGuard ReadGuard; typedef GridWriteGuard WriteGuard; @@ -325,8 +336,6 @@ enum InstanceResetMethod class TRINITY_DLL_SPEC InstanceMap : public Map { public: - typedef std::list<Player *> PlayerList; // online players only - InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); ~InstanceMap(); bool Add(Player *); @@ -334,33 +343,24 @@ class TRINITY_DLL_SPEC InstanceMap : public Map void Update(const uint32&); void CreateInstanceData(bool load); bool Reset(uint8 method); - std::string GetScript() { return i_script; } + uint32 GetScriptId() { return i_script_id; } InstanceData* GetInstanceData() { return i_data; } void PermBindAllPlayers(Player *player); - PlayerList const& GetPlayers() const { return i_Players;} - void SendToPlayers(WorldPacket const* data) const; time_t GetResetTime(); void UnloadAll(bool pForce); bool CanEnter(Player* player); - uint32 GetPlayersCountExceptGMs() const; - uint32 HavePlayers() const { return !i_Players.empty(); } - void SendResetWarnings(uint32 timeLeft); + void SendResetWarnings(uint32 timeLeft) const; void SetResetSchedule(bool on); private: bool m_resetAfterUnload; bool m_unloadWhenEmpty; InstanceData* i_data; - std::string i_script; - // only online players that are inside the instance currently - // TODO ? - use the grid instead to access the players - PlayerList i_Players; + uint32 i_script_id; }; class TRINITY_DLL_SPEC BattleGroundMap : public Map { public: - typedef std::list<Player *> PlayerList; // online players only - BattleGroundMap(uint32 id, time_t, uint32 InstanceId); ~BattleGroundMap(); @@ -369,8 +369,6 @@ class TRINITY_DLL_SPEC BattleGroundMap : public Map bool CanEnter(Player* player); void SetUnload(); void UnloadAll(bool pForce); - private: - PlayerList i_Players; }; /*inline diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index 9a9128363f2..7b8f5fb9b64 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MapInstanced.h" @@ -26,7 +26,7 @@ #include "InstanceSaveMgr.h" #include "World.h" -MapInstanced::MapInstanced(uint32 id, time_t expiry, uint32 aInstanceId) : Map(id, expiry, 0, 0) +MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, 0) { // initialize instanced maps list m_InstancedMaps.clear(); @@ -261,4 +261,3 @@ void MapInstanced::DestroyInstance(InstancedMaps::iterator &itr) delete itr->second; m_InstancedMaps.erase(itr++); } - diff --git a/src/game/MapInstanced.h b/src/game/MapInstanced.h index 44f39facbfe..cde37f9f3ff 100644 --- a/src/game/MapInstanced.h +++ b/src/game/MapInstanced.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITY_MAP_INSTANCED_H @@ -30,7 +30,7 @@ class TRINITY_DLL_DECL MapInstanced : public Map public: typedef UNORDERED_MAP< uint32, Map* > InstancedMaps; - MapInstanced(uint32 id, time_t, uint32 aInstanceId); + MapInstanced(uint32 id, time_t expiry); ~MapInstanced() {} // functions overwrite Map versions diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 86206fef49b..26279cb76ec 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "MapManager.h" @@ -111,7 +111,7 @@ MapManager::_GetBaseMap(uint32 id) const MapEntry* entry = sMapStore.LookupEntry(id); if (entry && entry->Instanceable()) { - m = new MapInstanced(id, i_gridCleanUpDelay, 0); + m = new MapInstanced(id, i_gridCleanUpDelay); } else { @@ -222,7 +222,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) return true; } -void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode) +void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId) { Map *m = _GetBaseMap(mapid); if (m && m->Instanceable()) @@ -246,6 +246,8 @@ MapManager::Update(time_t diff) if( !i_timer.Passed() ) return; + ObjectAccessor::Instance().UpdatePlayers(i_timer.GetCurrent()); + for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) { checkAndCorrectGridStatesArray(); // debugging code, should be deleted some day @@ -336,7 +338,7 @@ uint32 MapManager::GetNumPlayersInInstances() MapInstanced::InstancedMaps &maps = ((MapInstanced *)map)->GetInstancedMaps(); for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr) if(mitr->second->IsDungeon()) - ret += ((InstanceMap*)mitr->second)->GetPlayers().size(); + ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize(); } return ret; } diff --git a/src/game/MapManager.h b/src/game/MapManager.h index 44197ccd84a..cba0a86d1a5 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITY_MAPMANAGER_H @@ -27,6 +27,7 @@ #include "Common.h" #include "Map.h" #include "GridStates.h" + class Transport; class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLockable<MapManager, ZThread::Mutex> > @@ -44,7 +45,7 @@ class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinit // only const version for outer users Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); } - void DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode); + void DeleteInstance(uint32 mapid, uint32 instanceId); inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const { diff --git a/src/game/MapRefManager.h b/src/game/MapRefManager.h new file mode 100644 index 00000000000..da0c81a9138 --- /dev/null +++ b/src/game/MapRefManager.h @@ -0,0 +1,44 @@ +/*
+ * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _MAPREFMANAGER
+#define _MAPREFMANAGER
+
+#include "Utilities/LinkedReference/RefManager.h"
+
+class MapReference;
+
+class MapRefManager : public RefManager<Map, Player>
+{
+ public:
+ typedef LinkedListHead::Iterator< MapReference > iterator;
+ typedef LinkedListHead::Iterator< MapReference const > const_iterator;
+
+ MapReference* getFirst() { return (MapReference*)RefManager<Map, Player>::getFirst(); }
+ MapReference const* getFirst() const { return (MapReference const*)RefManager<Map, Player>::getFirst(); }
+ MapReference* getLast() { return (MapReference*)RefManager<Map, Player>::getLast(); }
+ MapReference const* getLast() const { return (MapReference const*)RefManager<Map, Player>::getLast(); }
+
+ iterator begin() { return iterator(getFirst()); }
+ iterator end() { return iterator(NULL); }
+ iterator rbegin() { return iterator(getLast()); }
+ iterator rend() { return iterator(NULL); }
+ const_iterator begin() const { return const_iterator(getFirst()); }
+ const_iterator end() const { return const_iterator(getLast()); }
+};
+#endif
diff --git a/src/game/MapReference.h b/src/game/MapReference.h new file mode 100644 index 00000000000..b41796ea91b --- /dev/null +++ b/src/game/MapReference.h @@ -0,0 +1,50 @@ +/*
+ * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _MAPREFERENCE_H
+#define _MAPREFERENCE_H
+
+#include "Utilities/LinkedReference/Reference.h"
+#include "Map.h"
+
+class TRINITY_DLL_SPEC MapReference : public Reference<Map, Player>
+{
+ protected:
+ void targetObjectBuildLink()
+ {
+ // called from link()
+ getTarget()->m_mapRefManager.insertFirst(this);
+ getTarget()->m_mapRefManager.incSize();
+ }
+ void targetObjectDestroyLink()
+ {
+ // called from unlink()
+ if(isValid()) getTarget()->m_mapRefManager.decSize();
+ }
+ void sourceObjectDestroyLink()
+ {
+ // called from invalidate()
+ getTarget()->m_mapRefManager.decSize();
+ }
+ public:
+ MapReference() : Reference<Map, Player>() {}
+ ~MapReference() { unlink(); }
+ MapReference *next() { return (MapReference*)Reference<Map, Player>::next(); }
+ MapReference const *next() const { return (MapReference const*)Reference<Map, Player>::next(); }
+};
+#endif
diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 15a77c6c01e..4936e9f0991 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -222,7 +222,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) // check present spell in trainer spell list TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); if(!trainer_spells) - return; + return; // not found, cheat? TrainerSpell const* trainer_spell = trainer_spells->Find(spellId); @@ -339,15 +339,13 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) if(!code.empty()) { - if (!Script->GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str())) unit->OnGossipSelect (_player, option); } else - { if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option))) - unit->OnGossipSelect (_player, option); + unit->OnGossipSelect (_player, option); } } @@ -377,7 +375,7 @@ void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) void WorldSession::SendSpiritResurrect() { - _player->ResurrectPlayer(0.5f,false, true); + _player->ResurrectPlayer(0.5f, true); _player->DurabilityLossAll(0.25f,true); diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index c03dbab09e9..8d9f3f63fc2 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -142,7 +142,15 @@ Creature* ObjectAccessor::GetCreature(WorldObject const &u, uint64 guid) { Creature * ret = GetObjectInWorld(guid, (Creature*)NULL); - if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL; + if(!ret) + return NULL; + + if(ret->GetMapId() != u.GetMapId()) + return NULL; + + if(ret->GetInstanceId() != u.GetInstanceId()) + return NULL; + return ret; } @@ -248,32 +256,6 @@ ObjectAccessor::SaveAllPlayers() } void -ObjectAccessor::_update() -{ - UpdateDataMapType update_players; - { - Guard guard(i_updateGuard); - while(!i_objects.empty()) - { - Object* obj = *i_objects.begin(); - i_objects.erase(i_objects.begin()); - if (!obj) - continue; - _buildUpdateObject(obj, update_players); - obj->ClearUpdateMask(false); - } - } - - WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 - for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) - { - iter->second.BuildPacket(&packet); - iter->first->GetSession()->SendPacket(&packet); - packet.clear(); // clean the string - } -} - -void ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) { UpdateDataMapType update_players; @@ -361,7 +343,7 @@ ObjectAccessor::_buildChangeObjectForPlayer(WorldObject *obj, UpdateDataMapType WorldObjectChangeAccumulator notifier(*obj, update_players); TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); CellLock<GridReadGuard> cell_lock(cell, p); - cell_lock->Visit(cell_lock, player_notifier, *MapManager::Instance().GetMap(obj->GetMapId(), obj)); + cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap()); } Pet* @@ -519,7 +501,10 @@ ObjectAccessor::RemoveActiveObject( WorldObject * obj ) void ObjectAccessor::Update(uint32 diff) { + { + //Player update now in MapManager -> UpdatePlayers + /* // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) @@ -528,8 +513,9 @@ ObjectAccessor::Update(uint32 diff) { iter->second->Update(diff); } - } + }*/ + // TODO: move this to Map::Update // clone the active object list, because update might remove from it std::set<WorldObject *> activeobjects(i_activeobjects); @@ -590,7 +576,36 @@ ObjectAccessor::Update(uint32 diff) } } - _update(); + UpdateDataMapType update_players; + { + Guard guard(i_updateGuard); + while(!i_objects.empty()) + { + Object* obj = *i_objects.begin(); + i_objects.erase(i_objects.begin()); + if (!obj) + continue; + _buildUpdateObject(obj, update_players); + obj->ClearUpdateMask(false); + } + } + + WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 + for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) + { + iter->second.BuildPacket(&packet); + iter->first->GetSession()->SendPacket(&packet); + packet.clear(); // clean the string + } +} + +void +ObjectAccessor::UpdatePlayers(uint32 diff) +{ + HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); + for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) + if(iter->second->IsInWorld()) + iter->second->Update(diff); } bool @@ -677,14 +692,14 @@ ObjectAccessor::UpdateObjectVisibility(WorldObject *obj) CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); Cell cell(p); - MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p); + obj->GetMap()->UpdateObjectVisibility(obj,cell,p); } void ObjectAccessor::UpdateVisibilityForPlayer( Player* player ) { CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); Cell cell(p); - Map* m = MapManager::Instance().GetMap(player->GetMapId(),player); + Map* m = player->GetMap(); m->UpdatePlayerVisibility(player,cell,p); m->UpdateObjectsVisibilityFor(player,cell,p); diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index d0007d37f21..89ea6d1e43d 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITY_OBJECTACCESSOR_H @@ -186,6 +186,7 @@ class TRINITY_DLL_DECL ObjectAccessor : public Trinity::Singleton<ObjectAccessor void RemoveUpdateObject(Object *obj); void Update(uint32 diff); + void UpdatePlayers(uint32 diff); Corpse* GetCorpseForPlayerGUID(uint64 guid); void RemoveCorpse(Corpse *corpse); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 43d867d779d..751a3ca4fbc 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -10,17 +10,18 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" #include "Database/DatabaseEnv.h" #include "Database/SQLStorage.h" +#include "Database/SQLStorageImpl.h" #include "Log.h" #include "MapManager.h" @@ -116,8 +117,12 @@ ObjectMgr::ObjectMgr() m_hiGoGuid = 1; m_hiDoGuid = 1; m_hiCorpseGuid = 1; - m_hiPetNumber = 1; + m_ItemTextId = 1; + m_mailid = 1; + m_auctionid = 1; + m_guildId = 1; + m_arenaTeamId = 1; mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); mGuildBankTabPrice[0] = 100; @@ -415,7 +420,7 @@ void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction ) sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() ); //prepare mail data... : - uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() ); + uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() ); // set owner to bidder (to prevent delete item with sender char deleting) // owner in `data` will set at mail receive and item extracting @@ -466,7 +471,7 @@ void ObjectMgr::SendAuctionSalePendingMail( AuctionEntry * auction ) sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); - uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() ); + uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() ); WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); } @@ -498,7 +503,7 @@ void ObjectMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); - uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() ); + uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() ); uint32 profit = auction->bid + auction->deposit - auctionCut; @@ -545,7 +550,6 @@ void ObjectMgr::SendAuctionExpiredMail( AuctionEntry * auction ) // will delete item or place to receiver mail list WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); - } // owner not found else @@ -563,8 +567,8 @@ CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id) void ObjectMgr::LoadCreatureLocales() { - mCreatureLocaleMap.clear(); - + mCreatureLocaleMap.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); if(!result) @@ -623,7 +627,7 @@ void ObjectMgr::LoadCreatureLocales() sLog.outString(); sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() ); } - + void ObjectMgr::LoadNpcOptionLocales() { mNpcOptionLocaleMap.clear(); // need for reload case @@ -692,9 +696,19 @@ void ObjectMgr::LoadNpcOptionLocales() sLog.outString( ">> Loaded %u npc_option locale strings", mNpcOptionLocaleMap.size() ); } +struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader> +{ + template<class D> + void convert_from_str(uint32 field_pos, char *src, D &dst) + { + dst = D(objmgr.GetScriptId(src)); + } +}; + void ObjectMgr::LoadCreatureTemplates() { - sCreatureStorage.Load(); + SQLCreatureLoader loader; + loader.Load(sCreatureStorage); sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); sLog.outString(); @@ -1512,7 +1526,7 @@ void ObjectMgr::LoadAuctions() aItem->deposit = fields[10].GetUInt32(); aItem->location = fields[11].GetUInt8(); //check if sold item exists - if ( this->GetAItem( aItem->item_guidlow ) ) + if ( GetAItem( aItem->item_guidlow ) ) { GetAuctionsMap( aItem->location )->AddAuction(aItem); } @@ -1532,8 +1546,8 @@ void ObjectMgr::LoadAuctions() void ObjectMgr::LoadItemLocales() { - mItemLocaleMap.clear(); - + mItemLocaleMap.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); if(!result) @@ -1594,9 +1608,19 @@ void ObjectMgr::LoadItemLocales() sLog.outString( ">> Loaded %u Item locale strings", mItemLocaleMap.size() ); } +struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader> +{ + template<class D> + void convert_from_str(uint32 field_pos, char *src, D &dst) + { + dst = D(objmgr.GetScriptId(src)); + } +}; + void ObjectMgr::LoadItemPrototypes() { - sItemStorage.Load (); + SQLItemLoader loader; + loader.Load(sItemStorage); sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); sLog.outString(); @@ -2506,7 +2530,7 @@ void ObjectMgr::LoadPlayerInfo() // skip expansion races if not playing with expansion if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI)) continue; - + // skip expansion classes if not playing with expansion if (sWorld.getConfig(CONFIG_EXPANSION) < 2 && class_ == CLASS_DEATH_KNIGHT) continue; @@ -3555,7 +3579,7 @@ void ObjectMgr::LoadQuests() void ObjectMgr::LoadQuestLocales() { - mQuestLocaleMap.clear(); + mQuestLocaleMap.clear(); // need for reload case QueryResult *result = WorldDatabase.Query("SELECT entry," "Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1," @@ -3749,7 +3773,7 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) scripts.clear(); // need for reload support - QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,datatext, x, y, z, o FROM %s", tablename ); + QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename ); uint32 count = 0; @@ -3771,16 +3795,16 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) Field *fields = result->Fetch(); ScriptInfo tmp; - tmp.id = fields[0].GetUInt32(); - tmp.delay = fields[1].GetUInt32(); - tmp.command = fields[2].GetUInt32(); - tmp.datalong = fields[3].GetUInt32(); + tmp.id = fields[0].GetUInt32(); + tmp.delay = fields[1].GetUInt32(); + tmp.command = fields[2].GetUInt32(); + tmp.datalong = fields[3].GetUInt32(); tmp.datalong2 = fields[4].GetUInt32(); - tmp.datatext = fields[5].GetCppString(); - tmp.x = fields[6].GetFloat(); - tmp.y = fields[7].GetFloat(); - tmp.z = fields[8].GetFloat(); - tmp.o = fields[9].GetFloat(); + tmp.dataint = fields[5].GetInt32(); + tmp.x = fields[6].GetFloat(); + tmp.y = fields[7].GetFloat(); + tmp.z = fields[8].GetFloat(); + tmp.o = fields[9].GetFloat(); // generic command args check switch(tmp.command) @@ -3792,6 +3816,18 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) sLog.outErrorDb("Table `%s` has invalid talk type (datalong = %u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.datalong,tmp.id); continue; } + if(tmp.dataint==0) + { + sLog.outErrorDb("Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,tmp.id); + continue; + } + if(tmp.dataint < MIN_DB_SCRIPT_STRING_ID || tmp.dataint >= MAX_DB_SCRIPT_STRING_ID) + { + sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID,tmp.id); + continue; + } + + // if(!objmgr.GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading break; } @@ -4156,8 +4192,8 @@ void ObjectMgr::LoadPageTexts() void ObjectMgr::LoadPageTextLocales() { - mPageTextLocaleMap.clear(); - + mPageTextLocaleMap.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); if(!result) @@ -4206,9 +4242,19 @@ void ObjectMgr::LoadPageTextLocales() sLog.outString( ">> Loaded %u PageText locale strings", mPageTextLocaleMap.size() ); } +struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader> +{ + template<class D> + void convert_from_str(uint32 field_pos, char *src, D &dst) + { + dst = D(objmgr.GetScriptId(src)); + } +}; + void ObjectMgr::LoadInstanceTemplate() { - sInstanceTemplate.Load(); + SQLInstanceLoader loader; + loader.Load(sInstanceTemplate); for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) { @@ -4324,8 +4370,8 @@ void ObjectMgr::LoadGossipText() void ObjectMgr::LoadNpcTextLocales() { - mNpcTextLocaleMap.clear(); - + mNpcTextLocaleMap.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query("SELECT entry," "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," "Text0_0_loc2,Text0_1_loc2,Text1_0_loc2,Text1_1_loc2,Text2_0_loc2,Text2_1_loc2,Text3_0_loc2,Text3_1_loc1,Text4_0_loc2,Text4_1_loc2,Text5_0_loc2,Text5_1_loc2,Text6_0_loc2,Text6_1_loc2,Text7_0_loc2,Text7_1_loc2," @@ -4622,7 +4668,7 @@ void ObjectMgr::LoadAreaTriggerScripts() Field *fields = result->Fetch(); uint32 Trigger_ID = fields[0].GetUInt32(); - std::string scriptName = fields[1].GetCppString(); + const char *scriptName = fields[1].GetString(); AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); if(!atEntry) @@ -4630,7 +4676,7 @@ void ObjectMgr::LoadAreaTriggerScripts() sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); continue; } - mAreaTriggerScripts[Trigger_ID] = scriptName; + mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName); } while( result->NextRow() ); delete result; @@ -4638,6 +4684,7 @@ void ObjectMgr::LoadAreaTriggerScripts() sLog.outString(); sLog.outString( ">> Loaded %u areatrigger scripts", count ); } + uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid ) { bool found = false; @@ -4696,11 +4743,11 @@ void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, ui uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) { - uint32 mount_entry = 0; - uint32 mount_id = 0; + uint16 mount_entry = 0; + uint16 mount_id = 0; TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); - if (node) + if(node) { if (team == ALLIANCE) mount_entry = node->alliance_mount_type; else mount_entry = node->horde_mount_type; @@ -4939,7 +4986,6 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float } } - // find now nearest graveyard at same map if(entryNear) return entryNear; @@ -5180,7 +5226,6 @@ void ObjectMgr::SetHighestGuids() if( result ) { m_hiCharGuid = (*result)[0].GetUInt32()+1; - delete result; } @@ -5188,23 +5233,16 @@ void ObjectMgr::SetHighestGuids() if( result ) { m_hiCreatureGuid = (*result)[0].GetUInt32()+1; - delete result; } - result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" ); - if( result ) - { - m_hiPetGuid = (*result)[0].GetUInt32()+1; - - delete result; - } + // pet guids are not saved to DB, set to 0 (pet guid != pet id) + m_hiPetGuid = 0; result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); if( result ) { m_hiItemGuid = (*result)[0].GetUInt32()+1; - delete result; } @@ -5218,7 +5256,6 @@ void ObjectMgr::SetHighestGuids() if( result ) { m_hiGoGuid = (*result)[0].GetUInt32()+1; - delete result; } @@ -5226,74 +5263,93 @@ void ObjectMgr::SetHighestGuids() if( result ) { m_auctionid = (*result)[0].GetUInt32()+1; - delete result; } - else - { - m_auctionid = 0; - } + result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); if( result ) { m_mailid = (*result)[0].GetUInt32()+1; - delete result; } - else - { - m_mailid = 0; - } + result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" ); if( result ) { - m_ItemTextId = (*result)[0].GetUInt32(); - + m_ItemTextId = (*result)[0].GetUInt32()+1; delete result; } - else - m_ItemTextId = 0; result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); if( result ) { m_hiCorpseGuid = (*result)[0].GetUInt32()+1; + delete result; + } + result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); + if (result) + { + m_arenaTeamId = (*result)[0].GetUInt32()+1; + delete result; + } + + result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); + if (result) + { + m_guildId = (*result)[0].GetUInt32()+1; delete result; } } +uint32 ObjectMgr::GenerateArenaTeamId() +{ + if(m_arenaTeamId>=0xFFFFFFFE) + { + sLog.outError("Arena team ids overflow!! Can't continue, shutting down server. "); + World::StopNow(ERROR_EXIT_CODE); + } + return m_arenaTeamId++; +} + +uint32 ObjectMgr::GenerateGuildId() +{ + if(m_guildId>=0xFFFFFFFE) + { + sLog.outError("Guild ids overflow!! Can't continue, shutting down server. "); + World::StopNow(ERROR_EXIT_CODE); + } + return m_guildId++; +} + uint32 ObjectMgr::GenerateAuctionID() { - ++m_auctionid; - if(m_auctionid>=0xFFFFFFFF) + if(m_auctionid>=0xFFFFFFFE) { sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_auctionid; + return m_auctionid++; } uint32 ObjectMgr::GenerateMailID() { - ++m_mailid; - if(m_mailid>=0xFFFFFFFF) + if(m_mailid>=0xFFFFFFFE) { sLog.outError("Mail ids overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_mailid; + return m_mailid++; } uint32 ObjectMgr::GenerateItemTextID() { - ++m_ItemTextId; - if(m_ItemTextId>=0xFFFFFFFF) + if(m_ItemTextId>=0xFFFFFFFE) { sLog.outError("Item text ids overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_ItemTextId; + return m_ItemTextId++; } uint32 ObjectMgr::CreateItemText(std::string text) @@ -5315,61 +5371,54 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh) switch(guidhigh) { case HIGHGUID_ITEM: - ++m_hiItemGuid; - if(m_hiItemGuid>=0xFFFFFFFF) + if(m_hiItemGuid>=0xFFFFFFFE) { sLog.outError("Item guid overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_hiItemGuid; + return m_hiItemGuid++; case HIGHGUID_UNIT: - ++m_hiCreatureGuid; - if(m_hiCreatureGuid>=0x00FFFFFF) + if(m_hiCreatureGuid>=0x00FFFFFE) { sLog.outError("Creature guid overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_hiCreatureGuid; + return m_hiCreatureGuid++; case HIGHGUID_PET: - ++m_hiPetGuid; - if(m_hiPetGuid>=0x00FFFFFF) + if(m_hiPetGuid>=0x00FFFFFE) { sLog.outError("Pet guid overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_hiPetGuid; + return m_hiPetGuid++; case HIGHGUID_PLAYER: - ++m_hiCharGuid; - if(m_hiCharGuid>=0xFFFFFFFF) + if(m_hiCharGuid>=0xFFFFFFFE) { sLog.outError("Players guid overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_hiCharGuid; + return m_hiCharGuid++; case HIGHGUID_GAMEOBJECT: - ++m_hiGoGuid; - if(m_hiGoGuid>=0x00FFFFFF) + if(m_hiGoGuid>=0x00FFFFFE) { sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_hiGoGuid; + return m_hiGoGuid++; case HIGHGUID_CORPSE: - ++m_hiCorpseGuid; - if(m_hiCorpseGuid>=0xFFFFFFFF) + if(m_hiCorpseGuid>=0xFFFFFFFE) { sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_hiCorpseGuid; + return m_hiCorpseGuid++; case HIGHGUID_DYNAMICOBJECT: - ++m_hiDoGuid; - if(m_hiDoGuid>=0xFFFFFFFF) + if(m_hiDoGuid>=0xFFFFFFFE) { sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); - sWorld.m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); } - return m_hiDoGuid; + return m_hiDoGuid++; default: ASSERT(0); } @@ -5380,8 +5429,8 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh) void ObjectMgr::LoadGameObjectLocales() { - mGameObjectLocaleMap.clear(); - + mGameObjectLocaleMap.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query("SELECT entry," "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," "castbarcaption_loc1,castbarcaption_loc2,castbarcaption_loc3,castbarcaption_loc4," @@ -5449,9 +5498,19 @@ void ObjectMgr::LoadGameObjectLocales() sLog.outString( ">> Loaded %u gameobject locale strings", mGameObjectLocaleMap.size() ); } +struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader> +{ + template<class D> + void convert_from_str(uint32 field_pos, char *src, D &dst) + { + dst = D(objmgr.GetScriptId(src)); + } +}; + void ObjectMgr::LoadGameobjectInfo() { - sGOStorage.Load(); + SQLGameObjectLoader loader; + loader.Load(sGOStorage); // some checks for(uint32 id = 1; id < sGOStorage.MaxEntry; id++) @@ -6624,12 +6683,12 @@ bool ObjectMgr::CheckDeclinedNames( std::wstring mainpart, DeclinedName const& n return true; } -const char* ObjectMgr::GetAreaTriggerScriptName(uint32 id) +uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id) { - AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(id); + AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(trigger_id); if(i!= mAreaTriggerScripts.end()) - return i->second.c_str(); - return ""; + return i->second; + return 0; } // Checks if player meets the condition @@ -6674,10 +6733,10 @@ bool PlayerCondition::Meets(Player const * player) const return true; return false; } - case CONDITION_NO_AURA: - return !player->HasAura(value1, value2); - case CONDITION_ACTIVE_EVENT: - return gameeventmgr.IsActiveEvent(value1); + case CONDITION_NO_AURA: + return !player->HasAura(value1, value2); + case CONDITION_ACTIVE_EVENT: + return gameeventmgr.IsActiveEvent(value1); default: return false; } @@ -6798,30 +6857,30 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val sLog.outErrorDb("Quest condition has useless data in value2 (%u)!", value2); break; } - case CONDITION_NO_AURA: - { - if(!sSpellStore.LookupEntry(value1)) - { - sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); - return false; - } - if(value2 > 2) - { - sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); - return false; - } - break; - } - case CONDITION_ACTIVE_EVENT: - { - GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); - if(value1 >=events.size() || !events[value1].isValid()) - { - sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1); - return false; - } - break; - } + case CONDITION_NO_AURA: + { + if(!sSpellStore.LookupEntry(value1)) + { + sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); + return false; + } + if(value2 > 2) + { + sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); + return false; + } + break; + } + case CONDITION_ACTIVE_EVENT: + { + GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); + if(value1 >=events.size() || !events[value1].isValid()) + { + sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1); + return false; + } + break; + } } return true; } @@ -6951,7 +7010,7 @@ bool ObjectMgr::AddGameTele(GameTele& tele) for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) if(itr->first > new_id) new_id = itr->first; - + // use next ++new_id; @@ -6991,7 +7050,7 @@ bool ObjectMgr::DeleteGameTele(std::string name) void ObjectMgr::LoadTrainerSpell() { - // For reload case + // For reload case for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) itr->second.Clear(); m_mCacheTrainerSpellMap.clear(); @@ -7082,7 +7141,7 @@ void ObjectMgr::LoadTrainerSpell() void ObjectMgr::LoadVendors() { - // For reload case + // For reload case for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) itr->second.Clear(); m_mCacheVendorItemMap.clear(); @@ -7189,6 +7248,7 @@ void ObjectMgr::LoadNpcOptions() // 0 1 2 3 4 5 6 7 8 "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text " "FROM npc_option"); + if( !result ) { barGoLink bar( 1 ); @@ -7341,10 +7401,84 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m return true; } +void ObjectMgr::LoadScriptNames() +{ + m_scriptNames.push_back(""); + QueryResult *result = WorldDatabase.Query( + "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' " + "UNION " + "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' " + "UNION " + "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' " + "UNION " + "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' " + "UNION " + "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''"); + if(result) + { + do + { + m_scriptNames.push_back((*result)[0].GetString()); + } while (result->NextRow()); + delete result; + } + + std::sort(m_scriptNames.begin(), m_scriptNames.end()); +} + +uint32 ObjectMgr::GetScriptId(const char *name) +{ + // use binary search to find the script name in the sorted vector + // assume "" is the first element + if(!name) return 0; + ScriptNameMap::const_iterator itr = + std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name); + if(itr == m_scriptNames.end()) return 0; + return itr - m_scriptNames.begin(); +} + +void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids) +{ + for(ScriptMapMap::const_iterator itrMM = scripts.begin(); itrMM != scripts.end(); ++itrMM) + { + for(ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM) + { + if(itrM->second.dataint) + { + if(!GetTrinityStringLocale (itrM->second.dataint)) + sLog.outErrorDb( "Table `db_script_string` has not existed string id %u", *itrM); + + if(ids.count(itrM->second.dataint)) + ids.erase(itrM->second.dataint); + } + } + } +} + +void ObjectMgr::LoadDbScriptStrings() +{ + LoadTrinityStrings(WorldDatabase,"db_script_string",MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID); + + std::set<int32> ids; + + for(int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i) + if(GetTrinityStringLocale(i)) + ids.insert(i); + + CheckScripts(sQuestEndScripts,ids); + CheckScripts(sQuestStartScripts,ids); + CheckScripts(sSpellScripts,ids); + CheckScripts(sGameObjectScripts,ids); + CheckScripts(sEventScripts,ids); + + for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr) + sLog.outErrorDb( "Table `db_script_string` has unused string id %u", *itr); +} + // Functions for scripting access -const char* GetAreaTriggerScriptNameById(uint32 id) +uint32 GetAreaTriggerScriptId(uint32 trigger_id) { - return objmgr.GetAreaTriggerScriptName(id); + return objmgr.GetAreaTriggerScriptId(trigger_id); } bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value, int32 end_value) @@ -7359,3 +7493,13 @@ bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value, i // for scripting localized strings allowed use _only_ negative entries return objmgr.LoadTrinityStrings(db,table,end_value,start_value); } + +uint32 TRINITY_DLL_SPEC GetScriptId(const char *name) +{ + return objmgr.GetScriptId(name); +} + +ObjectMgr::ScriptNameMap & GetScriptNames() +{ + return objmgr.GetScriptNames(); +} diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index a5d8a679fdd..9595418ed22 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _OBJECTMGR_H @@ -84,7 +84,7 @@ struct ScriptInfo uint32 command; uint32 datalong; uint32 datalong2; - std::string datatext; + int32 dataint; float x; float y; float z; @@ -128,6 +128,13 @@ typedef UNORDERED_MAP<uint32/*(mapid,spawnMode) pair*/,CellObjectGuidsMap> MapOb typedef UNORDERED_MAP<uint64/*(instance,guid) pair*/,time_t> RespawnTimes; + +// mangos string ranges +#define MIN_TRINITY_STRING_ID 1 +#define MAX_TRINITY_STRING_ID 2000000000 +#define MIN_DB_SCRIPT_STRING_ID MAX_TRINITY_STRING_ID +#define MAX_DB_SCRIPT_STRING_ID 2000010000 + struct TrinityStringLocale { std::vector<std::string> Content; // 0 -> default, i -> i-1 locale index @@ -207,8 +214,8 @@ enum ConditionType CONDITION_QUESTREWARDED = 8, // quest_id 0 CONDITION_QUESTTAKEN = 9, // quest_id 0, for condition true while quest active. CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD ñommission aura active - CONDITION_NO_AURA = 11, // spell_id effindex - CONDITION_ACTIVE_EVENT = 12, // event_id + CONDITION_NO_AURA = 11, // spell_id effindex + CONDITION_ACTIVE_EVENT = 12, // event_id }; #define MAX_CONDITION 13 // maximum value in ConditionType enum @@ -250,7 +257,7 @@ struct PlayerCondition // NPC gossip text id typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap; - +typedef std::list<GossipOption> CacheNpcOptionList; typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap; typedef UNORDERED_MAP<uint32, TrainerSpellData> CacheTrainerSpellMap; @@ -299,9 +306,10 @@ class ObjectMgr typedef UNORDERED_MAP<uint32, Quest*> QuestMap; + typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap; - typedef UNORDERED_MAP<uint32, std::string> AreaTriggerScriptMap; + typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap; typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap; @@ -309,6 +317,8 @@ class ObjectMgr typedef UNORDERED_MAP<uint32, PetCreateSpellEntry> PetCreateSpellMap; + typedef std::vector<std::string> ScriptNameMap; + Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);} Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); } @@ -476,7 +486,7 @@ class ObjectMgr AreaTrigger const* GetGoBackTrigger(uint32 Map) const; - const char* GetAreaTriggerScriptName(uint32 id); + uint32 GetAreaTriggerScriptId(uint32 trigger_id); ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const { @@ -522,7 +532,8 @@ class ObjectMgr void LoadSpellScripts(); bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value); - bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",1,std::numeric_limits<int32>::max()); } + bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); } + void LoadDbScriptStrings(); void LoadPetCreateSpells(); void LoadCreatureLocales(); void LoadCreatureTemplates(); @@ -592,6 +603,8 @@ class ObjectMgr uint32 GenerateMailID(); uint32 GenerateItemTextID(); uint32 GeneratePetNumber(); + uint32 GenerateArenaTeamId(); + uint32 GenerateGuildId(); void LoadPlayerInfoInCache(); PCachePlayerInfo GetPlayerInfoFromCache(uint32 unPlayerGuid) const; @@ -668,7 +681,6 @@ class ObjectMgr if(itr==mPageTextLocaleMap.end()) return NULL; return &itr->second; } - NpcOptionLocale const* GetNpcOptionLocale(uint32 entry) const { NpcOptionLocaleMap::const_iterator itr = mNpcOptionLocaleMap.find(entry); @@ -693,7 +705,7 @@ class ObjectMgr } const char *GetTrinityString(int32 entry, int locale_idx) const; const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); } - int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } + int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance); @@ -732,7 +744,7 @@ class ObjectMgr int GetIndexForLocale(LocaleConstant loc); LocaleConstant GetLocaleForIndex(int i); // guild bank tabs - const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } + uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const @@ -753,7 +765,7 @@ class ObjectMgr GameTeleMap const& GetGameTeleMap() const { return m_GameTeleMap; } bool AddGameTele(GameTele& data); bool DeleteGameTele(std::string name); - + CacheNpcOptionList const& GetNpcOptions() const { return m_mCacheNpcOptionList; } uint32 GetNpcGossip(uint32 entry) const @@ -761,7 +773,7 @@ class ObjectMgr CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry); if(iter == m_mCacheNpcTextIdMap.end()) return 0; - + return iter->second; } @@ -782,15 +794,25 @@ class ObjectMgr return &iter->second; } - void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); - bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); - bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const; + void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event + bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); // for event + bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0 ) const; + void LoadScriptNames(); + ScriptNameMap &GetScriptNames() { return m_scriptNames; } + const char * GetScriptName(uint32 id) { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; } + uint32 GetScriptId(const char *name); protected: + + // first free id for selected id type uint32 m_auctionid; uint32 m_mailid; uint32 m_ItemTextId; + uint32 m_arenaTeamId; + uint32 m_guildId; + uint32 m_hiPetNumber; + // first free low guid for seelcted guid type uint32 m_hiCharGuid; uint32 m_hiCreatureGuid; uint32 m_hiPetGuid; @@ -799,9 +821,7 @@ class ObjectMgr uint32 m_hiDoGuid; uint32 m_hiCorpseGuid; - uint32 m_hiPetNumber; - - QuestMap mQuestTemplates; + QuestMap mQuestTemplates; typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap; typedef UNORDERED_MAP<uint32, uint32> QuestAreaTriggerMap; @@ -848,6 +868,8 @@ class ObjectMgr GameTeleMap m_GameTeleMap; + ScriptNameMap m_scriptNames; + typedef std::vector<LocaleConstant> LocalForIndex; LocalForIndex m_LocalForIndex; int GetOrNewIndexForLocale(LocaleConstant loc); @@ -855,6 +877,7 @@ class ObjectMgr int DBCLocaleIndex; private: void LoadScripts(ScriptMapMap& scripts, char const* tablename); + void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids); void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr); void LoadQuestRelationsHelper(QuestRelations& map,char const* table); @@ -907,7 +930,9 @@ class ObjectMgr #define objmgr Trinity::Singleton<ObjectMgr>::Instance() // scripting access functions -bool TRINITY_DLL_SPEC LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min()); -TRINITY_DLL_SPEC const char* GetAreaTriggerScriptNameById(uint32 id); +TRINITY_DLL_SPEC bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min()); +TRINITY_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 trigger_id); +TRINITY_DLL_SPEC uint32 GetScriptId(const char *name); +TRINITY_DLL_SPEC ObjectMgr::ScriptNameMap& GetScriptNames(); #endif diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 9bf67fae2c1..65d5fd73199 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -286,6 +286,11 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu m_charmInfo->GetActionBarEntry(index)->Type = atol((*iter).c_str()); ++iter; m_charmInfo->GetActionBarEntry(index)->SpellOrAction = atol((*iter).c_str()); + + // patch for old data where some spells have ACT_DECIDE but should have ACT_CAST + // so overwrite old state + SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_charmInfo->GetActionBarEntry(index)->SpellOrAction); + if (spellInfo && spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) m_charmInfo->GetActionBarEntry(index)->Type = ACT_CAST; } //init teach spells @@ -1322,7 +1327,7 @@ void Pet::_LoadAuras(uint32 timediff) for(int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i) SetUInt32Value(i, 0); - QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); + QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); if(result) { @@ -1332,10 +1337,11 @@ void Pet::_LoadAuras(uint32 timediff) uint64 caster_guid = fields[0].GetUInt64(); uint32 spellid = fields[1].GetUInt32(); uint32 effindex = fields[2].GetUInt32(); - int32 damage = (int32)fields[3].GetUInt32(); - int32 maxduration = (int32)fields[4].GetUInt32(); - int32 remaintime = (int32)fields[5].GetUInt32(); - int32 remaincharges = (int32)fields[6].GetUInt32(); + uint32 stackcount= fields[3].GetUInt32(); + int32 damage = (int32)fields[4].GetUInt32(); + int32 maxduration = (int32)fields[5].GetUInt32(); + int32 remaintime = (int32)fields[6].GetUInt32(); + int32 remaincharges = (int32)fields[7].GetUInt32(); SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); if(!spellproto) @@ -1372,12 +1378,15 @@ void Pet::_LoadAuras(uint32 timediff) if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) continue; - Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); + for(uint32 i=0; i<stackcount; i++) + { + Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); - if(!damage) - damage = aura->GetModifier()->m_amount; - aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); - AddAura(aura); + if(!damage) + damage = aura->GetModifier()->m_amount; + aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); + AddAura(aura); + } } while( result->NextRow() ); @@ -1390,30 +1399,52 @@ void Pet::_SaveAuras() CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); AuraMap const& auras = GetAuras(); - for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - { - // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras. - SpellEntry const *spellInfo = itr->second->GetSpellProto(); - uint8 i; - for (i = 0; i < 3; i++) - if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH || - spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || - spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) - break; + if (auras.empty()) + return; - if (i != 3) - continue; - - if(itr->second->IsPassive()) - continue; + spellEffectPair lastEffectPair = auras.begin()->first; + uint32 stackCounter = 1; - /// do not save single target auras (unless they were cast by the player) - if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) - continue; + for(AuraMap::const_iterator itr = auras.begin(); ; ++itr) + { + if(itr == auras.end() || lastEffectPair != itr->first) + { + AuraMap::const_iterator itr2 = itr; + // save previous spellEffectPair to db + itr2--; + SpellEntry const *spellInfo = itr2->second->GetSpellProto(); + /// do not save single target auras (unless they were cast by the player) + if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))) + { + if(!itr2->second->IsPassive()) + { + // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras. + uint8 i; + for (i = 0; i < 3; i++) + if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH || + spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || + spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) + break; + + if (i == 3) + { + CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " + "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d')", + m_charmInfo->GetPetNumber(), itr2->second->GetCasterGUID(),(uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges)); + } + } + } + if(itr == auras.end()) + break; + } - CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')", - m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(),(*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); + if (lastEffectPair == itr->first) + stackCounter++; + else + { + lastEffectPair = itr->first; + stackCounter = 1; + } } } @@ -1434,6 +1465,10 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s return false; } + // same spells don't have autocast option + if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) + active = ACT_CAST; + PetSpellMap::iterator itr = m_spells.find(spell_id); if (itr != m_spells.end()) { @@ -1508,7 +1543,7 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s if (IsPassiveSpell(spell_id)) CastSpell(this, spell_id, true); else if(state == PETSPELL_NEW) - m_charmInfo->AddSpellToAB(oldspell_id, spell_id); + m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active); if(newspell->active == ACT_ENABLED) ToggleAutocast(spell_id, true); @@ -1658,10 +1693,10 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) if(IsPassiveSpell(spellid)) return; - if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) - if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER - && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE) - return; + //if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) + // if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER + // && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE) + // return; PetSpellMap::const_iterator itr = m_spells.find((uint16)spellid); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0ebd331ed04..5b63b87bc6f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -799,7 +799,7 @@ void Player::StopMirrorTimer(MirrorTimerType Type) GetSession()->SendPacket( &data ); } -void Player::EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage) +void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage) { WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); data << (uint64)guid; @@ -1641,7 +1641,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati else { // far teleport to another map - Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL; + Map* oldmap = IsInWorld() ? GetMap() : NULL; // check if we can enter before stopping combat / removing pet / totems / interrupting spells // Check enter rights before map getting to avoid creating instance copy for player @@ -3750,7 +3750,7 @@ void Player::SendDelayResponse(const uint32 ml_seconds) GetSession()->SendPacket( &data ); } -void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, bool applySickness) +void Player::ResurrectPlayer(float restore_percent, bool applySickness) { WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // remove spirit healer position data << uint32(-1); @@ -4281,7 +4281,7 @@ void Player::UpdateDefense() } } -void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats) +void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply) { if(modGroup >= BASEMOD_END || modType >= MOD_END) { @@ -5243,7 +5243,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele return false; } - Map *m = MapManager::Instance().GetMap(GetMapId(), this); + Map *m = GetMap(); const float old_x = GetPositionX(); const float old_y = GetPositionY(); @@ -5261,7 +5261,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele m->PlayerRelocation(this, x, y, z, orientation); // reread after Map::Relocation - m = MapManager::Instance().GetMap(GetMapId(), this); + m = GetMap(); x = GetPositionX(); y = GetPositionY(); z = GetPositionZ(); @@ -6176,7 +6176,9 @@ uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) if(!result) return 0; - return (*result)[0].GetUInt32(); + uint32 id = (*result)[0].GetUInt32(); + delete result; + return id; } uint32 Player::GetZoneIdFromDB(uint64 guid) @@ -6707,7 +6709,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply) SetBaseWeaponDamage(attType, MAXDAMAGE, damage); } - if(!IsUseEquippedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) + if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) return; if (proto->Delay) @@ -8485,7 +8487,7 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) cons if(!useable) return item; - if( item->IsBroken() || !IsUseEquippedWeapon(attackType==BASE_ATTACK) ) + if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) return NULL; return item; @@ -8640,6 +8642,7 @@ bool Player::IsValidPos( uint8 bag, uint8 slot ) return false; } + bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const { uint32 tempcount = 0; @@ -10155,7 +10158,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM || - pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) + pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) pItem->SetBinding( true ); if( bag == INVENTORY_SLOT_BAG_0 ) @@ -10201,7 +10204,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo { if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || - pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) + pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) pItem2->SetBinding( true ); pItem2->SetCount( pItem2->GetCount() + count ); @@ -10403,7 +10406,7 @@ void Player::VisualizeItem( uint8 slot, Item *pItem) return; // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) - if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) + if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) pItem->SetBinding( true ); sLog.outDebug( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); @@ -10548,8 +10551,6 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); - ItemPrototype const *pProto = pItem->GetProto(); - RemoveEnchantmentDurations(pItem); RemoveItemDurations(pItem); @@ -14207,7 +14208,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) for(int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i) SetUInt32Value(i, 0); - //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); + //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); if(result) { @@ -14217,10 +14218,11 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) uint64 caster_guid = fields[0].GetUInt64(); uint32 spellid = fields[1].GetUInt32(); uint32 effindex = fields[2].GetUInt32(); - int32 damage = (int32)fields[3].GetUInt32(); - int32 maxduration = (int32)fields[4].GetUInt32(); - int32 remaintime = (int32)fields[5].GetUInt32(); - int32 remaincharges = (int32)fields[6].GetUInt32(); + uint32 stackcount = fields[3].GetUInt32(); + int32 damage = (int32)fields[4].GetUInt32(); + int32 maxduration = (int32)fields[5].GetUInt32(); + int32 remaintime = (int32)fields[6].GetUInt32(); + int32 remaincharges = (int32)fields[7].GetUInt32(); SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); if(!spellproto) @@ -14257,11 +14259,15 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) continue; - Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); - if(!damage) - damage = aura->GetModifier()->m_amount; - aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); - AddAura(aura); + for(uint32 i=0; i<stackcount; i++) + { + Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); + if(!damage) + damage = aura->GetModifier()->m_amount; + aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); + AddAura(aura); + sLog.outString("Added aura spellid %u, effect %u", spellproto->Id, effindex); + } } while( result->NextRow() ); @@ -15320,31 +15326,54 @@ void Player::_SaveAuras() CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",GetGUIDLow()); AuraMap const& auras = GetAuras(); - for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + + if (auras.empty()) + return; + + spellEffectPair lastEffectPair = auras.begin()->first; + uint32 stackCounter = 1; + + for(AuraMap::const_iterator itr = auras.begin(); ; ++itr) { - SpellEntry const *spellInfo = itr->second->GetSpellProto(); + if(itr == auras.end() || lastEffectPair != itr->first) + { + AuraMap::const_iterator itr2 = itr; + // save previous spellEffectPair to db + itr2--; + SpellEntry const *spellInfo = itr2->second->GetSpellProto(); - //skip all auras from spells that are passive or need a shapeshift - if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost()) - continue; + //skip all auras from spells that are passive or need a shapeshift + if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost())) + { + //do not save single target auras (unless they were cast by the player) + if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))) + { + uint8 i; + // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras + for (i = 0; i < 3; i++) + if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || + spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) + break; - //do not save single target auras (unless they were cast by the player) - if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) - continue; + if (i == 3) + { + CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " + "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')", + GetGUIDLow(), itr2->second->GetCasterGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges)); + } + } + } - uint8 i; - // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras - for (i = 0; i < 3; i++) - if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || - spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) + if(itr == auras.end()) break; + } - if (i == 3) + if (lastEffectPair == itr->first) + stackCounter++; + else { - CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex()); - CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')", - GetGUIDLow(), itr->second->GetCasterGUID(), (uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(), (*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); + lastEffectPair = itr->first; + stackCounter = 1; } } } @@ -17910,7 +17939,7 @@ void Player::learnSkillRewardedSpells(uint32 skill_id ) if (pAbility->classmask && !(pAbility->classmask & classMask)) continue; - if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId)) + if (sSpellStore.LookupEntry(pAbility->spellId)) { // Ok need learn spell learnSpell(pAbility->spellId); @@ -18323,7 +18352,6 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) Player* member_with_max_level = NULL; Player* not_gray_member_with_max_level = NULL; - // gets the max member level of the group, and the max member level that still gets XP pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level); if(member_with_max_level) @@ -18332,7 +18360,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) // also no XP gained if there is no member below gray level xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim); - // skip in check PvP case (for speed, not used) + /// skip in check PvP case (for speed, not used) bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); float group_rate = Trinity::XP::xp_in_group_rate(count,is_raid); @@ -18660,6 +18688,18 @@ void Player::SetCanBlock( bool value ) UpdateBlockPercentage(); } +bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const +{ + for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) + if(itr->pos == pos) + return true; + return false; +} + +//*********************************** +//-------------TRINITY--------------- +//*********************************** + void Player::HandleFallDamage(MovementInfo& movementInfo) { //Players with Feather Fall or low fall time, or physical immunity (charges used) are ignored @@ -18961,15 +19001,6 @@ bool Player::isAllowUseBattleGroundObject() ); } -bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const -{ - for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) - if(itr->pos == this->pos) - return true; - - return false; -} - bool Player::isTotalImmunity() { AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY); diff --git a/src/game/Player.h b/src/game/Player.h index 4b92f8316d0..87f0ad11ae8 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PLAYER_H @@ -33,6 +33,7 @@ #include "Bag.h" #include "WorldSession.h" #include "Pet.h" +#include "MapReference.h" #include "Util.h" // for Tokens typedef #include<string> @@ -779,7 +780,7 @@ enum TeleportToOptions }; /// Type of environmental damages -enum EnvironmentalDamageType +enum EnviromentalDamage { DAMAGE_EXHAUSTED = 0, DAMAGE_DROWNING = 1, @@ -1124,7 +1125,7 @@ class TRINITY_DLL_SPEC Player : public Unit uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } uint32 GetArmorProficiency() const { return m_ArmorProficiency; } bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } - bool IsUseEquippedWeapon( bool mainhand ) const + bool IsUseEquipedWeapon( bool mainhand ) const { // disarm applied only to mainhand weapon return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) ); @@ -1306,7 +1307,7 @@ class TRINITY_DLL_SPEC Player : public Unit if(d < 0) SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); else - SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT); + SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); // "At Gold Limit" if(GetMoney() >= MAX_MONEY_AMOUNT) @@ -1428,7 +1429,6 @@ class TRINITY_DLL_SPEC Player : public Unit PlayerSpellMap const& GetSpellMap() const { return m_spells; } PlayerSpellMap & GetSpellMap() { return m_spells; } - ActionButtonList const& GetActionButtonList() const { return m_actionButtons; } void AddSpellMod(SpellModifier* mod, bool apply); int32 GetTotalFlatMods(uint32 spellId, SpellModOp op); @@ -1518,8 +1518,8 @@ class TRINITY_DLL_SPEC Player : public Unit void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); } void SendUpdateToOutOfRangeGroupMembers(); - void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); } - void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); } + void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); } + void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); } void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } static uint32 GetGuildIdFromDB(uint64 guid); @@ -1532,7 +1532,7 @@ class TRINITY_DLL_SPEC Player : public Unit void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot) { SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); - SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID()); + SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, GetGUID()); } uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot); @@ -1608,7 +1608,7 @@ class TRINITY_DLL_SPEC Player : public Unit void SendDelayResponse(const uint32); void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); - //Low Level Packets + //Low Level Packets void PlaySound(uint32 Sound, bool OnlySelf); //notifiers void SendAttackSwingCantAttack(); @@ -1640,7 +1640,7 @@ class TRINITY_DLL_SPEC Player : public Unit void CreateCorpse(); void KillPlayer(); uint32 GetResurrectionSpellId(); - void ResurrectPlayer(float restore_percent, bool updateToWorld = true, bool applySickness = false); + void ResurrectPlayer(float restore_percent, bool applySickness = false); void BuildPlayerRepop(); void RepopAtGraveyard(); @@ -1762,14 +1762,14 @@ class TRINITY_DLL_SPEC Player : public Unit void SetRegularAttackTime(); void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; } - void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats = true); + void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply); float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; float GetTotalBaseModValue(BaseModGroup modGroup) const; float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; } void _ApplyAllStatBonuses(); void _RemoveAllStatBonuses(); - void _ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply); + void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply); void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); @@ -1934,10 +1934,10 @@ class TRINITY_DLL_SPEC Player : public Unit void SetRestTime(uint32 v) { m_restTime = v;}; /*********************************************************/ - /*** ENVIRONMENTAL SYSTEM ***/ + /*** ENVIROMENTAL SYSTEM ***/ /*********************************************************/ - void EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage); + void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage); /*********************************************************/ /*** FLOOD FILTER SYSTEM ***/ @@ -2062,6 +2062,8 @@ class TRINITY_DLL_SPEC Player : public Unit Player* GetNextRandomRaidMember(float radius); GridReference<Player> &GetGridRef() { return m_gridRef; } + MapReference &GetMapRef() { return m_mapRef; } + bool isAllowedToLoot(Creature* creature); WorldLocation& GetTeleportDest() { return m_teleport_dest; } @@ -2307,6 +2309,7 @@ class TRINITY_DLL_SPEC Player : public Unit Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ); GridReference<Player> m_gridRef; + MapReference m_mapRef; }; void AddItemsSetItem(Player*player,Item *item); diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp index 78f90bc9c9e..7b32f547bff 100644 --- a/src/game/PlayerDump.cpp +++ b/src/game/PlayerDump.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -277,7 +277,7 @@ void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl // for guid set stop if set is empty if(guids && guids->empty()) - return; // nothing to do + return; // nothing to do // setup for guids case start position GUIDs::const_iterator guids_itr; @@ -343,7 +343,7 @@ DumpReturn PlayerDumpWriter::WriteDump(std::string file, uint32 guid) { FILE *fout = fopen(file.c_str(), "w"); if (!fout) - return DUMP_FILE_OPEN_ERROR; + return DUMP_FILE_OPEN_ERROR; std::string dump = GetDump(guid); @@ -371,9 +371,10 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str return DUMP_TOO_MANY_CHARS; } } + FILE *fin = fopen(file.c_str(), "r"); if(!fin) - return DUMP_FILE_OPEN_ERROR; + return DUMP_FILE_OPEN_ERROR; QueryResult * result = NULL; char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20]; @@ -390,7 +391,8 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str } else incHighest = false; } - else guid = objmgr.m_hiCharGuid; + else + guid = objmgr.m_hiCharGuid; // normalize the name if specified and check if it exists if(!normalizePlayerName(name)) @@ -468,29 +470,25 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str { case DTT_CHAR_TABLE: if(!changenth(line, 1, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); break; case DTT_CHARACTER: // character t. { if(!changenth(line, 1, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); // guid, data field:guid, items if(!changenth(line, 2, chraccount)) - ROLLBACK(DUMP_FILE_BROKEN); - + ROLLBACK(DUMP_FILE_BROKEN); std::string vals = getnth(line, 3); if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); - + ROLLBACK(DUMP_FILE_BROKEN); for(uint16 field = PLAYER_FIELD_INV_SLOT_HEAD; field < PLAYER_FARSIGHT; field++) if(!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true)) - ROLLBACK(DUMP_FILE_BROKEN); - + ROLLBACK(DUMP_FILE_BROKEN); if(!changenth(line, 3, vals.c_str())) - ROLLBACK(DUMP_FILE_BROKEN); - + ROLLBACK(DUMP_FILE_BROKEN); if (name == "") { // check if the original name already exists @@ -503,50 +501,49 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str delete result; // rename on login: `at_login` field 30 in raw field list if(!changenth(line, 30, "1")) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); } } else if(!changenth(line, 4, name.c_str())) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_INVENTORY: // character_inventory t. { if(!changenth(line, 1, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); // bag, item if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); + if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid)) + ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_ITEM: // item_instance t. { // item, owner, data field:item, owner guid if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changenth(line, 2, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); - + ROLLBACK(DUMP_FILE_BROKEN); + if(!changenth(line, 2, newguid)) + ROLLBACK(DUMP_FILE_BROKEN); std::string vals = getnth(line,3); if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changenth(line, 3, vals.c_str())) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); + if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid)) + ROLLBACK(DUMP_FILE_BROKEN); + if(!changenth(line, 3, vals.c_str())) + ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_ITEM_GIFT: // character_gift { // guid,item_guid, if(!changenth(line, 1, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); + if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) + ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_PET: // character_pet t @@ -569,9 +566,9 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str // item, entry, owner, ... if(!changenth(line, 1, newpetid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changenth(line, 3, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); + if(!changenth(line, 3, newguid)) + ROLLBACK(DUMP_FILE_BROKEN); break; } @@ -582,12 +579,12 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str // lookup currpetid and match to new inserted pet id std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid)); if(petids_iter == petids.end()) // couldn't find new inserted id - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); snprintf(newpetid, 20, "%d", petids_iter->second); if(!changenth(line, 1, newpetid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); break; } @@ -595,20 +592,20 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str { // id,messageType,stationery,sender,receiver if(!changeGuid(line, 1, mails, objmgr.m_mailid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changenth(line, 5, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); + if(!changenth(line, 5, newguid)) + ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_MAIL_ITEM: // mail_items { // mail_id,item_guid,item_template,receiver if(!changeGuid(line, 1, mails, objmgr.m_mailid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) - ROLLBACK(DUMP_FILE_BROKEN); - if(!changenth(line, 4, newguid)) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); + if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) + ROLLBACK(DUMP_FILE_BROKEN); + if(!changenth(line, 4, newguid)) + ROLLBACK(DUMP_FILE_BROKEN); break; } default: @@ -617,7 +614,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str } if(!CharacterDatabase.Execute(line.c_str())) - ROLLBACK(DUMP_FILE_BROKEN); + ROLLBACK(DUMP_FILE_BROKEN); } CharacterDatabase.CommitTransaction(); diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index dd097c68bcb..dc22b3affbc 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -248,7 +248,7 @@ enum ItemQualities #define SPELL_ATTR_EX_UNK14 0x00004000 // 14 #define SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY 0x00008000 // 15 remove auras on immunity #define SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE 0x00010000 // 16 unaffected by school immunity -#define SPELL_ATTR_EX_UNK17 0x00020000 // 17 +#define SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET 0x00020000 // 17 #define SPELL_ATTR_EX_UNK18 0x00040000 // 18 #define SPELL_ATTR_EX_UNK19 0x00080000 // 19 #define SPELL_ATTR_EX_REQ_COMBO_POINTS1 0x00100000 // 20 Req combo points on target diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index eae232085ed..59d019800ed 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -996,6 +996,9 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) } unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL); + //TODO: find a better way to judge CC auras + if(m_spellInfo->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) + unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); } else { diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 3548c19e6bc..35d39a22b27 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -169,10 +169,10 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus - &Aura::HandleAuraHealing, //115 SPELL_AURA_MOD_HEALING + &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult - &Aura::HandleAuraHealingPct, //118 SPELL_AURA_MOD_HEALING_PCT + &Aura::HandleNoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE &Aura::HandleAuraEmpathy, //121 SPELL_AURA_EMPATHY @@ -190,7 +190,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE - &Aura::HandleAuraHealingPct, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus + &Aura::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE &Aura::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION @@ -219,7 +219,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleAuraPowerBurn, //162 SPELL_AURA_POWER_BURN_MANA &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE &Aura::HandleUnused, //164 useless, only one test spell - &Aura::HandleAuraAttackPowerAttacker, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus + &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT &Aura::HandleNoImmediateEffect, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus @@ -1998,6 +1998,16 @@ void Aura::HandleAuraDummy(bool apply, bool Real) return; } + // Waiting to Resurrect + if(GetId()==2584) + { + // Waiting to resurrect spell cancel, we must remove player from resurrect queue + if(m_target->GetTypeId() == TYPEID_PLAYER) + if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) + bg->RemovePlayerFromResurrectQueue(m_target->GetGUID()); + return; + } + // Dark Fiend if(GetId()==45934) { @@ -2286,6 +2296,10 @@ void Aura::HandleAuraPeriodicDummy(bool apply, bool Real) void Aura::HandleAuraMounted(bool apply, bool Real) { + // only at real add/remove aura + if(!Real) + return; + if(apply) { CreatureInfo const* ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue); @@ -2685,7 +2699,9 @@ void Aura::HandleAuraTransform(bool apply, bool Real) } else { - if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); + // Will use the default model here + if (uint32 modelid = ci->GetRandomValidModelId()) + m_target->SetDisplayId(modelid); // Dragonmaw Illusion (set mount model also) if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty()) @@ -3581,7 +3597,7 @@ void Aura::HandleModTaunt(bool apply, bool Real) /*********************************************************/ /*** MODIFY SPEED ***/ /*********************************************************/ -void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real) +void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if(!Real) @@ -3590,7 +3606,7 @@ void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real) m_target->UpdateSpeed(MOVE_RUN, true); } -void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real) +void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if(!Real) @@ -3629,7 +3645,7 @@ void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real) m_target->UpdateSpeed(MOVE_FLY, true); } -void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real) +void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if(!Real) @@ -3638,7 +3654,7 @@ void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real) m_target->UpdateSpeed(MOVE_SWIM, true); } -void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) +void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if(!Real) @@ -3649,7 +3665,7 @@ void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) m_target->UpdateSpeed(MOVE_FLY, true); } -void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real) +void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if(!Real) @@ -4334,7 +4350,7 @@ void Aura::HandleModPercentStat(bool apply, bool Real) } } -void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real) +void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real) { if(m_target->GetTypeId() != TYPEID_PLAYER) return; @@ -4345,7 +4361,7 @@ void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real) ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); } -void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real) +void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real) { if(m_target->GetTypeId() != TYPEID_PLAYER) return; @@ -4363,7 +4379,7 @@ void Aura::HandleAuraModDispelResist(bool apply, bool Real) m_target->CastSpell(m_target,44416,true,NULL,this,GetCasterGUID()); } -void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real) +void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real) { if(m_target->GetTypeId() != TYPEID_PLAYER) return; @@ -4374,7 +4390,7 @@ void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real) ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); } -void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real) +void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real) { if(m_target->GetTypeId() != TYPEID_PLAYER) return; @@ -4383,7 +4399,7 @@ void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real) ((Player*)m_target)->UpdateSpellDamageAndHealingBonus(); } -void Aura::HandleModHealingDone(bool apply, bool Real) +void Aura::HandleModHealingDone(bool /*apply*/, bool Real) { if(m_target->GetTypeId() != TYPEID_PLAYER) return; @@ -4423,7 +4439,7 @@ void Aura::HandleModTotalPercentStat(bool apply, bool Real) } } -void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real) +void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real) { if(m_target->GetTypeId() != TYPEID_PLAYER) return; @@ -4558,7 +4574,7 @@ void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking ((Player*)m_target)->UpdateManaRegen(); } -void Aura::HandleModPowerRegenPCT(bool apply, bool Real) +void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if(!Real) @@ -4572,7 +4588,7 @@ void Aura::HandleModPowerRegenPCT(bool apply, bool Real) ((Player*)m_target)->UpdateManaRegen(); } -void Aura::HandleModManaRegen(bool apply, bool Real) +void Aura::HandleModManaRegen(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if(!Real) @@ -4659,7 +4675,7 @@ void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool Real) /*** FIGHT ***/ /********************************/ -void Aura::HandleAuraModParryPercent(bool apply, bool Real) +void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real) { if(m_target->GetTypeId()!=TYPEID_PLAYER) return; @@ -4667,7 +4683,7 @@ void Aura::HandleAuraModParryPercent(bool apply, bool Real) ((Player*)m_target)->UpdateParryPercentage(); } -void Aura::HandleAuraModDodgePercent(bool apply, bool Real) +void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real) { if(m_target->GetTypeId()!=TYPEID_PLAYER) return; @@ -4676,7 +4692,7 @@ void Aura::HandleAuraModDodgePercent(bool apply, bool Real) //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount)); } -void Aura::HandleAuraModBlockPercent(bool apply, bool Real) +void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real) { if(m_target->GetTypeId()!=TYPEID_PLAYER) return; @@ -4685,7 +4701,7 @@ void Aura::HandleAuraModBlockPercent(bool apply, bool Real) //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount)); } -void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real) +void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if(!Real) @@ -4753,7 +4769,7 @@ void Aura::HandleModSpellCritChance(bool apply, bool Real) } } -void Aura::HandleModSpellCritChanceShool(bool apply, bool Real) +void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if(!Real) @@ -4835,39 +4851,6 @@ void Aura::HandleAuraModRangedAttackPower(bool apply, bool Real) m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); } -void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real) -{ - // spells required only Real aura add/remove - if(!Real) - return; - Unit *caster = GetCaster(); - - if (!caster) - return; - - // Hunter's Mark - if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL) - { - // Check Improved Hunter's Mark bonus on caster - Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - // mproved Hunter's Mark script from 5236 to 5240 - if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240) - { - // Get amount of ranged bonus for this spell.. - int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target); - // Set melee attack power bonus % from ranged depends from Improved mask aura - m_modifier.m_amount = mod->m_amount * ranged_bonus / 100; - m_currentBasePoints = m_modifier.m_amount; - break; - } - } - return; - } -} - void Aura::HandleAuraModAttackPowerPercent(bool apply, bool Real) { //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1 @@ -5315,7 +5298,7 @@ void Aura::HandleForceMoveForward(bool apply, bool Real) m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); } -void Aura::HandleAuraModExpertise(bool apply, bool Real) +void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real) { if(m_target->GetTypeId() != TYPEID_PLAYER) return; @@ -5340,17 +5323,6 @@ void Aura::HandleModTargetResistance(bool apply, bool Real) m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply); } -//HandleNoImmediateEffect auras implementation to support new stat system -void Aura::HandleAuraHealing(bool apply, bool Real) -{ - //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply); -} - -void Aura::HandleAuraHealingPct(bool apply, bool Real) -{ - //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply); -} - void Aura::HandleShieldBlockValue(bool apply, bool Real) { BaseModType modType = FLAT_MOD; diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index e4fe29fbc60..d803d9ede13 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITY_SPELLAURAS_H #define TRINITY_SPELLAURAS_H @@ -185,15 +185,12 @@ class TRINITY_DLL_SPEC Aura void HandleAuraAllowFlight(bool Apply, bool Real); void HandleModRating(bool apply, bool Real); void HandleModTargetResistance(bool apply, bool Real); - void HandleAuraAttackPowerAttacker(bool apply, bool Real); void HandleAuraModAttackPowerPercent(bool apply, bool Real); void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real); void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real); void HandleSpiritOfRedemption(bool apply, bool Real); - void HandleAuraHealingPct(bool apply, bool Real); void HandleModManaRegen(bool apply, bool Real); void HandleComprehendLanguage(bool apply, bool Real); - void HandleAuraHealing(bool apply, bool Real); void HandleShieldBlockValue(bool apply, bool Real); void HandleModSpellCritChanceShool(bool apply, bool Real); void HandleAuraRetainComboPoints(bool apply, bool Real); @@ -253,7 +250,7 @@ class TRINITY_DLL_SPEC Aura { uint8 slot = GetAuraSlot(); - // only aura inslot with charges and without stack limitation + // only aura in slot with charges and without stack limitation if (slot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0) SetAuraApplication(slot, m_procCharges - 1); } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 9789200939b..b3dcc2c5069 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -333,13 +333,26 @@ void Spell::EffectSchoolDMG(uint32 effect_idx) damage = 200; break; } - // must only affect demons + // must only affect demons (also undead?) case 45072: { - if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON) + if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON + || unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) return; break; } + // gruul's shatter + case 33671: + { + // don't damage self and only players + if(unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[0])); + if(!radius) return; + float distance = m_caster->GetDistance2d(unitTarget); + damage = (distance > radius ) ? 0 : (int32)(m_spellInfo->EffectBasePoints[0]*((radius - distance)/radius)); + }break; } break; } @@ -1158,7 +1171,7 @@ void Spell::EffectDummy(uint32 i) //Converted Sentry Credit m_caster->CastSpell(m_caster, 45009, true); return; - } + } case 45030: // Impale Emissary { // Emissary of Hate Credit @@ -1261,7 +1274,7 @@ void Spell::EffectDummy(uint32 i) { //Polymorph Cast Visual Rank 1 const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820}; - unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); + unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); } return; } @@ -2237,7 +2250,7 @@ void Spell::EffectPowerDrain(uint32 i) m_caster->ModifyPower(POWER_MANA,gain); //send log - m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA,false); + m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA); } } @@ -2253,7 +2266,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex) case 23333: // Pickup Horde Flag /*do not uncomment . if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); sLog.outDebug("Send Event Horde Flag Picked Up"); break; /* not used : @@ -2266,7 +2279,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex) case 23335: // Pickup Alliance Flag /*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); sLog.outDebug("Send Event Alliance Flag Picked Up"); break; /* not used : @@ -2277,18 +2290,18 @@ void Spell::EffectSendEvent(uint32 EffectIndex) break; case 23385: // Alliance Flag Returns if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); sLog.outDebug("Alliance Flag Returned"); break; case 23386: // Horde Flag Returns if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); sLog.outDebug("Horde Flag Returned"); break;*/ case 34976: /* if(bg->GetTypeID()==BATTLEGROUND_EY) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); */ break; default: @@ -2637,6 +2650,7 @@ void Spell::EffectPersistentAA(uint32 i) { float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; + if(!caster) return; if(Player* modOwner = caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius); @@ -2666,24 +2680,24 @@ void Spell::EffectEnergize(uint32 i) return; // Some level depends spells - int multiplier = 0; + int multiplier = 0; int level_diff = 0; switch (m_spellInfo->Id) { // Restore Energy case 9512: level_diff = m_caster->getLevel() - 40; - multiplier = 2; + multiplier = 2; break; // Blood Fury case 24571: level_diff = m_caster->getLevel() - 60; - multiplier = 10; + multiplier = 10; break; // Burst of Energy case 24532: level_diff = m_caster->getLevel() - 60; - multiplier = 4; + multiplier = 4; break; default: break; @@ -3745,7 +3759,7 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i) if(unitTarget->GetTypeId() == TYPEID_PLAYER) ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); else - MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); + m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); } void Spell::EffectLearnSkill(uint32 i) @@ -3766,13 +3780,13 @@ void Spell::EffectAddHonor(uint32 /*i*/) if(unitTarget->GetTypeId() != TYPEID_PLAYER) return; - sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow()); + sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, damage, ((Player*)unitTarget)->GetGUIDLow()); // TODO: find formula for honor reward based on player's level! // now fixed only for level 70 players: if (((Player*)unitTarget)->getLevel() == 70) - ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage); + ((Player*)unitTarget)->RewardHonor(NULL, 1, damage); } void Spell::EffectTradeSkill(uint32 /*i*/) @@ -3987,7 +4001,7 @@ void Spell::EffectTameCreature(uint32 /*i*/) pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1); // add to world - MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); + pet->GetMap()->Add((Creature*)pet); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); @@ -4017,14 +4031,14 @@ void Spell::EffectSummonPet(uint32 i) if( OldSummon->isDead() ) return; - MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false); + OldSummon->GetMap()->Remove((Creature*)OldSummon,false); OldSummon->SetMapId(m_caster->GetMapId()); float px, py, pz; m_caster->GetClosePoint(px, py, pz, OldSummon->GetObjectSize()); OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); - MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon); + m_caster->GetMap()->Add((Creature*)OldSummon); if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) { @@ -4107,10 +4121,10 @@ void Spell::EffectSummonPet(uint32 i) uint32 faction = m_caster->getFaction(); if(m_caster->GetTypeId() == TYPEID_UNIT) { - if ( ((Creature*)m_caster)->isTotem() ) - NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); - else - NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); + if ( ((Creature*)m_caster)->isTotem() ) + NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); + else + NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); } NewSummon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); @@ -4432,6 +4446,7 @@ void Spell::EffectWeaponDmg(uint32 i) if(m_caster->GetTypeId()==TYPEID_PLAYER) ((Player*)m_caster)->AddComboPoints(unitTarget, 1); } + // Mangle (Cat): CP if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL)) { @@ -4439,7 +4454,6 @@ void Spell::EffectWeaponDmg(uint32 i) ((Player*)m_caster)->AddComboPoints(unitTarget,1); } - // take ammo if(m_attackType == RANGED_ATTACK && m_caster->GetTypeId() == TYPEID_PLAYER) { @@ -5434,7 +5448,7 @@ void Spell::EffectSummonObject(uint32 i) m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); } -void Spell::EffectResurrect(uint32 i) +void Spell::EffectResurrect(uint32 /*effIndex*/) { if(!unitTarget) return; @@ -5655,7 +5669,7 @@ void Spell::EffectSkinning(uint32 /*i*/) Creature* creature = (Creature*) unitTarget; int32 targetLevel = creature->getLevel(); - uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); + uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); @@ -5682,7 +5696,7 @@ void Spell::EffectCharge(uint32 /*i*/) m_caster->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_WALK_MODE, 1); if(m_caster->GetTypeId() != TYPEID_PLAYER) - MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); + m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); // not all charge effects used in negative spells if ( !IsPositiveSpell(m_spellInfo->Id)) @@ -6118,7 +6132,7 @@ void Spell::EffectTransmitted(uint32 effIndex) linkedGO->SetSpellId(m_spellInfo->Id); linkedGO->SetOwnerGUID(m_caster->GetGUID() ); - MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO); + linkedGO->GetMap()->Add(linkedGO); } else { diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 10b955fb7af..6caab76e061 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -55,6 +55,12 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) return; } + if(pItem->GetGUID() != item_guid) + { + pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); + return; + } + sLog.outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, spell_count: %u , cast_count: %u, Item: %u, data length = %i", bagIndex, slot, spell_count, cast_count, pItem->GetEntry(), recvPacket.size()); ItemPrototype const *proto = pItem->GetProto(); @@ -238,7 +244,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) uint32 flags = fields[1].GetUInt32(); pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0); - pItem->SetUInt32Value(OBJECT_FIELD_ENTRY, entry); + pItem->SetEntry(entry); pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags); pItem->SetState(ITEM_CHANGED, pUser); delete result; @@ -260,7 +266,6 @@ void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data ) CHECK_PACKET_SIZE(recv_data,8); uint64 guid; - uint32 spellId = OPEN_CHEST; recv_data >> guid; @@ -323,7 +328,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) } Spell *spell = new Spell(_player, spellInfo, false); - spell->m_cast_count = cast_count; //set count of casts + spell->m_cast_count = cast_count; // set count of casts spell->prepare(&targets); } @@ -364,10 +369,11 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_CHARM || spellInfo->EffectApplyAuraName[i] == SPELL_AURA_BIND_SIGHT) { + // Fix me: creature may be killed during player aura cancel _player->RemoveAurasDueToSpellByCancel(spellId); if (_player->GetCharm()) _player->GetCharm()->RemoveAurasDueToSpellByCancel(spellId); - else if (_player->GetFarsightTarget()->GetTypeId() != TYPEID_DYNAMICOBJECT) + else if (_player->GetFarsightTarget() && _player->GetFarsightTarget()->GetTypeId() != TYPEID_DYNAMICOBJECT) ((Unit*)_player->GetFarsightTarget())->RemoveAurasDueToSpellByCancel(spellId); return; } diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 07a0df04450..98585fceaaf 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -99,7 +99,7 @@ bool IsPassiveSpell(uint32 spellId) return (spellInfo->Attributes & SPELL_ATTR_PASSIVE) != 0; } -bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) +/*bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) { SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); @@ -113,7 +113,7 @@ bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_ return false; return true; -} +}*/ int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) { @@ -244,14 +244,24 @@ bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2) case SPELL_STING: case SPELL_CURSE: case SPELL_ASPECT: + case SPELL_POSITIVE_SHOUT: + case SPELL_JUDGEMENT: + case SPELL_WARLOCK_CORRUPTION: + return spellSpec1==spellSpec2; + default: + return false; + } +} + +bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1,uint32 spellSpec2) +{ + switch(spellSpec1) + { case SPELL_TRACKER: case SPELL_WARLOCK_ARMOR: case SPELL_MAGE_ARMOR: case SPELL_ELEMENTAL_SHIELD: case SPELL_MAGE_POLYMORPH: - case SPELL_POSITIVE_SHOUT: - case SPELL_JUDGEMENT: - case SPELL_WARLOCK_CORRUPTION: return spellSpec1==spellSpec2; case SPELL_BATTLE_ELIXIR: return spellSpec2==SPELL_BATTLE_ELIXIR @@ -1030,10 +1040,10 @@ bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo) return true; } -bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const +bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool sameCaster) const { - if(spellId_1 == spellId_2) // auras due to the same spell - return false; + //if(spellId_1 == spellId_2) // auras due to the same spell + // return false; SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); @@ -1041,22 +1051,65 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons if(!spellInfo_1 || !spellInfo_2) return false; + SpellSpecific spellId_spec_1 = GetSpellSpecific(spellId_1); + SpellSpecific spellId_spec_2 = GetSpellSpecific(spellId_2); + if (spellId_spec_1 && spellId_spec_2) + if (IsSingleFromSpellSpecificPerTarget(spellId_spec_1, spellId_spec_2) + ||(IsSingleFromSpellSpecificPerCaster(spellId_spec_1, spellId_spec_2) && sameCaster)) + return true; + if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) return false; - if(!spellInfo_1->SpellFamilyName) // generic spells + // generic spells + if(!spellInfo_1->SpellFamilyName) { if(!spellInfo_1->SpellIconID || spellInfo_1->SpellIconID != spellInfo_2->SpellIconID) return false; } - else if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) - return false; + + // if both elixirs are not battle/guardian/potions/flasks then always stack + else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION) + { + if(spellId_spec_1 || spellId_spec_2) + return false; + } + + // check for class spells + else + { + if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) + return false; + } for(uint32 i = 0; i < 3; ++i) + { if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i] - || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]) - return false; + || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i] + || spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i]) // paladin resist aura + return false; // need itemtype check? need an example to add that check + + if(spellInfo_1->EffectApplyAuraName[i] // both spell has the same auras + && !sameCaster + && spellInfo_1->Effect[i] != SPELL_EFFECT_APPLY_AREA_AURA_PARTY) // not area auras (shaman totem) + // a better check may be effect == SPELL_EFFECT_APPLY_AURA + { + switch(spellInfo_1->EffectApplyAuraName[i]) + { + // DOT or HOT from different casters will stack + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_PERIODIC_TRIGGER_SPELL: + case SPELL_AURA_PERIODIC_ENERGIZE: + case SPELL_AURA_PERIODIC_MANA_LEECH: + case SPELL_AURA_PERIODIC_LEECH: + return false; + default: + break; + } + } + } return true; } diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 7de9c54c6cb..6e3c5c3ddff 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -284,7 +284,7 @@ inline bool IsSpellHaveEffect(SpellEntry const *spellInfo, SpellEffects effect) return false; } -bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); +//bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); inline bool IsSealSpell(SpellEntry const *spellInfo) { @@ -300,7 +300,8 @@ inline bool IsElementalShield(SpellEntry const *spellInfo) } int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); -bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2); +bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1, uint32 spellSpec2); +bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1, uint32 spellSpec2); bool IsPassiveSpell(uint32 spellId); inline bool IsDeathPersistentSpell(SpellEntry const *spellInfo) @@ -768,7 +769,7 @@ class SpellMgr bool IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const; static bool canStackSpellRanks(SpellEntry const *spellInfo); - bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const; + bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool sameCaster) const; SpellEntry const* SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const; diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 0e766136696..3533c5c8a02 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -384,7 +384,7 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, fl weapon_mindamage = lvl*0.85*att_speed; weapon_maxdamage = lvl*1.25*att_speed; } - else if(!IsUseEquippedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc) + else if(!IsUseEquipedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc) { weapon_mindamage = BASE_MINDAMAGE; weapon_maxdamage = BASE_MAXDAMAGE; diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index 4f8b03827ae..73ae274644e 100644 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -97,6 +97,9 @@ void Totem::Summon(Unit* owner) case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break; default: break; } + + if(GetEntry() == SENTRY_TOTEM_ENTRY) + SetAggressive(true); } void Totem::UnSummon() diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index c54ab4b7f0d..bcdd771bcea 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1149,8 +1149,6 @@ void Unit::DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *da // Physical Damage if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL ) { - uint32 modDamage=*damage; - // apply spellmod to Done damage if(Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_DAMAGE, *damage); @@ -1435,7 +1433,7 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage { if(!this || !pVictim) return 0; - if(!this->isAlive() || !pVictim->isAlive()) + if(!isAlive() || !pVictim->isAlive()) return 0; SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); @@ -3798,7 +3796,6 @@ bool Unit::AddAura(Aura *Aur) if(Aur->GetSpellProto()->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) { m_ccAuras.push_back(Aur); - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); } } @@ -3914,32 +3911,18 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) if(!is_triggered_by_spell) { - SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); - - bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); - - if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) + bool sameCaster = Aur->GetCasterGUID() == (*i).second->GetCasterGUID(); + if( spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId, sameCaster) ) { - // cannot remove higher rank - if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) - if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) - return false; - - // Its a parent aura (create this aura in ApplyModifier) - if ((*i).second->IsInUse()) - { - sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); - continue; - } - RemoveAurasDueToSpell(i_spellId); + //some spells should be not removed by lower rank of them + // what is this spell? + if (!sameCaster + &&(spellProto->Effect[effIndex]==SPELL_EFFECT_APPLY_AREA_AURA_PARTY) + &&(spellProto->DurationIndex==21) + &&(spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) + &&(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)) + return false; - if( m_Auras.empty() ) - break; - else - next = m_Auras.begin(); - } - else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) - { // Its a parent aura (create this aura in ApplyModifier) if ((*i).second->IsInUse()) { @@ -3953,24 +3936,6 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) else next = m_Auras.begin(); } - // Potions stack aura by aura (elixirs/flask already checked) - else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION ) - { - if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex)) - { - if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) - return false; // cannot remove higher rank - - // Its a parent aura (create this aura in ApplyModifier) - if ((*i).second->IsInUse()) - { - sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); - continue; - } - RemoveAura(i); - next = i; - } - } } } return true; @@ -4144,12 +4109,17 @@ void Unit::RemoveNotOwnSingleTargetAuras() void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) { - if (IsSingleTargetSpell((*i).second->GetSpellProto())) + Aura* Aur = i->second; + SpellEntry const* AurSpellInfo = Aur->GetSpellProto(); + + Unit* caster = NULL; + if (IsSingleTargetSpell(AurSpellInfo)) { - if(Unit* caster = (*i).second->GetCaster()) + caster = Aur->GetCaster(); + if(caster) { AuraList& scAuras = caster->GetSingleCastAuras(); - scAuras.remove((*i).second); + scAuras.remove(Aur); } else { @@ -4158,7 +4128,8 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) } } - if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS) + // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) + if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) { m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); if((*i).second->GetSpellProto()->AuraInterruptFlags) @@ -4170,8 +4141,6 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) m_ccAuras.remove((*i).second); } - // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) - Aura* Aur = i->second; // Set remove mode Aur->SetRemoveMode(mode); // some ShapeshiftBoosts at remove trigger removing other auras including parent Shapeshift aura @@ -4179,13 +4148,22 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) m_Auras.erase(i); ++m_removedAuras; // internal count used by unit update - // Status unsummoned at aura remove + // Statue unsummoned at aura remove Totem* statue = NULL; - if(IsChanneledSpell(Aur->GetSpellProto())) - if(Unit* caster = Aur->GetCaster()) + bool caster_channeled = false; + if(IsChanneledSpell(AurSpellInfo)) + { + if(!caster) // can be already located for IsSingleTargetSpell case + caster = Aur->GetCaster(); + + if(caster) + { if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) statue = ((Totem*)caster); - + else + caster_channeled = caster==this; + } + } if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id)) { @@ -4203,6 +4181,9 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) Aur->_RemoveAura(); delete Aur; + if(caster_channeled) + RemoveAurasAtChanneledTarget (AurSpellInfo); + if(statue) statue->UnSummon(); @@ -4628,8 +4609,10 @@ void Unit::CastMeleeProcDamageAndSpell(Unit* pVictim, uint32 damage, SpellSchool ProcDamageAndSpell(pVictim, procAttacker, procVictim, damage, damageSchoolMask, spellCasted, isTriggeredSpell, attType); } -bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown) +bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 cooldown) { + SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto(); + Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; @@ -4689,8 +4672,11 @@ bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint return true; } -bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) +bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) { + SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); + uint32 effIndex = triggeredByAura->GetEffIndex (); + Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; @@ -6278,7 +6264,6 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB if(!pVictim || !pVictim->isAlive()) return false; - uint32 spell = 0; switch(triggeredByAura->GetSpellProto()->Id) { case 20186: @@ -6308,7 +6293,6 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB return false; // overwrite non existing triggered spell call in spell.dbc - uint32 spell = 0; switch(triggeredByAura->GetSpellProto()->Id) { case 20185: @@ -6508,8 +6492,10 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB return true; } -bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) +bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) { + int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; + if(!pVictim || !pVictim->isAlive()) return false; @@ -7275,7 +7261,7 @@ void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool c SendMessageToSet(&data, true); } -void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype, bool critical) +void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype) { WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); data.append(pVictim->GetPackGUID()); @@ -7375,7 +7361,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // ..taken AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) - if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) + if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto) ) TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; // .. taken pct: scripted (increases damage of * against targets *) @@ -8223,7 +8209,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT int32 TakenFlatBenefit = 0; // ..done (for creature type by mask) in taken - AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); + AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) DoneFlatBenefit += (*i)->GetModifier()->m_amount; @@ -8291,7 +8277,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT // SPELL_AURA_MOD_DAMAGE_PERCENT_DONE included in weapon damage // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage - AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); + AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; @@ -8521,7 +8507,8 @@ void Unit::CombatStart(Unit* target) if(!target->IsStandState() && !target->hasUnitState(UNIT_STAT_STUNNED)) target->SetStandState(PLAYER_STATE_NONE); - if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI()) + if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER + && ((Creature*)target)->isAggressive() && ((Creature*)target)->AI()) ((Creature*)target)->AI()->AttackStart(this); SetInCombatWith(target); @@ -8571,6 +8558,9 @@ bool Unit::canAttack(Unit const* target) const { assert(target); + if(!IsHostileTo(target)) + return false; + if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) return false; @@ -8746,7 +8736,7 @@ void Unit::SetVisibility(UnitVisibility x) if(IsInWorld()) { - Map *m = MapManager::Instance().GetMap(GetMapId(), this); + Map *m = GetMap(); if(GetTypeId()==TYPEID_PLAYER) m->PlayerRelocation((Player*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); @@ -9155,6 +9145,13 @@ bool Unit::SelectHostilTarget() } } + // search nearby enemy before enter evade mode + if(Unit *target = ((Creature*)this)->SelectNearestTarget()) + { + ((Creature*)this)->AI()->AttackStart(target); + return true; + } + // enter in evade mode in other case ((Creature*)this)->AI()->EnterEvadeMode(); @@ -9808,8 +9805,6 @@ void Unit::CleanupsBeforeDelete() RemoveFromWorld(); } - - CharmInfo* Unit::InitCharmInfo(Unit *charm) { if(!m_charmInfo) @@ -9984,17 +9979,15 @@ bool Unit::isFrozen() const struct ProcTriggeredData { - ProcTriggeredData(SpellEntry const * _spellInfo, uint32 _spellParam, Aura* _triggeredByAura, uint32 _cooldown) - : spellInfo(_spellInfo), spellParam(_spellParam), triggeredByAura(_triggeredByAura), + ProcTriggeredData(Aura* _triggeredByAura, uint32 _cooldown) + : triggeredByAura(_triggeredByAura), triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())), cooldown(_cooldown) - {} + {} - SpellEntry const * spellInfo; - uint32 spellParam; - Aura* triggeredByAura; - Unit::spellEffectPair triggeredByAura_SpellPair; - uint32 cooldown; + Aura* triggeredByAura; // triggred aura, can be invalidate at triggered aura proccessing + Unit::spellEffectPair triggeredByAura_SpellPair; // spell pair, used for re-find aura (by pointer comparison in range) + uint32 cooldown; // possible hidden cooldown }; typedef std::list< ProcTriggeredData > ProcTriggeredList; @@ -10011,87 +10004,13 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag { next = i; ++next; - SpellEntry const *spellProto = (*i)->GetSpellProto(); - if(!spellProto) - continue; - - SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); - if(!spellProcEvent) - { - // used to prevent spam in log about same non-handled spells - static std::set<uint32> nonHandledSpellProcSet; + Aura* i_aura = *i; - if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) - { - sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); - nonHandledSpellProcSet.insert(spellProto->Id); - } - - // spell.dbc use totally different flags, that only can create problems if used. + uint32 cooldown; // returned at next line + if(!IsTriggeredAtSpellProcEvent(i_aura->GetSpellProto(), procSpell, procFlag,attType,isVictim,cooldown)) continue; - } - - // Check spellProcEvent data requirements - if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) - continue; - - // Check if current equipment allows aura to proc - if(!isVictim && GetTypeId() == TYPEID_PLAYER ) - { - if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) - { - Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); - - if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) - continue; - } - else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) - { - // Check if player is wearing shield - Item *item = ((Player*)this)->GetShield(true); - if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) - continue; - } - } - - float chance = (float)spellProto->procChance; - - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); - - if(!isVictim && spellProcEvent->ppmRate != 0) - { - uint32 WeaponSpeed = GetAttackTime(attType); - chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); - } - - if(roll_chance_f(chance)) - { - uint32 cooldown = spellProcEvent->cooldown; - - uint32 i_spell_eff = (*i)->GetEffIndex(); - - int32 i_spell_param; - switch(*aur) - { - case SPELL_AURA_PROC_TRIGGER_SPELL: - i_spell_param = procFlag; - break; - case SPELL_AURA_DUMMY: - case SPELL_AURA_PRAYER_OF_MENDING: - case SPELL_AURA_MOD_HASTE: - i_spell_param = i_spell_eff; - break; - case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: - i_spell_param = (*i)->GetModifier()->m_miscvalue; - break; - default: - i_spell_param = (*i)->GetModifier()->m_amount; - break; - } - procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) ); - } + procTriggered.push_back( ProcTriggeredData(i_aura, cooldown) ); } // Handle effects proceed this time @@ -10124,106 +10043,71 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag } } - // save charges existence before processing to prevent crash at access to deleted triggered aura after - bool triggeredByAuraWithCharges = i->triggeredByAura->m_procCharges > 0; + /// this is aura triggering code call + Aura* triggeredByAura = i->triggeredByAura; + + /// save charges existence before processing to prevent crash at access to deleted triggered aura after + /// used in speedup code check before check aura existance. + bool triggeredByAuraWithCharges = triggeredByAura->m_procCharges > 0; + /// success in event proccesing + /// used in speedup code check before check aura existance. bool casted = false; + + /// process triggered code switch(*aur) { case SPELL_AURA_PROC_TRIGGER_SPELL: { - sLog.outDebug("ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown); + sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s proc aura of spell %u)", + (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); + casted = HandleProcTriggerSpell(pTarget, damage, triggeredByAura, procSpell, procFlag, attType, i->cooldown); break; } case SPELL_AURA_PROC_TRIGGER_DAMAGE: { - sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", i->spellParam, i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - uint32 damage = i->spellParam; - SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true); + uint32 triggered_damage = triggeredByAura->GetModifier()->m_amount; + sLog.outDebug("ProcDamageAndSpell: doing %u damage (triggered by %s aura of spell %u)", + triggered_damage, (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); + SpellNonMeleeDamageLog(pTarget, triggeredByAura->GetId(), triggered_damage, true, true); casted = true; break; } case SPELL_AURA_DUMMY: { - sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); + uint32 effect = triggeredByAura->GetEffIndex(); + sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s dummy aura of spell %u)", + (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); + casted = HandleDummyAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); break; } case SPELL_AURA_PRAYER_OF_MENDING: { - sLog.outDebug("ProcDamageAndSpell(mending): casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - - // aura can be deleted at casts - int32 heal = i->triggeredByAura->GetModifier()->m_amount; - uint64 caster_guid = i->triggeredByAura->GetCasterGUID(); - - // jumps - int32 jumps = i->triggeredByAura->m_procCharges-1; - - // current aura expire - i->triggeredByAura->m_procCharges = 1; // will removed at next charges decrease - - // next target selection - if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) - { - Aura* aura = i->triggeredByAura; - - SpellEntry const* spellProto = aura->GetSpellProto(); - uint32 effIdx = aura->GetEffIndex(); - - float radius; - if (spellProto->EffectRadiusIndex[effIdx]) - radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); - else - radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); - - if(Player* caster = ((Player*)aura->GetCaster())) - { - caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); - - if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) - { - // aura will applied from caster, but spell casted from current aura holder - SpellModifier *mod = new SpellModifier; - mod->op = SPELLMOD_CHARGES; - mod->value = jumps-5; // negative - mod->type = SPELLMOD_FLAT; - mod->spellId = spellProto->Id; - mod->effectId = effIdx; - mod->lastAffected = NULL; - mod->mask = spellProto->SpellFamilyFlags; - mod->charges = 0; - - caster->AddSpellMod(mod, true); - CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID()); - caster->AddSpellMod(mod, false); - } - } - } + sLog.outDebug("ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)", + (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); - // heal - CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); - casted = true; + casted = HandleMeandingAuraProc(triggeredByAura); break; } case SPELL_AURA_MOD_HASTE: { - sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s haste aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); + sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s haste aura of spell %u)", + (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); + casted = HandleHasteAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); break; } case SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN: { // nothing do, just charges counter // but count only in case appropriate school damage - casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; + casted = triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; break; } case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: { - sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown); + sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s class script aura of spell %u)", + (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); + casted = HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell,i->cooldown); break; } default: @@ -10234,27 +10118,27 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag } } - // Update charge (aura can be removed by triggers) + /// Update charge (aura can be removed by triggers) if(casted && triggeredByAuraWithCharges) { - // need found aura (can be dropped by triggers) + /// need re-found aura (can be dropped by triggers) AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) { - if(itr->second == i->triggeredByAura) + if(itr->second == triggeredByAura) // pointer still valid { - if(i->triggeredByAura->m_procCharges > 0) - i->triggeredByAura->m_procCharges -= 1; + if(triggeredByAura->m_procCharges > 0) + triggeredByAura->m_procCharges -= 1; - i->triggeredByAura->UpdateAuraCharges(); + triggeredByAura->UpdateAuraCharges(); break; } } } } - // Safely remove auras with zero charges + /// Safely remove auras with zero charges for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) { next = i; ++next; @@ -10367,7 +10251,7 @@ void Unit::StopMoving() // send explicit stop packet // rely on vmaps here because for example stormwind is in air - float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); + //float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); //if (fabs(GetPositionZ() - z) < 2.0f) // Relocate(GetPositionX(), GetPositionY(), z); Relocate(GetPositionX(), GetPositionY(),GetPositionZ()); @@ -10577,7 +10461,7 @@ void Unit::UpdateReactives( uint32 p_time ) } } -Unit* Unit::SelectNearbyTarget() const +Unit* Unit::SelectNearbyTarget(float dist) const { CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); Cell cell(p); @@ -10587,7 +10471,7 @@ Unit* Unit::SelectNearbyTarget() const std::list<Unit *> targets; { - Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE); + Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist); Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(targets, u_check); TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); @@ -10851,9 +10735,9 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) return NULL; } - pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID()); - pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID()); - pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction()); + pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()); + pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID()); + pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,getFaction()); pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); if(!pet->InitStatsForLevel(creatureTarget->getLevel())) @@ -10871,3 +10755,132 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) return pet; } + +bool Unit::IsTriggeredAtSpellProcEvent(SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ) +{ + SpellProcEventEntry const * spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); + + if(!spellProcEvent) + { + // used to prevent spam in log about same non-handled spells + static std::set<uint32> nonHandledSpellProcSet; + + if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) + { + sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); + nonHandledSpellProcSet.insert(spellProto->Id); + } + + // spell.dbc use totally different flags, that only can create problems if used. + return false; + } + + // Check spellProcEvent data requirements + if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) + return false; + + // Check if current equipment allows aura to proc + if(!isVictim && GetTypeId() == TYPEID_PLAYER ) + { + if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) + { + Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); + + if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + return false; + } + else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) + { + // Check if player is wearing shield + Item *item = ((Player*)this)->GetShield(true); + if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + return false; + } + } + + float chance = (float)spellProto->procChance; + + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); + + if(!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0) + { + uint32 WeaponSpeed = GetAttackTime(attType); + chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); + } + + cooldown = spellProcEvent ? spellProcEvent->cooldown : 0; + return roll_chance_f(chance); +} + +bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura ) +{ + // aura can be deleted at casts + SpellEntry const* spellProto = triggeredByAura->GetSpellProto(); + uint32 effIdx = triggeredByAura->GetEffIndex(); + int32 heal = triggeredByAura->GetModifier()->m_amount; + uint64 caster_guid = triggeredByAura->GetCasterGUID(); + + // jumps + int32 jumps = triggeredByAura->m_procCharges-1; + + // current aura expire + triggeredByAura->m_procCharges = 1; // will removed at next charges decrease + + // next target selection + if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) + { + float radius; + if (spellProto->EffectRadiusIndex[effIdx]) + radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); + else + radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); + + if(Player* caster = ((Player*)triggeredByAura->GetCaster())) + { + caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); + + if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) + { + // aura will applied from caster, but spell casted from current aura holder + SpellModifier *mod = new SpellModifier; + mod->op = SPELLMOD_CHARGES; + mod->value = jumps-5; // negative + mod->type = SPELLMOD_FLAT; + mod->spellId = spellProto->Id; + mod->effectId = effIdx; + mod->lastAffected = NULL; + mod->mask = spellProto->SpellFamilyFlags; + mod->charges = 0; + + caster->AddSpellMod(mod, true); + CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,triggeredByAura,caster->GetGUID()); + caster->AddSpellMod(mod, false); + } + } + } + + // heal + CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); + return true; +} + +void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo) +{ + uint64 target_guid = GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT); + + if(!IS_UNIT_GUID(target_guid)) + return; + + Unit* target = ObjectAccessor::GetUnit(*this, target_guid); + if(!target) + return; + + for (AuraMap::iterator iter = target->GetAuras().begin(); iter != target->GetAuras().end(); ) + { + if (iter->second->GetId() == spellInfo->Id && iter->second->GetCasterGUID()==GetGUID()) + target->RemoveAura(iter); + else + ++iter; + } +} diff --git a/src/game/Unit.h b/src/game/Unit.h index e9e44804444..5ae34624c96 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __UNIT_H @@ -763,7 +763,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject Unit* getVictim() const { return m_attacking; } void CombatStop(bool cast = false); void CombatStopWithPets(bool cast = false); - Unit* SelectNearbyTarget() const; + Unit* SelectNearbyTarget(float dist = ATTACK_DISTANCE) const; void addUnitState(uint32 f) { m_state |= f; } bool hasUnitState(const uint32 f) const { return (m_state & f); } @@ -934,7 +934,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject bool isInAccessiblePlaceFor(Creature const* c) const; void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false); - void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype, bool critical = false); + void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype); uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true); void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); @@ -1040,6 +1040,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler); void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); void RemoveAurasDueToSpellByCancel(uint32 spellId); + void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo); void RemoveNotOwnSingleTargetAuras(); void RemoveSpellsCausingAura(AuraType auraType); @@ -1371,10 +1372,12 @@ class TRINITY_DLL_SPEC Unit : public WorldObject //void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*) void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ); - bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); - bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown); - bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); - bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell,uint32 cooldown); + bool IsTriggeredAtSpellProcEvent( SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ); + bool HandleDummyAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); + bool HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, uint32 cooldown); + bool HandleHasteAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); + bool HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 cooldown); + bool HandleMeandingAuraProc(Aura* triggeredByAura); uint32 m_state; // Even derived shouldn't modify uint32 m_CombatTimer; diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index d72ac1e266e..a6dda2477ff 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Database/DatabaseEnv.h" @@ -24,20 +24,30 @@ #include "WaypointManager.h" #include "ProgressBar.h" #include "MapManager.h" +#include "ObjectMgr.h" INSTANTIATE_SINGLETON_1(WaypointManager); bool WaypointBehavior::isEmpty() { - return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() && - text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty(); + if (emote || spell || model1 || model2) + return false; + + for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + if(textid[i]) + return false; + + return true; } WaypointBehavior::WaypointBehavior(const WaypointBehavior &b) { - emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2; - text[0] = b.text[0]; text[1] = b.text[1]; text[2] = b.text[2]; - text[3] = b.text[3]; text[4] = b.text[4]; + emote = b.emote; + spell = b.spell; + model1 = b.model1; + model2 = b.model2; + for(int i=0; i < MAX_WAYPOINT_TEXT; ++i) + textid[i] = b.textid[i]; } void WaypointManager::Load() @@ -66,7 +76,7 @@ void WaypointManager::Load() delete result; } - result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id, point FROM creature_movement"); + result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement"); if(result) { barGoLink bar( result->GetRowCount() ); @@ -113,11 +123,33 @@ void WaypointManager::Load() be.model2 = fields[5].GetUInt32(); be.emote = fields[7].GetUInt32(); be.spell = fields[8].GetUInt32(); - be.text[0] = fields[9].GetCppString(); - be.text[1] = fields[10].GetCppString(); - be.text[2] = fields[11].GetCppString(); - be.text[3] = fields[12].GetCppString(); - be.text[4] = fields[13].GetCppString(); + + // load and store without holes in array + int j = 0; + for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + { + be.textid[j] = fields[9+i].GetUInt32(); + if(be.textid[j]) + { + if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID) + { + sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[j]); + continue; + } + + if (!objmgr.GetTrinityStringLocale (be.textid[j])) + { + sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.", + id, point, be.textid[j], i+1); + continue; + } + + ++j; // to next internal field + } + } + // fill array tail + for(; j < MAX_WAYPOINT_TEXT; ++j) + be.textid[j] = 0; // save memory by not storing empty behaviors if(!be.isEmpty()) @@ -265,11 +297,11 @@ void WaypointManager::SetNodeText(uint32 id, uint32 point, const char *text_fiel WaypointNode &node = itr->second[point-1]; if(!node.behavior) node.behavior = new WaypointBehavior(); - if(field == "text1") node.behavior->text[0] = text ? text : ""; - if(field == "text2") node.behavior->text[1] = text ? text : ""; - if(field == "text3") node.behavior->text[2] = text ? text : ""; - if(field == "text4") node.behavior->text[3] = text ? text : ""; - if(field == "text5") node.behavior->text[4] = text ? text : ""; +// if(field == "text1") node.behavior->text[0] = text ? text : ""; +// if(field == "text2") node.behavior->text[1] = text ? text : ""; +// if(field == "text3") node.behavior->text[2] = text ? text : ""; +// if(field == "text4") node.behavior->text[3] = text ? text : ""; +// if(field == "text5") node.behavior->text[4] = text ? text : ""; if(field == "emote") node.behavior->emote = text ? atoi(text) : 0; if(field == "spell") node.behavior->spell = text ? atoi(text) : 0; if(field == "model1") node.behavior->model1 = text ? atoi(text) : 0; diff --git a/src/game/WaypointManager.h b/src/game/WaypointManager.h index 2fdf5622c2e..75f01cc82f3 100644 --- a/src/game/WaypointManager.h +++ b/src/game/WaypointManager.h @@ -25,11 +25,12 @@ #include <string> #include "Utilities/UnorderedMap.h" +#define MAX_WAYPOINT_TEXT 5 struct WaypointBehavior { uint32 emote; uint32 spell; - std::string text[5]; + int32 textid[MAX_WAYPOINT_TEXT]; uint32 model1; uint32 model2; diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index ef3a8a04ef3..7969c375e81 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -21,11 +21,11 @@ /* creature_movement Table -alter table creature_movement add `text1` varchar(255) default NULL; -alter table creature_movement add `text2` varchar(255) default NULL; -alter table creature_movement add `text3` varchar(255) default NULL; -alter table creature_movement add `text4` varchar(255) default NULL; -alter table creature_movement add `text5` varchar(255) default NULL; +alter table creature_movement add `textid1` int(11) NOT NULL default '0'; +alter table creature_movement add `textid2` int(11) NOT NULL default '0'; +alter table creature_movement add `textid3` int(11) NOT NULL default '0'; +alter table creature_movement add `textid4` int(11) NOT NULL default '0'; +alter table creature_movement add `textid5` int(11) NOT NULL default '0'; alter table creature_movement add `emote` int(10) unsigned default '0'; alter table creature_movement add `spell` int(5) unsigned default '0'; alter table creature_movement add `wpguid` int(11) default '0'; @@ -148,22 +148,21 @@ WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint32 &di creature.CastSpell(&creature,behavior->spell, false); if(behavior->model1 != 0) creature.SetDisplayId(behavior->model1); - if(!behavior->text[0].empty()) + if(behavior->textid[0]) { - // Only one text is set - if( !behavior->text[1].empty() ) + // Not only one text is set + if( behavior->textid[1] ) { // Select one from max 5 texts (0 and 1 already checked) int i = 2; - for( ; i < 5; ++i ) - if( behavior->text[i].empty() ) + for( ; i < MAX_WAYPOINT_TEXT; ++i ) + if( !behavior->textid[i] ) break; - creature.Say(behavior->text[rand() % i].c_str(), 0, 0); - + creature.Say(behavior->textid[rand() % i], 0, 0); } else - creature.Say(behavior->text[0].c_str(), 0, 0); + creature.Say(behavior->textid[0], 0, 0); } } // wpBehaviour found i_hasDone[idx] = true; diff --git a/src/game/World.cpp b/src/game/World.cpp index d6017ac0669..64c2bd49099 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** \file @@ -66,6 +66,7 @@ INSTANTIATE_SINGLETON_1( World ); volatile bool World::m_stopEvent = false; +uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; volatile uint32 World::m_worldLoopCounter = 0; float World::m_MaxVisibleDistanceForCreature = DEFAULT_VISIBILITY_DISTANCE; @@ -542,7 +543,6 @@ void World::LoadConfigSettings(bool reload) else m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); - m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50); @@ -605,7 +605,6 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_SKIP_CINEMATICS] = 0; } - if(reload) { uint32 val = sConfig.GetIntDefault("MaxPlayerLevel", 60); @@ -769,8 +768,8 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); - // always use declined names in the Russian client - m_configs[CONFIG_DECLINED_NAMES_USED] = + // always use declined names in the russian client + m_configs[CONFIG_DECLINED_NAMES_USED] = (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); m_configs[CONFIG_LISTEN_RANGE_SAY] = sConfig.GetIntDefault("ListenRange.Say", 25); @@ -965,6 +964,9 @@ void World::SetInitialWorldSettings() LoadDBCStores(m_dataPath); DetectDBCLang(); + sLog.outString( "Loading Script Names..."); + objmgr.LoadScriptNames(); + sLog.outString( "Loading InstanceTemplate" ); objmgr.LoadInstanceTemplate(); @@ -1080,11 +1082,10 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading Tavern Area Triggers..." ); objmgr.LoadTavernAreaTriggers(); - + sLog.outString( "Loading AreaTrigger script names..." ); objmgr.LoadAreaTriggerScripts(); - sLog.outString( "Loading Graveyard-zone links..."); objmgr.LoadGraveyardZones(); @@ -1164,7 +1165,7 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading Npc Text Id..." ); objmgr.LoadNpcTextId(); // must be after load Creature and NpcText - + sLog.outString( "Loading Npc Options..." ); objmgr.LoadNpcOptions(); @@ -1192,6 +1193,9 @@ void World::SetInitialWorldSettings() objmgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data) objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) + sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls + objmgr.LoadDbScriptStrings(); + sLog.outString( "Initializing Scripts..." ); if(!LoadScriptingModule()) exit(1); @@ -1262,6 +1266,7 @@ void World::SetInitialWorldSettings() sLog.outString( "WORLD: World initialized" ); } + void World::DetectDBCLang() { uint32 m_lang_confid = sConfig.GetIntDefault("DBC.Locale", 255); @@ -1462,7 +1467,9 @@ void World::Update(time_t diff) m_timers[WUPDATE_EVENTS].Reset(); } - MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" + /// </ul> + ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" + MapManager::Instance().DoDelayedMovesAndRemoves(); // update the instance reset times sInstanceSaveManager.Update(); @@ -1582,6 +1589,8 @@ void World::ScriptsProcess() } } + //if(source && !source->IsInWorld()) source = NULL; + Object* target = NULL; if(step.targetGUID) @@ -1609,6 +1618,8 @@ void World::ScriptsProcess() } } + //if(target && !target->IsInWorld()) target = NULL; + switch (step.script->command) { case SCRIPT_COMMAND_TALK: @@ -1636,7 +1647,7 @@ void World::ScriptsProcess() switch(step.script->datalong) { case 0: // Say - ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); + ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); break; case 1: // Whisper if(!unit_target) @@ -1644,13 +1655,13 @@ void World::ScriptsProcess() sLog.outError("SCRIPT_COMMAND_TALK attempt to whisper (%u) NULL, skipping.",step.script->datalong); break; } - ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target); + ((Creature *)source)->Whisper(step.script->dataint,unit_target); break; case 2: // Yell - ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); + ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); break; case 3: // Emote text - ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target); + ((Creature *)source)->TextEmote(step.script->dataint, unit_target); break; default: break; // must be already checked at load @@ -1701,7 +1712,7 @@ void World::ScriptsProcess() break; } ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); - MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); + ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); break; case SCRIPT_COMMAND_FLAG_SET: if(!source) @@ -1851,7 +1862,7 @@ void World::ScriptsProcess() go->SetLootState(GO_READY); go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds - MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); + go->GetMap()->Add(go); break; } case SCRIPT_COMMAND_OPEN_DOOR: @@ -2373,13 +2384,13 @@ void World::_UpdateGameTime() m_gameTime = thisTime; ///- if there is a shutdown timer - if(m_ShutdownTimer > 0 && elapsed > 0) + if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) { ///- ... and it is overdue, stop the world (set m_stopEvent) if( m_ShutdownTimer <= elapsed ) { if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) - m_stopEvent = true; + m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; // minimum timer value to wait idle state } @@ -2394,15 +2405,20 @@ void World::_UpdateGameTime() } /// Shutdown the server -void World::ShutdownServ(uint32 time, uint32 options) +void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) { + // ignore if server shutdown at next tick + if(m_stopEvent) + return; + m_ShutdownMask = options; + m_ExitCode = exitcode; ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) if(time==0) { if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) - m_stopEvent = true; + m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick } @@ -2447,16 +2463,18 @@ void World::ShutdownMsg(bool show, Player* player) /// Cancel a planned server shutdown void World::ShutdownCancel() { - if(!m_ShutdownTimer) + // nothing cancel or too later + if(!m_ShutdownTimer || m_stopEvent) return; uint32 msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED; m_ShutdownMask = 0; m_ShutdownTimer = 0; + m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value SendServerMessage(msgid); - DEBUG_LOG("Server %s canceled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); + DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); } /// Send a server message to the user(s) @@ -2501,6 +2519,7 @@ void World::UpdateSessions( time_t diff ) ///- and remove not active sessions from the list if(!itr->second->Update(diff)) // As interval = 0 { + RemoveQueuedPlayer (itr->second); delete itr->second; m_sessions.erase(itr); } diff --git a/src/game/World.h b/src/game/World.h index c1ceb6891a5..50065b360dd 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /// \addtogroup world The World @@ -51,6 +51,13 @@ enum ShutdownMask SHUTDOWN_MASK_IDLE = 2, }; +enum ShutdownExitCode +{ + SHUTDOWN_EXIT_CODE = 0, + ERROR_EXIT_CODE = 1, + RESTART_EXIT_CODE = 2, +}; + /// Timers for different object refresh rates enum WorldTimers { @@ -61,8 +68,7 @@ enum WorldTimers WUPDATE_UPTIME = 4, WUPDATE_CORPSES = 5, WUPDATE_EVENTS = 6, - WUPDATE_COUNT = 7, - + WUPDATE_COUNT = 7 }; /// Configuration elements @@ -105,6 +111,8 @@ enum WorldConfigs CONFIG_INSTANCE_IGNORE_LEVEL, CONFIG_INSTANCE_IGNORE_RAID, CONFIG_BATTLEGROUND_CAST_DESERTER, + CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, + CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY, CONFIG_INSTANCE_RESET_TIME_HOUR, CONFIG_INSTANCE_UNLOAD_DELAY, CONFIG_CAST_UNSTUCK, @@ -143,6 +151,7 @@ enum WorldConfigs CONFIG_WORLD_BOSS_LEVEL_DIFF, CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, + CONFIG_DETECT_POS_COLLISION, CONFIG_RESTRICTED_LFG_CHANNEL, CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, CONFIG_TALENTS_INSPECTING, @@ -316,27 +325,26 @@ enum RealmZone /// Storage class for commands issued for delayed execution struct CliCommandHolder { - typedef void Print(const char*); + typedef void Print(const char*); - char *m_command; - Print* m_print; + char *m_command; + Print* m_print; - CliCommandHolder(const char *command, Print* zprint) - : m_print(zprint) - { - size_t len = strlen(command)+1; - m_command = new char[len]; - memcpy(m_command, command, len); - } + CliCommandHolder(const char *command, Print* zprint) + : m_print(zprint) + { + size_t len = strlen(command)+1; + m_command = new char[len]; + memcpy(m_command, command, len); + } - ~CliCommandHolder() { delete[] m_command; } + ~CliCommandHolder() { delete[] m_command; } }; /// The World class World { public: - static volatile bool m_stopEvent; static volatile uint32 m_worldLoopCounter; World(); @@ -344,7 +352,6 @@ class World WorldSession* FindSession(uint32 id) const; void AddSession(WorldSession *s); - bool RemoveSession(uint32 id); /// Get the number of current active sessions void UpdateMaxSessionCounters(); @@ -407,18 +414,20 @@ class World void SetInitialWorldSettings(); void LoadConfigSettings(bool reload = false); - void SendWorldText(int32 string_id, ...); + void SendWorldText(int32 string_id, ...); void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); void SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); void SendZoneText(uint32 zone, const char *text, WorldSession *self = 0, uint32 team = 0); void SendServerMessage(uint32 type, const char *text = "", Player* player = NULL); /// Are we in the middle of a shutdown? - uint32 GetShutdownMask() const { return m_ShutdownMask; } bool IsShutdowning() const { return m_ShutdownTimer > 0; } - void ShutdownServ(uint32 time, uint32 options = 0); + void ShutdownServ(uint32 time, uint32 options, uint8 exitcode); void ShutdownCancel(); void ShutdownMsg(bool show = false, Player* player = NULL); + static uint8 GetExitCode() { return m_ExitCode; } + static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; } + static bool IsStopped() { return m_stopEvent; } void Update(time_t diff); @@ -453,7 +462,7 @@ class World void KickAllLess(AccountTypes sec); void KickAllQueued(); BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); - bool RemoveBanAccount(BanMode mode, std::string nameOrIP); + bool RemoveBanAccount(BanMode mode, std::string nameOrIP); void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target); void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target); @@ -481,13 +490,13 @@ class World LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } - //used World DB version - void LoadDBVersion(); - char const* GetDBVersion() { return m_DBVersion.c_str(); } + //used World DB version + void LoadDBVersion(); + char const* GetDBVersion() { return m_DBVersion.c_str(); } - //used Script version - void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; } - char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); } + //used Script version + void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; } + char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); } protected: void _UpdateGameTime(); @@ -498,6 +507,11 @@ class World void InitDailyQuestResetTime(); void ResetDailyQuests(); private: + static volatile bool m_stopEvent; + static uint8 m_ExitCode; + uint32 m_ShutdownTimer; + uint32 m_ShutdownMask; + time_t m_startTime; time_t m_gameTime; IntervalTimer m_timers[WUPDATE_COUNT]; @@ -525,9 +539,6 @@ class World std::string m_dataPath; std::set<uint32> m_forbiddenMapIds; - uint32 m_ShutdownTimer; - uint32 m_ShutdownMask; - // for max speed access static float m_MaxVisibleDistanceForCreature; static float m_MaxVisibleDistanceForPlayer; @@ -545,14 +556,14 @@ class World //Player Queue Queue m_QueuedPlayer; - + //sessions that are added async void AddSession_(WorldSession* s); ZThread::LockedQueue<WorldSession*, ZThread::FastMutex> addSessQueue; - //used versions - std::string m_DBVersion; - std::string m_ScriptsVersion; + //used versions + std::string m_DBVersion; + std::string m_ScriptsVersion; }; extern uint32 realmID; diff --git a/src/shared/Database/DBCEnums.h b/src/shared/Database/DBCEnums.h new file mode 100644 index 00000000000..6ad7fdb127a --- /dev/null +++ b/src/shared/Database/DBCEnums.h @@ -0,0 +1,104 @@ +/* +* Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef DBCENUMS_H +#define DBCENUMS_H + +enum AreaTeams +{ + AREATEAM_NONE = 0, + AREATEAM_ALLY = 2, + AREATEAM_HORDE = 4 +}; + +enum AreaFlags +{ + AREA_FLAG_SNOW = 0x00000001, // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring) + AREA_FLAG_UNK1 = 0x00000002, // unknown, (only Naxxramas and Razorfen Downs) + AREA_FLAG_UNK2 = 0x00000004, // Only used on development map + AREA_FLAG_SLAVE_CAPITAL = 0x00000008, // slave capital city flag? + AREA_FLAG_UNK3 = 0x00000010, // unknown + AREA_FLAG_SLAVE_CAPITAL2 = 0x00000020, // slave capital city flag? + AREA_FLAG_UNK4 = 0x00000040, // many zones have this flag + AREA_FLAG_ARENA = 0x00000080, // arena, both instanced and world arenas + AREA_FLAG_CAPITAL = 0x00000100, // main capital city flag + AREA_FLAG_CITY = 0x00000200, // only for one zone named "City" (where it located?) + AREA_FLAG_OUTLAND = 0x00000400, // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag) + AREA_FLAG_SANCTUARY = 0x00000800, // sanctuary area (PvP disabled) + AREA_FLAG_NEED_FLY = 0x00001000, // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway + AREA_FLAG_UNUSED1 = 0x00002000, // not used now (no area/zones with this flag set in 2.4.2) + AREA_FLAG_OUTLAND2 = 0x00004000, // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag) + AREA_FLAG_PVP = 0x00008000, // pvp objective area? (Death's Door also has this flag although it's no pvp object area) + AREA_FLAG_ARENA_INSTANCE = 0x00010000, // used by instanced arenas only + AREA_FLAG_UNUSED2 = 0x00020000, // not used now (no area/zones with this flag set in 2.4.2) + AREA_FLAG_UNK5 = 0x00040000, // just used for Amani Pass, Hatchet Hills + AREA_FLAG_LOWLEVEL = 0x00100000 // used for some starting areas with area_level <=15 +}; + +enum FactionTemplateFlags +{ + FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats +}; + +enum FactionMasks +{ + FACTION_MASK_PLAYER = 1, // any player + FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team + FACTION_MASK_HORDE = 4, // player or creature from horde team + FACTION_MASK_MONSTER = 8 // aggressive creature from monster team + // if none flags set then non-aggressive creature +}; + +enum MapTypes +{ + MAP_COMMON = 0, + MAP_INSTANCE = 1, + MAP_RAID = 2, + MAP_BATTLEGROUND = 3, + MAP_ARENA = 4 +}; + +enum AbilytyLearnType +{ + ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, + ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2 +}; + +enum ItemEnchantmentType +{ + ITEM_ENCHANTMENT_TYPE_NONE = 0, + ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1, + ITEM_ENCHANTMENT_TYPE_DAMAGE = 2, + ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL = 3, + ITEM_ENCHANTMENT_TYPE_RESISTANCE = 4, + ITEM_ENCHANTMENT_TYPE_STAT = 5, + ITEM_ENCHANTMENT_TYPE_TOTEM = 6 +}; + +enum TotemCategoryType +{ + TOTEM_CATEGORY_TYPE_KNIFE = 1, + TOTEM_CATEGORY_TYPE_TOTEM = 2, + TOTEM_CATEGORY_TYPE_ROD = 3, + TOTEM_CATEGORY_TYPE_PICK = 21, + TOTEM_CATEGORY_TYPE_STONE = 22, + TOTEM_CATEGORY_TYPE_HAMMER = 23, + TOTEM_CATEGORY_TYPE_SPANNER = 24 +}; + +#endif diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index 020cd53e61d..71e3483a1ab 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "DBCStores.h" @@ -121,21 +121,9 @@ DBCStorage <TaxiPathEntry> sTaxiPathStore(TaxiPathEntryfmt); // DBC used only for initialization sTaxiPathSetBySource at startup. TaxiPathNodesByPath sTaxiPathNodesByPath; -struct TaxiPathNodeEntry -{ - uint32 path; - uint32 index; - uint32 mapid; - float x; - float y; - float z; - uint32 actionFlag; - uint32 delay; -}; -static DBCStorage <TaxiPathNodeEntry> sTaxiPathNodeStore(TaxiPathNodeEntryfmt); +static DBCStorage <TaxiPathNodeEntry> sTaxiPathNodeStore(TaxiPathNodeEntryfmt); DBCStorage <TotemCategoryEntry> sTotemCategoryStore(TotemCategoryEntryfmt); - DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore(WorldMapAreaEntryfmt); DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt); @@ -235,7 +223,7 @@ void LoadDBCStores(std::string dataPath) flist.push_back(i); } } - + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore, dbcPath,"FactionTemplate.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore, dbcPath,"GemProperties.dbc"); @@ -283,21 +271,21 @@ void LoadDBCStores(std::string dataPath) for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) { SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - + if(!skillLine) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); if(spellInfo && (spellInfo->Attributes & 0x1D0) == 0x1D0) - { + { for (unsigned int i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i) { CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i); if(!cFamily) continue; - if(skillLine->skillId != cFamily->skillLine && skillLine->skillId != cFamily->skillLine2) + if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1]) continue; sPetFamilySpellsStore[i].insert(spellInfo->Id); @@ -309,7 +297,6 @@ void LoadDBCStores(std::string dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore, dbcPath,"SpellDuration.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore, dbcPath,"SpellFocusObject.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRadiusStore, dbcPath,"SpellRadius.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRangeStore, dbcPath,"SpellRange.dbc"); @@ -455,11 +442,11 @@ void LoadDBCStores(std::string dataPath) // check at up-to-date DBC files (2425 is last item extended cost added in 2.4.3) // check at up-to-date DBC files (71 is last char title added in 2.4.3) // check at up-to-date DBC files (1768 is last area added in 2.4.3) - if( !sSpellStore.LookupEntry(53085) || - !sSkillLineAbilityStore.LookupEntry(17514) || + if( !sSpellStore.LookupEntry(53085) || + !sSkillLineAbilityStore.LookupEntry(17514) || !sMapStore.LookupEntry(598) || - !sGemPropertiesStore.LookupEntry(1127) || - !sItemExtendedCostStore.LookupEntry(2425) || + !sGemPropertiesStore.LookupEntry(1127) || + !sItemExtendedCostStore.LookupEntry(2425) || !sCharTitlesStore.LookupEntry(71) || !sAreaStore.LookupEntry(1768) ) { diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h index 2c17935d9f5..0375f20c7eb 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/shared/Database/DBCStores.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DBCSTORES_H @@ -75,7 +75,6 @@ class DBCStorage bool Load(char const* fn) { - DBCFile dbc; // Check if load was sucessful, only then continue if(!dbc.Load(fn, fmt)) diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index b57b031ef55..a71f80ac8c7 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -10,17 +10,18 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DBCSTRUCTURE_H #define DBCSTRUCTURE_H +#include "DBCEnums.h" #include "Platform/Define.h" #include <map> @@ -36,42 +37,6 @@ #pragma pack(push,1) #endif -enum AreaTeams -{ - AREATEAM_NONE = 0, - AREATEAM_ALLY = 2, - AREATEAM_HORDE = 4 -}; - -enum AreaFlags -{ - AREA_FLAG_SNOW = 0x00000001, // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring) - AREA_FLAG_UNK1 = 0x00000002, // unknown, (only Naxxramas and Razorfen Downs) - AREA_FLAG_UNK2 = 0x00000004, // Only used on development map - AREA_FLAG_SLAVE_CAPITAL = 0x00000008, // slave capital city flag? - AREA_FLAG_UNK3 = 0x00000010, // unknown - AREA_FLAG_SLAVE_CAPITAL2 = 0x00000020, // slave capital city flag? - AREA_FLAG_UNK4 = 0x00000040, // many zones have this flag - AREA_FLAG_ARENA = 0x00000080, // arena, both instanced and world arenas - AREA_FLAG_CAPITAL = 0x00000100, // main capital city flag - AREA_FLAG_CITY = 0x00000200, // only for one zone named "City" (where it located?) - AREA_FLAG_OUTLAND = 0x00000400, // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag) - AREA_FLAG_SANCTUARY = 0x00000800, // sanctuary area (PvP disabled) - AREA_FLAG_NEED_FLY = 0x00001000, // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway - AREA_FLAG_UNUSED1 = 0x00002000, // not used now (no area/zones with this flag set in 2.4.2) - AREA_FLAG_OUTLAND2 = 0x00004000, // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag) - AREA_FLAG_PVP = 0x00008000, // pvp objective area? (Death's Door also has this flag although it's no pvp object area) - AREA_FLAG_ARENA_INSTANCE = 0x00010000, // used by instanced arenas only - AREA_FLAG_UNUSED2 = 0x00020000, // not used now (no area/zones with this flag set in 2.4.2) - AREA_FLAG_UNK5 = 0x00040000, // just used for Amani Pass, Hatchet Hills - AREA_FLAG_LOWLEVEL = 0x00100000 // used for some starting areas with area_level <=15 -}; - -enum FactionTemplateFlags -{ - FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats -}; - struct AreaTableEntry { uint32 ID; // 0 @@ -179,7 +144,7 @@ struct ChrRacesEntry //char* string2[16]; // 48-63 used for DBC language detection/selection // 64 string flags, unused // 65-67 unused - uint32 addon; // 68 (0 - original race, 1 - tbc addon, ...) + uint32 addon; // 68 (0 - original race, 1 - tbc addon, ...) }; struct CreatureDisplayInfoEntry @@ -193,12 +158,11 @@ struct CreatureDisplayInfoEntry struct CreatureFamilyEntry { uint32 ID; // 0 - float minScale; // 1 - uint32 minScaleLevel; // 2 0/1 + float minScale; // 1 + uint32 minScaleLevel; // 2 0/1 float maxScale; // 3 uint32 maxScaleLevel; // 4 0/60 - uint32 skillLine; // 5 - uint32 skillLine2; // 6 + uint32 skillLine[2]; // 5-6 uint32 petFoodMask; // 7 char* Name[16]; // 8-23 // 24 string flags, unused @@ -244,15 +208,6 @@ struct FactionEntry // 52 string flags, unused }; -enum FactionMasks -{ - FACTION_MASK_PLAYER = 1, // any player - FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team - FACTION_MASK_HORDE = 4, // player or creature from horde team - FACTION_MASK_MONSTER = 8 // aggressive creature from monster team - // if none flags set then non-aggressive creature -}; - struct FactionTemplateEntry { uint32 ID; // 0 @@ -301,6 +256,7 @@ struct GemPropertiesEntry }; #define GT_MAX_LEVEL 100 + struct GtCombatRatingsEntry { float ratio; @@ -431,15 +387,6 @@ struct MailTemplateEntry //char* content[16]; // 18-33 }; -enum MapTypes -{ - MAP_COMMON = 0, - MAP_INSTANCE = 1, - MAP_RAID = 2, - MAP_BATTLEGROUND = 3, - MAP_ARENA = 4 -}; - struct MapEntry { uint32 MapID; // 0 @@ -545,12 +492,6 @@ struct SkillLineEntry uint32 spellIcon; // 37 }; -enum AbilytyLearnType -{ - ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, - ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2 -}; - struct SkillLineAbilityEntry { uint32 id; // 0, INDEX @@ -758,17 +699,6 @@ struct SpellDurationEntry int32 Duration[3]; }; -enum ItemEnchantmentType -{ - ITEM_ENCHANTMENT_TYPE_NONE = 0, - ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1, - ITEM_ENCHANTMENT_TYPE_DAMAGE = 2, - ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL = 3, - ITEM_ENCHANTMENT_TYPE_RESISTANCE = 4, - ITEM_ENCHANTMENT_TYPE_STAT = 5, - ITEM_ENCHANTMENT_TYPE_TOTEM = 6 -}; - struct SpellItemEnchantmentEntry { uint32 ID; // 0 @@ -826,14 +756,6 @@ struct TalentTabEntry //char* internalname; // 22 }; -struct TaxiPathEntry -{ - uint32 ID; - uint32 from; - uint32 to; - uint32 price; -}; - struct TaxiNodesEntry { uint32 ID; // 0 @@ -847,15 +769,24 @@ struct TaxiNodesEntry uint32 alliance_mount_type; // 24 }; -enum TotemCategoryType +struct TaxiPathEntry +{ + uint32 ID; + uint32 from; + uint32 to; + uint32 price; +}; + +struct TaxiPathNodeEntry { - TOTEM_CATEGORY_TYPE_KNIFE = 1, - TOTEM_CATEGORY_TYPE_TOTEM = 2, - TOTEM_CATEGORY_TYPE_ROD = 3, - TOTEM_CATEGORY_TYPE_PICK = 21, - TOTEM_CATEGORY_TYPE_STONE = 22, - TOTEM_CATEGORY_TYPE_HAMMER = 23, - TOTEM_CATEGORY_TYPE_SPANNER = 24 + uint32 path; + uint32 index; + uint32 mapid; + float x; + float y; + float z; + uint32 actionFlag; + uint32 delay; }; struct TotemCategoryEntry diff --git a/src/shared/Database/DatabaseEnv.h b/src/shared/Database/DatabaseEnv.h index 7491464285d..cc09b7611db 100644 --- a/src/shared/Database/DatabaseEnv.h +++ b/src/shared/Database/DatabaseEnv.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if !defined(DATABASEENV_H) diff --git a/src/shared/Database/DatabaseImpl.h b/src/shared/Database/DatabaseImpl.h index 694ac566db1..175de989d75 100644 --- a/src/shared/Database/DatabaseImpl.h +++ b/src/shared/Database/DatabaseImpl.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Database/Database.h" diff --git a/src/shared/Database/DatabaseMysql.cpp b/src/shared/Database/DatabaseMysql.cpp index 3d9358d9639..d11d29111be 100644 --- a/src/shared/Database/DatabaseMysql.cpp +++ b/src/shared/Database/DatabaseMysql.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DO_POSTGRESQL diff --git a/src/shared/Database/DatabaseMysql.h b/src/shared/Database/DatabaseMysql.h index 83d01758d58..23d1e4c8ff3 100644 --- a/src/shared/Database/DatabaseMysql.h +++ b/src/shared/Database/DatabaseMysql.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DO_POSTGRESQL diff --git a/src/shared/Database/Field.cpp b/src/shared/Database/Field.cpp index 1c1f9193059..3ec30cdfb64 100644 --- a/src/shared/Database/Field.cpp +++ b/src/shared/Database/Field.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "DatabaseEnv.h" diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index ebfdf04cca3..a81c61e8516 100644 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if !defined(FIELD_H) diff --git a/src/shared/Database/QueryResult.h b/src/shared/Database/QueryResult.h index e3d63c31029..5c26b04a2c0 100644 --- a/src/shared/Database/QueryResult.h +++ b/src/shared/Database/QueryResult.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if !defined(QUERYRESULT_H) diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index b9168cbc416..720e6e3e683 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -10,18 +10,16 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "SQLStorage.h" -#include "ProgressBar.h" -#include "Log.h" -#include "dbcfile.h" +#include "SQLStorageImpl.h" #ifdef DO_POSTGRESQL extern DatabasePostgre WorldDatabase; @@ -29,165 +27,57 @@ extern DatabasePostgre WorldDatabase; extern DatabaseMysql WorldDatabase; #endif -const char CreatureInfofmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis"; +const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis"; +const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiii"; const char CreatureDataAddonInfofmt[]="iiiiiiis"; const char CreatureModelfmt[]="iffbi"; const char CreatureInfoAddonInfofmt[]="iiiiiiis"; const char EquipmentInfofmt[]="iiiiiiiiii"; -const char GameObjectInfofmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis"; -const char ItemPrototypefmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii"; +const char GameObjectInfosrcfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis"; +const char GameObjectInfodstfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiii"; +const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii"; +const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiii"; const char PageTextfmt[]="isi"; const char SpellThreatfmt[]="ii"; -const char InstanceTemplatefmt[]="iiiiiiffffs"; +const char InstanceTemplatesrcfmt[]="iiiiiiffffs"; +const char InstanceTemplatedstfmt[]="iiiiiiffffi"; -SQLStorage sCreatureStorage(CreatureInfofmt,"entry","creature_template"); +SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template"); SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); SQLStorage sCreatureModelStorage(CreatureModelfmt,"modelid","creature_model_info"); SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon"); SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template"); -SQLStorage sGOStorage(GameObjectInfofmt,"entry","gameobject_template"); -SQLStorage sItemStorage(ItemPrototypefmt,"entry","item_template"); +SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template"); +SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template"); SQLStorage sPageTextStore(PageTextfmt,"entry","page_text"); SQLStorage sSpellThreatStore(SpellThreatfmt,"entry","spell_threat"); -SQLStorage sInstanceTemplate(InstanceTemplatefmt,"map","instance_template"); +SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map","instance_template"); void SQLStorage::Free () { uint32 offset=0; for(uint32 x=0;x<iNumFields;x++) - if (format[x]==FT_STRING) + if (dst_format[x]==FT_STRING) { for(uint32 y=0;y<MaxEntry;y++) if(pIndex[y]) delete [] *(char**)((char*)(pIndex[y])+offset); - offset+=sizeof(char*); + offset += sizeof(char*); } - else if (format[x]==FT_LOGIC) - offset+=sizeof(bool); - else if (format[x]==FT_BYTE) - offset+=sizeof(char); + else if (dst_format[x]==FT_LOGIC) + offset += sizeof(bool); + else if (dst_format[x]==FT_BYTE) + offset += sizeof(char); else - offset+=4; + offset += 4; delete [] pIndex; delete [] data; } -void SQLStorage::Load () +void SQLStorage::Load() { - uint32 maxi; - Field *fields; - QueryResult *result = WorldDatabase.PQuery("SELECT MAX(%s) FROM %s",entry_field,table); - if(!result) - { - sLog.outError("Error loading %s table (not exist?)\n",table); - exit(1); // Stop server at loading non exited table or not accessable table - } - - maxi= (*result)[0].GetUInt32()+1; - delete result; - - result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s",table); - if(result) - { - fields = result->Fetch(); - RecordCount=fields[0].GetUInt32(); - delete result; - } - else - RecordCount = 0; - - result = WorldDatabase.PQuery("SELECT * FROM %s",table); - - if(!result) - { - sLog.outError("%s table is empty!\n",table); - RecordCount = 0; - return; - } - - uint32 recordsize=0; - uint32 offset=0; - - if(iNumFields!=result->GetFieldCount()) - { - RecordCount = 0; - sLog.outError("Error in %s table, probably sql file format was updated (there should be %d fields in sql).\n",table,iNumFields); - delete result; - exit(1); // Stop server at loading broken or non-compatiable table. - } - - //get struct size - uint32 sc=0; - uint32 bo=0; - uint32 bb=0; - for(uint32 x=0;x<iNumFields;x++) - if(format[x]==FT_STRING) - ++sc; - else if (format[x]==FT_LOGIC) - ++bo; - else if (format[x]==FT_BYTE) - ++bb; - recordsize=(iNumFields-sc-bo-bb)*4+sc*sizeof(char*)+bo*sizeof(bool)+bb*sizeof(char); - - char** newIndex=new char*[maxi]; - memset(newIndex,0,maxi*sizeof(char*)); - - char * _data= new char[RecordCount *recordsize]; - uint32 count=0; - barGoLink bar( RecordCount ); - do - { - fields = result->Fetch(); - bar.step(); - char *p=(char*)&_data[recordsize*count]; - newIndex[fields[0].GetUInt32()]=p; - - offset=0; - for(uint32 x=0;x<iNumFields;x++) - switch(format[x]) - { - case FT_LOGIC: - *((bool*)(&p[offset]))=(fields[x].GetUInt32()>0); - offset+=sizeof(bool); - break; - case FT_BYTE: - *((char*)(&p[offset]))=(fields[x].GetUInt8()); - offset+=sizeof(char); - break; - case FT_INT: - *((uint32*)(&p[offset]))=fields[x].GetUInt32(); - offset+=sizeof(uint32); - break; - case FT_FLOAT: - *((float*)(&p[offset]))=fields[x].GetFloat(); - offset+=sizeof(float); - break; - case FT_STRING: - char const* tmp = fields[x].GetString(); - char* st; - if(!tmp) - { - st=new char[1]; - *st=0; - } - else - { - uint32 l=strlen(tmp)+1; - st=new char[l]; - memcpy(st,tmp,l); - } - *((char**)(&p[offset]))=st; - offset+=sizeof(char*); - break; - } - ++count; - }while( result->NextRow() ); - - delete result; - - pIndex =newIndex; - MaxEntry=maxi; - data=_data; + SQLStorageLoader loader; + loader.Load(*this); } diff --git a/src/shared/Database/SQLStorage.h b/src/shared/Database/SQLStorage.h index 5131a73fe4d..2d154f4e1ca 100644 --- a/src/shared/Database/SQLStorage.h +++ b/src/shared/Database/SQLStorage.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef SQLSTORAGE_H @@ -26,18 +26,26 @@ class SQLStorage { + template<class T> + friend struct SQLStorageLoaderBase; + public: - SQLStorage(const char*fmt,const char * _entry_field,const char * sqlname) + SQLStorage(const char* fmt, const char * _entry_field, const char * sqlname) { - format=fmt; - entry_field = _entry_field; - table=sqlname; - data=NULL; - pIndex=NULL; - iNumFields =strlen(fmt); - MaxEntry = 0; + src_format = fmt; + dst_format = fmt; + init(_entry_field, sqlname); + } + + SQLStorage(const char* src_fmt, const char* dst_fmt, const char * _entry_field, const char * sqlname) + { + src_format = src_fmt; + dst_format = dst_fmt; + init(_entry_field, sqlname); } + + ~SQLStorage() { Free(); @@ -56,15 +64,53 @@ class SQLStorage uint32 RecordCount; uint32 MaxEntry; uint32 iNumFields; + void Load(); void Free(); + private: + void init(const char * _entry_field, const char * sqlname) + { + entry_field = _entry_field; + table=sqlname; + data=NULL; + pIndex=NULL; + iNumFields = strlen(src_format); + MaxEntry = 0; + } + char** pIndex; char *data; - const char *format; + const char *src_format; + const char *dst_format; const char *table; const char *entry_field; //bool HasString; }; + +template <class T> +struct SQLStorageLoaderBase +{ + public: + void Load(SQLStorage &storage); + + template<class S, class D> + void convert(uint32 field_pos, S src, D &dst); + template<class S> + void convert_to_str(uint32 field_pos, S src, char * & dst); + template<class D> + void convert_from_str(uint32 field_pos, char * src, D& dst); + void convert_str_to_str(uint32 field_pos, char *src, char *&dst); + + private: + template<class V> + void storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset); + void storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset); +}; + +struct SQLStorageLoader : public SQLStorageLoaderBase<SQLStorageLoader> +{ +}; + #endif diff --git a/src/shared/Database/SQLStorageImpl.h b/src/shared/Database/SQLStorageImpl.h new file mode 100644 index 00000000000..4f10c6eee05 --- /dev/null +++ b/src/shared/Database/SQLStorageImpl.h @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ProgressBar.h" +#include "Log.h" +#include "dbcfile.h" + +template<class T> +template<class S, class D> +void SQLStorageLoaderBase<T>::convert(uint32 field_pos, S src, D &dst) +{ + dst = D(src); +} + +template<class T> +void SQLStorageLoaderBase<T>::convert_str_to_str(uint32 field_pos, char *src, char *&dst) +{ + if(!src) + { + dst = new char[1]; + *dst = 0; + } + else + { + uint32 l = strlen(src) + 1; + dst = new char[l]; + memcpy(dst, src, l); + } +} + +template<class T> +template<class S> +void SQLStorageLoaderBase<T>::convert_to_str(uint32 field_pos, S src, char * & dst) +{ + dst = new char[1]; + *dst = 0; +} + +template<class T> +template<class D> +void SQLStorageLoaderBase<T>::convert_from_str(uint32 field_pos, char * src, D& dst) +{ + dst = 0; +} + +template<class T> +template<class V> +void SQLStorageLoaderBase<T>::storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset) +{ + T * subclass = (static_cast<T*>(this)); + switch(store.dst_format[x]) + { + case FT_LOGIC: + subclass->convert(x, value, *((bool*)(&p[offset])) ); + offset+=sizeof(bool); + break; + case FT_BYTE: + subclass->convert(x, value, *((char*)(&p[offset])) ); + offset+=sizeof(char); + break; + case FT_INT: + subclass->convert(x, value, *((uint32*)(&p[offset])) ); + offset+=sizeof(uint32); + break; + case FT_FLOAT: + subclass->convert(x, value, *((float*)(&p[offset])) ); + offset+=sizeof(float); + break; + case FT_STRING: + subclass->convert_to_str(x, value, *((char**)(&p[offset])) ); + offset+=sizeof(char*); + break; + } +} + +template<class T> +void SQLStorageLoaderBase<T>::storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset) +{ + T * subclass = (static_cast<T*>(this)); + switch(store.dst_format[x]) + { + case FT_LOGIC: + subclass->convert_from_str(x, value, *((bool*)(&p[offset])) ); + offset+=sizeof(bool); + break; + case FT_BYTE: + subclass->convert_from_str(x, value, *((char*)(&p[offset])) ); + offset+=sizeof(char); + break; + case FT_INT: + subclass->convert_from_str(x, value, *((uint32*)(&p[offset])) ); + offset+=sizeof(uint32); + break; + case FT_FLOAT: + subclass->convert_from_str(x, value, *((float*)(&p[offset])) ); + offset+=sizeof(float); + break; + case FT_STRING: + subclass->convert_str_to_str(x, value, *((char**)(&p[offset])) ); + offset+=sizeof(char*); + break; + } +} + +template<class T> +void SQLStorageLoaderBase<T>::Load(SQLStorage &store) +{ + uint32 maxi; + Field *fields; + QueryResult *result = WorldDatabase.PQuery("SELECT MAX(%s) FROM %s", store.entry_field, store.table); + if(!result) + { + sLog.outError("Error loading %s table (not exist?)\n", store.table); + exit(1); // Stop server at loading non exited table or not accessable table + } + + maxi = (*result)[0].GetUInt32()+1; + delete result; + + result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s", store.table); + if(result) + { + fields = result->Fetch(); + store.RecordCount = fields[0].GetUInt32(); + delete result; + } + else + store.RecordCount = 0; + + result = WorldDatabase.PQuery("SELECT * FROM %s", store.table); + + if(!result) + { + sLog.outError("%s table is empty!\n", store.table); + store.RecordCount = 0; + return; + } + + uint32 recordsize = 0; + uint32 offset = 0; + + if(store.iNumFields != result->GetFieldCount()) + { + store.RecordCount = 0; + sLog.outError("Error in %s table, probably sql file format was updated (there should be %d fields in sql).\n", store.table, store.iNumFields); + delete result; + exit(1); // Stop server at loading broken or non-compatible table. + } + + //get struct size + uint32 sc=0; + uint32 bo=0; + uint32 bb=0; + for(uint32 x=0; x< store.iNumFields; x++) + if(store.dst_format[x]==FT_STRING) + ++sc; + else if (store.dst_format[x]==FT_LOGIC) + ++bo; + else if (store.dst_format[x]==FT_BYTE) + ++bb; + recordsize=(store.iNumFields-sc-bo-bb)*4+sc*sizeof(char*)+bo*sizeof(bool)+bb*sizeof(char); + + char** newIndex=new char*[maxi]; + memset(newIndex,0,maxi*sizeof(char*)); + + char * _data= new char[store.RecordCount *recordsize]; + uint32 count=0; + barGoLink bar( store.RecordCount ); + do + { + fields = result->Fetch(); + bar.step(); + char *p=(char*)&_data[recordsize*count]; + newIndex[fields[0].GetUInt32()]=p; + + offset=0; + for(uint32 x = 0; x < store.iNumFields; x++) + switch(store.src_format[x]) + { + case FT_LOGIC: + storeValue((bool)(fields[x].GetUInt32() > 0), store, p, x, offset); break; + case FT_BYTE: + storeValue((char)fields[x].GetUInt8(), store, p, x, offset); break; + case FT_INT: + storeValue((uint32)fields[x].GetUInt32(), store, p, x, offset); break; + case FT_FLOAT: + storeValue((float)fields[x].GetFloat(), store, p, x, offset); break; + case FT_STRING: + storeValue((char*)fields[x].GetString(), store, p, x, offset); break; + } + ++count; + }while( result->NextRow() ); + + delete result; + + store.pIndex = newIndex; + store.MaxEntry = maxi; + store.data = _data; +} diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index 12eb5585c21..b229b9a5918 100644 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "SqlOperations.h" diff --git a/src/shared/Database/SqlOperations.h b/src/shared/Database/SqlOperations.h index 7d9ecee6832..a51e48bf929 100644 --- a/src/shared/Database/SqlOperations.h +++ b/src/shared/Database/SqlOperations.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __SQLOPERATIONS_H diff --git a/src/shared/Database/dbcfile.cpp b/src/shared/Database/dbcfile.cpp index 07f7b662e73..c6c12a99b8b 100644 --- a/src/shared/Database/dbcfile.cpp +++ b/src/shared/Database/dbcfile.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdio.h> diff --git a/src/shared/Database/dbcfile.h b/src/shared/Database/dbcfile.h index cc2f117d6d1..8d0b2e45451 100644 --- a/src/shared/Database/dbcfile.h +++ b/src/shared/Database/dbcfile.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DBCFILE_H diff --git a/src/shared/ProgressBar.cpp b/src/shared/ProgressBar.cpp index 724e749c1d9..f4163a6133e 100644 --- a/src/shared/ProgressBar.cpp +++ b/src/shared/ProgressBar.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ProgressBar.h" diff --git a/src/shared/ProgressBar.h b/src/shared/ProgressBar.h index de73596dd55..98720c90385 100644 --- a/src/shared/ProgressBar.h +++ b/src/shared/ProgressBar.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITYCORE_PROGRESSBAR_H #define TRINITYCORE_PROGRESSBAR_H diff --git a/src/trinitycore/CliRunnable.cpp b/src/trinitycore/CliRunnable.cpp index 065a6662a50..0af892819b6 100644 --- a/src/trinitycore/CliRunnable.cpp +++ b/src/trinitycore/CliRunnable.cpp @@ -169,7 +169,7 @@ bool ChatHandler::HandleCharacterDeleteCommand(const char* args) bool ChatHandler::HandleServerExitCommand(const char* args) { SendSysMessage(LANG_COMMAND_EXIT); - World::m_stopEvent = true; + World::StopNow(SHUTDOWN_EXIT_CODE); return true; } @@ -310,14 +310,14 @@ void CliRunnable::run() printf("TC>"); ///- As long as the World is running (no World::m_stopEvent), get the command line and handle it - while (!World::m_stopEvent) + while (!World::IsStopped()) { fflush(stdout); #ifdef linux - while (!kb_hit_return() && !World::m_stopEvent) + while (!kb_hit_return() && !World::IsStopped()) // With this, we limit CLI to 10commands/second usleep(100); - if (World::m_stopEvent) + if (World::IsStopped()) break; #endif char *command_str = fgets(commandbuf,sizeof(commandbuf),stdin); @@ -348,7 +348,7 @@ void CliRunnable::run() } else if (feof(stdin)) { - World::m_stopEvent = true; + World::StopNow(SHUTDOWN_EXIT_CODE); } } diff --git a/src/trinitycore/Master.cpp b/src/trinitycore/Master.cpp index 47a12484151..317a3a31a15 100644 --- a/src/trinitycore/Master.cpp +++ b/src/trinitycore/Master.cpp @@ -77,7 +77,7 @@ public: w_loops = 0; m_lastchange = 0; w_lastchange = 0; - while(!World::m_stopEvent) + while(!World::IsStopped()) { ZThread::Thread::sleep(1000); uint32 curtime = getMSTime(); @@ -172,13 +172,13 @@ public: // if use ra spend time waiting for io, if not use ra ,just sleep if (usera) - while (!World::m_stopEvent) + while (!World::IsStopped()) { h.Select (0, socketSelecttime); checkping (); } else - while (!World::m_stopEvent) + while (!World::IsStopped()) { ZThread::Thread::sleep (static_cast<unsigned long> (socketSelecttime / 1000)); checkping (); @@ -323,7 +323,7 @@ int Master::Run() if (sWorldSocketMgr->StartNetwork (wsport, bind_ip.c_str ()) == -1) { sLog.outError ("Failed to start network"); - World::m_stopEvent = true; + World::StopNow(ERROR_EXIT_CODE); // go down and shutdown the server } @@ -394,7 +394,8 @@ int Master::Run() // fixes a memory leak related to detaching threads from the module UnloadScriptingModule(); - return sWorld.GetShutdownMask() & SHUTDOWN_MASK_RESTART ? 2 : 0; + // Exit the process with specified return value + return World::GetExitCode(); } /// Initialize connection to the databases @@ -477,17 +478,18 @@ void Master::clearOnlineAccounts() } /// Handle termination signals -/** Put the World::m_stopEvent to 'true' if a termination signal is caught **/ void Master::_OnSignal(int s) { switch (s) { case SIGINT: + World::StopNow(RESTART_EXIT_CODE); + break; case SIGTERM: #ifdef _WIN32 case SIGBREAK: #endif - World::m_stopEvent = true; + World::StopNow(SHUTDOWN_EXIT_CODE); break; } diff --git a/src/trinitycore/WorldRunnable.cpp b/src/trinitycore/WorldRunnable.cpp index 1a30740ddd9..5592b1d2064 100644 --- a/src/trinitycore/WorldRunnable.cpp +++ b/src/trinitycore/WorldRunnable.cpp @@ -51,7 +51,7 @@ void WorldRunnable::run() uint32 prevSleepTime = 0; // used for balanced full tick time length near WORLD_SLEEP_CONST ///- While we have not World::m_stopEvent, update the world - while (!World::m_stopEvent) + while (!World::IsStopped()) { ++World::m_worldLoopCounter; realCurrTime = getMSTime(); |