diff options
Diffstat (limited to 'src')
74 files changed, 1350 insertions, 670 deletions
diff --git a/src/bindings/scripts/Makefile.am b/src/bindings/scripts/Makefile.am index 8d871dfcf25..466236c3418 100644 --- a/src/bindings/scripts/Makefile.am +++ b/src/bindings/scripts/Makefile.am @@ -270,6 +270,12 @@ scripts/zone/naxxramas/boss_sapphiron.cpp \ scripts/zone/naxxramas/boss_thaddius.cpp \ scripts/zone/naxxramas/instance_naxxramas.cpp \ scripts/zone/netherstorm/netherstorm.cpp \ +scripts/zone/nexus/nexus/boss_magus_telestra.cpp \ +scripts/zone/nexus/nexus/boss_anomalus.cpp \ +scripts/zone/nexus/nexus/boss_ormorok.cpp \ +scripts/zone/nexus/nexus/boss_keristrasza.cpp \ +scripts/zone/nexus/nexus/def_nexus.h \ +scripts/zone/nexus/nexus/instance_nexus.cpp \ scripts/zone/onyxias_lair/boss_onyxia.cpp \ scripts/zone/orgrimmar/orgrimmar.cpp \ scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp \ diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index e98ea3395cb..0a440fb8c10 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -401,6 +401,13 @@ extern void AddSC_instance_naxxramas(); //Netherstorm extern void AddSC_netherstorm(); +//The Nexus +extern void AddSC_boss_magus_telestra(); +extern void AddSC_boss_anomalus(); +extern void AddSC_boss_ormorok(); +extern void AddSC_boss_keristrasza(); +extern void AddSC_instance_nexus(); + //Onyxia's Lair extern void AddSC_boss_onyxia(); @@ -1286,6 +1293,13 @@ void ScriptsInit(char const* cfg_file = "trinitycore.conf") //Netherstorm AddSC_netherstorm(); + //The Nexus + AddSC_boss_magus_telestra(); + AddSC_boss_anomalus(); + AddSC_boss_ormorok(); + AddSC_boss_keristrasza(); + AddSC_instance_nexus(); + //Onyxia's Lair AddSC_boss_onyxia(); diff --git a/src/bindings/scripts/VC80/80ScriptDev2.vcproj b/src/bindings/scripts/VC80/80ScriptDev2.vcproj index 1a39f5b3947..afe05d56e58 100644 --- a/src/bindings/scripts/VC80/80ScriptDev2.vcproj +++ b/src/bindings/scripts/VC80/80ScriptDev2.vcproj @@ -2514,22 +2514,30 @@ <Filter Name="Nexus" > - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_anomalus.cpp" - > - </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_keristrasza.cpp" - > - </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_magus_telestra.cpp" - > - </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_ormorok.cpp" - > - </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_magus_telestra.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_anomalus.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_ormorok.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_keristrasza.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\def_nexus.h" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\instance_nexus.cpp" + > + </File> <File RelativePath="..\scripts\zone\nexus\nexus\commander_kolurg.cpp" > @@ -2539,10 +2547,6 @@ > </File> <File - RelativePath="..\scripts\zone\nexus\nexus\def_nexus.h" - > - </File> - <File RelativePath="..\scripts\zone\nexus\nexus\instance_nexus.cpp" > </File> diff --git a/src/bindings/scripts/VC90/90ScriptDev2.vcproj b/src/bindings/scripts/VC90/90ScriptDev2.vcproj index cfcbcc54059..bf6ee205867 100644 --- a/src/bindings/scripts/VC90/90ScriptDev2.vcproj +++ b/src/bindings/scripts/VC90/90ScriptDev2.vcproj @@ -2513,22 +2513,30 @@ <Filter Name="Nexus" > - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_anomalus.cpp" - > - </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_keristrasza.cpp" - > - </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_magus_telestra.cpp" - > - </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\boss_ormorok.cpp" - > - </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_magus_telestra.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_anomalus.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_ormorok.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\boss_keristrasza.cpp" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\def_nexus.h" + > + </File> + <File + RelativePath="..\scripts\zone\nexus\nexus\instance_nexus.cpp" + > + </File> <File RelativePath="..\scripts\zone\nexus\nexus\commander_kolurg.cpp" > @@ -2537,14 +2545,6 @@ RelativePath="..\scripts\zone\nexus\nexus\commander_stoutbeard.cpp" > </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\def_nexus.h" - > - </File> - <File - RelativePath="..\scripts\zone\nexus\nexus\instance_nexus.cpp" - > - </File> </Filter> <Filter Name="Oculus" 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 57584769cfa..fbe926ffba0 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 @@ -37,7 +37,7 @@ struct TRINITY_DLL_DECL instance_sethekk_halls : public ScriptedInstance IkissDoor = NULL; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { 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 f99f9a130aa..34bda60c1b7 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 @@ -240,9 +240,9 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI void MoveInLineOfSight(Unit *who) { - if(who && !m_creature->getVictim() && m_creature->canStartAttack(who)) - AttackStart(who); - if (!Intro && who && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who)) + ScriptedAI::MoveInLineOfSight(who); + + if (!Intro && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who)) { DoScriptText(SAY_INTRO, m_creature); Intro = true; 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 37194a89b21..cc63d253d1b 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 @@ -69,7 +69,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance return false; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -78,7 +78,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance } } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -193,7 +193,7 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance std::string GetSaveData() { - return str_data.c_str(); + return str_data; } void Load(const char* in) diff --git a/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp b/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp index 595a05a727f..9e35d95cdcd 100644 --- a/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp +++ b/src/bindings/scripts/scripts/zone/azjol_nerub/ahnkahet/instance_ahnkahet.cpp @@ -69,9 +69,9 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch(creature_entry) + switch(creature->GetEntry()) { case 29309: Elder_Nadox = creature->GetGUID(); break; case 29308: Prince_Taldaram = creature->GetGUID(); break; @@ -142,7 +142,7 @@ struct TRINITY_DLL_DECL instance_ahnkahet : public ScriptedInstance str_data = saveStream.str(); OUT_SAVE_INST_DATA_COMPLETE; - return str_data.c_str(); + return str_data; } void Load(const char* in) diff --git a/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp b/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp index 7e0252f2009..a054e9ab2d8 100644 --- a/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp +++ b/src/bindings/scripts/scripts/zone/azjol_nerub/azjol_nerub/instance_azjol_nerub.cpp @@ -64,9 +64,9 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch(creature_entry) + switch(creature->GetEntry()) { case 28684: Krikthir = creature->GetGUID(); break; case 28921: Hadronox = creature->GetGUID(); break; @@ -130,7 +130,7 @@ struct TRINITY_DLL_DECL instance_azjol_nerub : public ScriptedInstance str_data = saveStream.str(); OUT_SAVE_INST_DATA_COMPLETE; - return str_data.c_str(); + return str_data; } void Load(const char* in) 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 3f71e2070ab..b0259a09518 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 @@ -129,7 +129,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance return NULL; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -148,7 +148,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance } } - void OnObjectCreate(GameObject* go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -305,7 +305,7 @@ struct TRINITY_DLL_DECL instance_black_temple : public ScriptedInstance std::string GetSaveData() { - return str_data.c_str(); + return str_data; } void Load(const char* in) diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp index d9f3ecd808a..d84bd96791d 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/instance_blackrock_depths.cpp @@ -131,7 +131,7 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance return NULL; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -140,7 +140,7 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance } } - void OnObjectCreate(GameObject* go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -267,7 +267,7 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance std::string GetSaveData() { - return str_data.c_str(); + return str_data; } void Load(const char* in) diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/instance_dark_portal.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/instance_dark_portal.cpp index 697134cd82d..e988782ad60 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/instance_dark_portal.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/instance_dark_portal.cpp @@ -149,7 +149,7 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance player->SendUpdateWorldState(WORLD_STATE_BM,0); } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { if (creature->GetEntry() == C_MEDIVH) MedivhGUID = creature->GetGUID(); diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp index 77ba7fd7ce2..b6a9f0fecae 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp @@ -434,14 +434,10 @@ void hyjalAI::EnterCombat(Unit *who) void hyjalAI::MoveInLineOfSight(Unit *who) { - if(IsDummy)return; - if (IsBeingEscorted && !GetAttack()) - return; - - if(m_creature->getVictim() || !m_creature->canStartAttack(who)) + if(IsDummy) return; - AttackStart(who); + npc_escortAI::MoveInLineOfSight(who); } void hyjalAI::SummonCreature(uint32 entry, float Base[4][3]) 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 cdcd6cb6b66..df0b1a7d9c1 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 @@ -94,7 +94,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance return false; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -120,7 +120,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance HandleGameObject(DoorGUID, open, NULL); } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -281,7 +281,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance std::string GetSaveData() { - return str_data.c_str(); + return str_data; } void Load(const char* in) 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 3c34e42cee5..dc9946e468a 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 @@ -96,7 +96,7 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance debug_log("TSCR: Instance Old Hillsbrad: UpdateOHWorldState, but PlayerList is empty!"); } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { 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 4e104fc2846..da3e6e15c8e 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 @@ -104,7 +104,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance return false; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -140,7 +140,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance Door->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY); } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { 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 55ef0716638..b2a58ef7ed1 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 @@ -105,7 +105,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance return NULL; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -115,7 +115,7 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance } } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { diff --git a/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp b/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp index 72498f388ec..c80f77f0f0f 100644 --- a/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp +++ b/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp @@ -141,7 +141,7 @@ struct TRINITY_DLL_DECL instance_deadmines : public ScriptedInstance DoorLever->SetUInt32Value(GAMEOBJECT_FLAGS, 4); } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { diff --git a/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp b/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp index 4790bf1f97d..68e15fd0282 100644 --- a/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp +++ b/src/bindings/scripts/scripts/zone/eastern_plaguelands/the_scarlet_enclave.cpp @@ -629,7 +629,7 @@ CreatureAI* GetAI_npc_dkc1_gothik(Creature *_Creature) return new npc_dkc1_gothikAI(_Creature); } -// npc 28912 quest 17217 boss 29001 go 191092 +// npc 28912 quest 17217 boss 29001 mob 29007 go 191092 void AddSC_the_scarlet_enclave() { 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 aaded603f80..6ee3aba6d12 100644 --- a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp +++ b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp @@ -649,22 +649,16 @@ struct TRINITY_DLL_DECL npc_infused_crystalAI : public Scripted_NoMovementAI WaveTimer = 0; } - void EnterCombat(Unit* who){} - void MoveInLineOfSight(Unit* who) { - if( who->GetTypeId() == TYPEID_PLAYER && !m_creature->canStartAttack(who) && !Progress) + if(!Progress && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 10.0f)) { if( CAST_PLR(who)->GetQuestStatus(QUEST_POWERING_OUR_DEFENSES) == QUEST_STATUS_INCOMPLETE ) { - float Radius = 10.0; - if( m_creature->IsWithinDistInMap(who, Radius) ) - { - PlayerGUID = who->GetGUID(); - WaveTimer = 1000; - EndTimer = 60000; - Progress = true; - } + PlayerGUID = who->GetGUID(); + WaveTimer = 1000; + EndTimer = 60000; + Progress = true; } } } 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 4c90fdf49a8..b2199e08576 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 @@ -71,7 +71,7 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance return false; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -83,7 +83,7 @@ struct TRINITY_DLL_DECL instance_gruuls_lair : public ScriptedInstance } } - void OnObjectCreate(GameObject* go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp index 035bd8aadfe..224f9bfe2a4 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/instance_blood_furnace.cpp @@ -42,7 +42,7 @@ struct TRINITY_DLL_DECL instance_blood_furnace : public ScriptedInstance Sewer2GUID = 0; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp index 9893c3c6849..c106924d5b7 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/instance_hellfire_ramparts.cpp @@ -42,12 +42,12 @@ struct TRINITY_DLL_DECL instance_ramparts : public ScriptedInstance } - void OnObjectCreate(GameObject* pGo) + void OnGameObjectCreate(GameObject *go, bool add) { - switch(pGo->GetEntry()) + switch(go->GetEntry()) { - case 185168: m_uiChestNGUID = pGo->GetGUID(); break; - case 185169: m_uiChestHGUID = pGo->GetGUID(); break; + case 185168: m_uiChestNGUID = go->GetGUID(); break; + case 185169: m_uiChestHGUID = go->GetGUID(); break; } } 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 8f3a28e02a3..872c074373d 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 @@ -71,7 +71,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance return false; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -84,7 +84,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance } } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { 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 b606ff0f97e..cc39ec22e63 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 @@ -45,7 +45,7 @@ struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance Encounter[i] = NOT_STARTED; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch( go->GetEntry() ) { @@ -53,9 +53,9 @@ struct TRINITY_DLL_DECL instance_shattered_halls : public ScriptedInstance } } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch( creature_entry ) + switch(creature->GetEntry()) { case 16807: nethekurseGUID = creature->GetGUID(); break; } diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp index 12c7c3fa2ad..df0ac6851af 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp @@ -170,10 +170,7 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI void MoveInLineOfSight(Unit *who) { if(!Intro && !Flying) - { - if(!m_creature->getVictim() && m_creature->canStartAttack(who)) - ScriptedAI::AttackStart(who); - } + ScriptedAI::MoveInLineOfSight(who); } void MovementInform(uint32 type, uint32 id) diff --git a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp index 62ad6fcf42c..e469a19707e 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp @@ -126,7 +126,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance return 0; } - void OnCreatureCreate(Creature *creature, uint32 entry) + void OnCreatureCreate(Creature *creature, bool add) { switch (creature->GetEntry()) { @@ -210,7 +210,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance } } - void OnObjectCreate(GameObject* go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -249,7 +249,7 @@ struct TRINITY_DLL_DECL instance_karazhan : public ScriptedInstance std::string GetSaveData() { - return str_data.c_str(); + return str_data; } void Load(const char* in) 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 57484cb5ef4..952bd4fc0b1 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 @@ -113,7 +113,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance } } - void OnCreatureCreate(Creature *creature, uint32 entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -123,7 +123,7 @@ struct TRINITY_DLL_DECL instance_magisters_terrace : public ScriptedInstance } } - void OnObjectCreate(GameObject* go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { 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 bfaa583e033..5050238ee92 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 @@ -95,7 +95,7 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance }; - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -124,9 +124,9 @@ struct TRINITY_DLL_DECL instance_molten_core : public ScriptedInstance } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch (creature_entry) + switch (creature->GetEntry()) { case ID_LUCIFRON: Lucifron = creature->GetGUID(); diff --git a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_anomalus.cpp b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_anomalus.cpp index 92f276e07d8..0220935873e 100644 --- a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_anomalus.cpp +++ b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_anomalus.cpp @@ -1,121 +1,256 @@ -/* Script Data Start -SDName: Boss anomalus -SDAuthor: LordVanMartin -SD%Complete: -SDComment: -SDCategory: -Script Data End */ - -/*** SQL START *** -update creature_template set scriptname = '' where entry = ''; -*** SQL END ***/ +/* Copyright (C) 2006 - 2009 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_Anomalus +SD%Complete: +SDComment: +SDCategory: The Nexus, The Nexus +EndScriptData */ + #include "precompiled.h" +#include "def_nexus.h" //Spells -#define SPELL_SPARK_1 47751 -#define SPELL_SPARK_2 57062 +#define SPELL_SPARK_N 47751 +#define SPELL_SPARK_H 57062 #define SPELL_RIFT_SHIELD 47748 -#define SPELL_CHARGE_RIFT 47747 -#define SPELL_ARCANE_ATTRACTION 57063 -#define SPELL_CREATE_RIFT 47743 //Dummy ---> summons (npc 26918) "Chaotic Rift", which spawns "Crazed Mana Wraith"s (npc 26746) +#define SPELL_CHARGE_RIFT 47747 //Works wrong (affect players, not rifts) +#define SPELL_CREATE_RIFT 47743 //Don't work, using WA +#define SPELL_ARCANE_ATTRACTION 57063 //No idea, when it's used -#define MOB_CRAZED_MANA_WRAITH 26746 -#define NPC_CHAOTIC_RIFT 26918 +#define MOB_CRAZED_MANA_WRAITH 26746 +#define MOB_CHAOTIC_RIFT 26918 +#define SPELL_CHAOTIC_ENERGY_BURST 47688 +#define SPELL_CHARGED_CHAOTIC_ENERGY_BURST 47737 +#define SPELL_ARCANEFORM 48019 //Chaotic Rift visual //Yell -#define SAY_AGGRO -1576000 -#define SAY_KILL -1576001 -#define SAY_DEATH -1576002 -#define SAY_RIFT -1576003 -#define SAY_SHIELD -1576004 +#define SAY_AGGRO -1576010 +#define SAY_DEATH -1576011 +#define SAY_RIFT -1576012 +#define SAY_SHIELD -1576013 + +float RiftLocation[6][3]= +{ + {652.64, -273.70, -8.75}, + {634.45, -265.94, -8.44}, + {620.73, -281.17, -9.02}, + {626.10, -304.67, -9.44}, + {639.87, -314.11, -9.49}, + {651.72, -297.44, -9.37} +}; struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI { - boss_anomalusAI(Creature *c) : ScriptedAI(c) {} + boss_anomalusAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + Reset(); + HeroicMode = c->GetMap()->IsHeroic(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; - void Reset() {} - void EnterCombat(Unit* who) + uint8 Phase; + uint32 SPELL_SPARK_Timer; + uint32 SPELL_CREATE_RIFT_Timer; + uint64 ChaoticRiftGUID; + + void Reset() + { + Phase = 0; + SPELL_SPARK_Timer = 5000; + SPELL_CREATE_RIFT_Timer = 25000; + ChaoticRiftGUID = 0; + + if(pInstance) + pInstance->SetData(DATA_ANOMALUS_EVENT, NOT_STARTED); + } + + void Aggro(Unit* who) { DoScriptText(SAY_AGGRO, m_creature); } - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) + + void UpdateAI(const uint32 diff) { - //Return since we have no target - if(!UpdateVictim()) + if (!UpdateVictim()) + { return; + } + + if (m_creature->HasAura(SPELL_RIFT_SHIELD)) + { + Unit* Rift; + if (ChaoticRiftGUID) + Rift = Unit::GetUnit((*m_creature), ChaoticRiftGUID); + if (Rift && Rift->isDead()) + { + m_creature->RemoveAurasDueToSpell(SPELL_RIFT_SHIELD); + ChaoticRiftGUID = 0; + } + return; + } else + ChaoticRiftGUID = 0; - //Source DBM - if((((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 80) && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) > 77)) - || (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 55) && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) > 52)) - || (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30) && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) > 27))) + if ((Phase == 0) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.75)) + { + Phase = 1; + DoScriptText(SAY_SHIELD, m_creature); + DoCast(m_creature, SPELL_RIFT_SHIELD); + + int tmp = rand()%(2); + Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if (Rift) + { + //DoCast(Rift, SPELL_CHARGE_RIFT); + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + Rift->AI()->AttackStart(target); + ChaoticRiftGUID = Rift->GetGUID(); + DoScriptText(SAY_RIFT , m_creature); + } + } + + if ((Phase == 1) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.50)) + { + Phase = 2; + DoScriptText(SAY_SHIELD , m_creature); + DoCast(m_creature,SPELL_RIFT_SHIELD); + + int tmp = rand()%(2); + Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if (Rift) + { + //DoCast(Rift, SPELL_CHARGE_RIFT); + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + Rift->AI()->AttackStart(target); + ChaoticRiftGUID = Rift->GetGUID(); + DoScriptText(SAY_RIFT , m_creature); + } + } + + if ((Phase == 2) && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.25)) + { + Phase = 3; + DoScriptText(SAY_SHIELD , m_creature); + DoCast(m_creature,SPELL_RIFT_SHIELD); + + int tmp = rand()%(2); + Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if (Rift) + { + //DoCast(Rift, SPELL_CHARGE_RIFT); + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + Rift->AI()->AttackStart(target); + ChaoticRiftGUID = Rift->GetGUID(); + DoScriptText(SAY_RIFT , m_creature); + } + } + + if (SPELL_SPARK_Timer < diff) { - //Summon rift at a random location - } + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + DoCast(target, HeroicMode ? SPELL_SPARK_H : SPELL_SPARK_N); + SPELL_SPARK_Timer = 5000; + }else SPELL_SPARK_Timer -=diff; + + if (SPELL_CREATE_RIFT_Timer < diff) + { + DoScriptText(SAY_RIFT , m_creature); - DoMeleeAttackIfReady(); + int tmp = rand()%(2); + Creature* Rift = m_creature->SummonCreature(MOB_CHAOTIC_RIFT, RiftLocation[tmp][0], RiftLocation[tmp][1], RiftLocation[tmp][2], 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if (Rift) + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + Rift->AI()->AttackStart(target); + SPELL_CREATE_RIFT_Timer = 25000; + }else SPELL_CREATE_RIFT_Timer -=diff; + + DoMeleeAttackIfReady(); } - void JustDied(Unit* killer) + + void JustDied(Unit* killer) { DoScriptText(SAY_DEATH, m_creature); - } - void KilledUnit(Unit *victim) - { - if(victim == m_creature) - return; - DoScriptText(SAY_KILL, m_creature); + if (pInstance) + pInstance->SetData(DATA_ANOMALUS_EVENT, DONE); } }; -/*###### -## Crazed Mana Wraiths -######*/ -#define SPELL_ARCANE_MISSILES 33833 - -struct TRINITY_DLL_DECL mob_crazed_mana_wraithAI : public ScriptedAI +struct TRINITY_DLL_DECL mob_chaotic_riftAI : public Scripted_NoMovementAI { - mob_crazed_mana_wraithAI(Creature *c) : ScriptedAI(c) {} + mob_chaotic_riftAI(Creature *c) : Scripted_NoMovementAI(c) + { + pInstance = c->GetInstanceData(); + Reset(); + } - void Reset() {} - void EnterCombat(Unit* who) {} - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if(!UpdateVictim()) - return; + ScriptedInstance* pInstance; - DoMeleeAttackIfReady(); - } - void JustDied(Unit* killer) {} -}; + uint32 SPELL_CHAOTIC_ENERGY_BURST_Timer; + uint32 SUMMON_CRAZED_MANA_WRAITH_Timer; -/*###### -## Chaotic Rift -######*/ -#define SPELL_CHAOTIC_ENERGY_BURST 47688 -#define SPELL_CHARGED_CHAOTIC_ENERGY_BURST 47737 + void Reset() + { + SPELL_CHAOTIC_ENERGY_BURST_Timer = 1000; + SUMMON_CRAZED_MANA_WRAITH_Timer = 5000; + m_creature->SetDisplayId(25206); //For some reason in DB models for ally and horde are different. + //Model for ally (1126) does not show auras. Horde model works perfect. + //Set model to horde number + DoCast(m_creature, SPELL_ARCANEFORM, false); + } -struct TRINITY_DLL_DECL npc_chaotic_riftAI : public ScriptedAI -{ - npc_chaotic_riftAI(Creature *c) : ScriptedAI(c) {} - - void Reset() {} - void EnterCombat(Unit* who) {} - void UpdateAI(const uint32 diff) + void UpdateAI(const uint32 diff) { - //Return since we have no target - if(!UpdateVictim()) + if (!UpdateVictim()) + { return; + } - DoMeleeAttackIfReady(); - } - void JustDied(Unit* killer) {} + if (SPELL_CHAOTIC_ENERGY_BURST_Timer < diff) + { + Unit* Anomalus = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ANOMALUS)); + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + if (Anomalus && Anomalus->HasAura(SPELL_RIFT_SHIELD)) + DoCast(target, SPELL_CHARGED_CHAOTIC_ENERGY_BURST); + else + DoCast(target, SPELL_CHAOTIC_ENERGY_BURST); + SPELL_CHAOTIC_ENERGY_BURST_Timer = 1000; + }else SPELL_CHAOTIC_ENERGY_BURST_Timer -=diff; + + if (SUMMON_CRAZED_MANA_WRAITH_Timer < diff) + { + Creature* Wraith = m_creature->SummonCreature(MOB_CRAZED_MANA_WRAITH, m_creature->GetPositionX()+1, m_creature->GetPositionY()+1, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if (Wraith) + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + Wraith->AI()->AttackStart(target); + Unit* Anomalus = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ANOMALUS)); + if (Anomalus && Anomalus->HasAura(SPELL_RIFT_SHIELD)) + SUMMON_CRAZED_MANA_WRAITH_Timer = 5000; + else + SUMMON_CRAZED_MANA_WRAITH_Timer = 10000; + }else SUMMON_CRAZED_MANA_WRAITH_Timer -=diff; + } }; -CreatureAI* GetAI_npc_chaotic_rift(Creature *_Creature) +CreatureAI* GetAI_mob_chaotic_rift(Creature *_Creature) { - return new npc_chaotic_riftAI (_Creature); + return new mob_chaotic_riftAI (_Creature); } CreatureAI* GetAI_boss_anomalus(Creature *_Creature) @@ -123,11 +258,6 @@ CreatureAI* GetAI_boss_anomalus(Creature *_Creature) return new boss_anomalusAI (_Creature); } -CreatureAI* GetAI_mob_crazed_mana_wraith(Creature *_Creature) -{ - return new boss_anomalusAI (_Creature); -} - void AddSC_boss_anomalus() { Script *newscript; @@ -136,14 +266,9 @@ void AddSC_boss_anomalus() newscript->Name="boss_anomalus"; newscript->GetAI = &GetAI_boss_anomalus; newscript->RegisterSelf(); - - newscript = new Script; - newscript->Name="mob_crazed_mana_wraith"; - newscript->GetAI = &GetAI_mob_crazed_mana_wraith; - newscript->RegisterSelf(); - + newscript = new Script; - newscript->Name="npc_chaotic_rift"; - newscript->GetAI = &GetAI_npc_chaotic_rift; + newscript->Name="mob_chaotic_rift"; + newscript->GetAI = &GetAI_mob_chaotic_rift; newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_keristrasza.cpp b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_keristrasza.cpp index c2b6d3d4a8b..ed7a3e6867e 100644 --- a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_keristrasza.cpp +++ b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_keristrasza.cpp @@ -1,74 +1,152 @@ -/* Script Data Start -SDName: Boss keristrasza -SDAuthor: LordVanMartin -SD%Complete: -SDComment: -SDCategory: -Script Data End */ - -/*** SQL START *** -update creature_template set scriptname = 'boss_maiden_of_grief' where entry = ''; -*** SQL END ***/ +/* Copyright (C) 2006 - 2009 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_Keristrasza +SD%Complete: +SDComment: +SDCategory: The Nexus, The Nexus +EndScriptData */ + #include "precompiled.h" +#include "def_nexus.h" //Spells +#define SPELL_FROZEN_PRISON 47854 #define SPELL_TAIL_SWEEP 50155 -#define SPELL_CRYSTAL_CHAINS 50997 +#define SPELL_CRYSTAL_CHAINS 50997 #define SPELL_ENRAGE 8599 -#define SPELL_CRYSTALFIRE_BREATH_1 48096 -#define SPELL_CRYSTALFIRE_BREATH_2 57091 -#define SPELL_CRYSTALIZE 48179 -#define SPELL_INTENSE_COLD 48095 //stackable debuff +#define SPELL_CRYSTALFIRE_BREATH_N 48096 +#define SPELL_CRYSTALFIRE_BREATH_H 57091 +#define SPELL_CRYSTALIZE 48179 +#define SPELL_INTENSE_COLD 48094 //Yell -#define SAY_AGGRO -1576005 -#define SAY_SLAY -1576006 -#define SAY_ENRAGE -1576007 -#define SAY_DEATH -1576008 -#define SAY_CRYSTAL_NOVA -1576009 +#define SAY_AGGRO -1576040 +#define SAY_SLAY -1576041 +#define SAY_ENRAGE -1576042 +#define SAY_DEATH -1576043 +#define SAY_CRYSTAL_NOVA -1576044 struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI { - boss_keristraszaAI(Creature *c) : ScriptedAI(c) {} + boss_keristraszaAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; + + uint32 CRYSTALFIRE_BREATH_Timer; + uint32 CRYSTAL_CHAINS_CRYSTALIZE_Timer; + uint32 TAIL_SWEEP_Timer; + bool Enrage; - bool enraged; + void Reset() + { + CRYSTALFIRE_BREATH_Timer = 14000; + CRYSTAL_CHAINS_CRYSTALIZE_Timer = HeroicMode ? 30000 : 11000; + TAIL_SWEEP_Timer = 5000; + Enrage = false; + m_creature->RemoveAurasDueToSpell(SPELL_INTENSE_COLD); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); + if (pInstance && pInstance->GetData(DATA_KERISTRASZA_FREED) == DONE) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + }else{ + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->CastSpell(m_creature, SPELL_FROZEN_PRISON, false); + } + } - void Reset() + void MoveInLineOfSight(Unit *who) { - enraged = false; + if (pInstance && pInstance->GetData(DATA_KERISTRASZA_FREED) != DONE && pInstance->GetData(DATA_MAGUS_TELESTRA_EVENT) == DONE && + pInstance->GetData(DATA_ANOMALUS_EVENT) == DONE && pInstance->GetData(DATA_ORMOROK_EVENT) == DONE && + m_creature->IsHostileTo(who) && m_creature->IsWithinDist(who, 15.0f, false)) + { + pInstance->SetData(DATA_KERISTRASZA_FREED, DONE); + } + if (pInstance->GetData(DATA_KERISTRASZA_FREED) == DONE) + { + m_creature->RemoveAurasDueToSpell(SPELL_FROZEN_PRISON); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + ScriptedAI::MoveInLineOfSight(who); + } } - void EnterCombat(Unit* who) + + void Aggro(Unit* who) { DoScriptText(SAY_AGGRO, m_creature); + DoCast(m_creature, SPELL_INTENSE_COLD); } - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) + + void UpdateAI(const uint32 diff) { - //Return since we have no target - if(!UpdateVictim()) + if (!UpdateVictim()) + { return; + } + + if (!Enrage && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.25)) + { + DoScriptText(SAY_ENRAGE , m_creature); + DoCast(m_creature, SPELL_ENRAGE); + Enrage = true; + } - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) == 10) + if (CRYSTALFIRE_BREATH_Timer < diff) { - if(!enraged) - { - DoScriptText(SAY_ENRAGE, m_creature); - DoCast(m_creature, SPELL_ENRAGE); - enraged = true; - } - } + DoCast(m_creature->getVictim(), HeroicMode ? SPELL_CRYSTALFIRE_BREATH_H : SPELL_CRYSTALFIRE_BREATH_N); + CRYSTALFIRE_BREATH_Timer = 14000; + }else CRYSTALFIRE_BREATH_Timer -=diff; + + if (TAIL_SWEEP_Timer < diff) + { + DoCast(m_creature, SPELL_TAIL_SWEEP); + TAIL_SWEEP_Timer = 5000; + }else TAIL_SWEEP_Timer -=diff; - DoMeleeAttackIfReady(); + if (CRYSTAL_CHAINS_CRYSTALIZE_Timer < diff) + { + DoScriptText(SAY_CRYSTAL_NOVA , m_creature); + if (HeroicMode) + DoCast(m_creature, SPELL_CRYSTALIZE); + else + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_CRYSTAL_CHAINS); + CRYSTAL_CHAINS_CRYSTALIZE_Timer = HeroicMode ? 30000 : 11000; + }else CRYSTAL_CHAINS_CRYSTALIZE_Timer -= diff; + + DoMeleeAttackIfReady(); } - void JustDied(Unit* killer) + + void JustDied(Unit* killer) { DoScriptText(SAY_DEATH, m_creature); } + void KilledUnit(Unit *victim) { - if(victim == m_creature) - return; DoScriptText(SAY_SLAY, m_creature); } }; diff --git a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_magus_telestra.cpp b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_magus_telestra.cpp index f3d9e72267f..8132b99b014 100644 --- a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_magus_telestra.cpp +++ b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_magus_telestra.cpp @@ -1,103 +1,278 @@ -/* Script Data Start -SDName: Boss magus_telestra -SDAuthor: LordVanMartin -SD%Complete: -SDComment: -SDCategory: -Script Data End */ - -/*** SQL START *** -update creature_template set scriptname = '' where entry = ''; -*** SQL END ***/ +/* Copyright (C) 2006 - 2009 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_Magus_Telestra +SD%Complete: +SDComment: +SDCategory: The Nexus, The Nexus +EndScriptData */ + #include "precompiled.h" #include "def_nexus.h" - //Spells -//phase 1 -#define SPELL_ICE_NOVA 47772 -#define SPELL_ICE_NOVA 56935 -#define SPELL_FIREBOMB 47773 -#define SPELL_FIREBOMB 56934 -#define SPELL_GAVITY_WELL 47756 - -//Phase 2 -->50% HP (3 clones, Frost, Fire, Arcane) -//Frost Magus (npc 26930) -#define FROST_MAGUS_VISUAL 47706 //Dummy -#define SPELL_BLIZZARD_N 47727 -#define SPELL_ICE_BARB_N 47729 -//heroic -#define SPELL_BLIZZARD_H 56936 -#define SPELL_ICE_BARB_H 56937 - -//Fire Magus (npc 26928) -#define FIRE_MAGUS_VISUAL 47705 //Dummy -#define SPELL_FIRE_BLAST 47721 -#define SPELL_SCORCH 47723 -//heroic -#define SPELL_FIRE_BLAST_H 56939 -#define SPELL_SCORCH_H 56938 - -//Arcane Magus (npc 26929) -#define ARCANE_MAGUS_VISUAL 47704 //Dummy -#define SPELL_CRITTER 47731 -#define SPELL_TIME_STOP 47736 +#define SPELL_ICE_NOVA_N 47772 +#define SPELL_ICE_NOVA_H 56935 +#define SPELL_FIREBOMB_N 47773 +#define SPELL_FIREBOMB_H 56934 +#define SPELL_GRAVITY_WELL 47756 +#define SPELL_TELESTRA_BACK 47714 + +float CenterOfRoom[1][4] = +{ + {504.80, 89.07, -16.12, 6.27} +}; + +//At 50% HP - 3 clones, Frost, Fire, Arcane (and in 10% HP in Heroic) +#define MOB_FIRE_MAGUS 26928 +#define MOB_FROST_MAGUS 26930 +#define MOB_ARCANE_MAGUS 26929 + +#define SPELL_FIRE_MAGUS_VISUAL 47705 +#define SPELL_FROST_MAGUS_VISUAL 47706 +#define SPELL_ARCANE_MAGUS_VISUAL 47704 //Yell -#define SAY_AGGRO -1576010 -#define SAY_KILL -1576011 -#define SAY_DEATH -1576012 -#define SAY_MERGE -1576013 -#define SAY_SPLIT_1 -1576014 -#define SAY_SPLIT_2 -1576015 +#define SAY_AGGRO -1576000 +#define SAY_KILL -1576001 +#define SAY_DEATH -1576002 +#define SAY_MERGE -1576003 +#define SAY_SPLIT_1 -1576004 +#define SAY_SPLIT_2 -1576005 struct TRINITY_DLL_DECL boss_magus_telestraAI : public ScriptedAI { - boss_magus_telestraAI(Creature *c) : ScriptedAI(c) {} + boss_magus_telestraAI(Creature* c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + Reset(); + HeroicMode = c->GetMap()->IsHeroic(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; - bool splited; - uint64 Magus_frost, - Magus_fire, - Magus_arcane; + uint64 FireMagusGUID; + uint64 FrostMagusGUID; + uint64 ArcaneMagusGUID; + bool FireMagusDead; + bool FrostMagusDead; + bool ArcaneMagusDead; + + uint32 AppearDelay_Timer; + bool AppearDelay; + + uint8 Phase; + + uint32 SPELL_ICE_NOVA_Timer; + uint32 SPELL_FIREBOMB_Timer; + uint32 SPELL_GRAVITY_WELL_Timer; void Reset() { - splited = false; + Phase = 0; + //These times are probably wrong + SPELL_ICE_NOVA_Timer = 7000; + SPELL_FIREBOMB_Timer = 0; + SPELL_GRAVITY_WELL_Timer = 15000; + + FireMagusGUID = 0; + FrostMagusGUID = 0; + ArcaneMagusGUID = 0; + + AppearDelay = false; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetVisibility(VISIBILITY_ON); + + if(pInstance) + pInstance->SetData(DATA_MAGUS_TELESTRA_EVENT, NOT_STARTED); } - void EnterCombat(Unit* who) + + void Aggro(Unit* who) { DoScriptText(SAY_AGGRO, m_creature); } - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) + + uint64 SplitPersonality(uint32 entry) + { + Creature* Summoned = m_creature->SummonCreature(entry, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if (Summoned) + { + switch (entry) + { + case MOB_FIRE_MAGUS: + { + Summoned->CastSpell(Summoned, SPELL_FIRE_MAGUS_VISUAL, false); + break; + } + case MOB_FROST_MAGUS: + { + Summoned->CastSpell(Summoned, SPELL_FROST_MAGUS_VISUAL, false); + break; + } + case MOB_ARCANE_MAGUS: + { + Summoned->CastSpell(Summoned, SPELL_ARCANE_MAGUS_VISUAL, false); + break; + } + } + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + Summoned->AI()->AttackStart(target); + return Summoned->GetGUID(); + } + return 0; + } + + void UpdateAI(const uint32 diff) { //Return since we have no target - if(!UpdateVictim()) + if (!UpdateVictim()) + { return; + } - if(!splited) + if (AppearDelay) { - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 50) + m_creature->StopMoving(); + m_creature->AttackStop(); + if (AppearDelay_Timer < diff) { - DoScriptText(SAY_SPLIT_1, m_creature); - //HandleSplit - splited = true; - } + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + AppearDelay = false; + }else AppearDelay_Timer -= diff; + return; } - DoMeleeAttackIfReady(); + + if ((Phase == 1)||(Phase == 3)) + { + Unit* FireMagus; + Unit* FrostMagus; + Unit* ArcaneMagus; + if (FireMagusGUID) + FireMagus = Unit::GetUnit((*m_creature), FireMagusGUID); + if (FrostMagusGUID) + FrostMagus = Unit::GetUnit((*m_creature), FrostMagusGUID); + if (ArcaneMagusGUID) + ArcaneMagus = Unit::GetUnit((*m_creature), ArcaneMagusGUID); + if (FireMagus && FireMagus->isDead()) + FireMagusDead = true; + if (FrostMagus && FrostMagus->isDead()) + FrostMagusDead = true; + if (ArcaneMagus && ArcaneMagus->isDead()) + ArcaneMagusDead = true; + if (FireMagusDead && FrostMagusDead && ArcaneMagusDead) + { + m_creature->GetMotionMaster()->Clear(); + m_creature->Relocate(CenterOfRoom[0][0], CenterOfRoom[0][1], CenterOfRoom[0][2], CenterOfRoom[0][3]); + DoCast(m_creature, SPELL_TELESTRA_BACK); + m_creature->SetVisibility(VISIBILITY_ON); + if (Phase == 1) + Phase = 2; + if (Phase == 3) + Phase = 4; + FireMagusGUID = 0; + FrostMagusGUID = 0; + ArcaneMagusGUID = 0; + AppearDelay = true; + AppearDelay_Timer = 4000; + DoScriptText(SAY_MERGE, m_creature); + }else + return; + } + + if ((Phase == 0) && (m_creature->GetHealth() <= (m_creature->GetMaxHealth() * 0.5))) + { + Phase = 1; + m_creature->CastStop(); + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + FireMagusGUID = SplitPersonality(MOB_FIRE_MAGUS); + FrostMagusGUID = SplitPersonality(MOB_FROST_MAGUS); + ArcaneMagusGUID = SplitPersonality(MOB_ARCANE_MAGUS); + FireMagusDead = false; + FrostMagusDead = false; + ArcaneMagusDead = false; + switch(rand()%2) + { + case 0: DoScriptText(SAY_SPLIT_1, m_creature); break; + case 1: DoScriptText(SAY_SPLIT_2, m_creature); break; + } + return; + } + + if (HeroicMode && (Phase == 2) && (m_creature->GetHealth() <= (m_creature->GetMaxHealth() * 0.1))) + { + Phase = 3; + m_creature->CastStop(); + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + FireMagusGUID = SplitPersonality(MOB_FIRE_MAGUS); + FrostMagusGUID = SplitPersonality(MOB_FROST_MAGUS); + ArcaneMagusGUID = SplitPersonality(MOB_ARCANE_MAGUS); + FireMagusDead = false; + FrostMagusDead = false; + ArcaneMagusDead = false; + switch(rand()%2) + { + case 0: DoScriptText(SAY_SPLIT_1, m_creature); break; + case 1: DoScriptText(SAY_SPLIT_2, m_creature); break; + } + return; + } + + if (SPELL_ICE_NOVA_Timer < diff) + { + m_creature->CastStop(); + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + DoCast(target, HeroicMode ? SPELL_ICE_NOVA_H : SPELL_ICE_NOVA_N); + SPELL_ICE_NOVA_Timer = 15000; + }else SPELL_ICE_NOVA_Timer -=diff; + + if (SPELL_GRAVITY_WELL_Timer < diff) + { + m_creature->CastStop(); + if (Unit* target = m_creature->getVictim()) + DoCast(target, SPELL_GRAVITY_WELL); + SPELL_GRAVITY_WELL_Timer = 15000; + }else SPELL_GRAVITY_WELL_Timer -=diff; + + if (SPELL_FIREBOMB_Timer < diff) + { + if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + DoCast(target, HeroicMode ? SPELL_FIREBOMB_H : SPELL_FIREBOMB_N); + SPELL_FIREBOMB_Timer = 2000; + }else SPELL_FIREBOMB_Timer -=diff; + + DoMeleeAttackIfReady(); } + void JustDied(Unit* killer) - { + { DoScriptText(SAY_DEATH, m_creature); - } + if (pInstance) + pInstance->SetData(DATA_MAGUS_TELESTRA_EVENT, DONE); + } + void KilledUnit(Unit *victim) { - if(victim == m_creature) - return; DoScriptText(SAY_KILL, m_creature); } }; diff --git a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_ormorok.cpp b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_ormorok.cpp index eacaf771071..51c12bbdb6a 100644 --- a/src/bindings/scripts/scripts/zone/nexus/nexus/boss_ormorok.cpp +++ b/src/bindings/scripts/scripts/zone/nexus/nexus/boss_ormorok.cpp @@ -1,79 +1,288 @@ -/* Script Data Start -SDName: Boss ormorok -SDAuthor: LordVanMartin -SD%Complete: -SDComment: -SDCategory: -Script Data End */ - -/*** SQL START *** -update creature_template set scriptname = '' where entry = ''; -*** SQL END ***/ +/* Copyright (C) 2006 - 2009 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_Ormorok +SD%Complete: +SDComment: +SDCategory: The Nexus, The Nexus +EndScriptData */ + #include "precompiled.h" +#include "def_nexus.h" //Spells -#define SPELL_CRYSTAL_SPIKES_1 47958 -#define SPELL_CRYSTAL_SPIKES_2 57082 -#define SPELL_CRYSTAL_SPIKES_3 57083 +#define SPELL_CRYSTAL_SPIKES_N 47958 //Don't work, using walkaround +#define SPELL_CRYSTAL_SPIKES_H 57082 //Don't work, using walkaround +//Walkaround for spells Crystal Spikes ----------------- +#define SPELL_CRYSTALL_SPIKE_DAMAGE_N 47944 +#define SPELL_CRYSTALL_SPIKE_DAMAGE_H 57067 +#define SPELL_CRYSTAL_SPIKE_PREVISUAL 50442 +#define MOB_CRYSTAL_SPIKE 27099 +//------------------------------------------------------ #define SPELL_SPELL_REFLECTION 47981 #define SPELL_TRAMPLE_N 48016 #define SPELL_TRAMPLE_H 57066 -#define SPELL_FRENZY_N 48017 -#define SPELL_FRENZY_H 57086 +#define SPELL_FRENZY 48017 #define SPELL_SUMMON_CRYSTALLINE_TANGLER 61564 //summons npc 32665 +#define MOB_CRYSTALLINE_TANGLER 32665 +#define SPELL_ROOTS 28858 //proper spell id is unknown //Yell -#define SAY_AGGRO -1576016 -#define SAY_KILL -1576017 -#define SAY_DEATH -1576018 -#define SAY_REFLECT -1576019 -#define SAY_ICE_SPIKES -1576020 +#define SAY_AGGRO -1576020 +#define SAY_DEATH -1576021 +#define SAY_REFLECT -1576022 +#define SAY_CRYSTAL_SPIKES -1576023 +#define SAY_KILL -1576024 + +#define SPIKE_DISTANCE 5.0f struct TRINITY_DLL_DECL boss_ormorokAI : public ScriptedAI { - boss_ormorokAI(Creature *c) : ScriptedAI(c) {} + boss_ormorokAI(Creature *c) : ScriptedAI(c) + { + pInstance = c->GetInstanceData(); + Reset(); + HeroicMode = c->GetMap()->IsHeroic(); + } - bool frenzy; + ScriptedInstance* pInstance; + bool HeroicMode; + bool Frenzy; + bool CrystalSpikes; + uint8 CrystalSpikes_Count; + float BaseX; + float BaseY; + float BaseZ; + float BaseO; + float SpikeXY[4][2]; - void Reset() - { - frenzy = false; - } - void EnterCombat(Unit* who) + uint32 SPELL_CRYSTAL_SPIKES_Timer; + uint32 CRYSTAL_SPIKES_Timer; + uint32 SPELL_TRAMPLE_Timer; + uint32 SPELL_FRENZY_Timer; + uint32 SPELL_SPELL_REFLECTION_Timer; + uint32 SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer; + + void Reset() + { + SPELL_CRYSTAL_SPIKES_Timer = 12000; + SPELL_TRAMPLE_Timer = 10000; + SPELL_SPELL_REFLECTION_Timer = 30000; + SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer = 17000; + Frenzy = false; + CrystalSpikes = false; + if(pInstance) + pInstance->SetData(DATA_ORMOROK_EVENT, NOT_STARTED); + } + + void Aggro(Unit* who) { DoScriptText(SAY_AGGRO, m_creature); } - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) + + void UpdateAI(const uint32 diff) { - //Return since we have no target - if(!UpdateVictim()) + if (!UpdateVictim()) + { return; + } + if (CrystalSpikes) + if (CRYSTAL_SPIKES_Timer < diff) + { + SpikeXY[0][0] = BaseX+(SPIKE_DISTANCE*CrystalSpikes_Count*cos(BaseO)); + SpikeXY[0][1] = BaseY+(SPIKE_DISTANCE*CrystalSpikes_Count*sin(BaseO)); + SpikeXY[1][0] = BaseX-(SPIKE_DISTANCE*CrystalSpikes_Count*cos(BaseO)); + SpikeXY[1][1] = BaseY-(SPIKE_DISTANCE*CrystalSpikes_Count*sin(BaseO)); + SpikeXY[2][0] = BaseX+(SPIKE_DISTANCE*CrystalSpikes_Count*cos(BaseO-(M_PI/2))); + SpikeXY[2][1] = BaseY+(SPIKE_DISTANCE*CrystalSpikes_Count*sin(BaseO-(M_PI/2))); + SpikeXY[3][0] = BaseX-(SPIKE_DISTANCE*CrystalSpikes_Count*cos(BaseO-(M_PI/2))); + SpikeXY[3][1] = BaseY-(SPIKE_DISTANCE*CrystalSpikes_Count*sin(BaseO-(M_PI/2))); + for (uint8 i = 0; i < 4; i++) + Creature* Spike = m_creature->SummonCreature(MOB_CRYSTAL_SPIKE, SpikeXY[i][0], SpikeXY[i][1], BaseZ, 0, TEMPSUMMON_TIMED_DESPAWN, 7000); + if (++CrystalSpikes_Count >= 13) + CrystalSpikes = false; + CRYSTAL_SPIKES_Timer = 200; + }else CRYSTAL_SPIKES_Timer -= diff; - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) == 25) + if (!Frenzy && (m_creature->GetHealth() < m_creature->GetMaxHealth() * 0.25)) { - if(!frenzy) - { - DoCast(m_creature, SPELL_FRENZY_N); - frenzy = true; - } - } + DoCast(m_creature, SPELL_FRENZY); + Frenzy = true; + } - DoMeleeAttackIfReady(); + if (SPELL_TRAMPLE_Timer < diff) + { + DoCast(m_creature, HeroicMode ? SPELL_TRAMPLE_H : SPELL_TRAMPLE_N); + SPELL_TRAMPLE_Timer = 10000; + }else SPELL_TRAMPLE_Timer -= diff; + + if (SPELL_SPELL_REFLECTION_Timer < diff) + { + DoScriptText(SAY_REFLECT, m_creature); + DoCast(m_creature, SPELL_SPELL_REFLECTION); + SPELL_SPELL_REFLECTION_Timer = 30000; + }else SPELL_SPELL_REFLECTION_Timer -= diff; + + if (SPELL_CRYSTAL_SPIKES_Timer < diff) + { + DoScriptText(SAY_CRYSTAL_SPIKES, m_creature); + CrystalSpikes = true; + CrystalSpikes_Count = 1; + CRYSTAL_SPIKES_Timer = 0; + BaseX = m_creature->GetPositionX(); + BaseY = m_creature->GetPositionY(); + BaseZ = m_creature->GetPositionZ(); + BaseO = m_creature->GetOrientation(); + SPELL_CRYSTAL_SPIKES_Timer = 20000; + }else SPELL_CRYSTAL_SPIKES_Timer -=diff; + + if (HeroicMode && (SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer < diff)) + { + Creature* Crystalline_Tangler = m_creature->SummonCreature(MOB_CRYSTALLINE_TANGLER, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if (Crystalline_Tangler) + { + Unit* target = NULL; + uint8 Healer = 0; + for (uint8 j = 1; j<=4; j++) + { + switch (j) + { + case 1: Healer = CLASS_PRIEST; break; + case 2: Healer = CLASS_PALADIN; break; + case 3: Healer = CLASS_DRUID; break; + case 4: Healer = CLASS_SHAMAN; break; + } + std::list<HostilReference*>::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Unit* pTemp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + if (pTemp && pTemp->GetTypeId() == TYPEID_PLAYER && pTemp->getClass() == Healer) + { + target = pTemp; + break; + } + } + if (target) + break; + } + if (!target) + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (target) + { + Crystalline_Tangler->AI()->AttackStart(target); + Crystalline_Tangler->getThreatManager().addThreat(target, 1000000000.0f); + } + } + SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer = 17000; + }else SPELL_SUMMON_CRYSTALLINE_TANGLER_Timer -=diff; + + DoMeleeAttackIfReady(); } - void JustDied(Unit* killer) + + void JustDied(Unit* killer) { DoScriptText(SAY_DEATH, m_creature); + if (pInstance) + pInstance->SetData(DATA_ORMOROK_EVENT, DONE); } - void KilledUnit(Unit *victim) + + void KilledUnit(Unit *victim) { - if(victim == m_creature) - return; DoScriptText(SAY_KILL, m_creature); } + }; +struct TRINITY_DLL_DECL mob_crystal_spikeAI : public Scripted_NoMovementAI +{ + mob_crystal_spikeAI(Creature *c) : Scripted_NoMovementAI(c) + { + Reset(); + HeroicMode = c->GetMap()->IsHeroic(); + } + + bool HeroicMode; + + uint32 SPELL_CRYSTALL_SPIKE_DAMAGE_Timer; + uint32 SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer; + + void Reset() + { + SPELL_CRYSTALL_SPIKE_DAMAGE_Timer = 3700; + SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer = 1000; + m_creature->SetLevel(80); // + m_creature->setFaction(16); //Walkaround to be independent from data in DB + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); // + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); // + } + + void UpdateAI(const uint32 diff) + { + if (SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer < diff) + { + DoCast(m_creature, SPELL_CRYSTAL_SPIKE_PREVISUAL); + SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer = 10000; + }else SPELL_CRYSTAL_SPIKE_PREVISUAL_Timer -=diff; + + if (SPELL_CRYSTALL_SPIKE_DAMAGE_Timer < diff) + { + DoCast(m_creature, HeroicMode ? SPELL_CRYSTALL_SPIKE_DAMAGE_H : SPELL_CRYSTALL_SPIKE_DAMAGE_N); + SPELL_CRYSTALL_SPIKE_DAMAGE_Timer = 10000; + }else SPELL_CRYSTALL_SPIKE_DAMAGE_Timer -=diff; + } +}; + +struct TRINITY_DLL_DECL mob_crystalline_tanglerAI : public ScriptedAI +{ + mob_crystalline_tanglerAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint32 SPELL_ROOTS_Timer; + + void Reset() + { + SPELL_ROOTS_Timer = 1000; + } + + void UpdateAI(const uint32 diff) + { + if (SPELL_ROOTS_Timer < diff) + { + if (m_creature->IsWithinDist(m_creature->getVictim(), 5.0f, false)) + { + DoCast(m_creature->getVictim(), SPELL_ROOTS); + SPELL_ROOTS_Timer = 15000; + } + }else SPELL_ROOTS_Timer -=diff; + } +}; + +CreatureAI* GetAI_mob_crystal_spike(Creature *_Creature) +{ + return new mob_crystal_spikeAI (_Creature); +} + +CreatureAI* GetAI_mob_crystalline_tangler(Creature *_Creature) +{ + return new mob_crystalline_tanglerAI (_Creature); +} + CreatureAI* GetAI_boss_ormorok(Creature *_Creature) { return new boss_ormorokAI (_Creature); @@ -85,6 +294,16 @@ void AddSC_boss_ormorok() newscript = new Script; newscript->Name="boss_ormorok"; - newscript->GetAI = &GetAI_boss_ormorok; + newscript->GetAI = GetAI_boss_ormorok; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_crystal_spike"; + newscript->GetAI = &GetAI_mob_crystal_spike; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="mob_crystalline_tangler"; + newscript->GetAI = &GetAI_mob_crystalline_tangler; newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/zone/nexus/nexus/def_nexus.h b/src/bindings/scripts/scripts/zone/nexus/nexus/def_nexus.h index d868c72adf6..59fb3528f69 100644 --- a/src/bindings/scripts/scripts/zone/nexus/nexus/def_nexus.h +++ b/src/bindings/scripts/scripts/zone/nexus/nexus/def_nexus.h @@ -1,35 +1,11 @@ #ifndef DEF_NEXUS_H #define DEF_NEXUS_H -#define DATA_ANOMALUSDEAD 1 -#define DATA_ANOMALUS_DEATH 2 -#define DATA_ORMOROKDDEAD 3 -#define DATA_ORMOROK_DEATH 4 +#define DATA_MAGUS_TELESTRA_EVENT 1 +#define DATA_ANOMALUS_EVENT 2 +#define DATA_ORMOROK_EVENT 3 +#define DATA_KERISTRASZA_FREED 4 -#define DATA_MAGUSTELESTRADEAD 5 -#define DATA_MAGUSTELESTRA_DEATH 6 -#define DATA_MAGUSTELESTRA_A_DEAD 7 -#define DATA_MAGUSTELESTRA_A_DEATH 8 -#define DATA_MAGUSTELESTRA_F_DEAD 9 -#define DATA_MAGUSTELESTRA_F_DEATH 10 -#define DATA_MAGUSTELESTRA_FI_DEAD 11 -#define DATA_MAGUSTELESTRA_FI_DEATH 12 +#define DATA_ANOMALUS 5 -#define DATA_KERISTRASZADEAD 13 -#define DATA_KERISTRASZA_DEATH 14 -#define DATA_COMMANDER_KOLURGDEAD 15 -#define DATA_COMMANDER_KOLURG_DEATH 16 -#define DATA_COMMANDER_STOUTBEARDDEAD 17 -#define DATA_COMMANDER_STOUTBEARD_DEATH 18 -#define DATA_ANOMALUS 19 -#define DATA_ORMOROK 20 - -#define DATA_MAGUSTELESTRA 21 -#define DATA_MAGUSTELESTRA_A 22 -#define DATA_MAGUSTELESTRA_F 23 -#define DATA_MAGUSTELESTRA_FI 24 - -#define DATA_KERISTRASZA 25 -#define DATA_COMMANDER_KOLURG 26 -#define DATA_COMMANDER_STOUTBEARD 27 #endif diff --git a/src/bindings/scripts/scripts/zone/nexus/nexus/instance_nexus.cpp b/src/bindings/scripts/scripts/zone/nexus/nexus/instance_nexus.cpp index 01d0ade1e25..e953fbc9b29 100644 --- a/src/bindings/scripts/scripts/zone/nexus/nexus/instance_nexus.cpp +++ b/src/bindings/scripts/scripts/zone/nexus/nexus/instance_nexus.cpp @@ -1,145 +1,176 @@ +/* Copyright (C) 2006 - 2009 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_Nexus +SD%Complete: +SDComment: +SDCategory: The Nexus, The Nexus +EndScriptData */ + #include "precompiled.h" #include "def_nexus.h" +#define NUMBER_OF_ENCOUNTERS 4 + struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance { instance_nexus(Map *Map) : ScriptedInstance(Map) {Initialize();}; - uint64 Anomalus, - Ormorok, - Magus_telestra, - Magus_frost, - Magus_fire, - Magus_arcane, - keristrasza, - Commander_kolurg, - Commander_stoutbeard; - bool IsBossDied[9]; + std::string strInstData; + uint64 Anomalus; + uint32 Encounters[NUMBER_OF_ENCOUNTERS]; void Initialize() { - Anomalus = 0; - Ormorok = 0; - Magus_telestra =0; - Magus_frost =0; - Magus_fire =0; - Magus_arcane =0; - keristrasza =0; - Commander_kolurg = 0; - Commander_stoutbeard = 0; - IsBossDied[0] = false; - IsBossDied[1] = false; - IsBossDied[2] = false; - IsBossDied[3] = false; - IsBossDied[4] = false; - IsBossDied[5] = false; - IsBossDied[6] = false; - IsBossDied[7] = false; - IsBossDied[8] = false; + Anomalus = 0; + for(uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; i++) + Encounters[i] = NOT_STARTED; } - bool IsEncounterInProgress() const + void OnCreatureCreate(Creature* pCreature, bool add) { - //not active - return false; + Map::PlayerList const& players = instance->GetPlayers(); + uint32 TeamInInstance; + + if (!players.isEmpty()) + { + if (Player* pPlayer = players.begin()->getSource()) + { + TeamInInstance = pPlayer->GetTeam(); + } + } + switch(pCreature->GetEntry()) + { + case 26763: Anomalus = pCreature->GetGUID(); break; + case 26800: + { + //26799 + pCreature->setFaction(16); + if (TeamInInstance == ALLIANCE) + pCreature->SetDisplayId(24358); + break; + } + case 26802: + { + //26801 + pCreature->setFaction(16); + if (TeamInInstance == ALLIANCE) + pCreature->SetDisplayId(24354); + break; + } + case 26805: + { + //26803 + pCreature->setFaction(16); + if (TeamInInstance == ALLIANCE) + pCreature->SetDisplayId(24357); + break; + } + case 27949: + { + //27947 + pCreature->setFaction(16); + if (TeamInInstance == ALLIANCE) + pCreature->SetDisplayId(24352); + break; + } + case 26796: + { + //26798 + pCreature->setFaction(16); + if (TeamInInstance == ALLIANCE) + pCreature->SetDisplayId(24352); + break; + } + } } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + + uint64 GetData64(uint32 uiIdentifier) { - switch(creature->GetEntry()) + switch(uiIdentifier) { - case 26763: Anomalus = creature->GetGUID(); break; - case 26794: Ormorok = creature->GetGUID(); break; - case 26731: Magus_telestra = creature->GetGUID(); break; - case 26930: Magus_frost = creature->GetGUID(); break; - case 26928: Magus_fire = creature->GetGUID(); break; - case 26926: Magus_arcane = creature->GetGUID(); break; - case 26723: keristrasza = creature->GetGUID(); break; - case 26798: Commander_kolurg = creature->GetGUID(); break; - case 26796: Commander_stoutbeard = creature->GetGUID(); break; + case DATA_ANOMALUS: + return Anomalus; } + return 0; } - uint32 GetData(uint32 type) + + uint32 GetData(uint32 identifier) { - switch(type) + switch(identifier) { - case DATA_ANOMALUSDEAD: - if(IsBossDied[0]) - return 1; - break; - case DATA_ORMOROKDDEAD: - if(IsBossDied[1]) - return 1; - break; - case DATA_MAGUSTELESTRADEAD: - if(IsBossDied[2]) - return 1; - break; - case DATA_MAGUSTELESTRA_A_DEAD: - if(IsBossDied[3]) - return 1; - break; - case DATA_MAGUSTELESTRA_F_DEAD: - if(IsBossDied[4]) - return 1; - break; - case DATA_MAGUSTELESTRA_FI_DEAD: - if(IsBossDied[5]) - return 1; - break; - case DATA_KERISTRASZADEAD: - if(IsBossDied[6]) - return 1; - break; - case DATA_COMMANDER_KOLURGDEAD: - if(IsBossDied[7]) - return 1; - break; - case DATA_COMMANDER_STOUTBEARDDEAD: - if(IsBossDied[8]) - return 1; - break; + case DATA_MAGUS_TELESTRA_EVENT: return Encounters[0]; + case DATA_ANOMALUS_EVENT: return Encounters[1]; + case DATA_ORMOROK_EVENT: return Encounters[2]; + case DATA_KERISTRASZA_FREED: return Encounters[3]; } - return 0; } - uint64 GetData64 (uint32 identifier) + void SetData(uint32 identifier, uint32 data) { - return 0; + switch(identifier) + { + case DATA_MAGUS_TELESTRA_EVENT: Encounters[0] = data; break; + case DATA_ANOMALUS_EVENT: Encounters[1] = data; break; + case DATA_ORMOROK_EVENT: Encounters[2] = data; break; + case DATA_KERISTRASZA_FREED: Encounters[3] = data; break; + } + + if (data == DONE) + { + OUT_SAVE_INST_DATA; + + std::ostringstream saveStream; + saveStream << Encounters[0] << " " << Encounters[1] << " " << Encounters[2] << " " + << Encounters[3]; + + strInstData = saveStream.str(); + + SaveToDB(); + OUT_SAVE_INST_DATA_COMPLETE; + } + } + + std::string GetSaveData() + { + return strInstData; } - void SetData(uint32 type, uint32 data) + void Load(const char* chrIn) { - switch(type) + if (!chrIn) { - case DATA_ANOMALUS_DEATH: - IsBossDied[0] = true; - break; - case DATA_ORMOROK_DEATH: - IsBossDied[1] = true; - break; - case DATA_MAGUSTELESTRA_DEATH: - IsBossDied[2] = true; - break; - case DATA_MAGUSTELESTRA_A_DEATH: - IsBossDied[3] = true; - break; - case DATA_MAGUSTELESTRA_F_DEATH: - IsBossDied[4] = true; - break; - case DATA_MAGUSTELESTRA_FI_DEAD: - IsBossDied[5] = true; - break; - case DATA_KERISTRASZA_DEATH: - IsBossDied[6] = true; - break; - case DATA_COMMANDER_KOLURG_DEATH: - IsBossDied[7] = true; - break; - case DATA_COMMANDER_STOUTBEARD_DEATH: - IsBossDied[8] = true; - break; + OUT_LOAD_INST_DATA_FAIL; + return; } + + OUT_LOAD_INST_DATA(chrIn); + + std::istringstream loadStream(chrIn); + loadStream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3]; + + for(uint8 i = 1; i < NUMBER_OF_ENCOUNTERS; ++i) + { + if (Encounters[i] == IN_PROGRESS) + Encounters[i] = NOT_STARTED; + } + + OUT_LOAD_INST_DATA_COMPLETE; } }; diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/instance_scarlet_monastery.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/instance_scarlet_monastery.cpp index 4c1bd810388..ec694063a1b 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/instance_scarlet_monastery.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/instance_scarlet_monastery.cpp @@ -64,7 +64,7 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance Encounter[i] = NOT_STARTED; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -73,9 +73,9 @@ struct TRINITY_DLL_DECL instance_scarlet_monastery : public ScriptedInstance } } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch(creature_entry) + switch(creature->GetEntry()) { case ENTRY_HORSEMAN: HorsemanGUID = creature->GetGUID(); break; case ENTRY_HEAD: HeadGUID = creature->GetGUID(); break; diff --git a/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp b/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp index d99546fbcea..b98de35d038 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp @@ -70,7 +70,7 @@ struct TRINITY_DLL_DECL instance_scholomance : public ScriptedInstance Encounter[i] = NOT_STARTED; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { 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 fc8970c6f8a..fb8b14c368e 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 @@ -82,7 +82,7 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance return NULL; } - void OnCreatureCreate(Creature* pCreature, uint32 uiCreature) + void OnCreatureCreate(Creature* pCreature, bool add) { switch(pCreature->GetEntry()) { @@ -91,7 +91,7 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance } } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -188,7 +188,7 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance std::string GetSaveData() { - return str_data.c_str(); + return str_data; } void Load(const char* in) diff --git a/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp b/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp index 988667ebe5c..71d9b66aa4c 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp @@ -150,7 +150,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance } } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -162,7 +162,7 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance } } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { 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 72c062c865a..f8c7dde1ca2 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 @@ -119,9 +119,9 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance return NULL; } - void OnCreatureCreate(Creature* creature, uint32 entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch(entry) + switch(creature->GetEntry()) { case 24850: Kalecgos_Dragon = creature->GetGUID(); break; case 24891: Kalecgos_Human = creature->GetGUID(); break; @@ -139,17 +139,17 @@ struct TRINITY_DLL_DECL instance_sunwell_plateau : public ScriptedInstance } } - void OnObjectCreate(GameObject* gobj) + void OnGameObjectCreate(GameObject *go, bool add) { - switch(gobj->GetEntry()) + switch(go->GetEntry()) { - case 188421: ForceField = gobj->GetGUID(); break; - case 188075: FireBarrier = gobj->GetGUID(); break; - case 187979: Gate[0] = gobj->GetGUID(); break; - case 187770: Gate[1] = gobj->GetGUID(); break; - case 187896: Gate[2] = gobj->GetGUID(); break; - case 187990: Gate[3] = gobj->GetGUID(); break; - case 188118: Gate[4] = gobj->GetGUID(); break; + case 188421: ForceField = go->GetGUID(); break; + case 188075: FireBarrier = go->GetGUID(); break; + case 187979: Gate[0] = go->GetGUID(); break; + case 187770: Gate[1] = go->GetGUID(); break; + case 187896: Gate[2] = go->GetGUID(); break; + case 187990: Gate[3] = go->GetGUID(); break; + case 188118: Gate[4] = go->GetGUID(); break; } } 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 a0d21e302b5..ec52a8b116e 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 @@ -91,7 +91,7 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance return false; } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -107,7 +107,7 @@ struct TRINITY_DLL_DECL instance_arcatraz : public ScriptedInstance } } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { if (creature->GetEntry() == MELLICHAR) MellicharGUID = creature->GetGUID(); 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 55ef8c60bbd..d6e7ee20f2b 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 @@ -75,7 +75,7 @@ struct TRINITY_DLL_DECL instance_the_eye : public ScriptedInstance return false; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { 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 e8806b62957..907cf6c67d5 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 @@ -33,10 +33,6 @@ struct TRINITY_DLL_DECL instance_mechanar : public ScriptedInstance uint32 Encounters[ENCOUNTERS]; - void OnCreatureCreate (Creature *creature, uint32 creature_entry) - { - } - void Initialize() { for(uint8 i = 0; i < ENCOUNTERS; ++i) 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 9048591b774..9b5a3f4f5f3 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 @@ -59,9 +59,9 @@ struct TRINITY_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance CthunPhase = 0; } - void OnCreatureCreate (Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch (creature_entry) + switch (creature->GetEntry()) { case 15263: SkeramGUID = creature->GetGUID(); break; case 15544: VemGUID = creature->GetGUID(); break; diff --git a/src/bindings/scripts/scripts/zone/uldaman/instance_uldaman.cpp b/src/bindings/scripts/scripts/zone/uldaman/instance_uldaman.cpp index 3da5e679cab..119d0b1c885 100644 --- a/src/bindings/scripts/scripts/zone/uldaman/instance_uldaman.cpp +++ b/src/bindings/scripts/scripts/zone/uldaman/instance_uldaman.cpp @@ -57,7 +57,7 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance std::vector<uint64> earthenGuardian; std::vector<uint64> archaedasWallMinions; // minions lined up around the wall - void OnObjectCreate (GameObject* go) + void OnGameObjectCreate(GameObject *go, bool add) { switch (go->GetEntry()) { @@ -238,9 +238,9 @@ struct TRINITY_DLL_DECL instance_uldaman : public ScriptedInstance } - void OnCreatureCreate (Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch (creature_entry) { + switch (creature->GetEntry()) { case 4857: // Stone Keeper SetFrozenState (creature); stoneKeeper.push_back(creature->GetGUID()); diff --git a/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp b/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp index d483006642d..44147a4e5c5 100644 --- a/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp +++ b/src/bindings/scripts/scripts/zone/utgarde_keep/utgarde_keep/instance_utgarde_keep.cpp @@ -105,9 +105,9 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance return NULL; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch(creature_entry) + switch(creature->GetEntry()) { case 23953: Keleseth = creature->GetGUID(); break; case 24201: Dalronn = creature->GetGUID(); break; @@ -116,7 +116,7 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance } } - void OnObjectCreate(GameObject* go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { @@ -242,7 +242,7 @@ struct TRINITY_DLL_DECL instance_utgarde_keep : public ScriptedInstance str_data = saveStream.str(); OUT_SAVE_INST_DATA_COMPLETE; - return str_data.c_str(); + return str_data; } void Load(const char* in) diff --git a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp index 8ff01927908..22477bb4b4f 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp @@ -104,7 +104,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance return false; } - void OnCreatureCreate(Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { switch(creature->GetEntry()) { @@ -117,7 +117,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance } } - void OnObjectCreate(GameObject *go) + void OnGameObjectCreate(GameObject *go, bool add) { switch(go->GetEntry()) { diff --git a/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp b/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp index eb3cbd1d495..e09335bba92 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp @@ -37,9 +37,9 @@ struct TRINITY_DLL_DECL instance_zulgurub : public ScriptedInstance uint64 ThekalGUID; uint64 JindoGUID; - void OnCreatureCreate (Creature *creature, uint32 creature_entry) + void OnCreatureCreate(Creature *creature, bool add) { - switch (creature_entry) + switch (creature->GetEntry()) { case 11347: LorKhanGUID = creature->GetGUID(); diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index 75588c7094a..7080c5dcd0b 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -205,6 +205,14 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria) return false; } return true; + case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM: + if(team.team != ALLIANCE && team.team != HORDE) + { + sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM (%u) have unknown team in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,dataType,gender.gender); + return false; + } + return true; default: sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) have data for not supported data type (%u), ignore.", criteria->ID, criteria->requiredType,dataType); return false; @@ -265,6 +273,10 @@ bool AchievementCriteriaData::Meets(Player const* source, Unit const* target, ui return source->GetMap()->GetSpawnMode()==difficalty.difficalty; case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT: return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount; + case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM: + if (!target || target->GetTypeId() != TYPEID_PLAYER) + return false; + return ((Player*)target)->GetTeam() == team.team; } return false; } diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h index 5cf5fe46a60..4931ca302f6 100644 --- a/src/game/AchievementMgr.h +++ b/src/game/AchievementMgr.h @@ -53,12 +53,13 @@ enum AchievementCriteriaDataType ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE = 8, // minvalue value provided with achievement update must be not less that limit ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL = 9, // minlevel minlevel of target ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER = 10,// gender 0=male; 1=female - ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED = 11,// used to prevent achievement createria complete if not all requirement implemented and listed in table + ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED = 11,// used to prevent achievement creteria complete if not all requirement implemented and listed in table ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY = 12,// difficulty normal/heroic difficulty for current event map ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT = 13,// count "with less than %u people in the zone" + ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM = 14,// team HORDE(67), ALLIANCE(469) }; -#define MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE 14 // maximum value in AchievementCriteriaDataType enum +#define MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE 15 // maximum value in AchievementCriteriaDataType enum class Player; class Unit; @@ -128,6 +129,11 @@ struct AchievementCriteriaData { uint32 maxcount; } map_players; + // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM = 14 + struct + { + uint32 team; + } team; // ... struct { diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 7f249b36fbd..4e4cd734d5f 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1646,15 +1646,17 @@ bool Creature::IsWithinSightDist(Unit const* u) const return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); } -bool Creature::canStartAttack(Unit const* who) const +bool Creature::canStartAttack(Unit const* who, bool force) const { - if(isCivilian() || IsNeutralToAll() + if(isCivilian() || !who->isInAccessiblePlaceFor(this) - || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE - || !IsWithinDistInMap(who, GetAttackDistance(who))) + || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) return false; - if(!canAttack(who, false)) + if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who)))) + return false; + + if(!canAttack(who, force)) return false; return IsWithinLOSInMap(who); diff --git a/src/game/Creature.h b/src/game/Creature.h index ec02eb41742..4249e497c4b 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -643,7 +643,7 @@ class TRINITY_DLL_SPEC Creature : public Unit bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const; bool IsWithinSightDist(Unit const* u) const; - bool canStartAttack(Unit const* u) const; + bool canStartAttack(Unit const* u, bool force) const; float GetAttackDistance(Unit const* pl) const; Unit* SelectNearestTarget(float dist = 0) const; diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 143dfec99d3..1c3179b2e23 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -100,11 +100,11 @@ void CreatureAI::MoveInLineOfSight(Unit *who) if(me->getVictim()) return; - if(me->canStartAttack(who)) + if(me->canStartAttack(who, false)) AttackStart(who); else if(who->getVictim() && me->IsFriendlyTo(who) && me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)) - && me->canAttack(who->getVictim())) + && me->canStartAttack(who->getVictim(), true)) AttackStart(who->getVictim()); } diff --git a/src/game/CreatureAIRegistry.cpp b/src/game/CreatureAIRegistry.cpp index d4b30508563..03c12afaaf6 100644 --- a/src/game/CreatureAIRegistry.cpp +++ b/src/game/CreatureAIRegistry.cpp @@ -37,6 +37,7 @@ namespace AIRegistry void Initialize() { (new CreatureAIFactory<NullCreatureAI>("NullCreatureAI"))->RegisterSelf(); + (new CreatureAIFactory<TriggerAI>("TriggerAI"))->RegisterSelf(); (new CreatureAIFactory<AggressorAI>("AggressorAI"))->RegisterSelf(); (new CreatureAIFactory<ReactorAI>("ReactorAI"))->RegisterSelf(); (new CreatureAIFactory<PassiveAI>("PassiveAI"))->RegisterSelf(); diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index bcec34781b0..65e50a2e41b 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -60,12 +60,17 @@ namespace FactorySelector ai_factory = ai_registry.GetRegistryItem("NullCreatureAI"); else if(creature->isGuard()) ai_factory = ai_registry.GetRegistryItem("GuardAI"); - else if(creature->HasSummonMask(SUMMON_MASK_GUARDIAN)) + else if(creature->isGuardian()) ai_factory = ai_registry.GetRegistryItem("PetAI"); else if(creature->isTotem()) ai_factory = ai_registry.GetRegistryItem("TotemAI"); - else if(creature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) - ai_factory = ai_registry.GetRegistryItem("NullCreatureAI"); + else if(creature->isTrigger()) + { + if(creature->m_spells[0]) + ai_factory = ai_registry.GetRegistryItem("TriggerAI"); + else + ai_factory = ai_registry.GetRegistryItem("NullCreatureAI"); + } else if(creature->GetCreatureType() == CREATURE_TYPE_CRITTER) ai_factory = ai_registry.GetRegistryItem("CritterAI"); } diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 834741fd2ae..3eb3a75c874 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -957,11 +957,12 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who) } } - //if (m_creature->isCivilian() && m_creature->IsNeutralToAll()) - // return; - - if(me->canStartAttack(who)) + if(me->canStartAttack(who, false)) AttackStart(who); + else if(who->getVictim() && me->IsFriendlyTo(who) + && me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)) + && me->canStartAttack(who->getVictim(), true)) + AttackStart(who->getVictim()); } void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell) diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 31fc350af70..27c4490801d 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -45,7 +45,7 @@ FleeingMovementGenerator<T>::_setTargetLocation(T &owner) if(!_getPoint(owner, x, y, z)) return; - owner.addUnitState(UNIT_STAT_FLEEING); + owner.addUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); Traveller<T> traveller(owner); i_destinationHolder.SetDestination(traveller, x, y, z); } @@ -304,7 +304,7 @@ FleeingMovementGenerator<T>::Initialize(T &owner) _Init(owner); owner.CastStop(); - owner.addUnitState(UNIT_STAT_FLEEING); + owner.addUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); owner.SetUInt64Value(UNIT_FIELD_TARGET, 0); owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); @@ -353,7 +353,7 @@ void FleeingMovementGenerator<T>::Finalize(T &owner) { owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); - owner.clearUnitState(UNIT_STAT_FLEEING); + owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); if(owner.GetTypeId() == TYPEID_UNIT && owner.getVictim()) owner.SetUInt64Value(UNIT_FIELD_TARGET, owner.getVictim()->GetGUID()); } @@ -413,7 +413,7 @@ template bool FleeingMovementGenerator<Creature>::Update(Creature &, const uint3 void TimedFleeingMovementGenerator::Finalize(Unit &owner) { - owner.clearUnitState(UNIT_STAT_FLEEING); + owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING); if (Unit* victim = owner.getVictim()) { if (owner.isAlive()) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 667891c0e38..5418bd09b16 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -997,7 +997,7 @@ namespace Trinity } else { - if(!m_creature->canStartAttack(u)) + if(!m_creature->canStartAttack(u, false)) return false; } diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp index bb4bfe5e8fc..cca4d7ca786 100644 --- a/src/game/InstanceData.cpp +++ b/src/game/InstanceData.cpp @@ -53,12 +53,6 @@ bool InstanceData::IsEncounterInProgress() const return false; } -//This will be removed in the future, just compitiable with Mangos -void InstanceData::OnCreatureCreate(Creature *creature, bool add) -{ - OnCreatureCreate(creature, creature->GetEntry()); -} - void InstanceData::LoadMinionData(const MinionData *data) { while(data->entry) diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h index f3d45cc0cf6..d5be00580ea 100644 --- a/src/game/InstanceData.h +++ b/src/game/InstanceData.h @@ -138,12 +138,6 @@ class TRINITY_DLL_SPEC InstanceData : public ZoneScript //Called when a player successfully enters the instance. virtual void OnPlayerEnter(Player *) {} - //Called when a gameobject is created - void OnGameObjectCreate(GameObject *go, bool add) { OnObjectCreate(go); } - - //called on creature creation - void OnCreatureCreate(Creature *, bool add); - //Handle open / close objects //use HandleGameObject(NULL,boolen,GO); in OnObjectCreate in instance scripts //use HandleGameObject(GUID,boolen,NULL); in any other script diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 06268f2fef7..3be555cbaba 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -1002,6 +1002,12 @@ bool Item::IsBindedNotWith( Player const* player ) const bool ItemRequiredTarget::IsFitToRequirements( Unit* pUnitTarget ) const { + if(pUnitTarget->GetTypeId() != TYPEID_UNIT) + return false; + + if(pUnitTarget->GetEntry() != m_uiTargetEntry) + return false; + switch(m_uiType) { case ITEM_TARGET_TYPE_CREATURE: diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 3af876f6fde..e3da8480719 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -370,16 +370,16 @@ void Map::AddNotifier(T*) template<> void Map::AddNotifier(Player* obj) { - obj->m_Notified = false; - obj->m_IsInNotifyList = false; + //obj->m_Notified = false; + //obj->m_IsInNotifyList = false; AddUnitToNotify(obj); } template<> void Map::AddNotifier(Creature* obj) { - obj->m_Notified = false; - obj->m_IsInNotifyList = false; + //obj->m_Notified = false; + //obj->m_IsInNotifyList = false; AddUnitToNotify(obj); } @@ -561,25 +561,21 @@ bool Map::loaded(const GridPair &p) const void Map::RelocationNotify() { - //Move backlog to notify list - for(std::vector<uint64>::iterator iter = i_unitsToNotifyBacklog.begin(); iter != i_unitsToNotifyBacklog.end(); ++iter) - { - if(Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL)) - { - i_unitsToNotify.push_back(unit); - } - } - i_unitsToNotifyBacklog.clear(); + i_lock = true; //Notify for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) { Unit *unit = *iter; - if(unit->m_Notified || !unit->IsInWorld() || unit->GetMapId() != GetId()) + if(!unit) + continue; + + unit->m_NotifyListPos = -1; + + if(unit->m_Notified) continue; unit->m_Notified = true; - unit->m_IsInNotifyList = false; float dist = abs(unit->GetPositionX() - unit->oldX) + abs(unit->GetPositionY() - unit->oldY); if(dist > 10.0f) @@ -592,10 +588,10 @@ void Map::RelocationNotify() if(unit->GetTypeId() == TYPEID_PLAYER) { Trinity::PlayerRelocationNotifier notifier(*((Player*)unit)); - if(((Player*)unit)->m_seer != unit) + //if(((Player*)unit)->m_seer != unit) VisitAll(((Player*)unit)->m_seer->GetPositionX(), ((Player*)unit)->m_seer->GetPositionY(), World::GetMaxVisibleDistance() + dist, notifier); - else - VisitAll(((Player*)unit)->GetPositionX(), ((Player*)unit)->GetPositionY(), World::GetMaxVisibleDistance() + dist, notifier); + //else + //VisitAll(((Player*)unit)->GetPositionX(), ((Player*)unit)->GetPositionY(), World::GetMaxVisibleDistance() + dist, notifier); notifier.Notify(); } else @@ -605,31 +601,55 @@ void Map::RelocationNotify() } } for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter) + if(*iter) + (*iter)->m_Notified = false; + i_unitsToNotify.clear(); + + i_lock = false; + + if(!i_unitsToNotifyBacklog.empty()) { - (*iter)->m_Notified = false; + i_unitsToNotify.insert(i_unitsToNotify.end(), i_unitsToNotifyBacklog.begin(), i_unitsToNotifyBacklog.end()); + i_unitsToNotifyBacklog.clear(); } - i_unitsToNotify.clear(); } void Map::AddUnitToNotify(Unit* u) { - if(u->m_IsInNotifyList) - return; + if(u->m_NotifyListPos < 0) + { + u->oldX = u->GetPositionX(); + u->oldY = u->GetPositionY(); - u->m_IsInNotifyList = true; - u->oldX = u->GetPositionX(); - u->oldY = u->GetPositionY(); + if(i_lock) + { + u->m_NotifyListPos = i_unitsToNotifyBacklog.size(); + i_unitsToNotifyBacklog.push_back(u); + } + else + { + u->m_NotifyListPos = i_unitsToNotify.size(); + i_unitsToNotify.push_back(u); + } + } +} +void Map::RemoveUnitFromNotify(int32 slot) +{ if(i_lock) - i_unitsToNotifyBacklog.push_back(u->GetGUID()); + { + assert(slot < i_unitsToNotifyBacklog.size()); + i_unitsToNotifyBacklog[slot] = NULL; + } else - i_unitsToNotify.push_back(u); + { + assert(slot < i_unitsToNotify.size()); + i_unitsToNotify[slot] = NULL; + } } void Map::Update(const uint32 &t_diff) { - i_lock = false; - resetMarkedCells(); Trinity::ObjectUpdater updater(t_diff); @@ -734,10 +754,7 @@ void Map::Update(const uint32 &t_diff) } } - i_lock = true; - MoveAllCreaturesInMoveList(); - RelocationNotify(); RemoveAllObjectsInRemoveList(); // 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 ! @@ -2109,11 +2126,11 @@ inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y) i_grids[x][y] = grid; } -void Map::DoDelayedMovesAndRemoves() -{ - MoveAllCreaturesInMoveList(); - RemoveAllObjectsInRemoveList(); -} +//void Map::DoDelayedMovesAndRemoves() +//{ + //MoveAllCreaturesInMoveList(); + //RemoveAllObjectsInRemoveList(); +//} void Map::AddObjectToRemoveList(WorldObject *obj) { diff --git a/src/game/Map.h b/src/game/Map.h index 9e9f7a9d402..514308c699a 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -340,6 +340,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj virtual void MoveAllCreaturesInMoveList(); virtual void RemoveAllObjectsInRemoveList(); + virtual void RelocationNotify(); bool CreatureRespawnRelocation(Creature *c); // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader @@ -373,7 +374,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj void AddObjectToRemoveList(WorldObject *obj); void AddObjectToSwitchList(WorldObject *obj, bool on); - void DoDelayedMovesAndRemoves(); + //void DoDelayedMovesAndRemoves(); virtual bool RemoveBones(uint64 guid, float x, float y); @@ -388,7 +389,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj bool ActiveObjectsNearGrid(uint32 x, uint32 y) const; void AddUnitToNotify(Unit* unit); - void RelocationNotify(); + void RemoveUnitFromNotify(int32 slot); void SendToPlayers(WorldPacket const* data) const; @@ -496,7 +497,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj time_t i_gridExpiry; bool i_lock; - std::vector<uint64> i_unitsToNotifyBacklog; + std::vector<Unit*> i_unitsToNotifyBacklog; std::vector<Unit*> i_unitsToNotify; std::set<WorldObject *> i_objectsToRemove; std::map<WorldObject*, bool> i_objectsToSwitch; diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index df0fca8016c..ca106d6506c 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -77,6 +77,12 @@ void MapInstanced::RemoveAllObjectsInRemoveList() Map::RemoveAllObjectsInRemoveList(); } +void MapInstanced::RelocationNotify() +{ + for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) + i->second->RelocationNotify(); +} + bool MapInstanced::RemoveBones(uint64 guid, float x, float y) { bool remove_result = false; diff --git a/src/game/MapInstanced.h b/src/game/MapInstanced.h index 70e59065577..bbca6ca0abb 100644 --- a/src/game/MapInstanced.h +++ b/src/game/MapInstanced.h @@ -37,6 +37,7 @@ class TRINITY_DLL_DECL MapInstanced : public Map void Update(const uint32&); void MoveAllCreaturesInMoveList(); void RemoveAllObjectsInRemoveList(); + void RelocationNotify(); bool RemoveBones(uint64 guid, float x, float y); void UnloadAll(); bool CanEnter(Player* player); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index d75ba22b19a..43c778858b5 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -270,7 +270,7 @@ MapManager::Update(uint32 diff) void MapManager::DoDelayedMovesAndRemoves() { for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) - iter->second->DoDelayedMovesAndRemoves(); + iter->second->RelocationNotify(); } bool MapManager::ExistMapAndVMap(uint32 mapid, float x,float y) diff --git a/src/game/NullCreatureAI.cpp b/src/game/NullCreatureAI.cpp index be59ed6e40d..5547ad8f059 100644 --- a/src/game/NullCreatureAI.cpp +++ b/src/game/NullCreatureAI.cpp @@ -20,6 +20,7 @@ #include "NullCreatureAI.h" #include "Creature.h" +#include "TemporarySummon.h" void PassiveAI::UpdateAI(const uint32) { @@ -68,3 +69,13 @@ void CritterAI::EnterEvadeMode() me->SetControlled(false, UNIT_STAT_FLEEING); CreatureAI::EnterEvadeMode(); } + +void TriggerAI::UpdateAI(const uint32 diff) +{ + if(!casted) + { + casted = true; + if(me->m_spells[0] && me->isSummon()) + me->CastSpell(me, me->m_spells[0], false, 0, 0, ((TempSummon*)me)->GetSummonerGUID()); + } +} diff --git a/src/game/NullCreatureAI.h b/src/game/NullCreatureAI.h index 2f481c0a758..84031f179b0 100644 --- a/src/game/NullCreatureAI.h +++ b/src/game/NullCreatureAI.h @@ -75,5 +75,14 @@ class TRINITY_DLL_DECL CritterAI : public PassiveAI void EnterEvadeMode(); }; +class TRINITY_DLL_DECL TriggerAI : public NullCreatureAI +{ + public: + explicit TriggerAI(Creature *c) : NullCreatureAI(c), casted(false) {} + void UpdateAI(const uint32); + private: + bool casted; +}; + #endif diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 18b2de26c70..89979ef439a 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -204,12 +204,12 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool case SUMMON_PET: petlevel=owner->getLevel(); - SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); + SetUInt32Value(UNIT_FIELD_BYTES_0, 0x800); //class=mage SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); // this enables popup window (pet dismiss, cancel) break; case HUNTER_PET: - SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); + SetUInt32Value(UNIT_FIELD_BYTES_0, 0x02020100); //class=warrior,gender=none,power=focus SetSheath(SHEATH_STATE_MELEE); SetByteValue(UNIT_FIELD_BYTES_2, 2, fields[9].GetBool() ? UNIT_RENAME_NOT_ALLOWED : UNIT_RENAME_ALLOWED); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7099b7e3945..2ffd1a8fb58 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -6489,7 +6489,7 @@ void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) return; // not apply mods for broken item - if(item->IsBroken() && apply) + if(item->IsBroken()) return; ItemPrototype const *proto = item->GetProto(); diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 7a405fc57ec..b481afb4bce 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -176,12 +176,22 @@ void TempSummon::InitStats(uint32 duration) if(m_type == TEMPSUMMON_MANUAL_DESPAWN) m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; + Unit *owner = GetSummoner(); + + if(owner && isTrigger() && m_spells[0]) + { + setFaction(owner->getFaction()); + SetLevel(owner->getLevel()); + if(owner->GetTypeId() == TYPEID_PLAYER) + m_ControlledByPlayer = true; + } + if(!m_Properties) return; - if(uint32 slot = m_Properties->Slot) + if(owner) { - if(Unit *owner = GetSummoner()) + if(uint32 slot = m_Properties->Slot) { if(owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID()) { @@ -204,13 +214,6 @@ void TempSummon::InitSummon() { if(owner->GetTypeId()==TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled) ((Creature*)owner)->AI()->JustSummoned(this); - - if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && m_spells[0]) - { - setFaction(owner->getFaction()); - SetLevel(owner->getLevel()); - CastSpell(this, m_spells[0], false, 0, 0, m_summonerGUID); - } } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7704e4e0daa..39a14825573 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -80,7 +80,7 @@ static bool procPrepared = InitTriggerAuraData(); Unit::Unit() : WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) -, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false) +, m_NotifyListPos(-1), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false) , i_AI(NULL), i_disabledAI(NULL), m_removedAurasCount(0), m_Vehicle(NULL), m_transport(NULL) , m_ControlledByPlayer(false), m_procDeep(0) { @@ -10450,8 +10450,7 @@ void Unit::SetVisibility(UnitVisibility x) { m_Visibility = x; - if(IsInWorld()) - SetToNotify(); + SetToNotify(); if(x == VISIBILITY_GROUP_STEALTH) DestroyForNearbyPlayers(); @@ -11685,7 +11684,8 @@ void Unit::AddToWorld() { WorldObject::AddToWorld(); m_Notified = false; - m_IsInNotifyList = false; + //assert(m_NotifyListPos < 0); instance : crash + m_NotifyListPos = -1; SetToNotify(); } } @@ -11704,6 +11704,12 @@ void Unit::RemoveFromWorld() RemoveNotOwnSingleTargetAuras(); ExitVehicle(); + if(m_NotifyListPos >= 0) + { + GetMap()->RemoveUnitFromNotify(m_NotifyListPos); + m_NotifyListPos = -1; + } + if(GetCharmerGUID()) { sLog.outCrash("Unit %u has charmer guid when removed from world", GetEntry()); @@ -13229,11 +13235,9 @@ bool Unit::HandleAuraRaidProcFromCharge( AuraEffect* triggeredByAura ) void Unit::SetToNotify() { - if(m_IsInNotifyList) - return; - - if(Map *map = GetMap()) - map->AddUnitToNotify(this); + // it is called somewhere when obj is not in world (crash when log in instance) + if(m_NotifyListPos < 0) + GetMap()->AddUnitToNotify(this); } void Unit::Kill(Unit *pVictim, bool durabilityLoss) @@ -13668,7 +13672,7 @@ void Unit::SetCharmedBy(Unit* charmer, CharmType type) if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) { //to prevent client crash - //SetFlag(UNIT_FIELD_BYTES_0, 2048); + SetByteValue(UNIT_FIELD_BYTES_0, 1, (uint8)CLASS_MAGE); //just to enable stat window if(GetCharmInfo()) @@ -13763,6 +13767,7 @@ void Unit::RemoveCharmedBy(Unit *charmer) CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo(); if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) { + SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class)); if(GetCharmInfo()) GetCharmInfo()->SetPetNumber(0, true); else diff --git a/src/game/Unit.h b/src/game/Unit.h index 65621ca02b7..5dea3b3304b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1722,7 +1722,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject // relocation notification void SetToNotify(); - bool m_Notified, m_IsInNotifyList; + bool m_Notified; + int32 m_NotifyListPos; float oldX, oldY; void SetReducedThreatPercent(uint32 pct, uint64 guid) diff --git a/src/game/World.cpp b/src/game/World.cpp index 5ab3c46a036..92453ce1f52 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1500,7 +1500,7 @@ void World::SetInitialWorldSettings() LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)", realmID, uint64(m_startTime), isoDate); - m_timers[WUPDATE_OBJECTS].SetInterval(0); + m_timers[WUPDATE_OBJECTS].SetInterval(IN_MILISECONDS/2); m_timers[WUPDATE_SESSIONS].SetInterval(0); m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILISECONDS); m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILISECONDS); @@ -1698,14 +1698,9 @@ void World::Update(uint32 diff) auctionmgr.Update(); } - RecordTimeDiff(NULL); /// <li> Handle session updates when the timer has passed - if (m_timers[WUPDATE_SESSIONS].Passed()) - { - m_timers[WUPDATE_SESSIONS].Reset(); - - UpdateSessions(diff); - } + RecordTimeDiff(NULL); + UpdateSessions(diff); RecordTimeDiff("UpdateSessions"); /// <li> Handle weather updates when the timer has passed @@ -1754,26 +1749,29 @@ void World::Update(uint32 diff) } /// <li> Handle all other objects - if (m_timers[WUPDATE_OBJECTS].Passed()) + ///- Update objects when the timer has passed (maps, transport, creatures,...) + MapManager::Instance().Update(diff); // As interval = 0 + + if(m_timers[WUPDATE_OBJECTS].Passed()) { m_timers[WUPDATE_OBJECTS].Reset(); - ///- Update objects when the timer has passed (maps, transport, creatures,...) - MapManager::Instance().Update(diff); // As interval = 0 + MapManager::Instance().DoDelayedMovesAndRemoves(); + } + ///- Process necessary scripts + if (!m_scriptSchedule.empty()) + { RecordTimeDiff(NULL); - ///- Process necessary scripts - if (!m_scriptSchedule.empty()) - ScriptsProcess(); + ScriptsProcess(); RecordTimeDiff("UpdateScriptsProcess"); + } - sBattleGroundMgr.Update(diff); - RecordTimeDiff("UpdateBattleGroundMgr"); + sBattleGroundMgr.Update(diff); + RecordTimeDiff("UpdateBattleGroundMgr"); - sOutdoorPvPMgr.Update(diff); - RecordTimeDiff("UpdateOutdoorPvPMgr"); - } + sOutdoorPvPMgr.Update(diff); + RecordTimeDiff("UpdateOutdoorPvPMgr"); - RecordTimeDiff(NULL); // execute callbacks from sql queries that were queued recently UpdateResultQueue(); RecordTimeDiff("UpdateResultQueue"); @@ -1795,10 +1793,6 @@ void World::Update(uint32 diff) m_timers[WUPDATE_EVENTS].Reset(); } - /// </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(); |