diff options
Diffstat (limited to 'src')
541 files changed, 11506 insertions, 10119 deletions
diff --git a/src/server/authserver/CMakeLists.txt b/src/server/authserver/CMakeLists.txt index 0d94dc47407..581b48f571c 100644 --- a/src/server/authserver/CMakeLists.txt +++ b/src/server/authserver/CMakeLists.txt @@ -15,15 +15,9 @@ file(GLOB_RECURSE sources_realms Realms/*.cpp Realms/*.h) file(GLOB_RECURSE sources_server Server/*.cpp Server/*.h) file(GLOB sources_localdir *.cpp *.h) -if( USE_COREPCH ) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) -endif() - -if ( USE_COREPCH AND MSVC ) - set(authserver_SRCS - PrecompiledHeaders/authPCH.cpp - PrecompiledHeaders/authPCH.h - ) +if (USE_COREPCH) + set(authserver_PCH_HDR PrecompiledHeaders/authPCH.h) + set(authserver_PCH_SRC PrecompiledHeaders/authPCH.cpp) endif() set(authserver_SRCS @@ -62,34 +56,23 @@ include_directories( ${OPENSSL_INCLUDE_DIR} ) -set(authserver_LINK_FLAGS "") - add_executable(authserver ${authserver_SRCS} + ${authserver_PCH_SRC} ) add_dependencies(authserver revision.h) if( NOT WIN32 ) - add_definitions(-D_TRINITY_REALM_CONFIG='"${CONF_DIR}/authserver.conf"') -endif() - -if( UNIX ) - set(authserver_LINK_FLAGS "-pthread ${authserver_LINK_FLAGS}") -endif() - -if( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) - set(authserver_LINK_FLAGS "-framework Carbon ${authserver_LINK_FLAGS}") + set_target_properties(authserver PROPERTIES + COMPILE_DEFINITIONS _TRINITY_REALM_CONFIG="${CONF_DIR}/authserver.conf" + ) endif() -set_target_properties(authserver PROPERTIES LINK_FLAGS "${authserver_LINK_FLAGS}") - target_link_libraries(authserver shared ${MYSQL_LIBRARY} ${OPENSSL_LIBRARIES} - ${OPENSSL_EXTRA_LIBRARIES} - ${OSX_LIBS} ) if( WIN32 ) @@ -108,11 +91,6 @@ elseif( WIN32 ) endif() # Generate precompiled header -if( USE_COREPCH ) - if(CMAKE_COMPILER_IS_GNUCXX) - add_precompiled_header(authserver ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/authPCH.h) - elseif(MSVC) - add_native_precompiled_header(authserver ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/authPCH) - endif() +if (USE_COREPCH) + add_cxx_pch(authserver ${authserver_PCH_HDR} ${authserver_PCH_SRC}) endif() - diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index fc4d4dfcc9b..ed3b3cf4145 100755 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -280,7 +280,7 @@ void AuthSocket::_SetVSFields(const std::string& rI) v = g.ModExp(x, N); // No SQL injection (username escaped) - const char *v_hex, *s_hex; + char *v_hex, *s_hex; v_hex = v.AsHexStr(); s_hex = s.AsHexStr(); @@ -290,8 +290,8 @@ void AuthSocket::_SetVSFields(const std::string& rI) stmt->setString(2, _login); LoginDatabase.Execute(stmt); - OPENSSL_free((void*)v_hex); - OPENSSL_free((void*)s_hex); + OPENSSL_free(v_hex); + OPENSSL_free(s_hex); } // Logon Challenge command handler diff --git a/src/server/authserver/Server/RealmSocket.cpp b/src/server/authserver/Server/RealmSocket.cpp index c868bb43777..d65431eca44 100755 --- a/src/server/authserver/Server/RealmSocket.cpp +++ b/src/server/authserver/Server/RealmSocket.cpp @@ -79,7 +79,7 @@ int RealmSocket::open(void * arg) return 0; } -int RealmSocket::close(int) +int RealmSocket::close(u_long) { shutdown(); diff --git a/src/server/authserver/Server/RealmSocket.h b/src/server/authserver/Server/RealmSocket.h index c03a0e3ad1e..b093691047c 100755 --- a/src/server/authserver/Server/RealmSocket.h +++ b/src/server/authserver/Server/RealmSocket.h @@ -59,7 +59,7 @@ public: virtual int open(void *); - virtual int close(int); + virtual int close(u_long); virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE); virtual int handle_output(ACE_HANDLE = ACE_INVALID_HANDLE); diff --git a/src/server/collision/CMakeLists.txt b/src/server/collision/CMakeLists.txt index d54d5f91046..a9605759d46 100644 --- a/src/server/collision/CMakeLists.txt +++ b/src/server/collision/CMakeLists.txt @@ -17,12 +17,10 @@ file(GLOB_RECURSE sources_Maps Maps/*.cpp Maps/*.h) file(GLOB_RECURSE sources_Models Models/*.cpp Models/*.h) file(GLOB sources_localdir *.cpp *.h) -if( USE_COREPCH AND MSVC ) - set(collision_STAT_SRCS - PrecompiledHeaders/collisionPCH.cpp - PrecompiledHeaders/collisionPCH.h - ) -endif() +if (USE_COREPCH) + set(collision_STAT_PCH_HDR PrecompiledHeaders/collisionPCH.h) + set(collision_STAT_PCH_SRC PrecompiledHeaders/collisionPCH.cpp) +endif () set(collision_STAT_SRCS ${collision_STAT_SRCS} @@ -33,6 +31,7 @@ set(collision_STAT_SRCS ) include_directories( + ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/dep/g3dlite/include ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour ${CMAKE_SOURCE_DIR}/src/server/shared @@ -75,20 +74,16 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Management ${CMAKE_CURRENT_SOURCE_DIR}/Maps ${CMAKE_CURRENT_SOURCE_DIR}/Models - ${CMAKE_BINARY_DIR} ${ACE_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR} - ${OPENSSL_INCLUDE_DIR} ) -add_library(collision STATIC ${collision_STAT_SRCS}) +add_library(collision STATIC + ${collision_STAT_SRCS} + ${collision_STAT_PCH_SRC} +) # Generate precompiled header -if( USE_COREPCH ) - if(CMAKE_COMPILER_IS_GNUCXX) - add_precompiled_header(collision ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/collisionPCH.h) - elseif(MSVC) - add_native_precompiled_header(collision ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/collisionPCH) - endif() -endif() - +if (USE_COREPCH) + add_cxx_pch(collision ${collision_STAT_PCH_HDR} ${collision_STAT_PCH_SRC}) +endif () diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp index d8c39925dc6..ae8465843b5 100644 --- a/src/server/collision/Models/GameObjectModel.cpp +++ b/src/server/collision/Models/GameObjectModel.cpp @@ -28,6 +28,7 @@ #include "TemporarySummon.h" #include "Object.h" #include "DBCStores.h" +#include "World.h" using G3D::Vector3; using G3D::Ray; diff --git a/src/server/collision/RegularGrid.h b/src/server/collision/RegularGrid.h index 00d7b0cd209..5b7d1d74987 100644 --- a/src/server/collision/RegularGrid.h +++ b/src/server/collision/RegularGrid.h @@ -86,7 +86,7 @@ public: static Cell ComputeCell(float fx, float fy) { - Cell c = {fx * (1.f/CELL_SIZE) + (CELL_NUMBER/2), fy * (1.f/CELL_SIZE) + (CELL_NUMBER/2)}; + Cell c = { int(fx * (1.f/CELL_SIZE) + (CELL_NUMBER/2)), int(fy * (1.f/CELL_SIZE) + (CELL_NUMBER/2)) }; return c; } diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 5ab5f99310a..d9d19c2f009 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -21,6 +21,7 @@ #include "SpellInfo.h" #include "Vehicle.h" #include "ObjectAccessor.h" +#include "Player.h" int AggressorAI::Permissible(const Creature* creature) { diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index 6dfea9ac158..4561aa92741 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -37,12 +37,12 @@ class GameObjectAI virtual void InitializeAI() { Reset(); } - virtual void Reset() {}; + virtual void Reset() { } // Pass parameters between AI virtual void DoAction(const int32 /*param = 0 */) {} - virtual void SetGUID(const uint64& /*guid*/, int32 /*id = 0 */) {} - virtual uint64 GetGUID(int32 /*id = 0 */) { return 0; } + virtual void SetGUID(uint64 /*guid*/, int32 /*id = 0 */) {} + virtual uint64 GetGUID(int32 /*id = 0 */) const { return 0; } static int Permissible(GameObject const* go); @@ -53,9 +53,9 @@ class GameObjectAI virtual bool QuestReward(Player* /*player*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; } virtual uint32 GetDialogStatus(Player* /*player*/) { return 100; } virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) {} - virtual uint32 GetData(uint32 /*id*/) { return 0; } + virtual uint32 GetData(uint32 /*id*/) const { return 0; } virtual void SetData64(uint32 /*id*/, uint64 /*value*/) {} - virtual uint64 GetData64(uint32 /*id*/) { return 0; } + virtual uint64 GetData64(uint32 /*id*/) const { return 0; } virtual void SetData(uint32 /*id*/, uint32 /*value*/) {} virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) {} virtual void OnStateChanged(uint32 /*state*/, Unit* /*unit*/) {} diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 6802c109401..1de5417b820 100755 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -90,8 +90,6 @@ void PetAI::UpdateAI(const uint32 diff) else m_updateAlliesTimer -= diff; - // me->getVictim() can't be used for check in case stop fighting, me->getVictim() clear at Unit death etc. - // Must also check if victim is alive if (me->getVictim() && me->getVictim()->isAlive()) { // is only necessary to stop casting, the pet must not exit combat @@ -108,7 +106,9 @@ void PetAI::UpdateAI(const uint32 diff) return; } - DoMeleeAttackIfReady(); + // Check before attacking to prevent pets from leaving stay position + if (CanAttack(me->getVictim())) + DoMeleeAttackIfReady(); } else if (owner && me->GetCharmInfo()) //no victim { @@ -335,7 +335,8 @@ void PetAI::AttackStart(Unit* target) if (Unit* owner = me->GetOwner()) owner->SetInCombatWith(target); - DoAttack(target, true); + // Only chase if not commanded to stay or if stay but commanded to attack + DoAttack(target, (!me->GetCharmInfo()->HasCommandState(COMMAND_STAY) || me->GetCharmInfo()->IsCommandAttack())); } void PetAI::OwnerDamagedBy(Unit* attacker) @@ -382,31 +383,42 @@ void PetAI::OwnerAttacked(Unit* target) Unit* PetAI::SelectNextTarget() { // Provides next target selection after current target death + // Targets are not evaluated here for being valid attack targets // Passive pets don't do next target selection if (me->HasReactState(REACT_PASSIVE)) return NULL; - Unit* target = me->getAttackerForHelper(); + // Check pet attackers first so we don't drag a bunch of targets to the owner + if (Unit* myAttacker = me->getAttackerForHelper()) + if (!myAttacker->HasBreakableByDamageCrowdControlAura()) + return myAttacker; - // Check pet's attackers first to prevent dragging mobs back to owner - if (target && !target->HasBreakableByDamageCrowdControlAura()) - return target; - - if (me->GetCharmerOrOwner()) - { - // Check owner's attackers if pet didn't have any - target = me->GetCharmerOrOwner()->getAttackerForHelper(); - if (target && !target->HasBreakableByDamageCrowdControlAura()) - return target; - - // 3.0.2 - Pets now start attacking their owners target in defensive mode as soon as the hunter does - target = me->GetCharmerOrOwner()->getVictim(); - if (target && !target->HasBreakableByDamageCrowdControlAura()) - return target; - } + // Not sure why we wouldn't have an owner but just in case... + if (!me->GetCharmerOrOwner()) + return NULL; - // Default + // Check owner attackers + if (Unit* ownerAttacker = me->GetCharmerOrOwner()->getAttackerForHelper()) + if (!ownerAttacker->HasBreakableByDamageCrowdControlAura()) + return ownerAttacker; + + // Check owner victim + // 3.0.2 - Pets now start attacking their owners victim in defensive mode as soon as the hunter does + if (Unit* ownerVictim = me->GetCharmerOrOwner()->getVictim()) + if (!ownerVictim->HasBreakableByDamageCrowdControlAura()) + return ownerVictim; + + // Neither pet or owner had a target and aggressive pets can pick any target + // Note: Creature::SelectNearestTarget() If no distance is supplied it uses MAX_VISIBILITY_DISTANCE + // We also want to lock this to LOS so pet doesn't go running through walls and stuff + if (me->HasReactState(REACT_AGGRESSIVE)) + if (Unit* nearTarget = me->ToCreature()->SelectNearestTarget()) + if (nearTarget->IsHostileTo(me) && !nearTarget->HasBreakableByDamageCrowdControlAura()) + if (nearTarget->IsWithinLOS(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ())) + return nearTarget; + + // Default - no valid targets return NULL; } @@ -518,6 +530,10 @@ bool PetAI::CanAttack(Unit* target) // Evaluates wether a pet can attack a specific // target based on CommandState, ReactState and other flags + // Can't attack dead targets... + if (!target->isAlive()) + return false; + // Returning - check first since pets returning ignore attacks if (me->GetCharmInfo()->IsReturning()) return false; @@ -526,19 +542,17 @@ bool PetAI::CanAttack(Unit* target) if (me->HasReactState(REACT_PASSIVE)) return me->GetCharmInfo()->IsCommandAttack(); - // Pets commanded to attack should not stop their approach if attacked by another creature - if (me->getVictim() && (me->getVictim() != target)) - return !me->GetCharmInfo()->IsCommandAttack(); - - // From this point on, pet will always be either aggressive or defensive + // Follow + if (me->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW)) + return true; // Stay - can attack if target is within range or commanded to if (me->GetCharmInfo()->HasCommandState(COMMAND_STAY)) - return (me->IsWithinMeleeRange(target, MELEE_RANGE) || me->GetCharmInfo()->IsCommandAttack()); + return (me->IsWithinMeleeRange(target) || me->GetCharmInfo()->IsCommandAttack()); - // Follow - if (me->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW)) - return true; + // Pets commanded to attack should not stop their approach if attacked by another creature + if (me->getVictim() && (me->getVictim() != target)) + return !me->GetCharmInfo()->IsCommandAttack(); // default, though we shouldn't ever get here return false; diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index b07c766ae0b..2eab0e89fcd 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -24,8 +24,9 @@ #include "Containers.h" #include <list> -class Unit; class Player; +class Quest; +class Unit; struct AISpellInfoType; // Default script texts @@ -146,10 +147,10 @@ class UnitAI // Pass parameters between AI virtual void DoAction(int32 const /*param*/) {} - virtual uint32 GetData(uint32 /*id = 0*/) { return 0; } + virtual uint32 GetData(uint32 /*id = 0*/) const { return 0; } virtual void SetData(uint32 /*id*/, uint32 /*value*/) {} virtual void SetGUID(uint64 /*guid*/, int32 /*id*/ = 0) {} - virtual uint64 GetGUID(int32 /*id*/ = 0) { return 0; } + virtual uint64 GetGUID(int32 /*id*/ = 0) const { return 0; } Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0); // Select the targets satifying the predicate. diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index 78a84eb7ae4..84e44109e58 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -497,23 +497,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } break; } - case ACTION_T_SUMMON: - { - Unit* target = GetTargetByType(action.summon.target, actionInvoker); - - Creature* creature = NULL; - - if (action.summon.duration) - creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); - else - creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - - if (!creature) - sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, eventId, me->GetEntry()); - else if (action.summon.target != TARGET_T_SELF && target) - creature->AI()->AttackStart(target); - break; - } case ACTION_T_THREAT_SINGLE_PCT: if (Unit* target = GetTargetByType(action.threat_single_pct.target, actionInvoker)) me->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); @@ -663,30 +646,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 else sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", eventId, me->GetEntry()); break; - case ACTION_T_SUMMON_ID: - { - Unit* target = GetTargetByType(action.summon_id.target, actionInvoker); - - CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr->GetCreatureEventAISummonMap().find(action.summon_id.spawnId); - if (i == sEventAIMgr->GetCreatureEventAISummonMap().end()) - { - sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, eventId, me->GetEntry()); - return; - } - - Creature* creature = NULL; - if ((*i).second.SpawnTimeSecs) - creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); - else - creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - - if (!creature) - sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, eventId, me->GetEntry()); - else if (action.summon_id.target != TARGET_T_SELF && target) - creature->AI()->AttackStart(target); - - break; - } case ACTION_T_KILLED_MONSTER: //first attempt player who tapped creature if (Player* player = me->GetLootRecipient()) @@ -798,7 +757,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } break; } - case ACTION_T_SET_SHEATH: { me->SetSheath(SheathState(action.set_sheath.sheath)); diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp index 2d973d9eb8f..f3df332c1e9 100755 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp @@ -26,6 +26,7 @@ #include "ConditionMgr.h" #include "SpellMgr.h" #include "SpellInfo.h" +#include "Player.h" // ------------------- void CreatureEventAIMgr::LoadCreatureEventAI_Texts() @@ -100,52 +101,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts() sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u additional CreatureEventAI Texts data in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } -void CreatureEventAIMgr::LoadCreatureEventAI_Summons() -{ - uint32 oldMSTime = getMSTime(); - - //Drop Existing EventSummon Map - m_CreatureEventAI_Summon_Map.clear(); - - // Gather additional data for EventAI - QueryResult result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM creature_ai_summons"); - - if (!result) - { - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 CreatureEventAI Summon definitions. DB table `creature_ai_summons` is empty."); - return; - } - - uint32 count = 0; - - do - { - Field* fields = result->Fetch(); - - CreatureEventAI_Summon temp; - - uint32 i = fields[0].GetUInt32(); - temp.position_x = fields[1].GetFloat(); - temp.position_y = fields[2].GetFloat(); - temp.position_z = fields[3].GetFloat(); - temp.orientation = fields[4].GetFloat(); - temp.SpawnTimeSecs = fields[5].GetUInt32(); - - if (!Trinity::IsValidMapCoord(temp.position_x, temp.position_y, temp.position_z, temp.orientation)) - { - sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Summon id %u have wrong coordinates (%f, %f, %f, %f), skipping.", i, temp.position_x, temp.position_y, temp.position_z, temp.orientation); - continue; - } - - //Add to map - m_CreatureEventAI_Summon_Map[i] = temp; - ++count; - } - while (result->NextRow()); - - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u CreatureEventAI summon definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); -} - void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { uint32 oldMSTime = getMSTime(); @@ -622,14 +577,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() // equal case processed at call } break; - case ACTION_T_SUMMON_ID: - if (!sObjectMgr->GetCreatureTemplate(action.summon_id.creatureId)) - sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.summon_id.creatureId); - if (action.summon_id.target >= TARGET_T_END) - sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); - if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end()) - sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j+1, action.summon_id.spawnId); - break; case ACTION_T_KILLED_MONSTER: if (!sObjectMgr->GetCreatureTemplate(action.killed_monster.creatureId)) sLog->outError(LOG_FILTER_SQL, "CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.killed_monster.creatureId); diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.h b/src/server/game/AI/EventAI/CreatureEventAIMgr.h index 93e953681b6..75e24266fb5 100755 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.h +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.h @@ -32,16 +32,13 @@ class CreatureEventAIMgr public: void LoadCreatureEventAI_Texts(); - void LoadCreatureEventAI_Summons(); void LoadCreatureEventAI_Scripts(); CreatureEventAI_Event_Map const& GetCreatureEventAIMap() const { return m_CreatureEventAI_Event_Map; } - CreatureEventAI_Summon_Map const& GetCreatureEventAISummonMap() const { return m_CreatureEventAI_Summon_Map; } CreatureEventAI_TextMap const& GetCreatureEventAITextMap() const { return m_CreatureEventAI_TextMap; } private: CreatureEventAI_Event_Map m_CreatureEventAI_Event_Map; - CreatureEventAI_Summon_Map m_CreatureEventAI_Summon_Map; CreatureEventAI_TextMap m_CreatureEventAI_TextMap; }; diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index f8025a32b7f..67cabc6ccb1 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -77,17 +77,13 @@ void SummonList::RemoveNotExisting() } } -bool SummonList::HasEntry(uint32 entry) +bool SummonList::HasEntry(uint32 entry) const { - for (iterator i = begin(); i != end();) + for (const_iterator i = begin(); i != end(); ++i) { Creature* summon = Unit::GetCreature(*me, *i); - if (!summon) - erase(i++); - else if (summon->GetEntry() == entry) + if (summon && summon->GetEntry() == entry) return true; - else - ++i; } return false; diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index aa46d555b7d..2a221d04404 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -54,7 +54,7 @@ class SummonList : public std::list<uint64> void DoZoneInCombat(uint32 entry = 0); void RemoveNotExisting(); - bool HasEntry(uint32 entry); + bool HasEntry(uint32 entry) const; private: Creature* me; }; diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 9c666e7de32..3f5952a210d 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -12,6 +12,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "Group.h" +#include "Player.h" enum ePoints { diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index ebb734156b4..96209084240 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -12,6 +12,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedFollowerAI.h" #include "Group.h" +#include "Player.h" const float MAX_PLAYER_DISTANCE = 100.0f; diff --git a/src/server/game/AI/ScriptedAI/ScriptedGossip.h b/src/server/game/AI/ScriptedAI/ScriptedGossip.h index 34300ff406c..ae1b5fcc12d 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedGossip.h +++ b/src/server/game/AI/ScriptedAI/ScriptedGossip.h @@ -8,7 +8,6 @@ #ifndef SC_GOSSIP_H #define SC_GOSSIP_H -#include "Player.h" #include "GossipDef.h" #include "QuestDef.h" diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 7dd4053b82f..6aebcbb2d8a 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -698,7 +698,7 @@ void SmartAI::DoAction(const int32 param) GetScript()->ProcessEventsFor(SMART_EVENT_ACTION_DONE, NULL, param); } -uint32 SmartAI::GetData(uint32 /*id*/) +uint32 SmartAI::GetData(uint32 /*id*/) const { return 0; } @@ -712,7 +712,7 @@ void SmartAI::SetGUID(uint64 /*guid*/, int32 /*id*/) { } -uint64 SmartAI::GetGUID(int32 /*id*/) +uint64 SmartAI::GetGUID(int32 /*id*/) const { return 0; } diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index f81d6e86850..6f748f9dee2 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -22,7 +22,6 @@ #include "Creature.h" #include "CreatureAI.h" #include "Unit.h" -#include "ConditionMgr.h" #include "Spell.h" #include "SmartScript.h" @@ -151,7 +150,7 @@ class SmartAI : public CreatureAI void DoAction(const int32 param = 0); // Used in scripts to share variables - uint32 GetData(uint32 id = 0); + uint32 GetData(uint32 id = 0) const; // Used in scripts to share variables void SetData(uint32 id, uint32 value); @@ -160,7 +159,7 @@ class SmartAI : public CreatureAI void SetGUID(uint64 guid, int32 id = 0); // Used in scripts to share variables - uint64 GetGUID(int32 id = 0); + uint64 GetGUID(int32 id = 0) const; //core related static int Permissible(const Creature*); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index a1fb2147cc2..2cd65c42f74 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -15,25 +15,25 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "Cell.h" +#include "CellImpl.h" +#include "CreatureTextMgr.h" #include "DatabaseEnv.h" -#include "ObjectMgr.h" -#include "ObjectDefines.h" +#include "GossipDef.h" #include "GridDefines.h" #include "GridNotifiers.h" -#include "SpellMgr.h" #include "GridNotifiersImpl.h" -#include "Cell.h" -#include "CellImpl.h" +#include "Group.h" #include "InstanceScript.h" +#include "Language.h" +#include "ObjectDefines.h" +#include "ObjectMgr.h" #include "ScriptedCreature.h" -#include "GossipDef.h" -#include "ScriptedCreature.h" -#include "SmartScript.h" +#include "ScriptedGossip.h" #include "SmartAI.h" -#include "Group.h" +#include "SmartScript.h" +#include "SpellMgr.h" #include "Vehicle.h" -#include "ScriptedGossip.h" -#include "CreatureTextMgr.h" class TrinityStringTextBuilder { @@ -472,6 +472,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { + // Special handling for vehicles + if (IsUnit(*itr)) + if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit()) + for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it) + if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger)) + player->AreaExploredOrEventHappens(e.action.quest.quest); + if (IsPlayer(*itr)) { (*itr)->ToPlayer()->AreaExploredOrEventHappens(e.action.quest.quest); @@ -746,12 +753,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_CALL_GROUPEVENTHAPPENS: { + if (!unit) + break; + if (IsPlayer(unit) && GetBaseObject()) { unit->ToPlayer()->GroupEventHappens(e.action.quest.quest, GetBaseObject()); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_CALL_GROUPEVENTHAPPENS: Player %u, group credit for quest %u", unit->GetGUIDLow(), e.action.quest.quest); } + + // Special handling for vehicles + if (Vehicle* vehicle = unit->GetVehicleKit()) + for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it) + if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger)) + player->GroupEventHappens(e.action.quest.quest, GetBaseObject()); break; } case SMART_ACTION_CALL_CASTEDCREATUREORGO: @@ -878,6 +894,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { + // Special handling for vehicles + if (IsUnit(*itr)) + if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit()) + for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it) + if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger)) + player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player); + if (!IsPlayer(*itr)) continue; diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 2a0eceb574a..61e22b25d17 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -22,7 +22,6 @@ #include "Creature.h" #include "CreatureAI.h" #include "Unit.h" -#include "ConditionMgr.h" #include "Spell.h" #include "GridNotifiers.h" diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index 2b67acfd6d0..a82de501ea6 100755 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -22,6 +22,7 @@ #include "Player.h" #include "Util.h" #include "SHA1.h" +#include "WorldSession.h" namespace AccountMgr { diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 0ee133edce9..91437ae3bb5 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -16,30 +16,32 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" -#include "DBCEnums.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "World.h" -#include "WorldPacket.h" -#include "DatabaseEnv.h" #include "AchievementMgr.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "BattlegroundAB.h" +#include "Battleground.h" #include "CellImpl.h" +#include "Common.h" +#include "DatabaseEnv.h" +#include "DBCEnums.h" +#include "DisableMgr.h" #include "GameEventMgr.h" #include "GridNotifiersImpl.h" #include "Guild.h" +#include "GuildMgr.h" +#include "InstanceScript.h" #include "Language.h" +#include "Map.h" +#include "MapManager.h" +#include "ObjectMgr.h" #include "Player.h" -#include "SpellMgr.h" -#include "DisableMgr.h" +#include "ReputationMgr.h" #include "ScriptMgr.h" -#include "MapManager.h" -#include "Battleground.h" -#include "BattlegroundAB.h" -#include "Map.h" -#include "InstanceScript.h" +#include "SpellMgr.h" +#include "World.h" +#include "WorldPacket.h" + namespace Trinity { @@ -355,7 +357,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un return false; return target->getGender() == gender.gender; case ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT: - return sScriptMgr->OnCriteriaCheck(this, const_cast<Player*>(source), const_cast<Unit*>(target)); + return sScriptMgr->OnCriteriaCheck(ScriptId, const_cast<Player*>(source), const_cast<Unit*>(target)); case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY: if (source->GetMap()->IsRaid()) if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0)) @@ -1617,7 +1619,6 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK: case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE: case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE: - case ACHIEVEMENT_CRITERIA_TYPE_TOTAL: break; // Not implemented yet :( } @@ -2405,7 +2406,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements() if (!result) { - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 completed achievements. DB table `character_achievement` is empty."); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 realm first completed achievements. DB table `character_achievement` is empty."); return; } @@ -2432,7 +2433,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements() m_allCompletedAchievements.insert(achievementId); } while (result->NextRow()); - sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %lu completed achievements in %u ms", (unsigned long)m_allCompletedAchievements.size(), GetMSTimeDiffToNow(oldMSTime)); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %lu realm first completed achievements in %u ms", (unsigned long)m_allCompletedAchievements.size(), GetMSTimeDiffToNow(oldMSTime)); } void AchievementGlobalMgr::LoadRewards() diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index b3f5c7bf704..7e3b3cc0f1a 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -587,12 +587,12 @@ bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player* player) //-------------------- //-Battlefield Method- //-------------------- -BfGraveyard* Battlefield::GetGraveyardById(uint32 id) +BfGraveyard* Battlefield::GetGraveyardById(uint32 id) const { if (id < m_GraveyardList.size()) { - if (m_GraveyardList[id]) - return m_GraveyardList[id]; + if (BfGraveyard* graveyard = m_GraveyardList.at(id)) + return graveyard; else sLog->outError(LOG_FILTER_BATTLEFIELD, "Battlefield::GetGraveyardById Id:%u not existed", id); } diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 0752fa88fc1..4533c666869 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -79,6 +79,8 @@ class BfCapturePoint public: BfCapturePoint(Battlefield* bf); + virtual ~BfCapturePoint() { } + virtual void FillInitialWorldStates(WorldPacket& /*data*/) {} // Send world state update to all players present @@ -145,7 +147,7 @@ class BfGraveyard // Method to changing who controls the graveyard void GiveControlTo(TeamId team); - TeamId GetControlTeamId() { return m_ControlTeam; } + TeamId GetControlTeamId() const { return m_ControlTeam; } // Find the nearest graveyard to a player float GetDistance(Player* player); @@ -185,7 +187,7 @@ class BfGraveyard bool HasPlayer(uint64 guid) { return m_ResurrectQueue.find(guid) != m_ResurrectQueue.end(); } // Get the graveyard's ID. - uint32 GetGraveyardId() { return m_GraveyardId; } + uint32 GetGraveyardId() const { return m_GraveyardId; } protected: TeamId m_ControlTeam; @@ -258,11 +260,11 @@ class Battlefield : public ZoneScript void HandlePlayerLeaveZone(Player* player, uint32 zone); // All-purpose data storage 64 bit - virtual uint64 GetData64(uint32 dataId) { return m_Data64[dataId]; } + virtual uint64 GetData64(uint32 dataId) const { return m_Data64[dataId]; } virtual void SetData64(uint32 dataId, uint64 value) { m_Data64[dataId] = value; } // All-purpose data storage 32 bit - virtual uint32 GetData(uint32 dataId) { return m_Data32[dataId]; } + virtual uint32 GetData(uint32 dataId) const { return m_Data32[dataId]; } virtual void SetData(uint32 dataId, uint32 value) { m_Data32[dataId] = value; } virtual void UpdateData(uint32 index, int32 pad) { m_Data32[index] += pad; } @@ -290,7 +292,7 @@ class Battlefield : public ZoneScript virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid); void RemovePlayerFromResurrectQueue(uint64 player_guid); void SetGraveyardNumber(uint32 number) { m_GraveyardList.resize(number); } - BfGraveyard* GetGraveyardById(uint32 id); + BfGraveyard* GetGraveyardById(uint32 id) const; // Misc methods Creature* SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team); diff --git a/src/server/game/Battlefield/BattlefieldHandler.cpp b/src/server/game/Battlefield/BattlefieldHandler.cpp index 1ebeb664fb3..a2d8cec3936 100644 --- a/src/server/game/Battlefield/BattlefieldHandler.cpp +++ b/src/server/game/Battlefield/BattlefieldHandler.cpp @@ -25,6 +25,7 @@ #include "Battlefield.h" #include "BattlefieldMgr.h" #include "Opcodes.h" +#include "Player.h" //This send to player windows for invite player to join the war //Param1:(BattleId) the BattleId of Bf diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 59dc6761583..0ea4266cc22 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -20,10 +20,14 @@ // TODO: Use spell victory/defeat in wg instead of RewardMarkOfHonor() && RewardHonor // TODO: Add proper implement of achievement -#include "ObjectMgr.h" #include "BattlefieldWG.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "Player.h" #include "SpellAuras.h" +#include "TemporarySummon.h" #include "Vehicle.h" +#include "WorldSession.h" enum WGVehicles { @@ -453,7 +457,7 @@ void BattlefieldWG::OnStartGrouping() SendWarningToAllInZone(BATTLEFIELD_WG_TEXT_WILL_START); } -uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) +uint8 BattlefieldWG::GetSpiritGraveyardId(uint32 areaId) const { switch (areaId) { @@ -801,7 +805,7 @@ void BattlefieldWG::OnPlayerEnterZone(Player* player) SendInitWorldStatesTo(player); } -uint32 BattlefieldWG::GetData(uint32 data) +uint32 BattlefieldWG::GetData(uint32 data) const { switch (data) { @@ -812,8 +816,8 @@ uint32 BattlefieldWG::GetData(uint32 data) case AREA_WESTPARK_WORKSHOP: case AREA_EASTPARK_WORKSHOP: // Graveyards and Workshops are controlled by the same team. - if (m_GraveyardList[GetSpiritGraveyardId(data)]) - return m_GraveyardList[GetSpiritGraveyardId(data)]->GetControlTeamId(); + if (BfGraveyard const* graveyard = GetGraveyardById(GetSpiritGraveyardId(data))) + return graveyard->GetControlTeamId(); } return Battlefield::GetData(data); diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h index 49ea25a5e04..bd616167e8b 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.h +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h @@ -21,11 +21,10 @@ #include "ObjectAccessor.h" #include "WorldPacket.h" -#include "World.h" -#include "Group.h" -#include "GroupMgr.h" #include "Battlefield.h" +#include "World.h" +class Group; class BattlefieldWG; class WintergraspCapturePoint; @@ -153,10 +152,10 @@ class BfGraveyardWG : public BfGraveyard public: BfGraveyardWG(BattlefieldWG* Bf); - void SetTextId(uint32 textid) { m_GossipTextId = textid; } - uint32 GetTextId() { return m_GossipTextId; } + void SetTextId(int32 textid) { m_GossipTextId = textid; } + int32 GetTextId() { return m_GossipTextId; } protected: - uint32 m_GossipTextId; + int32 m_GossipTextId; }; enum WGGraveyardId @@ -227,7 +226,7 @@ struct BfWGCoordGY float o; uint32 gyid; uint8 type; - uint32 textid; // for gossip menu + int32 textid; // for gossip menu TeamId startcontrol; }; @@ -412,9 +411,9 @@ class BattlefieldWG : public Battlefield bool FindAndRemoveVehicleFromList(Unit* vehicle); // returns the graveyardId in the specified area. - uint8 GetSpiritGraveyardId(uint32 areaId); + uint8 GetSpiritGraveyardId(uint32 areaId) const; - uint32 GetData(uint32 data); + uint32 GetData(uint32 data) const; protected: bool m_isRelicInteractible; diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index d763b29bbc1..fd58765b056 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -22,6 +22,9 @@ #include "World.h" #include "Group.h" #include "ArenaTeamMgr.h" +#include "Player.h" +#include "WorldSession.h" +#include "Opcodes.h" ArenaTeam::ArenaTeam() : TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0), @@ -510,6 +513,23 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCoun sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_EVENT"); } +void ArenaTeam::MassInviteToEvent(WorldSession* session) +{ + WorldPacket data(SMSG_CALENDAR_ARENA_TEAM, (Members.size() - 1) * (4 + 8 + 1)); + data << uint32(Members.size() - 1); + + for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) + { + if (itr->Guid != session->GetPlayer()->GetGUID()) + { + data.appendPackGUID(itr->Guid); + data << uint8(0); // unk + } + } + + session->SendPacket(&data); +} + uint8 ArenaTeam::GetSlotByType(uint32 type) { switch (type) diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 7d2d680cddc..137ac93d3c0 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -162,6 +162,8 @@ class ArenaTeam void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3); void NotifyStatsChanged(); + void MassInviteToEvent(WorldSession* session); + void Roster(WorldSession* session); void Query(WorldSession* session); void SendStats(WorldSession* session); diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp index 55de445345b..8a2dcecd209 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp @@ -22,6 +22,7 @@ #include "DatabaseEnv.h" #include "Language.h" #include "ObjectAccessor.h" +#include "Player.h" ArenaTeamMgr::ArenaTeamMgr() { diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 50f8554d5db..40a74a49b69 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -16,24 +16,24 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Player.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "World.h" -#include "WorldPacket.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" #include "Battleground.h" #include "BattlegroundMgr.h" #include "Creature.h" #include "Formulas.h" #include "GridNotifiersImpl.h" #include "Group.h" -#include "Language.h" #include "MapManager.h" #include "Object.h" -#include "SpellAuras.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ReputationMgr.h" #include "SpellAuraEffects.h" +#include "SpellAuras.h" #include "Util.h" +#include "World.h" +#include "WorldPacket.h" namespace Trinity { @@ -404,6 +404,17 @@ inline void Battleground::_ProcessRessurect(uint32 diff) } } +uint32 Battleground::GetPrematureWinner() +{ + uint32 winner = 0; + if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam()) + winner = ALLIANCE; + else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam()) + winner = HORDE; + + return winner; +} + inline void Battleground::_ProcessProgress(uint32 diff) { // ********************************************************* @@ -418,13 +429,7 @@ inline void Battleground::_ProcessProgress(uint32 diff) else if (m_PrematureCountDownTimer < diff) { // time's up! - uint32 winner = 0; - if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam()) - winner = ALLIANCE; - else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam()) - winner = HORDE; - - EndBattleground(winner); + EndBattleground(GetPrematureWinner()); m_PrematureCountDown = false; } else if (!sBattlegroundMgr->isTesting()) @@ -642,7 +647,12 @@ void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket* packet, Player* for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) if (Player* player = _GetPlayerForTeam(TeamID, itr, "SendPacketToTeam")) if (self || sender != player) - player->GetSession()->SendPacket(packet); + { + WorldSession* session = player->GetSession(); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "%s %s - SendPacketToTeam %u, Player: %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), + session->GetPlayerInfo().c_str(), TeamID, sender ? sender->GetName().c_str() : "null"); + session->SendPacket(packet); + } } void Battleground::PlaySoundToAll(uint32 SoundID) @@ -1064,7 +1074,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac if (Transport) player->TeleportToBGEntryPoint(); - sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Removed player %s from Battleground.", player->GetName().c_str()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Removed player %s from Battleground.", player->GetName().c_str()); } //battleground object will be deleted next Battleground::Update() call @@ -1078,9 +1088,6 @@ void Battleground::Reset() SetStartTime(0); SetEndTime(0); SetLastResurrectTime(0); - SetArenaType(0); - SetRated(false); - m_Events = 0; if (m_InvitedAlliance > 0 || m_InvitedHorde > 0) @@ -1177,10 +1184,9 @@ void Battleground::AddPlayer(Player* player) player->ResetAllPowers(); } - WorldPacket teammate; - teammate.Initialize(SMSG_ARENA_OPPONENT_UPDATE, 8); - teammate << uint64(player->GetGUID()); - SendPacketToTeam(team, &teammate, player, false); + WorldPacket data(SMSG_ARENA_OPPONENT_UPDATE, 8); + data << uint64(player->GetGUID()); + SendPacketToTeam(team, &data, player, false); } else { @@ -1203,9 +1209,6 @@ void Battleground::AddPlayer(Player* player) // setup BG group membership PlayerAddedToBGCheckIfBGIsRunning(player); AddOrSetPlayerToCorrectBgGroup(player, team); - - // Log - sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Player %s joined the battle.", player->GetName().c_str()); } // this method adds player to his team's bg group, or sets his correct group if player is already in bg group diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 6d188d1367a..71dbd097b0a 100755 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -168,23 +168,6 @@ struct BattlegroundObjectInfo uint32 spellid; }; -// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time -enum BattlegroundQueueTypeId -{ - BATTLEGROUND_QUEUE_NONE = 0, - BATTLEGROUND_QUEUE_AV = 1, - BATTLEGROUND_QUEUE_WS = 2, - BATTLEGROUND_QUEUE_AB = 3, - BATTLEGROUND_QUEUE_EY = 4, - BATTLEGROUND_QUEUE_SA = 5, - BATTLEGROUND_QUEUE_IC = 6, - BATTLEGROUND_QUEUE_RB = 7, - BATTLEGROUND_QUEUE_2v2 = 8, - BATTLEGROUND_QUEUE_3v3 = 9, - BATTLEGROUND_QUEUE_5v5 = 10, - MAX_BATTLEGROUND_QUEUE_TYPES -}; - enum ScoreType { SCORE_KILLING_BLOWS = 1, @@ -253,27 +236,6 @@ enum BattlegroundStartingEventsIds }; #define BG_STARTING_EVENT_COUNT 4 -enum GroupJoinBattlegroundResult -{ - // positive values are indexes in BattlemasterList.dbc - ERR_GROUP_JOIN_BATTLEGROUND_FAIL = 0, // Your group has joined a battleground queue, but you are not eligible (showed for non existing BattlemasterList.dbc indexes) - ERR_BATTLEGROUND_NONE = -1, // not show anything - ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS = -2, // You cannot join the battleground yet because you or one of your party members is flagged as a Deserter. - ERR_ARENA_TEAM_PARTY_SIZE = -3, // Incorrect party size for this arena. - ERR_BATTLEGROUND_TOO_MANY_QUEUES = -4, // You can only be queued for 2 battles at once - ERR_BATTLEGROUND_CANNOT_QUEUE_FOR_RATED = -5, // You cannot queue for a rated match while queued for other battles - ERR_BATTLEDGROUND_QUEUED_FOR_RATED = -6, // You cannot queue for another battle while queued for a rated arena match - ERR_BATTLEGROUND_TEAM_LEFT_QUEUE = -7, // Your team has left the arena queue - ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND = -8, // You can't do that in a battleground. - ERR_BATTLEGROUND_JOIN_XP_GAIN = -9, // wtf, doesn't exist in client... - ERR_BATTLEGROUND_JOIN_RANGE_INDEX = -10, // Cannot join the queue unless all members of your party are in the same battleground level range. - ERR_BATTLEGROUND_JOIN_TIMED_OUT = -11, // %s was unavailable to join the queue. (uint64 guid exist in client cache) - ERR_BATTLEGROUND_JOIN_FAILED = -12, // Join as a group failed (uint64 guid doesn't exist in client cache) - ERR_LFG_CANT_USE_BATTLEGROUND = -13, // You cannot queue for a battleground or arena while using the dungeon system. - ERR_IN_RANDOM_BG = -14, // Can't do that while in a Random Battleground queue. - ERR_IN_NON_RANDOM_BG = -15 // Can't queue for Random Battleground while in another Battleground queue. -}; - struct BattlegroundScore { BattlegroundScore() : KillingBlows(0), Deaths(0), HonorableKills(0), BonusHonor(0), @@ -566,6 +528,8 @@ class Battleground virtual uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return 0; } virtual void SetDroppedFlagGUID(uint64 /*guid*/, int32 /*team*/ = -1) {} uint32 GetTeamScore(uint32 TeamID) const; + + virtual uint32 GetPrematureWinner(); protected: // this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index bfa3b955427..a0f95e1eaef 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -44,6 +44,7 @@ #include "SharedDefines.h" #include "Formulas.h" #include "DisableMgr.h" +#include "Opcodes.h" /*********************************************************/ /*** BATTLEGROUND MANAGER ***/ @@ -131,7 +132,7 @@ void BattlegroundMgr::Update(uint32 diff) if (m_NextRatedArenaUpdate < diff) { // forced update for rated arenas (scan all, but skipped non rated) - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr: UPDATING ARENA QUEUES"); + sLog->outTrace(LOG_FILTER_ARENAS, "BattlegroundMgr: UPDATING ARENA QUEUES"); for (int qtype = BATTLEGROUND_QUEUE_2v2; qtype <= BATTLEGROUND_QUEUE_5v5; ++qtype) for (int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket) m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(diff, @@ -699,8 +700,8 @@ void BattlegroundMgr::CreateInitialBattlegrounds() data.MaxPlayersPerTeam = fields[2].GetUInt16(); data.LevelMin = fields[3].GetUInt8(); data.LevelMax = fields[4].GetUInt8(); - uint8 spawn = fields[9].GetUInt8(); - data.StartMaxDist = float(spawn * spawn); + float dist = fields[9].GetFloat(); + data.StartMaxDist = dist * dist; data.scriptId = sObjectMgr->GetScriptId(fields[11].GetCString()); data.BattlegroundName = bl->name[sWorld->GetDefaultDbcLocale()]; @@ -904,25 +905,25 @@ BattlegroundQueueTypeId BattlegroundMgr::BGQueueTypeId(BattlegroundTypeId bgType { switch (bgTypeId) { - case BATTLEGROUND_WS: - return BATTLEGROUND_QUEUE_WS; case BATTLEGROUND_AB: return BATTLEGROUND_QUEUE_AB; case BATTLEGROUND_AV: return BATTLEGROUND_QUEUE_AV; case BATTLEGROUND_EY: return BATTLEGROUND_QUEUE_EY; - case BATTLEGROUND_SA: - return BATTLEGROUND_QUEUE_SA; case BATTLEGROUND_IC: return BATTLEGROUND_QUEUE_IC; case BATTLEGROUND_RB: return BATTLEGROUND_QUEUE_RB; + case BATTLEGROUND_SA: + return BATTLEGROUND_QUEUE_SA; + case BATTLEGROUND_WS: + return BATTLEGROUND_QUEUE_WS; case BATTLEGROUND_AA: - case BATTLEGROUND_NA: - case BATTLEGROUND_RL: case BATTLEGROUND_BE: case BATTLEGROUND_DS: + case BATTLEGROUND_NA: + case BATTLEGROUND_RL: case BATTLEGROUND_RV: switch (arenaType) { diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 922cccb9186..c610cafa1b1 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -16,14 +16,16 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "BattlegroundQueue.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" #include "BattlegroundMgr.h" +#include "BattlegroundQueue.h" #include "Chat.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "Log.h" #include "Group.h" +#include "Log.h" +#include "Language.h" +#include "ObjectMgr.h" +#include "Player.h" /*********************************************************/ /*** BATTLEGROUND QUEUE SYSTEM ***/ @@ -216,7 +218,7 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr // Show queue status to player only (when joining queue) if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY)) { - ChatHandler(leader).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level, + ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level, qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); } // System message @@ -475,7 +477,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u", player->GetName().c_str(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); // send status packet diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index 5a887c647b1..47320db27cf 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -26,6 +26,7 @@ #include "Object.h" #include "Player.h" #include "Util.h" +#include "WorldSession.h" BattlegroundAB::BattlegroundAB() { @@ -548,6 +549,25 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*targ PlaySoundToAll(sound); } +uint32 BattlegroundAB::GetPrematureWinner() +{ + // How many bases each team owns + uint8 ally = 0, horde = 0; + for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i) + if (m_Nodes[i] == BG_AB_NODE_STATUS_ALLY_OCCUPIED) + ++ally; + else if (m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED) + ++horde; + + if (ally > horde) + return ALLIANCE; + else if (horde > ally) + return HORDE; + + // If the values are equal, fall back to the original result (based on number of players on each team) + return Battleground::GetPrematureWinner(); +} + bool BattlegroundAB::SetupBattleground() { for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index 63c89717c8f..b80e216a216 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -272,6 +272,8 @@ class BattlegroundAB : public Battleground /* achievement req. */ bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; } + + uint32 GetPrematureWinner(); private: void PostUpdateImpl(uint32 diff); /* Gameobject spawning/despawning */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index a348ec69b8a..918cef4d261 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -21,11 +21,12 @@ #include "ObjectMgr.h" #include "WorldPacket.h" -#include "Miscellaneous/Formulas.h" +#include "Formulas.h" #include "GameObject.h" -#include "Miscellaneous/Language.h" +#include "Language.h" #include "Player.h" #include "SpellAuras.h" +#include "WorldSession.h" BattlegroundAV::BattlegroundAV() { @@ -1695,3 +1696,16 @@ bool BattlegroundAV::IsAllTowersControlledAndCaptainAlive(uint32 team) const return false; } + +uint32 BattlegroundAV::GetPrematureWinner() +{ + uint32 allianceScore = m_Team_Scores[GetTeamIndexByTeamId(ALLIANCE)]; + uint32 hordeScore = m_Team_Scores[GetTeamIndexByTeamId(HORDE)]; + + if (allianceScore > hordeScore) + return ALLIANCE; + else if (hordeScore > allianceScore) + return HORDE; + + return Battleground::GetPrematureWinner(); +} diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index dab67fe3258..bedd946a78c 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -1556,7 +1556,7 @@ class BattlegroundAV : public Battleground /*general stuff*/ void UpdateScore(uint16 team, int16 points); - void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); /*handlestuff*/ //these are functions which get called from extern void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); @@ -1572,6 +1572,8 @@ class BattlegroundAV : public Battleground /* achievement req. */ bool IsBothMinesControlledByTeam(uint32 team) const; bool IsAllTowersControlledAndCaptainAlive(uint32 team) const; + + uint32 GetPrematureWinner(); private: void PostUpdateImpl(uint32 diff); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index a64184261c7..02c5167c9ec 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -17,11 +17,12 @@ */ #include "BattlegroundDS.h" -#include "ObjectAccessor.h" +#include "Creature.h" +#include "GameObject.h" #include "Language.h" +#include "ObjectAccessor.h" #include "Player.h" #include "WorldPacket.h" -#include "GameObject.h" BattlegroundDS::BattlegroundDS() { diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index e900bc9b1d3..458e86729e7 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -937,3 +937,13 @@ bool BattlegroundEY::IsAllNodesConrolledByTeam(uint32 team) const return count == EY_POINTS_MAX; } + +uint32 BattlegroundEY::GetPrematureWinner() +{ + if (GetTeamScore(TEAM_ALLIANCE) > GetTeamScore(TEAM_HORDE)) + return ALLIANCE; + else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE)) + return HORDE; + + return Battleground::GetPrematureWinner(); +}
\ No newline at end of file diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 61ee5b16c1c..2cfd4ca7e0f 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -369,6 +369,8 @@ class BattlegroundEY : public Battleground /* achievement req. */ bool IsAllNodesConrolledByTeam(uint32 team) const; + + uint32 GetPrematureWinner(); private: void PostUpdateImpl(uint32 diff); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index 90c0dae9f5e..dbffc318c78 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -25,6 +25,7 @@ #include "ObjectMgr.h" #include "Vehicle.h" #include "Transport.h" +#include "WorldSession.h" BattlegroundIC::BattlegroundIC() { diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 1386af13186..9e58a93fd2d 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -20,6 +20,8 @@ #define __BATTLEGROUNDIC_H #include "Battleground.h" +#include "Language.h" +#include "Object.h" const uint32 BG_IC_Factions[2] = { diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 7dba811c1a1..ab479eeff2d 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -22,6 +22,7 @@ #include "GameObject.h" #include "ObjectMgr.h" #include "WorldPacket.h" +#include "WorldSession.h" BattlegroundSA::BattlegroundSA() { diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 5fd6e43c029..965045c5293 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -858,3 +858,12 @@ void BattlegroundWS::FillInitialWorldStates(WorldPacket& data) data << uint32(BG_WS_FLAG_STATE_ALLIANCE) << uint32(1); } +uint32 BattlegroundWS::GetPrematureWinner() +{ + if (GetTeamScore(TEAM_ALLIANCE) > GetTeamScore(TEAM_HORDE)) + return ALLIANCE; + else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE)) + return HORDE; + + return Battleground::GetPrematureWinner(); +}
\ No newline at end of file diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index ec9f4ab1506..5b72de43b32 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -211,6 +211,8 @@ class BattlegroundWS : public Battleground void AddPoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; } void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; } void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; } + + uint32 GetPrematureWinner(); private: uint64 m_FlagKeepers[2]; // 0 - alliance, 1 - horde uint64 m_DroppedFlagGUID[2]; diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt index 0f8bec7f0e5..15eb61b8477 100644 --- a/src/server/game/CMakeLists.txt +++ b/src/server/game/CMakeLists.txt @@ -8,10 +8,6 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -if( USE_COREPCH ) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) -endif() - file(GLOB_RECURSE sources_Accounts Accounts/*.cpp Accounts/*.h) file(GLOB_RECURSE sources_Achievements Achievements/*.cpp Achievements/*.h) file(GLOB_RECURSE sources_Addons Addons/*.cpp Addons/*.h) @@ -55,12 +51,10 @@ file(GLOB_RECURSE sources_World World/*.cpp World/*.h) # Create game-libary -if( USE_COREPCH AND MSVC ) - set(game_STAT_SRCS - PrecompiledHeaders/gamePCH.cpp - PrecompiledHeaders/gamePCH.h - ) -endif() +if (USE_COREPCH) + set(game_STAT_PCH_HDR PrecompiledHeaders/gamePCH.h) + set(game_STAT_PCH_SRC PrecompiledHeaders/gamePCH.cpp) +endif () set(game_STAT_SRCS ${game_STAT_SRCS} @@ -207,15 +201,14 @@ include_directories( ${OPENSSL_INCLUDE_DIR} ) -add_library(game STATIC ${game_STAT_SRCS}) +add_library(game STATIC + ${game_STAT_SRCS} + ${game_STAT_PCH_SRC} +) add_dependencies(game revision.h) # Generate precompiled header -if( USE_COREPCH ) - if(CMAKE_COMPILER_IS_GNUCXX) - add_precompiled_header(game ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/gamePCH.h) - elseif(MSVC) - add_native_precompiled_header(game ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/gamePCH) - endif() -endif() +if (USE_COREPCH) + add_cxx_pch(game ${game_STAT_PCH_HDR} ${game_STAT_PCH_SRC}) +endif () diff --git a/src/server/game/Calendar/Calendar.cpp b/src/server/game/Calendar/Calendar.cpp deleted file mode 100755 index 139e63614cc..00000000000 --- a/src/server/game/Calendar/Calendar.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "Player.h" -#include "Calendar.h" - -std::string CalendarInvite::GetDebugString() const -{ - std::ostringstream data; - - data << "CalendarInvite::" - << " inviteId: " << _inviteId - << " EventId: " << _eventId - << " Status: " << uint32(_status) - << " Invitee: " << _invitee - << " Sender: " << _senderGUID - << " Rank: " << uint32(_rank) - << " Text: " << _text; - - return data.str(); -} - -void CalendarInvite::Init() -{ - _eventId = 0; - _invitee = 0; - _senderGUID = 0; - _statusTime = 0; - _status = CALENDAR_STATUS_INVITED; // default (0)? - _rank = CALENDAR_RANK_PLAYER; - _text = ""; -} - -std::string CalendarEvent::GetDebugString() const -{ - std::ostringstream data; - - data << "CalendarEvent::" - << " EventId: " << _eventId - << " Title: " << _title - << " Description" << _description - << " Type: " << uint32(_type) - << " Max Invites: " << _maxInvites - << " Creator: " << _creatorGUID - << " Flags: " << _flags - << " Guild: " << _guildId - << " Time: " << _eventTime - << " Time2: " << _timezoneTime - << " Repeatable: " << uint32(_repeatable) - << " DungeonId: " << _dungeonId; - - return data.str(); -} - -void CalendarEvent::Init() -{ - _creatorGUID = 0; - _guildId = 0; - _type = CALENDAR_TYPE_OTHER; - _dungeonId = -1; - _maxInvites = 0; - _eventTime = 0; - _flags = 0; - _repeatable = false; - _timezoneTime = 0; - _title = ""; - _description = ""; - -} - -std::string CalendarAction::GetDebugString() const -{ - std::ostringstream data; - - data << "CalendarAction::" - << " Action: " << GetAction() - << " Guid: " << GetPlayer()->GetGUID() - << " Invite Id: " << GetInviteId() - << " Extra data: " << GetExtraData() - << " Event: " << Event.GetDebugString() - << " Invite: " << Invite.GetDebugString(); - - return data.str(); -} diff --git a/src/server/game/Calendar/Calendar.h b/src/server/game/Calendar/Calendar.h deleted file mode 100755 index 273db4c3854..00000000000 --- a/src/server/game/Calendar/Calendar.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef TRINITY_CALENDAR_H -#define TRINITY_CALENDAR_H - -#include "Errors.h" -#include "SharedDefines.h" -#include <map> - -class CalendarInvite -{ - public: - CalendarInvite() : _inviteId(0) { Init(); } - explicit CalendarInvite(uint64 inviteId) : _inviteId(inviteId) { Init(); } - - ~CalendarInvite() { } - - void SetInviteId(uint64 inviteId) { _inviteId = inviteId; } - uint64 GetInviteId() const { return _inviteId; } - - void SetEventId(uint64 eventId) { _eventId = eventId; } - uint64 GetEventId() const { return _eventId; } - - void SetSenderGUID(uint64 guid) { _senderGUID = guid; } - uint64 GetSenderGUID() const { return _senderGUID; } - - void SetInvitee(uint64 guid) { _invitee = guid; } - uint64 GetInvitee() const { return _invitee; } - - void SetStatusTime(uint32 statusTime) { _statusTime = statusTime; } - uint32 GetStatusTime() const { return _statusTime; } - - void SetText(std::string const& text) { _text = text; } - std::string const& GetText() const { return _text; } - - void SetStatus(CalendarInviteStatus status) { _status = status; } - CalendarInviteStatus GetStatus() const { return _status; } - - void SetRank(CalendarModerationRank rank) { _rank = rank; } - CalendarModerationRank GetRank() const { return _rank; } - - std::string GetDebugString() const; - - private: - void Init(); - - uint64 _inviteId; - uint64 _eventId; - uint64 _invitee; - uint64 _senderGUID; - uint32 _statusTime; - CalendarInviteStatus _status; - CalendarModerationRank _rank; - std::string _text; -}; - -typedef std::set<uint64> CalendarInviteIdList; - -class CalendarEvent -{ - public: - CalendarEvent() : _eventId(0) { Init(); } - explicit CalendarEvent(uint64 eventId) : _eventId(eventId) { Init(); } - - ~CalendarEvent() { } - - void SetEventId(uint64 eventId) { _eventId = eventId; } - uint64 GetEventId() const { return _eventId; } - - void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; } - uint64 GetCreatorGUID() const { return _creatorGUID; } - - void SetGuildId(uint32 guildId) { _guildId = guildId; } - uint32 GetGuildId() const { return _guildId; } - - void SetTitle(std::string const& title) { _title = title; } - std::string const& GetTitle() const { return _title; } - - void SetDescription(std::string const& description) { _description = description; } - std::string const& GetDescription() const { return _description; } - - void SetType(CalendarEventType type) { _type = type; } - CalendarEventType GetType() const { return _type; } - - void SetMaxInvites(uint32 limit) { _maxInvites = limit; } - uint32 GetMaxInvites() const { return _maxInvites; } - - void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; } - int32 GetDungeonId() const { return _dungeonId; } - - void SetTime(uint32 eventTime) { _eventTime = eventTime; } - uint32 GetTime() const { return _eventTime; } - - void SetFlags(uint32 flags) { _flags = flags; } - uint32 GetFlags() const { return _flags; } - - void SetRepeatable(bool repeatable) { _repeatable = repeatable; } - bool GetRepeatable() const { return _repeatable; } - - void SetTimeZoneTime(uint32 timezoneTime) { _timezoneTime = timezoneTime; } - uint32 GetTimeZoneTime() const { return _timezoneTime; } - - void AddInvite(uint64 inviteId) - { - if (inviteId) - _invites.insert(inviteId); - } - - void RemoveInvite(uint64 inviteId) { _invites.erase(inviteId); } - bool HasInvite(uint64 inviteId) const { return _invites.find(inviteId) != _invites.end(); } - CalendarInviteIdList const& GetInviteIdList() const { return _invites; } - void SetInviteIdList(CalendarInviteIdList const& list) { _invites = list; } - void ClearInviteIdList() { _invites.clear(); } - - std::string GetDebugString() const; - - private: - void Init(); - - uint64 _eventId; - uint64 _creatorGUID; - uint32 _guildId; - CalendarEventType _type; - int32 _dungeonId; - uint32 _maxInvites; - uint32 _eventTime; - uint32 _flags; - bool _repeatable; - uint32 _timezoneTime; - std::string _title; - std::string _description; - CalendarInviteIdList _invites; -}; - -typedef std::set<uint64> CalendarEventIdList; -typedef std::map<uint64, CalendarInviteIdList> CalendarPlayerInviteIdMap; -typedef std::map<uint64, CalendarEventIdList> CalendarPlayerEventIdMap; -typedef std::map<uint64, CalendarInvite> CalendarInviteMap; -typedef std::map<uint64, CalendarEvent> CalendarEventMap; - -class Player; - -struct CalendarAction -{ - CalendarAction(): _action(CALENDAR_ACTION_NONE), _player(NULL), _inviteId(0), _data(0) - { - } - - void SetAction(CalendarActionData data) { _action = data; } - CalendarActionData GetAction() const { return _action; } - - void SetPlayer(Player* player) { ASSERT(player); _player = player; } - Player* GetPlayer() const { return _player; } - - void SetInviteId(uint64 id) { _inviteId = id; } - uint64 GetInviteId() const { return _inviteId; } - - void SetExtraData(uint32 data) { _data = data; } - uint32 GetExtraData() const { return _data; } - - CalendarEvent Event; - CalendarInvite Invite; - - std::string GetDebugString() const; - - private: - CalendarActionData _action; - Player* _player; - uint64 _inviteId; - uint32 _data; -}; - -#endif diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 80de42c0ce2..9f4816d6c7c 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -15,579 +15,621 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* - -DROP TABLE IF EXISTS `calendar_events`; -CREATE TABLE IF NOT EXISTS `calendar_events` ( - `id` int(11) unsigned NOT NULL DEFAULT '0', - `creator` int(11) unsigned NOT NULL DEFAULT '0', - `title` varchar(255) NOT NULL DEFAULT '', - `description` varchar(255) NOT NULL DEFAULT '', - `type` tinyint(1) unsigned NOT NULL DEFAULT '4', - `dungeon` tinyint(3) NOT NULL DEFAULT '-1', - `eventtime` int(10) unsigned NOT NULL DEFAULT '0', - `flags` int(10) unsigned NOT NULL DEFAULT '0', - `repeatable` tinyint(1) unsigned NOT NULL DEFAULT '0', - `time2` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -); - -DROP TABLE IF EXISTS `calendar_invites`; -CREATE TABLE IF NOT EXISTS `calendar_invites` ( - `id` int(11) unsigned NOT NULL DEFAULT '0', - `event` int(11) unsigned NOT NULL DEFAULT '0', - `invitee` int(11) unsigned NOT NULL DEFAULT '0', - `sender` int(11) unsigned NOT NULL DEFAULT '0', - `status` tinyint(1) unsigned NOT NULL DEFAULT '0', - `statustime` int(10) unsigned NOT NULL DEFAULT '0', - `rank` tinyint(1) unsigned NOT NULL DEFAULT '0', - `text` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) -); -*/ - #include "CalendarMgr.h" #include "QueryResult.h" #include "DatabaseEnv.h" #include "Log.h" #include "Player.h" +#include "GuildMgr.h" #include "ObjectAccessor.h" +#include "Opcodes.h" -CalendarMgr::CalendarMgr() : - _eventNum(0), _inviteNum(0) +CalendarInvite::~CalendarInvite() { + sCalendarMgr->FreeInviteId(_inviteId); } -CalendarMgr::~CalendarMgr() +CalendarEvent::~CalendarEvent() { + sCalendarMgr->FreeEventId(_eventId); } -uint32 CalendarMgr::GetPlayerNumPending(uint64 guid) +CalendarMgr::CalendarMgr() { - if (!guid) - return 0; - - CalendarPlayerInviteIdMap::const_iterator itr = _playerInvites.find(guid); - if (itr == _playerInvites.end()) - return 0; - - uint32 pendingNum = 0; - for (CalendarInviteIdList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) - if (CalendarInvite* invite = GetInvite(*it)) - if (invite->GetRank() != CALENDAR_RANK_OWNER - && invite->GetStatus() != CALENDAR_STATUS_CONFIRMED - && invite->GetStatus() != CALENDAR_STATUS_8 - && invite->GetStatus() != CALENDAR_STATUS_9) // FIXME Check the proper value - ++pendingNum; - - return pendingNum; } -CalendarInviteIdList const& CalendarMgr::GetPlayerInvites(uint64 guid) +CalendarMgr::~CalendarMgr() { - return _playerInvites[guid]; } -CalendarEventIdList const& CalendarMgr::GetPlayerEvents(uint64 guid) +void CalendarMgr::LoadFromDB() { - return _playerEvents[guid]; -} + uint32 count = 0; + _maxEventId = 0; + _maxInviteId = 0; -CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId) -{ - CalendarInviteMap::iterator itr = _invites.find(inviteId); - if (itr != _invites.end()) - return &(itr->second); + // 0 1 2 3 4 5 6 7 8 + if (QueryResult result = CharacterDatabase.Query("SELECT id, creator, title, description, type, dungeon, eventtime, flags, time2 FROM calendar_events")) + do + { + Field* fields = result->Fetch(); - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId); - return NULL; -} + uint64 eventId = fields[0].GetUInt64(); + uint64 creatorGUID = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER); + std::string title = fields[2].GetString(); + std::string description = fields[3].GetString(); + CalendarEventType type = CalendarEventType(fields[4].GetUInt8()); + int32 dungeonId = fields[5].GetInt32(); + uint32 eventTime = fields[6].GetUInt32(); + uint32 flags = fields[7].GetUInt32(); + uint32 timezoneTime = fields[8].GetUInt32(); + uint32 guildId = 0; -CalendarEvent* CalendarMgr::GetEvent(uint64 eventId) -{ - CalendarEventMap::iterator itr = _events.find(eventId); - if (itr != _events.end()) - return &(itr->second); + if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES) + guildId = Player::GetGuildIdFromDB(creatorGUID); - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId); - return NULL; -} + CalendarEvent* calendarEvent = new CalendarEvent(eventId, creatorGUID , guildId, type, dungeonId, time_t(eventTime), flags, time_t(timezoneTime), title, description); + _events.insert(calendarEvent); -uint64 CalendarMgr::GetFreeEventId() -{ - return ++_eventNum; -} -uint64 CalendarMgr::GetFreeInviteId() -{ - return ++_inviteNum; -} + _maxEventId = std::max(_maxEventId, eventId); -void CalendarMgr::LoadFromDB() -{ - /* - uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 - if (QueryResult result = CharacterDatabase.Query("SELECT id, creator, title, description, type, dungeon, eventtime, flags, repeatable, time2 FROM calendar_events")) - do - { - Field * fields = result->Fetch(); - - uint64 eventId = fields[0].GetUInt64(); - CalendarEvent& calendarEvent = _events[eventId]; - - calendarEvent.SetEventId(eventId); - calendarEvent.SetCreatorGUID(fields[1].GetUInt64()); - calendarEvent.SetTitle(fields[2].GetString()); - calendarEvent.SetDescription(fields[3].GetString()); - calendarEvent.SetType(fields[4].GetUInt8()); - calendarEvent.SetDungeonId(fields[5].GetInt32()); - calendarEvent.SetTime(fields[6].GetUInt32()); - calendarEvent.SetFlags(fields[7].GetUInt32()); - calendarEvent.SetRepeatable(fields[8].GetBool()); - calendarEvent.SetTimeZoneTime(fields[9].GetUInt32()); ++count; } while (result->NextRow()); - sLog->outInfo(LOG_FILTER_CALENDAR, ">> Loaded %u calendar events", count); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u calendar events", count); count = 0; // 0 1 2 3 4 5 6 7 if (QueryResult result = CharacterDatabase.Query("SELECT id, event, invitee, sender, status, statustime, rank, text FROM calendar_invites")) do { - Field * fields = result->Fetch(); + Field* fields = result->Fetch(); - uint64 inviteId = fields[0].GetUInt64(); - uint64 eventId = fields[1].GetUInt64(); + uint64 inviteId = fields[0].GetUInt64(); + uint64 eventId = fields[1].GetUInt64(); + uint64 invitee = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); + uint64 senderGUID = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER); + CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8()); + uint32 statusTime = fields[5].GetUInt32(); + CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8()); + std::string text = fields[7].GetString(); - CalendarInvite& invite = _invites[inviteId]; + CalendarInvite* invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, time_t(statusTime), status, rank, text); + _invites[eventId].push_back(invite); - invite.SetEventId(eventId); - invite.SetInvitee(fields[2].GetUInt64()); - invite.SetSenderGUID(fields[3].GetUInt64()); - invite.SetStatus(fields[4].GetUInt8()); - invite.SetStatusTime(fields[5].GetUInt32()); - invite.SetRank(fields[6].GetUInt8()); - invite.SetText(fields[7].GetString()); + _maxInviteId = std::max(_maxInviteId, inviteId); - CalendarEvent& calendarEvent = _events[eventId]; - calendarEvent.AddInvite(inviteId); + ++count; } while (result->NextRow()); - sLog->outInfo(LOG_FILTER_CALENDAR, ">> Loaded %u calendar Invites", count); - */ + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u calendar invites", count); + + for (uint64 i = 1; i < _maxEventId; ++i) + if (!GetEvent(i)) + _freeEventIds.push_back(i); + + for (uint64 i = 1; i < _maxInviteId; ++i) + if (!GetInvite(i)) + _freeInviteIds.push_back(i); } -CalendarEvent* CalendarMgr::CheckPermisions(uint64 eventId, Player* player, uint64 inviteId, CalendarModerationRank minRank) +void CalendarMgr::AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType) { - if (!player) - return NULL; // CALENDAR_ERROR_INTERNAL + _events.insert(calendarEvent); + UpdateEvent(calendarEvent); + SendCalendarEvent(calendarEvent->GetCreatorGUID(), *calendarEvent, sendType); +} - CalendarEvent* calendarEvent = GetEvent(eventId); - if (!calendarEvent) - { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_EVENT_INVALID); - return NULL; - } +void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite) +{ + if (!calendarEvent->IsGuildAnnouncement()) + SendCalendarEventInvite(*invite); - CalendarInvite* invite = GetInvite(inviteId); - if (!invite) - { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_NO_INVITE); - return NULL; - } + if (!calendarEvent->IsGuildEvent() || invite->GetInviteeGUID() == calendarEvent->GetCreatorGUID()) + SendCalendarEventInviteAlert(*calendarEvent, *invite); - if (!calendarEvent->HasInvite(inviteId)) + if (!calendarEvent->IsGuildAnnouncement()) { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_NOT_INVITED); - return NULL; + _invites[invite->GetEventId()].push_back(invite); + UpdateInvite(invite); } +} + +void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover) +{ + CalendarEvent* calendarEvent = GetEvent(eventId); - if (invite->GetEventId() != calendarEvent->GetEventId() || invite->GetInvitee() != player->GetGUID()) + if (!calendarEvent) { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_INTERNAL); - return NULL; + SendCalendarCommandResult(remover, CALENDAR_ERROR_EVENT_INVALID); + return; } - if (invite->GetRank() < minRank) + SendCalendarEventRemovedAlert(*calendarEvent); + + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt; + MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody()); + + std::vector<CalendarInvite*>::iterator itr = _invites[eventId].begin(); + while (itr != _invites[eventId].end()) { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_PERMISSIONS); - return NULL; + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE); + stmt->setUInt64(0, (*itr)->GetInviteId()); + trans->Append(stmt); + + // guild events only? check invite status here? + // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki) + if (remover && (*itr)->GetInviteeGUID() != remover) + mail.SendMailTo(trans, MailReceiver((*itr)->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED); + + delete *itr; + _invites[eventId].erase(itr); } - return calendarEvent; + _invites.erase(eventId); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT); + stmt->setUInt64(0, eventId); + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); + + delete calendarEvent; + _events.erase(calendarEvent); } -void CalendarMgr::AddAction(CalendarAction const& action) +void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, uint64 /*remover*/) { - switch (action.GetAction()) - { - case CALENDAR_ACTION_ADD_EVENT: - { - if (AddEvent(action.Event) && AddInvite(action.Invite)) - { - SendCalendarEventInviteAlert(action.Event, action.Invite); - SendCalendarEvent(action.Event, CALENDAR_SENDTYPE_ADD); - } - break; - } - case CALENDAR_ACTION_MODIFY_EVENT: - { - uint64 eventId = action.Event.GetEventId(); - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - if (!calendarEvent) - return; - - calendarEvent->SetEventId(action.Event.GetEventId()); - calendarEvent->SetType(action.Event.GetType()); - calendarEvent->SetFlags(action.Event.GetFlags()); - calendarEvent->SetTime(action.Event.GetTime()); - calendarEvent->SetTimeZoneTime(action.Event.GetTimeZoneTime()); - calendarEvent->SetRepeatable(action.Event.GetRepeatable()); - calendarEvent->SetDungeonId(action.Event.GetDungeonId()); - calendarEvent->SetTitle(action.Event.GetTitle()); - calendarEvent->SetDescription(action.Event.GetDescription()); - calendarEvent->SetMaxInvites(action.Event.GetMaxInvites()); - - CalendarInviteIdList const& invites = calendarEvent->GetInviteIdList(); - for (CalendarInviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) - if (CalendarInvite* invite = GetInvite(*itr)) - SendCalendarEventUpdateAlert(invite->GetInvitee(), *calendarEvent, CALENDAR_SENDTYPE_ADD); + CalendarEvent* calendarEvent = GetEvent(eventId); - break; - } - case CALENDAR_ACTION_COPY_EVENT: - { - CalendarEvent* calendarEvent = CheckPermisions(action.Event.GetEventId(), action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); - - if (!calendarEvent) - return; - - uint64 eventId = GetFreeEventId(); - CalendarEvent newEvent(eventId); - newEvent.SetType(calendarEvent->GetType()); - newEvent.SetFlags(calendarEvent->GetFlags()); - newEvent.SetTime(action.Event.GetTime()); - newEvent.SetTimeZoneTime(calendarEvent->GetTimeZoneTime()); - newEvent.SetRepeatable(calendarEvent->GetRepeatable()); - newEvent.SetDungeonId(calendarEvent->GetDungeonId()); - newEvent.SetTitle(calendarEvent->GetTitle()); - newEvent.SetDescription(calendarEvent->GetDescription()); - newEvent.SetMaxInvites(calendarEvent->GetMaxInvites()); - newEvent.SetCreatorGUID(calendarEvent->GetCreatorGUID()); - newEvent.SetGuildId(calendarEvent->GetGuildId()); - - CalendarInviteIdList const invites = calendarEvent->GetInviteIdList(); - for (CalendarInviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) - { - if (CalendarInvite* invite = GetInvite(*itr)) - { - uint64 inviteId = GetFreeInviteId(); - CalendarInvite newInvite(inviteId); - newInvite.SetEventId(eventId); - newInvite.SetSenderGUID(action.GetPlayer()->GetGUID()); - newInvite.SetInvitee(invite->GetInvitee()); - newInvite.SetStatus(invite->GetStatus()); - newInvite.SetStatusTime(invite->GetStatusTime()); - newInvite.SetText(invite->GetText()); - newInvite.SetRank(invite->GetRank()); - if (AddInvite(newInvite)) - { - SendCalendarEventInviteAlert(newEvent, newInvite); - newEvent.AddInvite(inviteId); - } - } - } - - if (AddEvent(newEvent)) - SendCalendarEvent(newEvent, CALENDAR_SENDTYPE_COPY); + if (!calendarEvent) + return; + std::vector<CalendarInvite*>::iterator itr = _invites[eventId].begin(); + for (; itr != _invites[eventId].end(); ++itr) + if ((*itr)->GetInviteId() == inviteId) break; - } - case CALENDAR_ACTION_REMOVE_EVENT: - { - uint64 eventId = action.Event.GetEventId(); - //uint32 flags = action.Event.GetFlags(); - // FIXME - Use of Flags here! - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); - if (!calendarEvent) - return; + if (itr == _invites[eventId].end()) + return; - RemoveEvent(eventId); - break; - } - case CALENDAR_ACTION_ADD_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - if (!calendarEvent) - return; - - if (AddInvite(action.Invite)) - { - calendarEvent->AddInvite(action.Invite.GetInviteId()); - SendCalendarEventInvite(action.Invite, (!(calendarEvent->GetFlags() & CALENDAR_FLAG_INVITES_LOCKED) && - !action.Invite.GetStatusTime())); - SendCalendarEventInviteAlert(*calendarEvent, action.Invite); - } + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE); + stmt->setUInt64(0, (*itr)->GetInviteId()); + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); - break; - } - case CALENDAR_ACTION_SIGNUP_TO_EVENT: - { - uint64 eventId = action.Event.GetEventId(); - CalendarEvent* calendarEvent = GetEvent(eventId); - CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); + if (!calendarEvent->IsGuildEvent()) + SendCalendarEventInviteRemoveAlert((*itr)->GetInviteeGUID(), *calendarEvent, CALENDAR_STATUS_REMOVED); - if (!calendarEvent || !(calendarEvent->GetFlags() & CALENDAR_FLAG_GUILD_ONLY) - || !calendarEvent->GetGuildId() || calendarEvent->GetGuildId() != action.GetExtraData()) - return; + SendCalendarEventInviteRemove(*calendarEvent, **itr, calendarEvent->GetFlags()); - CalendarInviteStatus status = action.Invite.GetStatus(); + // we need to find out how to use CALENDAR_INVITE_REMOVED_MAIL_SUBJECT to force client to display different mail + //if ((*itr)->GetInviteeGUID() != remover) + // MailDraft(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody()) + // .SendMailTo(trans, MailReceiver((*itr)->GetInvitee()), calendarEvent, MAIL_CHECK_MASK_COPIED); - if (status == CALENDAR_STATUS_INVITED) - status = CALENDAR_STATUS_CONFIRMED; - else if (status == CALENDAR_STATUS_ACCEPTED) - status = CALENDAR_STATUS_8; + delete *itr; + _invites[eventId].erase(itr); +} - CalendarInvite newInvite(GetFreeInviteId()); - newInvite.SetStatus(status); - newInvite.SetStatusTime(uint32(time(NULL))); - newInvite.SetEventId(eventId); - newInvite.SetInvitee(action.GetPlayer()->GetGUID()); - newInvite.SetSenderGUID(action.GetPlayer()->GetGUID()); +void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) +{ + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT); + stmt->setUInt64(0, calendarEvent->GetEventId()); + stmt->setUInt32(1, GUID_LOPART(calendarEvent->GetCreatorGUID())); + stmt->setString(2, calendarEvent->GetTitle()); + stmt->setString(3, calendarEvent->GetDescription()); + stmt->setUInt8(4, calendarEvent->GetType()); + stmt->setInt32(5, calendarEvent->GetDungeonId()); + stmt->setUInt32(6, uint32(calendarEvent->GetEventTime())); + stmt->setUInt32(7, calendarEvent->GetFlags()); + stmt->setUInt32(8, calendarEvent->GetTimeZoneTime()); // correct? + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); +} - if (AddInvite(newInvite)) - SendCalendarEventInvite(newInvite, false); +void CalendarMgr::UpdateInvite(CalendarInvite* invite) +{ + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE); + stmt->setUInt64(0, invite->GetInviteId()); + stmt->setUInt64(1, invite->GetEventId()); + stmt->setUInt32(2, GUID_LOPART(invite->GetInviteeGUID())); + stmt->setUInt32(3, GUID_LOPART(invite->GetSenderGUID())); + stmt->setUInt8(4, invite->GetStatus()); + stmt->setUInt32(5, uint32(invite->GetStatusTime())); + stmt->setUInt8(6, invite->GetRank()); + stmt->setString(7, invite->GetText()); + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); +} - break; - } - case CALENDAR_ACTION_MODIFY_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - uint64 inviteId = action.Invite.GetInviteId(); +void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) +{ + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetCreatorGUID() == guid) + RemoveEvent((*itr)->GetEventId(), 0); // don't send mail if removing a character - CalendarEvent* calendarEvent = NULL; - if (action.GetInviteId() != action.Invite.GetInviteId()) - calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - else - calendarEvent = GetEvent(eventId); + std::vector<CalendarInvite*> playerInvites = GetPlayerInvites(guid); + for (std::vector<CalendarInvite*>::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) + RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); +} - CalendarInvite* invite = GetInvite(inviteId); +void CalendarMgr::RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId) +{ + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) + RemoveEvent((*itr)->GetEventId(), guid); + + std::vector<CalendarInvite*> playerInvites = GetPlayerInvites(guid); + for (std::vector<CalendarInvite*>::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) + if (CalendarEvent* calendarEvent = GetEvent((*itr)->GetEventId())) + if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == guildId) + RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); +} - if (!calendarEvent || !invite || !calendarEvent->HasInvite(inviteId)) - return; +CalendarEvent* CalendarMgr::GetEvent(uint64 eventId) +{ + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetEventId() == eventId) + return *itr; - invite->SetStatus(action.Invite.GetStatus()); - SendCalendarEventStatus(invite->GetSenderGUID(), *calendarEvent, *invite); - break; - } - case CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - uint64 inviteId = action.Invite.GetInviteId(); + sLog->outDebug(LOG_FILTER_CALENDAR, "CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId); + return NULL; +} - CalendarEvent* calendarEvent = NULL; - if (action.GetInviteId() != action.Invite.GetInviteId()) - calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); - else - calendarEvent = GetEvent(eventId); +CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId) +{ + for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr) + for (std::vector<CalendarInvite*>::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + if ((*itr2)->GetInviteId() == inviteId) + return *itr2; - CalendarInvite* invite = GetInvite(inviteId); + sLog->outDebug(LOG_FILTER_CALENDAR, "CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId); + return NULL; +} - if (!calendarEvent || !invite || !calendarEvent->HasInvite(inviteId)) - return; +void CalendarMgr::FreeEventId(uint64 id) +{ + if (id == _maxEventId) + --_maxEventId; + else + _freeEventIds.push_back(id); +} - invite->SetStatus(action.Invite.GetStatus()); - SendCalendarEventModeratorStatusAlert(*invite); - break; - } - case CALENDAR_ACTION_REMOVE_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - uint64 inviteId = action.Invite.GetInviteId(); - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - if (!calendarEvent) - return; - - // already checked in CheckPermisions - CalendarInvite* invite = GetInvite(inviteId); - if (!invite) - return; - - if (calendarEvent->GetCreatorGUID() == invite->GetInvitee()) - { - action.GetPlayer()->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_DELETE_CREATOR_FAILED); - return; - } - - if (uint64 invitee = RemoveInvite(inviteId)) - { - SendCalendarEventInviteRemoveAlert(invitee, *calendarEvent, CALENDAR_STATUS_9); - SendCalendarEventInviteRemove(action.GetPlayer()->GetGUID(), action.Invite, calendarEvent->GetFlags()); - } - break; - } - default: - break; +uint64 CalendarMgr::GetFreeEventId() +{ + if (_freeEventIds.empty()) + return ++_maxEventId; + else + { + uint64 eventId = _freeEventIds.front(); + _freeEventIds.pop_front(); + return eventId; } +} +void CalendarMgr::FreeInviteId(uint64 id) +{ + if (id == _maxInviteId) + --_maxInviteId; + else + _freeInviteIds.push_back(id); } -bool CalendarMgr::AddEvent(CalendarEvent const& newEvent) +uint64 CalendarMgr::GetFreeInviteId() { - uint64 eventId = newEvent.GetEventId(); - if (_events.find(eventId) != _events.end()) + if (_freeInviteIds.empty()) + return ++_maxInviteId; + else { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::AddEvent: Event [" UI64FMTD "] exists", eventId); - return false; + uint64 inviteId = _freeInviteIds.front(); + _freeInviteIds.pop_front(); + return inviteId; } +} + +CalendarEventStore CalendarMgr::GetPlayerEvents(uint64 guid) +{ + CalendarEventStore events; + + for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr) + for (std::vector<CalendarInvite*>::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + if ((*itr2)->GetInviteeGUID() == guid) + events.insert(GetEvent(itr->first)); - _events[eventId] = newEvent; - return true; + if (Player* player = ObjectAccessor::FindPlayer(guid)) + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetGuildId() == player->GetGuildId()) + events.insert(*itr); + + return events; } -bool CalendarMgr::RemoveEvent(uint64 eventId) +std::vector<CalendarInvite*> CalendarMgr::GetEventInvites(uint64 eventId) { - CalendarEventMap::iterator itr = _events.find(eventId); - if (itr == _events.end()) - { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::RemoveEvent: Event [" UI64FMTD "] does not exist", eventId); - return false; - } + return _invites[eventId]; +} - bool val = true; +std::vector<CalendarInvite*> CalendarMgr::GetPlayerInvites(uint64 guid) +{ + std::vector<CalendarInvite*> invites; - CalendarInviteIdList const& invites = itr->second.GetInviteIdList(); - for (CalendarInviteIdList::const_iterator itrInvites = invites.begin(); itrInvites != invites.end(); ++itrInvites) - { - CalendarInvite* invite = GetInvite(*itrInvites); - if (!invite || !RemovePlayerEvent(invite->GetInvitee(), eventId)) - val = false; + for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr) + for (std::vector<CalendarInvite*>::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + if ((*itr2)->GetInviteeGUID() == guid) + invites.push_back(*itr2); - if (uint64 invitee = RemoveInvite(*itrInvites)) - SendCalendarEventRemovedAlert(invitee, itr->second); - } + return invites; +} + +uint32 CalendarMgr::GetPlayerNumPending(uint64 guid) +{ + std::vector<CalendarInvite*> const& invites = GetPlayerInvites(guid); - _events.erase(itr); + uint32 pendingNum = 0; + for (std::vector<CalendarInvite*>::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) + // correct? + if ((*itr)->GetStatus() == CALENDAR_STATUS_INVITED || (*itr)->GetStatus() == CALENDAR_STATUS_TENTATIVE || (*itr)->GetStatus() == CALENDAR_STATUS_NOT_SIGNED_UP) + ++pendingNum; - return val; + return pendingNum; } -bool CalendarMgr::AddPlayerEvent(uint64 guid, uint64 eventId) +std::string CalendarEvent::BuildCalendarMailSubject(uint64 remover) const { - _playerEvents[guid].insert(eventId); - return true; + std::ostringstream strm; + strm << remover << ':' << _title; + return strm.str(); } -bool CalendarMgr::RemovePlayerEvent(uint64 guid, uint64 eventId) +std::string CalendarEvent::BuildCalendarMailBody() const { - _playerEvents[guid].erase(eventId); - return true; + WorldPacket data; + uint32 time; + std::ostringstream strm; + + // we are supposed to send PackedTime so i used WorldPacket to pack it + data.AppendPackedTime(_eventTime); + data >> time; + strm << time; + return strm.str(); } -bool CalendarMgr::AddInvite(CalendarInvite const& newInvite) +void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite) { - uint64 inviteId = newInvite.GetInviteId(); - if (!inviteId) + CalendarEvent* calendarEvent = GetEvent(invite.GetEventId()); + time_t statusTime = invite.GetStatusTime(); + bool hasStatusTime = statusTime != 946684800; // 01/01/2000 00:00:00 + + uint64 invitee = invite.GetInviteeGUID(); + Player* player = ObjectAccessor::FindPlayer(invitee); + + uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(invitee); + + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1); + data.appendPackGUID(invitee); + data << uint64(invite.GetEventId()); + data << uint64(invite.GetInviteId()); + data << uint8(level); + data << uint8(invite.GetStatus()); + data << uint8(hasStatusTime); + if (hasStatusTime) + data.AppendPackedTime(statusTime); + data << uint8(invite.GetSenderGUID() != invite.GetInviteeGUID()); // false only if the invite is sign-up + + if (!calendarEvent) // Pre-invite { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::AddInvite: Cant add Invite 0"); - return false; + if (Player* player = ObjectAccessor::FindPlayer(invite.GetSenderGUID())) + player->SendDirectMessage(&data); } - - if (_invites.find(inviteId) != _invites.end()) + else { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::AddInvite: Invite [" UI64FMTD "] exists", inviteId); - return false; + if (calendarEvent->GetCreatorGUID() != invite.GetInviteeGUID()) // correct? + SendPacketToAllEventRelatives(data, *calendarEvent); } - - _invites[inviteId] = newInvite; - uint64 guid = newInvite.GetInvitee(); - bool inviteAdded = AddPlayerInvite(guid, inviteId); - bool eventAdded = AddPlayerEvent(guid, newInvite.GetEventId()); - return eventAdded && inviteAdded; } -uint64 CalendarMgr::RemoveInvite(uint64 inviteId) +void CalendarMgr::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime) { - CalendarInviteMap::iterator itr = _invites.find(inviteId); - if (itr == _invites.end()) - { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::RemoveInvite: Invite [" UI64FMTD "] does not exist", inviteId); - return 0; - } - - uint64 invitee = itr->second.GetInvitee(); - _invites.erase(itr); - - return RemovePlayerInvite(invitee, inviteId) ? invitee : 0; + WorldPacket data(SMSG_CALENDAR_EVENT_UPDATED_ALERT, 1 + 8 + 4 + 4 + 4 + 1 + 4 + + calendarEvent.GetTitle().size() + calendarEvent.GetDescription().size() + 1 + 4 + 4); + data << uint8(1); // unk + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(oldEventTime); + data << uint32(calendarEvent.GetFlags()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint8(calendarEvent.GetType()); + data << int32(calendarEvent.GetDungeonId()); + data << calendarEvent.GetTitle(); + data << calendarEvent.GetDescription(); + data << uint8(CALENDAR_REPEAT_NEVER); // repeatable + data << uint32(CALENDAR_MAX_INVITES); + data << uint32(0); // unk + + SendPacketToAllEventRelatives(data, calendarEvent); } -bool CalendarMgr::AddPlayerInvite(uint64 guid, uint64 inviteId) +void CalendarMgr::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - _playerInvites[guid].insert(inviteId); - return true; + WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); + data.appendPackGUID(invite.GetInviteeGUID()); + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint32(calendarEvent.GetFlags()); + data << uint8(invite.GetStatus()); + data << uint8(invite.GetRank()); + data.AppendPackedTime(invite.GetStatusTime()); + + SendPacketToAllEventRelatives(data, calendarEvent); } -bool CalendarMgr::RemovePlayerInvite(uint64 guid, uint64 inviteId) +void CalendarMgr::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent) { - _playerInvites[guid].erase(inviteId); - return true; + WorldPacket data(SMSG_CALENDAR_EVENT_REMOVED_ALERT, 1 + 8 + 1); + data << uint8(1); // FIXME: If true does not SignalEvent(EVENT_CALENDAR_ACTION_PENDING) + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + + SendPacketToAllEventRelatives(data, calendarEvent); } -void CalendarMgr::SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType type) +void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags) { - if (Player* player = ObjectAccessor::FindPlayer(calendarEvent.GetCreatorGUID())) - player->GetSession()->SendCalendarEvent(calendarEvent, type); + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1); + data.appendPackGUID(invite.GetInviteeGUID()); + data << uint64(invite.GetEventId()); + data << uint32(flags); + data << uint8(1); // FIXME + + SendPacketToAllEventRelatives(data, calendarEvent); } -void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite, bool pending) +void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - if (Player* player = ObjectAccessor::FindPlayer(invite.GetSenderGUID())) - player->GetSession()->SendCalendarEventInvite(invite, pending); + WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1); + data.appendPackGUID(invite.GetInviteeGUID()); + data << uint64(invite.GetEventId()); + data << uint8(invite.GetRank()); + data << uint8(1); // Unk boolean - Display to client? + + SendPacketToAllEventRelatives(data, calendarEvent); } void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - if (Player* player = ObjectAccessor::FindPlayer(invite.GetInvitee())) - player->GetSession()->SendCalendarEventInviteAlert(calendarEvent, invite); + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT); + data << uint64(calendarEvent.GetEventId()); + data << calendarEvent.GetTitle(); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint32(calendarEvent.GetFlags()); + data << uint32(calendarEvent.GetType()); + data << int32(calendarEvent.GetDungeonId()); + data << uint64(invite.GetInviteId()); + data << uint8(invite.GetStatus()); + data << uint8(invite.GetRank()); + data.appendPackGUID(calendarEvent.GetCreatorGUID()); + data.appendPackGUID(invite.GetSenderGUID()); + + if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) + { + if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) + guild->BroadcastPacket(&data); + } + else + if (Player* player = ObjectAccessor::FindPlayer(invite.GetInviteeGUID())) + player->SendDirectMessage(&data); } -void CalendarMgr::SendCalendarEventUpdateAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType type) +void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType) { - if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventUpdateAlert(calendarEvent, type); -} + Player* player = ObjectAccessor::FindPlayer(guid); + if (!player) + return; + + std::vector<CalendarInvite*> const& eventInviteeList = _invites[calendarEvent.GetEventId()]; + + WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32); + data << uint8(sendType); + data.appendPackGUID(calendarEvent.GetCreatorGUID()); + data << uint64(calendarEvent.GetEventId()); + data << calendarEvent.GetTitle(); + data << calendarEvent.GetDescription(); + data << uint8(calendarEvent.GetType()); + data << uint8(CALENDAR_REPEAT_NEVER); // repeatable + data << uint32(CALENDAR_MAX_INVITES); + data << int32(calendarEvent.GetDungeonId()); + data << uint32(calendarEvent.GetFlags()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data.AppendPackedTime(calendarEvent.GetTimeZoneTime()); + data << uint32(calendarEvent.GetGuildId()); + + data << uint32(eventInviteeList.size()); + for (std::vector<CalendarInvite*>::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr) + { + CalendarInvite const* calendarInvite = (*itr); + uint64 inviteeGuid = calendarInvite->GetInviteeGUID(); + Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid); + + uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid); + uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid); + + data.appendPackGUID(inviteeGuid); + data << uint8(inviteeLevel); + data << uint8(calendarInvite->GetStatus()); + data << uint8(calendarInvite->GetRank()); + data << uint8(calendarEvent.IsGuildEvent() && calendarEvent.GetGuildId() == inviteeGuildId); + data << uint64(calendarInvite->GetInviteId()); + data.AppendPackedTime(calendarInvite->GetStatusTime()); + data << calendarInvite->GetText(); + } -void CalendarMgr::SendCalendarEventStatus(uint64 guid, CalendarEvent const& calendarEvent, CalendarInvite const& invite) -{ - if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventStatus(calendarEvent, invite); + player->SendDirectMessage(&data); } -void CalendarMgr::SendCalendarEventRemovedAlert(uint64 guid, CalendarEvent const& calendarEvent) +void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status) { if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventRemovedAlert(calendarEvent); + { + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 8 + 4 + 4 + 1); + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint32(calendarEvent.GetFlags()); + data << uint8(status); + + player->SendDirectMessage(&data); + } } -void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status) +void CalendarMgr::SendCalendarClearPendingAction(uint64 guid) { if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventInviteRemoveAlert(calendarEvent, status); + { + WorldPacket data(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0); + player->SendDirectMessage(&data); + } } -void CalendarMgr::SendCalendarEventInviteRemove(uint64 guid, CalendarInvite const& invite, uint32 flags) +void CalendarMgr::SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param /*= NULL*/) { if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventInviteRemove(invite, flags); + { + WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0); + data << uint32(0); + data << uint8(0); + switch (err) + { + case CALENDAR_ERROR_OTHER_INVITES_EXCEEDED: + case CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S: + case CALENDAR_ERROR_IGNORING_YOU_S: + data << param; + break; + default: + data << uint8(0); + break; + } + + data << uint32(err); + + player->SendDirectMessage(&data); + } } -void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite) +void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket packet, CalendarEvent const& calendarEvent) { - if (Player* player = ObjectAccessor::FindPlayer(invite.GetInvitee())) - player->GetSession()->SendCalendarEventModeratorStatusAlert(invite); + // Send packet to all guild members + if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) + if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) + guild->BroadcastPacket(&packet); + + // Send packet to all invitees if event is non-guild, in other case only to non-guild invitees (packet was broadcasted for them) + std::vector<CalendarInvite*> invites = _invites[calendarEvent.GetEventId()]; + for (std::vector<CalendarInvite*>::iterator itr = invites.begin(); itr != invites.end(); ++itr) + if (Player* player = ObjectAccessor::FindPlayer((*itr)->GetInviteeGUID())) + if (!calendarEvent.IsGuildEvent() || (calendarEvent.IsGuildEvent() && player->GetGuildId() != calendarEvent.GetGuildId())) + player->SendDirectMessage(&packet); } diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index a8749778cb3..db6acb667ec 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -19,60 +19,311 @@ #define TRINITY_CALENDARMGR_H #include <ace/Singleton.h> -#include "Calendar.h" +#include "Common.h" +#include "WorldPacket.h" + +enum CalendarMailAnswers +{ + // else + CALENDAR_EVENT_REMOVED_MAIL_SUBJECT = 0, + // if ( *(_DWORD *)(a1 + 8292) & 0x100 ) + CALENDAR_INVITE_REMOVED_MAIL_SUBJECT = 0x100 +}; + +enum CalendarFlags +{ + CALENDAR_FLAG_ALL_ALLOWED = 0x001, + CALENDAR_FLAG_INVITES_LOCKED = 0x010, + CALENDAR_FLAG_WITHOUT_INVITES = 0x040, + CALENDAR_FLAG_GUILD_EVENT = 0x400 +}; + +enum CalendarModerationRank +{ + CALENDAR_RANK_PLAYER = 0, + CALENDAR_RANK_MODERATOR = 1, + CALENDAR_RANK_OWNER = 2 +}; + +enum CalendarSendEventType +{ + CALENDAR_SENDTYPE_GET = 0, + CALENDAR_SENDTYPE_ADD = 1, + CALENDAR_SENDTYPE_COPY = 2 +}; + +enum CalendarEventType +{ + CALENDAR_TYPE_RAID = 0, + CALENDAR_TYPE_DUNGEON = 1, + CALENDAR_TYPE_PVP = 2, + CALENDAR_TYPE_MEETING = 3, + CALENDAR_TYPE_OTHER = 4 +}; + +enum CalendarRepeatType +{ + CALENDAR_REPEAT_NEVER = 0, + CALENDAR_REPEAT_WEEKLY = 1, + CALENDAR_REPEAT_BIWEEKLY = 2, + CALENDAR_REPEAT_MONTHLY = 3 +}; + +enum CalendarInviteStatus +{ + CALENDAR_STATUS_INVITED = 0, + CALENDAR_STATUS_ACCEPTED = 1, + CALENDAR_STATUS_DECLINED = 2, + CALENDAR_STATUS_CONFIRMED = 3, + CALENDAR_STATUS_OUT = 4, + CALENDAR_STATUS_STANDBY = 5, + CALENDAR_STATUS_SIGNED_UP = 6, + CALENDAR_STATUS_NOT_SIGNED_UP = 7, + CALENDAR_STATUS_TENTATIVE = 8, + CALENDAR_STATUS_REMOVED = 9 // correct name? +}; + +enum CalendarError +{ + CALENDAR_OK = 0, + CALENDAR_ERROR_GUILD_EVENTS_EXCEEDED = 1, + CALENDAR_ERROR_EVENTS_EXCEEDED = 2, + CALENDAR_ERROR_SELF_INVITES_EXCEEDED = 3, + CALENDAR_ERROR_OTHER_INVITES_EXCEEDED = 4, + CALENDAR_ERROR_PERMISSIONS = 5, + CALENDAR_ERROR_EVENT_INVALID = 6, + CALENDAR_ERROR_NOT_INVITED = 7, + CALENDAR_ERROR_INTERNAL = 8, + CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD = 9, + CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S = 10, + CALENDAR_ERROR_PLAYER_NOT_FOUND = 11, + CALENDAR_ERROR_NOT_ALLIED = 12, + CALENDAR_ERROR_IGNORING_YOU_S = 13, + CALENDAR_ERROR_INVITES_EXCEEDED = 14, + CALENDAR_ERROR_INVALID_DATE = 16, + CALENDAR_ERROR_INVALID_TIME = 17, + + CALENDAR_ERROR_NEEDS_TITLE = 19, + CALENDAR_ERROR_EVENT_PASSED = 20, + CALENDAR_ERROR_EVENT_LOCKED = 21, + CALENDAR_ERROR_DELETE_CREATOR_FAILED = 22, + CALENDAR_ERROR_SYSTEM_DISABLED = 24, + CALENDAR_ERROR_RESTRICTED_ACCOUNT = 25, + CALENDAR_ERROR_ARENA_EVENTS_EXCEEDED = 26, + CALENDAR_ERROR_RESTRICTED_LEVEL = 27, + CALENDAR_ERROR_USER_SQUELCHED = 28, + CALENDAR_ERROR_NO_INVITE = 29, + + CALENDAR_ERROR_EVENT_WRONG_SERVER = 36, + CALENDAR_ERROR_INVITE_WRONG_SERVER = 37, + CALENDAR_ERROR_NO_GUILD_INVITES = 38, + CALENDAR_ERROR_INVALID_SIGNUP = 39, + CALENDAR_ERROR_NO_MODERATOR = 40 +}; + +#define CALENDAR_MAX_EVENTS 30 +#define CALENDAR_MAX_GUILD_EVENTS 100 +#define CALENDAR_MAX_INVITES 100 + +struct CalendarInvite +{ + public: + CalendarInvite(CalendarInvite const& calendarInvite, uint64 inviteId, uint64 eventId) + { + _inviteId = inviteId; + _eventId = eventId; + _invitee = calendarInvite.GetInviteeGUID(); + _senderGUID = calendarInvite.GetSenderGUID(); + _statusTime = calendarInvite.GetStatusTime(); + _status = calendarInvite.GetStatus(); + _rank = calendarInvite.GetRank(); + _text = calendarInvite.GetText(); + } + + CalendarInvite() : _inviteId(1), _eventId(0), _invitee(0), _senderGUID(0), _statusTime(time(NULL)), + _status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { } + + CalendarInvite(uint64 inviteId, uint64 eventId, uint64 invitee, uint64 senderGUID, time_t statusTime, + CalendarInviteStatus status, CalendarModerationRank rank, std::string text) : + _inviteId(inviteId), _eventId(eventId), _invitee(invitee), _senderGUID(senderGUID), _statusTime(statusTime), + _status(status), _rank(rank), _text(text) { } + + ~CalendarInvite(); + + void SetInviteId(uint64 inviteId) { _inviteId = inviteId; } + uint64 GetInviteId() const { return _inviteId; } + + void SetEventId(uint64 eventId) { _eventId = eventId; } + uint64 GetEventId() const { return _eventId; } + + void SetSenderGUID(uint64 guid) { _senderGUID = guid; } + uint64 GetSenderGUID() const { return _senderGUID; } + + void SetInvitee(uint64 guid) { _invitee = guid; } + uint64 GetInviteeGUID() const { return _invitee; } + + void SetStatusTime(time_t statusTime) { _statusTime = statusTime; } + time_t GetStatusTime() const { return _statusTime; } + + void SetText(std::string text) { _text = text; } + std::string GetText() const { return _text; } + + void SetStatus(CalendarInviteStatus status) { _status = status; } + CalendarInviteStatus GetStatus() const { return _status; } + + void SetRank(CalendarModerationRank rank) { _rank = rank; } + CalendarModerationRank GetRank() const { return _rank; } + + private: + uint64 _inviteId; + uint64 _eventId; + uint64 _invitee; + uint64 _senderGUID; + time_t _statusTime; + CalendarInviteStatus _status; + CalendarModerationRank _rank; + std::string _text; +}; + +struct CalendarEvent +{ + public: + CalendarEvent(CalendarEvent const& calendarEvent, uint64 eventId) + { + _eventId = eventId; + _creatorGUID = calendarEvent.GetCreatorGUID(); + _guildId = calendarEvent.GetGuildId(); + _type = calendarEvent.GetType(); + _dungeonId = calendarEvent.GetDungeonId(); + _eventTime = calendarEvent.GetEventTime(); + _flags = calendarEvent.GetFlags(); + _timezoneTime = calendarEvent.GetTimeZoneTime(); + _title = calendarEvent.GetTitle(); + _description = calendarEvent.GetDescription(); + } + + CalendarEvent(uint64 eventId, uint64 creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId, + time_t eventTime, uint32 flags, time_t timezoneTime, std::string title, std::string description) : + _eventId(eventId), _creatorGUID(creatorGUID), _guildId(guildId), _type(type), _dungeonId(dungeonId), + _eventTime(eventTime), _flags(flags), _timezoneTime(timezoneTime), _title(title), + _description(description) { } + + CalendarEvent() : _eventId(1), _creatorGUID(0), _guildId(0), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0), + _flags(0), _timezoneTime(0), _title(""), _description("") { } + + ~CalendarEvent(); + + void SetEventId(uint64 eventId) { _eventId = eventId; } + uint64 GetEventId() const { return _eventId; } + + void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; } + uint64 GetCreatorGUID() const { return _creatorGUID; } + + void SetGuildId(uint32 guildId) { _guildId = guildId; } + uint32 GetGuildId() const { return _guildId; } + + void SetTitle(std::string title) { _title = title; } + std::string GetTitle() const { return _title; } + + void SetDescription(std::string description) { _description = description; } + std::string GetDescription() const { return _description; } + + void SetType(CalendarEventType type) { _type = type; } + CalendarEventType GetType() const { return _type; } + + void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; } + int32 GetDungeonId() const { return _dungeonId; } + + void SetEventTime(time_t eventTime) { _eventTime = eventTime; } + time_t GetEventTime() const { return _eventTime; } + + void SetFlags(uint32 flags) { _flags = flags; } + uint32 GetFlags() const { return _flags; } + + void SetTimeZoneTime(time_t timezoneTime) { _timezoneTime = timezoneTime; } + time_t GetTimeZoneTime() const { return _timezoneTime; } + + bool IsGuildEvent() const { return _flags & CALENDAR_FLAG_GUILD_EVENT; } + bool IsGuildAnnouncement() const { return _flags & CALENDAR_FLAG_WITHOUT_INVITES; } + + std::string BuildCalendarMailSubject(uint64 remover) const; + std::string BuildCalendarMailBody() const; + + private: + uint64 _eventId; + uint64 _creatorGUID; + uint32 _guildId; + CalendarEventType _type; + int32 _dungeonId; + time_t _eventTime; + uint32 _flags; + time_t _timezoneTime; + std::string _title; + std::string _description; +}; + +typedef std::set<CalendarEvent*> CalendarEventStore; +typedef std::map<uint64 /* eventId */, std::vector<CalendarInvite*> > CalendarInviteStore; class CalendarMgr { - friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>; + friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>; + private: CalendarMgr(); ~CalendarMgr(); + CalendarEventStore _events; + CalendarInviteStore _invites; + + std::deque<uint64> _freeEventIds; + std::deque<uint64> _freeInviteIds; + uint64 _maxEventId; + uint64 _maxInviteId; + public: void LoadFromDB(); - CalendarInvite* GetInvite(uint64 inviteId); CalendarEvent* GetEvent(uint64 eventId); + CalendarEventStore const& GetEvents() const { return _events; } + CalendarEventStore GetPlayerEvents(uint64 guid); - CalendarInviteIdList const& GetPlayerInvites(uint64 guid); - CalendarEventIdList const& GetPlayerEvents(uint64 guid); + CalendarInvite* GetInvite(uint64 inviteId); + CalendarInviteStore const& GetInvites() const { return _invites; } + std::vector<CalendarInvite*> GetEventInvites(uint64 eventId); + std::vector<CalendarInvite*> GetPlayerInvites(uint64 guid); - uint32 GetPlayerNumPending(uint64 guid); + void FreeEventId(uint64 id); uint64 GetFreeEventId(); + void FreeInviteId(uint64 id); uint64 GetFreeInviteId(); - void AddAction(CalendarAction const& action); - - void SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType type); - void SendCalendarEventInvite(CalendarInvite const& invite, bool pending); - void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); - void SendCalendarEventInviteRemove(uint64 guid, CalendarInvite const& invite, uint32 flags); - void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status); - void SendCalendarEventUpdateAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType type); - void SendCalendarEventStatus(uint64 guid, CalendarEvent const& calendarEvent, CalendarInvite const& invite); - void SendCalendarEventRemovedAlert(uint64 guid, CalendarEvent const& calendarEvent); - void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite); + uint32 GetPlayerNumPending(uint64 guid); - private: - CalendarEvent* CheckPermisions(uint64 eventId, Player* player, uint64 inviteId, CalendarModerationRank minRank); + void AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType); + void RemoveEvent(uint64 eventId, uint64 remover); + void UpdateEvent(CalendarEvent* calendarEvent); - bool AddEvent(CalendarEvent const& calendarEvent); - bool RemoveEvent(uint64 eventId); - bool AddPlayerEvent(uint64 guid, uint64 eventId); - bool RemovePlayerEvent(uint64 guid, uint64 eventId); + void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite); + void RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover); + void UpdateInvite(CalendarInvite* invite); - bool AddInvite(CalendarInvite const& invite); - uint64 RemoveInvite(uint64 inviteId); - bool AddPlayerInvite(uint64 guid, uint64 inviteId); - bool RemovePlayerInvite(uint64 guid, uint64 inviteId); + void RemoveAllPlayerEventsAndInvites(uint64 guid); + void RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId); - CalendarEventMap _events; - CalendarInviteMap _invites; - CalendarPlayerInviteIdMap _playerInvites; - CalendarPlayerEventIdMap _playerEvents; + void SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType); + void SendCalendarEventInvite(CalendarInvite const& invite); + void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); + void SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags); + void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status); + void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime); + void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite); + void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent); + void SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); + void SendCalendarClearPendingAction(uint64 guid); + void SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param = NULL); - uint64 _eventNum; - uint64 _inviteNum; + void SendPacketToAllEventRelatives(WorldPacket packet, CalendarEvent const& calendarEvent); }; #define sCalendarMgr ACE_Singleton<CalendarMgr, ACE_Null_Mutex>::instance() diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 66f964fb4cf..cba38a3ebf1 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -23,49 +23,56 @@ #include "World.h" #include "DatabaseEnv.h" #include "AccountMgr.h" - -Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) : m_announce(true), - m_ownership(true), m_name(name), m_password(""), m_flags(0), m_channelId(channel_id), - m_ownerGUID(0), m_Team(Team) +#include "Player.h" + +Channel::Channel(std::string const& name, uint32 channelId, uint32 team): + _announce(true), + _ownership(true), + _IsSaved(false), + _flags(0), + _channelId(channelId), + _Team(team), + _ownerGUID(0), + _name(name), + _password("") { - m_IsSaved = false; // set special flags if built-in channel - if (ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(channel_id)) // check whether it's a built-in channel + if (ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(channelId)) // check whether it's a built-in channel { - m_announce = false; // no join/leave announces - m_ownership = false; // no ownership handout + _announce = false; // no join/leave announces + _ownership = false; // no ownership handout - m_flags |= CHANNEL_FLAG_GENERAL; // for all built-in channels + _flags |= CHANNEL_FLAG_GENERAL; // for all built-in channels if (ch->flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel - m_flags |= CHANNEL_FLAG_TRADE; + _flags |= CHANNEL_FLAG_TRADE; if (ch->flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels - m_flags |= CHANNEL_FLAG_CITY; + _flags |= CHANNEL_FLAG_CITY; if (ch->flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel - m_flags |= CHANNEL_FLAG_LFG; + _flags |= CHANNEL_FLAG_LFG; else // for all other channels - m_flags |= CHANNEL_FLAG_NOT_LFG; + _flags |= CHANNEL_FLAG_NOT_LFG; } else // it's custom channel { - m_flags |= CHANNEL_FLAG_CUSTOM; + _flags |= CHANNEL_FLAG_CUSTOM; // If storing custom channels in the db is enabled either load or save the channel if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS)) { PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHANNEL); stmt->setString(0, name); - stmt->setUInt32(1, m_Team); + stmt->setUInt32(1, _Team); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) //load { Field* fields = result->Fetch(); - m_announce = fields[0].GetBool(); - m_ownership = fields[1].GetBool(); - m_password = fields[2].GetString(); + _announce = fields[0].GetBool(); + _ownership = fields[1].GetBool(); + _password = fields[2].GetString(); const char* db_BannedList = fields[3].GetCString(); if (db_BannedList) @@ -76,8 +83,8 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) : m_an uint64 banned_guid = atol(*i); if (banned_guid) { - sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) loaded banned guid:" UI64FMTD "", name.c_str(), banned_guid); - banned.insert(banned_guid); + sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) loaded bannedStore guid:" UI64FMTD "", name.c_str(), banned_guid); + bannedStore.insert(banned_guid); } } } @@ -86,45 +93,45 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) : m_an { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL); stmt->setString(0, name); - stmt->setUInt32(1, m_Team); + stmt->setUInt32(1, _Team); CharacterDatabase.Execute(stmt); sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) saved in database", name.c_str()); } - m_IsSaved = true; + _IsSaved = true; } } } void Channel::UpdateChannelInDB() const { - if (m_IsSaved) + if (_IsSaved) { std::ostringstream banlist; - BannedList::const_iterator iter; - for (iter = banned.begin(); iter != banned.end(); ++iter) + BannedContainer::const_iterator iter; + for (iter = bannedStore.begin(); iter != bannedStore.end(); ++iter) banlist << (*iter) << ' '; std::string banListStr = banlist.str(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL); - stmt->setBool(0, m_announce); - stmt->setBool(1, m_ownership); - stmt->setString(2, m_password); + stmt->setBool(0, _announce); + stmt->setBool(1, _ownership); + stmt->setString(2, _password); stmt->setString(3, banListStr); - stmt->setString(4, m_name); - stmt->setUInt32(5, m_Team); + stmt->setString(4, _name); + stmt->setUInt32(5, _Team); CharacterDatabase.Execute(stmt); - sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) updated in database", m_name.c_str()); + sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) updated in database", _name.c_str()); } } void Channel::UpdateChannelUseageInDB() const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_USAGE); - stmt->setString(0, m_name); - stmt->setUInt32(1, m_Team); + stmt->setString(0, _name); + stmt->setUInt32(1, _Team); CharacterDatabase.Execute(stmt); } @@ -140,531 +147,507 @@ void Channel::CleanOldChannelsInDB() } } -void Channel::Join(uint64 p, const char *pass) +void Channel::JoinChannel(Player* player, std::string const& pass) { - WorldPacket data; - if (IsOn(p)) + uint64 guid = player->GetGUID(); + if (IsOn(guid)) { - if (!IsConstant()) // non send error message for built-in channels + // Do not send error message for built-in channels + if (!IsConstant()) { - MakePlayerAlreadyMember(&data, p); - SendToOne(&data, p); + WorldPacket data; + MakePlayerAlreadyMember(&data, guid); + SendToOne(&data, guid); } return; } - if (IsBanned(p)) + if (IsBanned(guid)) { + WorldPacket data; MakeBanned(&data); - SendToOne(&data, p); + SendToOne(&data, guid); return; } - if (m_password.length() > 0 && strcmp(pass, m_password.c_str())) + if (!_password.empty() && pass != _password) { + WorldPacket data; MakeWrongPassword(&data); - SendToOne(&data, p); + SendToOne(&data, guid); return; } - Player* player = ObjectAccessor::FindPlayer(p); - - if (player) + if (HasFlag(CHANNEL_FLAG_LFG) && + sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && + AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && + player->GetGroup()) { - if (HasFlag(CHANNEL_FLAG_LFG) && - sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->GetGroup()) - { - MakeNotInLfg(&data); - SendToOne(&data, p); - return; - } - - player->JoinedChannel(this); + WorldPacket data; + MakeNotInLfg(&data); + SendToOne(&data, guid); + return; } - if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + player->JoinedChannel(this); + + if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || + !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { - MakeJoined(&data, p); + WorldPacket data; + MakeJoined(&data, guid); SendToAll(&data); } - data.clear(); - PlayerInfo pinfo; - pinfo.player = p; + pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; - players[p] = pinfo; + playersStore[guid] = pinfo; + WorldPacket data; MakeYouJoined(&data); - SendToOne(&data, p); + SendToOne(&data, guid); - JoinNotify(p); + JoinNotify(guid); // Custom channel handling if (!IsConstant()) { // Update last_used timestamp in db - if (!players.empty()) + if (!playersStore.empty()) UpdateChannelUseageInDB(); // If the channel has no owner yet and ownership is allowed, set the new owner. - if (!m_ownerGUID && m_ownership) + if (!_ownerGUID && _ownership) { - SetOwner(p, (players.size() > 1 ? true : false)); - players[p].SetModerator(true); + SetOwner(guid, playersStore.size() > 1); + playersStore[guid].SetModerator(true); } } } -void Channel::Leave(uint64 p, bool send) +void Channel::LeaveChannel(Player* player, bool send) { - if (!IsOn(p)) + uint64 guid = player->GetGUID(); + if (!IsOn(guid)) { if (send) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); } + return; } - else + + if (send) { - Player* player = ObjectAccessor::FindPlayer(p); + WorldPacket data; + MakeYouLeft(&data); + SendToOne(&data, guid); + player->LeftChannel(this); + data.clear(); + } - if (send) - { - WorldPacket data; - MakeYouLeft(&data); - SendToOne(&data, p); - if (player) - player->LeftChannel(this); - data.clear(); - } + bool changeowner = playersStore[guid].IsOwner(); - bool changeowner = players[p].IsOwner(); + playersStore.erase(guid); + if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || + !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + { + WorldPacket data; + MakeLeft(&data, guid); + SendToAll(&data); + } - players.erase(p); - if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) - { - WorldPacket data; - MakeLeft(&data, p); - SendToAll(&data); - } + LeaveNotify(guid); - LeaveNotify(p); + if (!IsConstant()) + { + // Update last_used timestamp in db + UpdateChannelUseageInDB(); - if (!IsConstant()) + // If the channel owner left and there are still playersStore inside, pick a new owner + if (changeowner && _ownership && !playersStore.empty()) { - // Update last_used timestamp in db - UpdateChannelUseageInDB(); - - // If the channel owner left and there are still players inside, pick a new owner - if (changeowner && m_ownership && !players.empty()) - { - uint64 newowner = players.begin()->second.player; - players[newowner].SetModerator(true); - SetOwner(newowner); - } + uint64 newowner = playersStore.begin()->second.player; + playersStore[newowner].SetModerator(true); + SetOwner(newowner); } } } -void Channel::KickOrBan(uint64 good, const char *badname, bool ban) +void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban) { - AccountTypes sec = SEC_PLAYER; - Player* gplr = ObjectAccessor::FindPlayer(good); - if (gplr) - sec = gplr->GetSession()->GetSecurity(); + AccountTypes sec = player->GetSession()->GetSecurity(); + uint64 good = player->GetGUID(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); + return; } - else if (!players[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) + + if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); + return; } - else + + Player* bad = sObjectAccessor->FindPlayerByName(badname); + uint64 victim = bad ? bad->GetGUID() : 0; + if (!victim || !IsOn(victim)) { - Player* bad = sObjectAccessor->FindPlayerByName(badname); - if (bad == NULL || !IsOn(bad->GetGUID())) - { - WorldPacket data; - MakePlayerNotFound(&data, badname); - SendToOne(&data, good); - } - else if (!AccountMgr::IsGMAccount(sec) && bad->GetGUID() == m_ownerGUID && good != m_ownerGUID) - { - WorldPacket data; - MakeNotOwner(&data); - SendToOne(&data, good); - } - else - { - bool changeowner = (m_ownerGUID == bad->GetGUID()); - - WorldPacket data; - bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); + WorldPacket data; + MakePlayerNotFound(&data, badname); + SendToOne(&data, good); + return; + } - if (ban && !IsBanned(bad->GetGUID())) - { - banned.insert(bad->GetGUID()); - UpdateChannelInDB(); + bool changeowner = _ownerGUID == victim; - if (notify) - MakePlayerBanned(&data, bad->GetGUID(), good); - } - else if (notify) - MakePlayerKicked(&data, bad->GetGUID(), good); + if (!AccountMgr::IsGMAccount(sec) && changeowner && good != _ownerGUID) + { + WorldPacket data; + MakeNotOwner(&data); + SendToOne(&data, good); + return; + } - if (notify) - SendToAll(&data); + bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); - players.erase(bad->GetGUID()); - bad->LeftChannel(this); + if (ban && !IsBanned(victim)) + { + bannedStore.insert(victim); + UpdateChannelInDB(); - if (changeowner && m_ownership && !players.empty()) - { - uint64 newowner = good; - players[newowner].SetModerator(true); - SetOwner(newowner); - } + if (notify) + { + WorldPacket data; + MakePlayerBanned(&data, victim, good); + SendToAll(&data); } } + else if (notify) + { + WorldPacket data; + MakePlayerKicked(&data, victim, good); + SendToAll(&data); + } + + playersStore.erase(victim); + bad->LeftChannel(this); + + if (changeowner && _ownership && !playersStore.empty()) + { + uint64 newowner = good; + playersStore[newowner].SetModerator(true); + SetOwner(newowner); + } } -void Channel::UnBan(uint64 good, const char *badname) +void Channel::UnBan(Player const* player, std::string const& badname) { - uint32 sec = 0; - Player* gplr = ObjectAccessor::FindPlayer(good); - if (gplr) - sec = gplr->GetSession()->GetSecurity(); + uint32 sec = player->GetSession()->GetSecurity(); + uint64 good = player->GetGUID(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); + return; } - else if (!players[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) + + if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); + return; } - else - { - Player* bad = sObjectAccessor->FindPlayerByName(badname); - if (bad == NULL || !IsBanned(bad->GetGUID())) - { - WorldPacket data; - MakePlayerNotFound(&data, badname); - SendToOne(&data, good); - } - else - { - banned.erase(bad->GetGUID()); - WorldPacket data; - MakePlayerUnbanned(&data, bad->GetGUID(), good); - SendToAll(&data); + Player* bad = sObjectAccessor->FindPlayerByName(badname); + uint64 victim = bad ? bad->GetGUID(): 0; - UpdateChannelInDB(); - } + if (!victim || !IsBanned(victim)) + { + WorldPacket data; + MakePlayerNotFound(&data, badname); + SendToOne(&data, good); + return; } + + bannedStore.erase(victim); + + WorldPacket data; + MakePlayerUnbanned(&data, victim, good); + SendToAll(&data); + + UpdateChannelInDB(); } -void Channel::Password(uint64 p, const char *pass) +void Channel::Password(Player const* player, std::string const& pass) { - uint32 sec = 0; - Player* player = ObjectAccessor::FindPlayer(p); - if (player) - sec = player->GetSession()->GetSecurity(); - - ChatHandler chat(player); + uint64 guid = player->GetGUID(); - if (!IsOn(p)) + ChatHandler chat(player->GetSession()); + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else if (!players[p].IsModerator() && !AccountMgr::IsGMAccount(sec)) + + if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity())) { WorldPacket data; MakeNotModerator(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else - { - m_password = pass; - WorldPacket data; - MakePasswordChanged(&data, p); - SendToAll(&data); + _password = pass; - UpdateChannelInDB(); - } + WorldPacket data; + MakePasswordChanged(&data, guid); + SendToAll(&data); + + UpdateChannelInDB(); } -void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) +void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bool set) { - Player* player = ObjectAccessor::FindPlayer(p); - if (!player) - return; - + uint64 guid = player->GetGUID(); uint32 sec = player->GetSession()->GetSecurity(); - if (!IsOn(p)) + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else if (!players[p].IsModerator() && !AccountMgr::IsGMAccount(sec)) + + if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else - { - Player* newp = sObjectAccessor->FindPlayerByName(p2n); - if (!newp) - { - WorldPacket data; - MakePlayerNotFound(&data, p2n); - SendToOne(&data, p); - return; - } - if (p == m_ownerGUID && newp->GetGUID() == m_ownerGUID && mod) - return; + if (guid == _ownerGUID && std::string(p2n) == player->GetName() && mod) + return; - if (!IsOn(newp->GetGUID())) - { - WorldPacket data; - MakePlayerNotFound(&data, p2n); - SendToOne(&data, p); - return; - } + Player* newp = sObjectAccessor->FindPlayerByName(p2n); + uint64 victim = newp ? newp->GetGUID() : 0; + if (!victim || !IsOn(victim) || // allow make moderator from another team only if both is GMs // at this moment this only way to show channel post for GM from another team - if ((!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && - player->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) - { - WorldPacket data; - MakePlayerNotFound(&data, p2n); - SendToOne(&data, p); - return; - } - - if (m_ownerGUID == newp->GetGUID() && m_ownerGUID != p) - { - WorldPacket data; - MakeNotOwner(&data); - SendToOne(&data, p); - return; - } + ((!AccountMgr::IsGMAccount(sec) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && + player->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))) + { + WorldPacket data; + MakePlayerNotFound(&data, p2n); + SendToOne(&data, guid); + return; + } - if (mod) - SetModerator(newp->GetGUID(), set); - else - SetMute(newp->GetGUID(), set); + if (_ownerGUID == victim && _ownerGUID != guid) + { + WorldPacket data; + MakeNotOwner(&data); + SendToOne(&data, guid); + return; } + + if (mod) + SetModerator(newp->GetGUID(), set); + else + SetMute(newp->GetGUID(), set); } -void Channel::SetOwner(uint64 p, const char *newname) +void Channel::SetOwner(Player const* player, std::string const& newname) { - Player* player = ObjectAccessor::FindPlayer(p); - if (!player) - return; - + uint64 guid = player->GetGUID(); uint32 sec = player->GetSession()->GetSecurity(); - if (!IsOn(p)) + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); return; } - if (!AccountMgr::IsGMAccount(sec) && p != m_ownerGUID) + if (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID) { WorldPacket data; MakeNotOwner(&data); - SendToOne(&data, p); + SendToOne(&data, guid); return; } Player* newp = sObjectAccessor->FindPlayerByName(newname); - if (newp == NULL || !IsOn(newp->GetGUID())) + uint64 victim = newp ? newp->GetGUID() : 0; + + if (!victim || !IsOn(victim) || + (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))) { WorldPacket data; MakePlayerNotFound(&data, newname); - SendToOne(&data, p); + SendToOne(&data, guid); return; } - if (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) - { - WorldPacket data; - MakePlayerNotFound(&data, newname); - SendToOne(&data, p); - return; - } - - players[newp->GetGUID()].SetModerator(true); - SetOwner(newp->GetGUID()); + playersStore[victim].SetModerator(true); + SetOwner(victim); } -void Channel::SendWhoOwner(uint64 p) +void Channel::SendWhoOwner(uint64 guid) { - if (!IsOn(p)) - { - WorldPacket data; - MakeNotMember(&data); - SendToOne(&data, p); - } - else - { - WorldPacket data; + WorldPacket data; + if (IsOn(guid)) MakeChannelOwner(&data); - SendToOne(&data, p); - } + else + MakeNotMember(&data); + SendToOne(&data, guid); } -void Channel::List(Player* player) +void Channel::List(Player const* player) { - uint64 p = player->GetGUID(); + uint64 guid = player->GetGUID(); - if (!IsOn(p)) + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else - { - WorldPacket data(SMSG_CHANNEL_LIST, 1+(GetName().size()+1)+1+4+players.size()*(8+1)); - data << uint8(1); // channel type? - data << GetName(); // channel name - data << uint8(GetFlags()); // channel flags? - size_t pos = data.wpos(); - data << uint32(0); // size of list, placeholder + sLog->outDebug(LOG_FILTER_CHATSYS, "SMSG_CHANNEL_LIST %s Channel: %s", + player->GetSession()->GetPlayerInfo().c_str(), GetName().c_str()); - uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST); + WorldPacket data(SMSG_CHANNEL_LIST, 1+(GetName().size()+1)+1+4+playersStore.size()*(8+1)); + data << uint8(1); // channel type? + data << GetName(); // channel name + data << uint8(GetFlags()); // channel flags? - uint32 count = 0; - for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) - { - Player* member = ObjectAccessor::FindPlayer(i->first); + size_t pos = data.wpos(); + data << uint32(0); // size of list, placeholder - // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters - // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (member && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || member->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && - member->IsVisibleGloballyFor(player)) - { - data << uint64(i->first); - data << uint8(i->second.flags); // flags seems to be changed... - ++count; - } - } + uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST); - data.put<uint32>(pos, count); + uint32 count = 0; + for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i) + { + Player* member = ObjectAccessor::FindPlayer(i->first); - SendToOne(&data, p); + // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters + // MODERATOR, GAME MASTER, ADMINISTRATOR can see all + if (member && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || member->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && + member->IsVisibleGloballyFor(player)) + { + data << uint64(i->first); + data << uint8(i->second.flags); // flags seems to be changed... + ++count; + } } + + data.put<uint32>(pos, count); + + SendToOne(&data, guid); } -void Channel::Announce(uint64 p) +void Channel::Announce(Player const* player) { - uint32 sec = 0; - Player* player = ObjectAccessor::FindPlayer(p); - if (player) - sec = player->GetSession()->GetSecurity(); + uint64 guid = player->GetGUID(); + uint32 sec = player->GetSession()->GetSecurity(); - if (!IsOn(p)) + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else if (!players[p].IsModerator() && !AccountMgr::IsGMAccount(sec)) + + if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else - { - m_announce = !m_announce; - WorldPacket data; - if (m_announce) - MakeAnnouncementsOn(&data, p); - else - MakeAnnouncementsOff(&data, p); - SendToAll(&data); + _announce = !_announce; - UpdateChannelInDB(); - } + WorldPacket data; + if (_announce) + MakeAnnouncementsOn(&data, guid); + else + MakeAnnouncementsOff(&data, guid); + SendToAll(&data); + + UpdateChannelInDB(); } -void Channel::Say(uint64 p, const char *what, uint32 lang) +void Channel::Say(uint64 guid, std::string const& what, uint32 lang) { - if (!what) + if (what.empty()) return; + if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; - Player* player = ObjectAccessor::FindPlayer(p); - - if (!IsOn(p)) + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); + return; } - else if (players[p].IsMuted()) + + if (playersStore[guid].IsMuted()) { WorldPacket data; MakeMuted(&data); - SendToOne(&data, p); - } - else - { - uint32 messageLength = strlen(what) + 1; - - WorldPacket data(SMSG_MESSAGECHAT, 1+4+8+4+m_name.size()+1+8+4+messageLength+1); - data << (uint8)CHAT_MSG_CHANNEL; - data << (uint32)lang; - data << p; // 2.1.0 - data << uint32(0); // 2.1.0 - data << m_name; - data << p; - data << messageLength; - data << what; - data << uint8(player ? player->GetChatTag() : 0); - - SendToAll(&data, !players[p].IsModerator() ? p : false); + SendToOne(&data, guid); + return; } + + WorldPacket data(SMSG_MESSAGECHAT, 1 + 4 + 8 + 4 + _name.size() + 8 + 4 + what.size() + 1); + data << uint8(CHAT_MSG_CHANNEL); + data << uint32(lang); + data << uint64(guid); + data << uint32(0); + data << _name; + data << uint64(guid); + data << uint32(what.size() + 1); + data << what; + Player* player = ObjectAccessor::FindPlayer(guid); + data << uint8(player ? player->GetChatTag() : 0); + + SendToAll(&data, !playersStore[guid].IsModerator() ? guid : false); } -void Channel::Invite(uint64 p, const char *newname) +void Channel::Invite(Player const* player, std::string const& newname) { - if (!IsOn(p)) + uint64 guid = player->GetGUID(); + + if (!IsOn(guid)) { WorldPacket data; MakeNotMember(&data); - SendToOne(&data, p); + SendToOne(&data, guid); return; } @@ -673,7 +656,7 @@ void Channel::Invite(uint64 p, const char *newname) { WorldPacket data; MakePlayerNotFound(&data, newname); - SendToOne(&data, p); + SendToOne(&data, guid); return; } @@ -681,19 +664,15 @@ void Channel::Invite(uint64 p, const char *newname) { WorldPacket data; MakePlayerInviteBanned(&data, newname); - SendToOne(&data, p); + SendToOne(&data, guid); return; } - Player* player = ObjectAccessor::FindPlayer(p); - if (!player) - return; - if (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; MakeInviteWrongFaction(&data); - SendToOne(&data, p); + SendToOne(&data, guid); return; } @@ -701,45 +680,47 @@ void Channel::Invite(uint64 p, const char *newname) { WorldPacket data; MakePlayerAlreadyMember(&data, newp->GetGUID()); - SendToOne(&data, p); + SendToOne(&data, guid); return; } - WorldPacket data; - if (!newp->GetSocial()->HasIgnore(GUID_LOPART(p))) + if (!newp->GetSocial()->HasIgnore(GUID_LOPART(guid))) { - MakeInvite(&data, p); + WorldPacket data; + MakeInvite(&data, guid); SendToOne(&data, newp->GetGUID()); data.clear(); } + + WorldPacket data; MakePlayerInvited(&data, newp->GetName()); - SendToOne(&data, p); + SendToOne(&data, guid); } void Channel::SetOwner(uint64 guid, bool exclaim) { - if (m_ownerGUID) + if (_ownerGUID) { // [] will re-add player after it possible removed - PlayerList::iterator p_itr = players.find(m_ownerGUID); - if (p_itr != players.end()) + PlayerContainer::iterator p_itr = playersStore.find(_ownerGUID); + if (p_itr != playersStore.end()) p_itr->second.SetOwner(false); } - m_ownerGUID = guid; - if (m_ownerGUID) + _ownerGUID = guid; + if (_ownerGUID) { - uint8 oldFlag = GetPlayerFlags(m_ownerGUID); - players[m_ownerGUID].SetModerator(true); - players[m_ownerGUID].SetOwner(true); + uint8 oldFlag = GetPlayerFlags(_ownerGUID); + playersStore[_ownerGUID].SetModerator(true); + playersStore[_ownerGUID].SetOwner(true); WorldPacket data; - MakeModeChange(&data, m_ownerGUID, oldFlag); + MakeModeChange(&data, _ownerGUID, oldFlag); SendToAll(&data); if (exclaim) { - MakeOwnerChanged(&data, m_ownerGUID); + MakeOwnerChanged(&data, _ownerGUID); SendToAll(&data); } @@ -747,36 +728,25 @@ void Channel::SetOwner(uint64 guid, bool exclaim) } } -void Channel::SendToAll(WorldPacket* data, uint64 p) +void Channel::SendToAll(WorldPacket* data, uint64 guid) { - for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) - { - Player* player = ObjectAccessor::FindPlayer(i->first); - if (player) - { - if (!p || !player->GetSocial()->HasIgnore(GUID_LOPART(p))) + for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i) + if (Player* player = ObjectAccessor::FindPlayer(i->first)) + if (!guid || !player->GetSocial()->HasIgnore(GUID_LOPART(guid))) player->GetSession()->SendPacket(data); - } - } } void Channel::SendToAllButOne(WorldPacket* data, uint64 who) { - for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) - { + for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i) if (i->first != who) - { - Player* player = ObjectAccessor::FindPlayer(i->first); - if (player) + if (Player* player = ObjectAccessor::FindPlayer(i->first)) player->GetSession()->SendPacket(data); - } - } } void Channel::SendToOne(WorldPacket* data, uint64 who) { - Player* player = ObjectAccessor::FindPlayer(who); - if (player) + if (Player* player = ObjectAccessor::FindPlayer(who)) player->GetSession()->SendPacket(data); } @@ -790,29 +760,25 @@ void Channel::DeVoice(uint64 /*guid1*/, uint64 /*guid2*/) } -// done void Channel::MakeNotifyPacket(WorldPacket* data, uint8 notify_type) { - data->Initialize(SMSG_CHANNEL_NOTIFY, 1+m_name.size()+1); + data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + _name.size()); *data << uint8(notify_type); - *data << m_name; + *data << _name; } -// done 0x00 void Channel::MakeJoined(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_JOINED_NOTICE); *data << uint64(guid); } -// done 0x01 void Channel::MakeLeft(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_LEFT_NOTICE); *data << uint64(guid); } -// done 0x02 void Channel::MakeYouJoined(WorldPacket* data) { MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE); @@ -821,7 +787,6 @@ void Channel::MakeYouJoined(WorldPacket* data) *data << uint32(0); } -// done 0x03 void Channel::MakeYouLeft(WorldPacket* data) { MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE); @@ -829,64 +794,55 @@ void Channel::MakeYouLeft(WorldPacket* data) *data << uint8(IsConstant()); } -// done 0x04 void Channel::MakeWrongPassword(WorldPacket* data) { MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE); } -// done 0x05 void Channel::MakeNotMember(WorldPacket* data) { MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE); } -// done 0x06 void Channel::MakeNotModerator(WorldPacket* data) { MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE); } -// done 0x07 void Channel::MakePasswordChanged(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE); *data << uint64(guid); } -// done 0x08 void Channel::MakeOwnerChanged(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE); *data << uint64(guid); } -// done 0x09 -void Channel::MakePlayerNotFound(WorldPacket* data, const std::string& name) +void Channel::MakePlayerNotFound(WorldPacket* data, std::string const& name) { MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE); *data << name; } -// done 0x0A void Channel::MakeNotOwner(WorldPacket* data) { MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE); } -// done 0x0B void Channel::MakeChannelOwner(WorldPacket* data) { std::string name = ""; - if (!sObjectMgr->GetPlayerNameByGUID(m_ownerGUID, name) || name.empty()) + if (!sObjectMgr->GetPlayerNameByGUID(_ownerGUID, name) || name.empty()) name = "PLAYER_NOT_FOUND"; MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE); - *data << ((IsConstant() || !m_ownerGUID) ? "Nobody" : name); + *data << ((IsConstant() || !_ownerGUID) ? "Nobody" : name); } -// done 0x0C void Channel::MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags) { MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE); @@ -895,27 +851,23 @@ void Channel::MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags) *data << uint8(GetPlayerFlags(guid)); } -// done 0x0D void Channel::MakeAnnouncementsOn(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE); *data << uint64(guid); } -// done 0x0E void Channel::MakeAnnouncementsOff(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE); *data << uint64(guid); } -// done 0x11 void Channel::MakeMuted(WorldPacket* data) { MakeNotifyPacket(data, CHAT_MUTED_NOTICE); } -// done 0x12 void Channel::MakePlayerKicked(WorldPacket* data, uint64 bad, uint64 good) { MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE); @@ -923,13 +875,11 @@ void Channel::MakePlayerKicked(WorldPacket* data, uint64 bad, uint64 good) *data << uint64(good); } -// done 0x13 void Channel::MakeBanned(WorldPacket* data) { MakeNotifyPacket(data, CHAT_BANNED_NOTICE); } -// done 0x14 void Channel::MakePlayerBanned(WorldPacket* data, uint64 bad, uint64 good) { MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE); @@ -937,7 +887,6 @@ void Channel::MakePlayerBanned(WorldPacket* data, uint64 bad, uint64 good) *data << uint64(good); } -// done 0x15 void Channel::MakePlayerUnbanned(WorldPacket* data, uint64 bad, uint64 good) { MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE); @@ -945,91 +894,77 @@ void Channel::MakePlayerUnbanned(WorldPacket* data, uint64 bad, uint64 good) *data << uint64(good); } -// done 0x16 void Channel::MakePlayerNotBanned(WorldPacket* data, const std::string &name) { MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE); *data << name; } -// done 0x17 void Channel::MakePlayerAlreadyMember(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE); *data << uint64(guid); } -// done 0x18 void Channel::MakeInvite(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_INVITE_NOTICE); *data << uint64(guid); } -// done 0x19 void Channel::MakeInviteWrongFaction(WorldPacket* data) { MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE); } -// done 0x1A void Channel::MakeWrongFaction(WorldPacket* data) { MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE); } -// done 0x1B void Channel::MakeInvalidName(WorldPacket* data) { MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE); } -// done 0x1C void Channel::MakeNotModerated(WorldPacket* data) { MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE); } -// done 0x1D void Channel::MakePlayerInvited(WorldPacket* data, const std::string& name) { MakeNotifyPacket(data, CHAT_PLAYER_INVITED_NOTICE); *data << name; } -// done 0x1E void Channel::MakePlayerInviteBanned(WorldPacket* data, const std::string& name) { MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE); *data << name; } -// done 0x1F void Channel::MakeThrottled(WorldPacket* data) { MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE); } -// done 0x20 void Channel::MakeNotInArea(WorldPacket* data) { MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE); } -// done 0x21 void Channel::MakeNotInLfg(WorldPacket* data) { MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE); } -// done 0x22 void Channel::MakeVoiceOn(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE); *data << uint64(guid); } -// done 0x23 void Channel::MakeVoiceOff(WorldPacket* data, uint64 guid) { MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE); @@ -1038,13 +973,7 @@ void Channel::MakeVoiceOff(WorldPacket* data, uint64 guid) void Channel::JoinNotify(uint64 guid) { - WorldPacket data; - - if (IsConstant()) - data.Initialize(SMSG_USERLIST_ADD, 8+1+1+4+GetName().size()+1); - else - data.Initialize(SMSG_USERLIST_UPDATE, 8+1+1+4+GetName().size()+1); - + WorldPacket data(IsConstant() ? SMSG_USERLIST_ADD : SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size()); data << uint64(guid); data << uint8(GetPlayerFlags(guid)); data << uint8(GetFlags()); @@ -1059,7 +988,7 @@ void Channel::JoinNotify(uint64 guid) void Channel::LeaveNotify(uint64 guid) { - WorldPacket data(SMSG_USERLIST_REMOVE, 8+1+4+GetName().size()+1); + WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size()); data << uint64(guid); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index bdb5112c7ef..c816cd91257 100755 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -26,7 +26,6 @@ #include "Common.h" #include "Opcodes.h" -#include "Player.h" #include "WorldPacket.h" enum ChatNotify @@ -52,10 +51,10 @@ enum ChatNotify // CHAT_MODERATION_OFF_NOTICE = 0x10, //+ "[%s] Channel moderation disabled by %s."; CHAT_MUTED_NOTICE = 0x11, //+ "[%s] You do not have permission to speak."; CHAT_PLAYER_KICKED_NOTICE = 0x12, //? "[%s] Player %s kicked by %s."; - CHAT_BANNED_NOTICE = 0x13, //+ "[%s] You are banned from that channel."; - CHAT_PLAYER_BANNED_NOTICE = 0x14, //? "[%s] Player %s banned by %s."; + CHAT_BANNED_NOTICE = 0x13, //+ "[%s] You are bannedStore from that channel."; + CHAT_PLAYER_BANNED_NOTICE = 0x14, //? "[%s] Player %s bannedStore by %s."; CHAT_PLAYER_UNBANNED_NOTICE = 0x15, //? "[%s] Player %s unbanned by %s."; - CHAT_PLAYER_NOT_BANNED_NOTICE = 0x16, //+ "[%s] Player %s is not banned."; + CHAT_PLAYER_NOT_BANNED_NOTICE = 0x16, //+ "[%s] Player %s is not bannedStore."; CHAT_PLAYER_ALREADY_MEMBER_NOTICE = 0x17, //+ "[%s] Player %s is already on the channel."; CHAT_INVITE_NOTICE = 0x18, //+ "%2$s has invited you to join the channel '%1$s'."; CHAT_INVITE_WRONG_FACTION_NOTICE = 0x19, //+ "Target is in the wrong alliance for %s."; @@ -63,7 +62,7 @@ enum ChatNotify CHAT_INVALID_NAME_NOTICE = 0x1B, //+ "Invalid channel name"; CHAT_NOT_MODERATED_NOTICE = 0x1C, //+ "%s is not moderated"; CHAT_PLAYER_INVITED_NOTICE = 0x1D, //+ "[%s] You invited %s to join the channel"; - CHAT_PLAYER_INVITE_BANNED_NOTICE = 0x1E, //+ "[%s] %s has been banned."; + CHAT_PLAYER_INVITE_BANNED_NOTICE = 0x1E, //+ "[%s] %s has been bannedStore."; CHAT_THROTTLED_NOTICE = 0x1F, //+ "[%s] The number of messages that can be sent to this channel is limited, please wait to send another message."; CHAT_NOT_IN_AREA_NOTICE = 0x20, //+ "[%s] You are not in the correct area for this channel."; -- The user is trying to send a chat to a zone specific channel, and they're not physically in that zone. CHAT_NOT_IN_LFG_NOTICE = 0x21, //+ "[%s] You must be queued in looking for group before joining this channel."; -- The user must be in the looking for group system to join LFG chat channels. @@ -146,18 +145,45 @@ class Channel } }; - typedef std::map<uint64, PlayerInfo> PlayerList; - PlayerList players; - typedef std::set<uint64> BannedList; - BannedList banned; - bool m_announce; - bool m_ownership; - std::string m_name; - std::string m_password; - uint8 m_flags; - uint32 m_channelId; - uint64 m_ownerGUID; - bool m_IsSaved; + public: + Channel(std::string const& name, uint32 channel_id, uint32 Team = 0); + std::string const& GetName() const { return _name; } + uint32 GetChannelId() const { return _channelId; } + bool IsConstant() const { return _channelId != 0; } + bool IsAnnounce() const { return _announce; } + bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; } + std::string const& GetPassword() const { return _password; } + void SetPassword(std::string const& npassword) { _password = npassword; } + void SetAnnounce(bool nannounce) { _announce = nannounce; } + uint32 GetNumPlayers() const { return playersStore.size(); } + uint8 GetFlags() const { return _flags; } + bool HasFlag(uint8 flag) const { return _flags & flag; } + + void JoinChannel(Player* player, std::string const& pass); + void LeaveChannel(Player* player, bool send = true); + void KickOrBan(Player const* player, std::string const& badname, bool ban); + void Kick(Player const* player, std::string const& badname) { KickOrBan(player, badname, false); } + void Ban(Player const* player, std::string const& badname) { KickOrBan(player, badname, true); } + void UnBan(Player const* player, std::string const& badname); + void Password(Player const* player, std::string const& pass); + void SetMode(Player const* player, std::string const& p2n, bool mod, bool set); + void SetOwner(uint64 guid, bool exclaim = true); + void SetOwner(Player const* player, std::string const& name); + void SendWhoOwner(uint64 guid); + void SetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, true); } + void UnsetModerator(Player const* player, std::string const& newname) { SetMode(player, newname, true, false); } + void SetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, true); } + void UnsetMute(Player const* player, std::string const& newname) { SetMode(player, newname, false, false); } + void List(Player const* player); + void Announce(Player const* player); + void Say(uint64 guid, std::string const& what, uint32 lang); + void Invite(Player const* player, std::string const& newp); + void Voice(uint64 guid1, uint64 guid2); + void DeVoice(uint64 guid1, uint64 guid2); + void JoinNotify(uint64 guid); // invisible notify + void LeaveNotify(uint64 guid); // invisible notify + void SetOwnership(bool ownership) { _ownership = ownership; }; + static void CleanOldChannelsInDB(); private: // initial packet data (notify type and channel name) @@ -198,91 +224,62 @@ class Channel void MakeVoiceOn(WorldPacket* data, uint64 guid); //+ 0x22 void MakeVoiceOff(WorldPacket* data, uint64 guid); //+ 0x23 - void SendToAll(WorldPacket* data, uint64 p = 0); + void SendToAll(WorldPacket* data, uint64 guid = 0); void SendToAllButOne(WorldPacket* data, uint64 who); void SendToOne(WorldPacket* data, uint64 who); - bool IsOn(uint64 who) const { return players.find(who) != players.end(); } - bool IsBanned(uint64 guid) const { return banned.find(guid) != banned.end(); } + bool IsOn(uint64 who) const { return playersStore.find(who) != playersStore.end(); } + bool IsBanned(uint64 guid) const { return bannedStore.find(guid) != bannedStore.end(); } void UpdateChannelInDB() const; void UpdateChannelUseageInDB() const; - uint8 GetPlayerFlags(uint64 p) const + uint8 GetPlayerFlags(uint64 guid) const { - PlayerList::const_iterator p_itr = players.find(p); - if (p_itr == players.end()) - return 0; - - return p_itr->second.flags; + PlayerContainer::const_iterator itr = playersStore.find(guid); + return itr != playersStore.end() ? itr->second.flags : 0; } - void SetModerator(uint64 p, bool set) + void SetModerator(uint64 guid, bool set) { - if (players[p].IsModerator() != set) + if (playersStore[guid].IsModerator() != set) { - uint8 oldFlag = GetPlayerFlags(p); - players[p].SetModerator(set); + uint8 oldFlag = GetPlayerFlags(guid); + playersStore[guid].SetModerator(set); WorldPacket data; - MakeModeChange(&data, p, oldFlag); + MakeModeChange(&data, guid, oldFlag); SendToAll(&data); } } - void SetMute(uint64 p, bool set) + void SetMute(uint64 guid, bool set) { - if (players[p].IsMuted() != set) + if (playersStore[guid].IsMuted() != set) { - uint8 oldFlag = GetPlayerFlags(p); - players[p].SetMuted(set); + uint8 oldFlag = GetPlayerFlags(guid); + playersStore[guid].SetMuted(set); WorldPacket data; - MakeModeChange(&data, p, oldFlag); + MakeModeChange(&data, guid, oldFlag); SendToAll(&data); } } - public: - uint32 m_Team; - Channel(std::string const& name, uint32 channel_id, uint32 Team = 0); - std::string const& GetName() const { return m_name; } - uint32 GetChannelId() const { return m_channelId; } - bool IsConstant() const { return m_channelId != 0; } - bool IsAnnounce() const { return m_announce; } - bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; } - std::string const& GetPassword() const { return m_password; } - void SetPassword(std::string const& npassword) { m_password = npassword; } - void SetAnnounce(bool nannounce) { m_announce = nannounce; } - uint32 GetNumPlayers() const { return players.size(); } - uint8 GetFlags() const { return m_flags; } - bool HasFlag(uint8 flag) const { return m_flags & flag; } + typedef std::map<uint64, PlayerInfo> PlayerContainer; + typedef std::set<uint64> BannedContainer; - void Join(uint64 p, const char *pass); - void Leave(uint64 p, bool send = true); - void KickOrBan(uint64 good, const char *badname, bool ban); - void Kick(uint64 good, const char *badname) { KickOrBan(good, badname, false); } - void Ban(uint64 good, const char *badname) { KickOrBan(good, badname, true); } - void UnBan(uint64 good, const char *badname); - void Password(uint64 p, const char *pass); - void SetMode(uint64 p, const char *p2n, bool mod, bool set); - void SetOwner(uint64 p, bool exclaim = true); - void SetOwner(uint64 p, const char *newname); - void SendWhoOwner(uint64 p); - void SetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, true); } - void UnsetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, false); } - void SetMute(uint64 p, const char *newname) { SetMode(p, newname, false, true); } - void UnsetMute(uint64 p, const char *newname) { SetMode(p, newname, false, false); } - void List(Player* p); - void Announce(uint64 p); - void Say(uint64 p, const char *what, uint32 lang); - void Invite(uint64 p, const char *newp); - void Voice(uint64 guid1, uint64 guid2); - void DeVoice(uint64 guid1, uint64 guid2); - void JoinNotify(uint64 guid); // invisible notify - void LeaveNotify(uint64 guid); // invisible notify - void SetOwnership(bool ownership) { m_ownership = ownership; }; - static void CleanOldChannelsInDB(); + bool _announce; + bool _ownership; + bool _IsSaved; + uint8 _flags; + uint32 _channelId; + uint32 _Team; + uint64 _ownerGUID; + std::string _name; + std::string _password; + PlayerContainer playersStore; + BannedContainer bannedStore; }; #endif diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 78b71744e0e..acd85f11ed8 100755 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -17,7 +17,7 @@ */ #include "ChannelMgr.h" - +#include "Player.h" #include "World.h" ChannelMgr::~ChannelMgr() @@ -35,13 +35,14 @@ ChannelMgr* ChannelMgr::forTeam(uint32 team) if (team == ALLIANCE) return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance(); + if (team == HORDE) return ACE_Singleton<HordeChannelMgr, ACE_Null_Mutex>::instance(); return NULL; } -Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id) +Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channelId) { std::wstring wname; Utf8toWStr(name, wname); @@ -51,7 +52,7 @@ Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id) if (i == channels.end()) { - Channel* nchan = new Channel(name, channel_id, team); + Channel* nchan = new Channel(name, channelId, team); channels[wname] = nchan; return nchan; } @@ -78,8 +79,8 @@ Channel* ChannelMgr::GetChannel(std::string const& name, Player* player, bool pk return NULL; } - else - return i->second; + + return i->second; } void ChannelMgr::LeftChannel(std::string const& name) @@ -95,7 +96,7 @@ void ChannelMgr::LeftChannel(std::string const& name) Channel* channel = i->second; - if (channel->GetNumPlayers() == 0 && !channel->IsConstant()) + if (!channel->GetNumPlayers() && !channel->IsConstant()) { channels.erase(wname); delete channel; @@ -104,6 +105,6 @@ void ChannelMgr::LeftChannel(std::string const& name) void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string const& name) { - data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size - (*data) << (uint8)0x05 << name; + data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + name.size()); + (*data) << uint8(5) << name; } diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 7faf05a577c..c1ea96b0db1 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -1169,6 +1169,11 @@ int ChatHandler::GetSessionDbLocaleIndex() const return m_session->GetSessionDbLocaleIndex(); } +std::string ChatHandler::GetNameLink(Player* chr) const +{ + return playerLink(chr->GetName()); +} + const char *CliHandler::GetTrinityString(int32 entry) const { return sObjectMgr->GetTrinityStringForDBCLocale(entry); diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 0c1b22182e1..3b08fd9aa76 100755 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -20,16 +20,18 @@ #define TRINITYCORE_CHAT_H #include "SharedDefines.h" -#include "Player.h" +#include "WorldSession.h" #include <vector> class ChatHandler; -class WorldSession; -class WorldObject; class Creature; +class Group; class Player; class Unit; +class WorldSession; +class WorldObject; + struct GameTele; class ChatCommand @@ -48,7 +50,6 @@ class ChatHandler public: WorldSession* GetSession() { return m_session; } explicit ChatHandler(WorldSession* session) : m_session(session), sentErrorMessage(false) {} - explicit ChatHandler(Player* player) : m_session(player->GetSession()), sentErrorMessage(false) {} virtual ~ChatHandler() {} static void FillMessageData(WorldPacket* data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit* speaker); @@ -115,7 +116,7 @@ class ChatHandler bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL); std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; } - std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); } + std::string GetNameLink(Player* chr) const; GameObject* GetNearbyGameObject(); GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry); diff --git a/src/server/game/Chat/ChatLink.cpp b/src/server/game/Chat/ChatLink.cpp index d26f937c43d..a9c72e1112e 100644 --- a/src/server/game/Chat/ChatLink.cpp +++ b/src/server/game/Chat/ChatLink.cpp @@ -19,6 +19,7 @@ #include "SpellMgr.h" #include "ObjectMgr.h" #include "SpellInfo.h" +#include "DBCStores.h" // Supported shift-links (client generated and server side) // |color|Hachievement:achievement_id:player_guid:0:0:0:0:0:0:0:0|h[name]|h|r @@ -74,7 +75,7 @@ inline bool CheckDelimiter(std::istringstream& iss, char delimiter, const char* char c = iss.peek(); if (c != delimiter) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid %s link structure ('%c' expected, '%c' found)", iss.str().c_str(), context, delimiter, c); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid %s link structure ('%c' expected, '%c' found)", iss.str().c_str(), context, delimiter, c); return false; } iss.ignore(1); @@ -108,20 +109,20 @@ bool ItemChatLink::Initialize(std::istringstream& iss) uint32 itemEntry = 0; if (!ReadUInt32(iss, itemEntry)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item entry", iss.str().c_str()); return false; } // Validate item _item = sObjectMgr->GetItemTemplate(itemEntry); if (!_item) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid itemEntry %u in |item command", iss.str().c_str(), itemEntry); return false; } // Validate item's color if (_color != ItemQualityColors[_item->Quality]) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item has color %u, but user claims %u", iss.str().c_str(), ItemQualityColors[_item->Quality], _color); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item has color %u, but user claims %u", iss.str().c_str(), ItemQualityColors[_item->Quality], _color); return false; } // Number of various item properties after item entry @@ -135,7 +136,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss) int32 id = 0; if (!ReadInt32(iss, id)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item property (%u)", iss.str().c_str(), index); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading item property (%u)", iss.str().c_str(), index); return false; } if (id && (index == randomPropertyPosition)) @@ -146,7 +147,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss) _property = sItemRandomPropertiesStore.LookupEntry(id); if (!_property) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item property id %u in |item command", iss.str().c_str(), id); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item property id %u in |item command", iss.str().c_str(), id); return false; } } @@ -155,7 +156,7 @@ bool ItemChatLink::Initialize(std::istringstream& iss) _suffix = sItemRandomSuffixStore.LookupEntry(-id); if (!_suffix) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item suffix id %u in |item command", iss.str().c_str(), -id); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid item suffix id %u in |item command", iss.str().c_str(), -id); return false; } } @@ -197,7 +198,7 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context) } } if (!res) - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId); return res; } @@ -209,14 +210,14 @@ bool QuestChatLink::Initialize(std::istringstream& iss) uint32 questId = 0; if (!ReadUInt32(iss, questId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest entry", iss.str().c_str()); return false; } // Validate quest _quest = sObjectMgr->GetQuestTemplate(questId); if (!_quest) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest template %u not found", iss.str().c_str(), questId); return false; } // Check delimiter @@ -225,13 +226,13 @@ bool QuestChatLink::Initialize(std::istringstream& iss) // Read quest level if (!ReadInt32(iss, _questLevel)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading quest level", iss.str().c_str()); return false; } // Validate quest level if (_questLevel >= STRONG_MAX_LEVEL) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(), _questLevel); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): quest level %d is too big", iss.str().c_str(), _questLevel); return false; } return true; @@ -251,7 +252,7 @@ bool QuestChatLink::ValidateName(char* buffer, const char* context) break; } if (!res) - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId()); return res; } @@ -265,14 +266,14 @@ bool SpellChatLink::Initialize(std::istringstream& iss) uint32 spellId = 0; if (!ReadUInt32(iss, spellId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading spell entry", iss.str().c_str()); return false; } // Validate spell _spell = sSpellMgr->GetSpellInfo(spellId); if (!_spell) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |spell command", iss.str().c_str(), spellId); return false; } return true; @@ -288,19 +289,19 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context) SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(_spell->Id); if (bounds.first == bounds.second) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context, _spell->Id); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for spell %u", context, _spell->Id); return false; } SkillLineAbilityEntry const* skillInfo = bounds.first->second; if (!skillInfo) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context, _spell->Id); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line ability not found for spell %u", context, _spell->Id); return false; } SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillInfo->skillId); if (!skillLine) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->skillId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): skill line not found for skill %u", context, skillInfo->skillId); return false; } @@ -326,7 +327,7 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context) } if (!res) - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id); return res; } @@ -340,14 +341,14 @@ bool AchievementChatLink::Initialize(std::istringstream& iss) uint32 achievementId = 0; if (!ReadUInt32(iss, achievementId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str()); return false; } // Validate achievement _achievement = sAchievementStore.LookupEntry(achievementId); if (!_achievement) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid achivement id %u in |achievement command", iss.str().c_str(), achievementId); return false; } // Check delimiter @@ -356,7 +357,7 @@ bool AchievementChatLink::Initialize(std::istringstream& iss) // Read HEX if (!ReadHex(iss, _guid, 0)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading char's guid", iss.str().c_str()); return false; } // Skip progress @@ -368,7 +369,7 @@ bool AchievementChatLink::Initialize(std::istringstream& iss) if (!ReadUInt32(iss, _data[index])) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement property (%u)", iss.str().c_str(), index); return false; } } @@ -388,7 +389,7 @@ bool AchievementChatLink::ValidateName(char* buffer, const char* context) } if (!res) - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID); return res; } @@ -402,14 +403,14 @@ bool TradeChatLink::Initialize(std::istringstream& iss) uint32 spellId = 0; if (!ReadUInt32(iss, spellId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement entry", iss.str().c_str()); return false; } // Validate spell _spell = sSpellMgr->GetSpellInfo(spellId); if (!_spell) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), spellId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), spellId); return false; } // Check delimiter @@ -418,7 +419,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss) // Minimum talent level if (!ReadInt32(iss, _minSkillLevel)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading minimum talent level", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading minimum talent level", iss.str().c_str()); return false; } // Check delimiter @@ -427,7 +428,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss) // Maximum talent level if (!ReadInt32(iss, _maxSkillLevel)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading maximum talent level", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading maximum talent level", iss.str().c_str()); return false; } // Check delimiter @@ -436,7 +437,7 @@ bool TradeChatLink::Initialize(std::istringstream& iss) // Something hexadecimal if (!ReadHex(iss, _guid, 0)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement's owner guid", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading achievement's owner guid", iss.str().c_str()); return false; } // Skip base64 encoded stuff @@ -453,21 +454,21 @@ bool TalentChatLink::Initialize(std::istringstream& iss) // Read talent entry if (!ReadUInt32(iss, _talentId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent entry", iss.str().c_str()); return false; } // Validate talent TalentEntry const* talentInfo = sTalentStore.LookupEntry(_talentId); if (!talentInfo) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid talent id %u in |talent command", iss.str().c_str(), _talentId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid talent id %u in |talent command", iss.str().c_str(), _talentId); return false; } // Validate talent's spell _spell = sSpellMgr->GetSpellInfo(talentInfo->RankID[0]); if (!_spell) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), talentInfo->RankID[0]); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |trade command", iss.str().c_str(), talentInfo->RankID[0]); return false; } // Delimiter @@ -476,7 +477,7 @@ bool TalentChatLink::Initialize(std::istringstream& iss) // Rank if (!ReadInt32(iss, _rankId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent rank", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading talent rank", iss.str().c_str()); return false; } return true; @@ -492,14 +493,14 @@ bool EnchantmentChatLink::Initialize(std::istringstream& iss) uint32 spellId = 0; if (!ReadUInt32(iss, spellId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading enchantment spell entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading enchantment spell entry", iss.str().c_str()); return false; } // Validate spell _spell = sSpellMgr->GetSpellInfo(spellId); if (!_spell) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |enchant command", iss.str().c_str(), spellId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |enchant command", iss.str().c_str(), spellId); return false; } return true; @@ -514,7 +515,7 @@ bool GlyphChatLink::Initialize(std::istringstream& iss) // Slot if (!ReadUInt32(iss, _slotId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading slot id", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading slot id", iss.str().c_str()); return false; } // Check delimiter @@ -524,21 +525,21 @@ bool GlyphChatLink::Initialize(std::istringstream& iss) uint32 glyphId = 0; if (!ReadUInt32(iss, glyphId)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading glyph entry", iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly while reading glyph entry", iss.str().c_str()); return false; } // Validate glyph _glyph = sGlyphPropertiesStore.LookupEntry(glyphId); if (!_glyph) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid glyph id %u in |glyph command", iss.str().c_str(), glyphId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid glyph id %u in |glyph command", iss.str().c_str(), glyphId); return false; } // Validate glyph's spell _spell = sSpellMgr->GetSpellInfo(_glyph->SpellId); if (!_spell) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |glyph command", iss.str().c_str(), _glyph->SpellId); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid spell id %u in |glyph command", iss.str().c_str(), _glyph->SpellId); return false; } return true; @@ -576,14 +577,14 @@ bool LinkExtractor::IsValidMessage() } else if (_iss.get() != PIPE_CHAR) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence aborted unexpectedly", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence aborted unexpectedly", _iss.str().c_str()); return false; } // pipe has always to be followed by at least one char if (_iss.peek() == '\0') { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): pipe followed by '\\0'", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): pipe followed by '\\0'", _iss.str().c_str()); return false; } @@ -606,14 +607,14 @@ bool LinkExtractor::IsValidMessage() } else { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid sequence, expected '%c' but got '%c'", _iss.str().c_str(), *validSequenceIterator, commandChar); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid sequence, expected '%c' but got '%c'", _iss.str().c_str(), *validSequenceIterator, commandChar); return false; } } else if (validSequence != validSequenceIterator) { // no escaped pipes in sequences - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got escaped pipe in sequence", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got escaped pipe in sequence", _iss.str().c_str()); return false; } @@ -622,7 +623,7 @@ bool LinkExtractor::IsValidMessage() case 'c': if (!ReadHex(_iss, color, 8)) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading color", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): invalid hexadecimal number while reading color", _iss.str().c_str()); return false; } break; @@ -631,7 +632,7 @@ bool LinkExtractor::IsValidMessage() _iss.getline(buffer, 256, DELIMITER); if (_iss.eof()) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str()); return false; } @@ -653,7 +654,7 @@ bool LinkExtractor::IsValidMessage() link = new GlyphChatLink(); else { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): user sent unsupported link type '%s'", _iss.str().c_str(), buffer); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): user sent unsupported link type '%s'", _iss.str().c_str(), buffer); return false; } _links.push_back(link); @@ -668,13 +669,13 @@ bool LinkExtractor::IsValidMessage() // links start with '[' if (_iss.get() != '[') { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): link caption doesn't start with '['", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): link caption doesn't start with '['", _iss.str().c_str()); return false; } _iss.getline(buffer, 256, ']'); if (_iss.eof()) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): sequence finished unexpectedly", _iss.str().c_str()); return false; } @@ -692,7 +693,7 @@ bool LinkExtractor::IsValidMessage() // no further payload break; default: - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid command |%c", _iss.str().c_str(), commandChar); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): got invalid command |%c", _iss.str().c_str(), commandChar); return false; } } @@ -700,7 +701,7 @@ bool LinkExtractor::IsValidMessage() // check if every opened sequence was also closed properly if (validSequence != validSequenceIterator) { - sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): EOF in active sequence", _iss.str().c_str()); + sLog->outTrace(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): EOF in active sequence", _iss.str().c_str()); return false; } diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 72f00406c69..2f3cb0fbaaf 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -16,15 +16,16 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Player.h" -#include "SpellAuras.h" -#include "SpellMgr.h" +#include "ConditionMgr.h" #include "GameEventMgr.h" -#include "ObjectMgr.h" #include "InstanceScript.h" -#include "ConditionMgr.h" -#include "ScriptMgr.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ReputationMgr.h" #include "ScriptedCreature.h" +#include "ScriptMgr.h" +#include "SpellAuras.h" +#include "SpellMgr.h" #include "Spell.h" // Checks if object meets the condition diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 57af0562dcd..7b0dc1f20bf 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -19,8 +19,11 @@ #ifndef TRINITY_CONDITIONMGR_H #define TRINITY_CONDITIONMGR_H -#include "LootMgr.h" +#include "Define.h" +#include "Errors.h" #include <ace/Singleton.h> +#include <list> +#include <map> class Player; class Unit; diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index a209d9b6cf6..cc23036c534 100755 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -21,6 +21,7 @@ #include "OutdoorPvP.h" #include "SpellMgr.h" #include "VMapManager2.h" +#include "Player.h" namespace DisableMgr { diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index 12ec7206141..4fa2e3e748e 100755 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -19,18 +19,21 @@ #ifndef DBCENUMS_H #define DBCENUMS_H -// Client expected level limitation, like as used in DBC item max levels for "until max player level" -// use as default max player level, must be fit max level for used client -// also see MAX_LEVEL and STRONG_MAX_LEVEL define -#define DEFAULT_MAX_LEVEL 80 - -// client supported max level for player/pets/etc. Avoid overflow or client stability affected. -// also see GT_MAX_LEVEL define -#define MAX_LEVEL 100 - -// Server side limitation. Base at used code requirements. -// also see MAX_LEVEL and GT_MAX_LEVEL define -#define STRONG_MAX_LEVEL 255 +enum LevelLimit +{ + // Client expected level limitation, like as used in DBC item max levels for "until max player level" + // use as default max player level, must be fit max level for used client + // also see MAX_LEVEL and STRONG_MAX_LEVEL define + DEFAULT_MAX_LEVEL = 80, + + // client supported max level for player/pets/etc. Avoid overflow or client stability affected. + // also see GT_MAX_LEVEL define + MAX_LEVEL = 100, + + // Server side limitation. Base at used code requirements. + // also see MAX_LEVEL and GT_MAX_LEVEL define + STRONG_MAX_LEVEL = 255, +}; enum BattlegroundBracketId // bracketId for level ranges { @@ -58,16 +61,16 @@ enum AchievementFaction enum AchievementFlags { - ACHIEVEMENT_FLAG_COUNTER = 0x00000001, // Just count statistic (never stop and complete) - ACHIEVEMENT_FLAG_HIDDEN = 0x00000002, // Not sent to client - internal use only - ACHIEVEMENT_FLAG_STORE_MAX_VALUE = 0x00000004, // Store only max value? used only in "Reach level xx" - ACHIEVEMENT_FLAG_SUMM = 0x00000008, // Use summ criteria value from all reqirements (and calculate max value) - ACHIEVEMENT_FLAG_MAX_USED = 0x00000010, // Show max criteria (and calculate max value ??) - ACHIEVEMENT_FLAG_REQ_COUNT = 0x00000020, // Use not zero req count (and calculate max value) - ACHIEVEMENT_FLAG_AVERAGE = 0x00000040, // Show as average value (value / time_in_days) depend from other flag (by def use last criteria value) - ACHIEVEMENT_FLAG_BAR = 0x00000080, // Show as progress bar (value / max vale) depend from other flag (by def use last criteria value) - ACHIEVEMENT_FLAG_REALM_FIRST_REACH = 0x00000100, // - ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200 // + ACHIEVEMENT_FLAG_COUNTER = 0x00000001, // Just count statistic (never stop and complete) + ACHIEVEMENT_FLAG_HIDDEN = 0x00000002, // Not sent to client - internal use only + ACHIEVEMENT_FLAG_STORE_MAX_VALUE = 0x00000004, // Store only max value? used only in "Reach level xx" + ACHIEVEMENT_FLAG_SUMM = 0x00000008, // Use summ criteria value from all requirements (and calculate max value) + ACHIEVEMENT_FLAG_MAX_USED = 0x00000010, // Show max criteria (and calculate max value ??) + ACHIEVEMENT_FLAG_REQ_COUNT = 0x00000020, // Use not zero req count (and calculate max value) + ACHIEVEMENT_FLAG_AVERAGE = 0x00000040, // Show as average value (value / time_in_days) depend from other flag (by def use last criteria value) + ACHIEVEMENT_FLAG_BAR = 0x00000080, // Show as progress bar (value / max vale) depend from other flag (by def use last criteria value) + ACHIEVEMENT_FLAG_REALM_FIRST_REACH = 0x00000100, // + ACHIEVEMENT_FLAG_REALM_FIRST_KILL = 0x00000200 // }; #define MAX_CRITERIA_REQUIREMENTS 2 @@ -108,124 +111,117 @@ enum AchievementCriteriaTimedTypes enum AchievementCriteriaTypes { - ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE = 0, - ACHIEVEMENT_CRITERIA_TYPE_WIN_BG = 1, - ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL = 5, - ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL = 7, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT = 8, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT = 9, - // you have to complete a daily quest x times in a row - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11, - ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE = 13, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND= 15, - ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP= 16, - ACHIEVEMENT_CRITERIA_TYPE_DEATH= 17, - ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19, - ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE = 20, - ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER = 23, - ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING = 24, - ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM = 26, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST = 27, - ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET = 28, - ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL= 29, - ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE = 30, - ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31, - ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA = 32, - ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA = 33, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL = 34, - ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL = 35, - ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM = 36, - // TODO: the archievements 1162 and 1163 requires a special rating which can't be found in the dbc - ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA = 37, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING = 38, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING = 39, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL = 40, - ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM = 41, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM= 42, - ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA = 43, - ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK= 44, - ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT= 45, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION= 46, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION= 47, - // noted: rewarded as soon as the player payed, not at taking place at the seat - ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP= 48, - ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49, - // TODO: itemlevel is mentioned in text but not present in dbc - ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50, - ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT= 51, - ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS = 52, - ACHIEVEMENT_CRITERIA_TYPE_HK_RACE = 53, - ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE = 54, - ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE = 55, - // TODO: in some cases map not present, and in some cases need do without die - ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS = 56, - ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM = 57, - ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS = 59, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS = 60, - ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS = 61, - ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD = 62, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING = 63, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER = 65, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL = 66, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY = 67, - ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT = 68, - ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2= 69, - ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL= 70, - ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT = 72, - // TODO: title id is not mentioned in dbc - ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE = 74, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS= 75, - ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76, - ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL = 77, - // TODO: creature type (demon, undead etc.) is not stored in dbc - ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE = 78, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS= 80, - ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION= 82, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID= 83, - ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS= 84, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD = 85, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED = 86, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION = 87, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION = 88, - ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS = 89, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM = 90, - ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM = 91, - ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED = 93, - ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED = 94, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH = 95, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER = 96, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT = 97, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER = 98, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR = 99, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING = 100, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT = 101, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED = 102, - ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED = 103, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED = 104, - ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED = 105, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED = 106, - ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED = 107, - ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN = 108, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE = 109, - // TODO: target entry is missing - ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE= 112, - ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113, - ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS = 114, - // 0..115 => 116 criteria types total - ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115, + ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE = 0, + ACHIEVEMENT_CRITERIA_TYPE_WIN_BG = 1, + ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL = 5, + ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL = 7, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT = 8, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT = 9, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY = 10, // you have to complete a daily quest x times in a row + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11, + ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE = 13, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND = 15, + ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP = 16, + ACHIEVEMENT_CRITERIA_TYPE_DEATH = 17, + ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19, + ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE = 20, + ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER = 23, + ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING = 24, + ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM = 26, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST = 27, + ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET = 28, + ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL = 29, + ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE = 30, + ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31, + ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA = 32, + ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA = 33, + ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL = 34, + ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL = 35, + ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM = 36, + ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA = 37, // TODO: the archievements 1162 and 1163 requires a special rating which can't be found in the dbc + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING = 38, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING = 39, + ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL = 40, + ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM = 41, + ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM = 42, + ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA = 43, + ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK = 44, + ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT = 45, + ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION = 46, + ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION = 47, + ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP = 48, + ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49, + ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50, // TODO: itemlevel is mentioned in text but not present in dbc + ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT = 51, + ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS = 52, + ACHIEVEMENT_CRITERIA_TYPE_HK_RACE = 53, + ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE = 54, + ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE = 55, + ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS = 56, // TODO: in some cases map not present, and in some cases need do without die + ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM = 57, + ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS = 59, + ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS = 60, + ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS = 61, + ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD = 62, + ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TRAVELLING = 63, + ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER = 65, + ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL = 66, + ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY = 67, + ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT = 68, + ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2 = 69, + ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL = 70, + ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT = 72, + // TODO 73: Achievements 1515, 1241, 1103 (Name: Mal'Ganis) + ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE = 74, // TODO: title id is not mentioned in dbc + ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS = 75, + ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76, + ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL = 77, + ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE = 78, + ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS = 80, + ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION = 82, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID = 83, + ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS = 84, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD = 85, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED = 86, + ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION = 87, + ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION = 88, + ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS = 89, + ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM = 90, + ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM = 91, + ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED = 93, + ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED = 94, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH = 95, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_POWER = 96, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT = 97, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER = 98, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR = 99, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING = 100, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT = 101, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED = 102, + ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED = 103, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED = 104, + ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED = 105, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED = 106, + ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED = 107, + ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN = 108, + ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE = 109, + ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110, // TODO: target entry is missing + ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE = 112, + ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113, + ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS = 114, + ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115, ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS = 119, // 120 // 121 // 122 // 123 // 0..123 => 124 criteria types total - ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 124 }; +#define ACHIEVEMENT_CRITERIA_TYPE_TOTAL 124 + enum AchievementCategory { CATEGORY_CHILDRENS_WEEK = 163 @@ -286,7 +282,7 @@ enum Difficulty enum SpawnMask { - SPAWNMASK_CONTINENT = (1 << REGULAR_DIFFICULTY), // any any maps without spawn modes + SPAWNMASK_CONTINENT = (1 << REGULAR_DIFFICULTY), // any maps without spawn modes SPAWNMASK_DUNGEON_NORMAL = (1 << DUNGEON_DIFFICULTY_NORMAL), SPAWNMASK_DUNGEON_HEROIC = (1 << DUNGEON_DIFFICULTY_HEROIC), @@ -349,19 +345,19 @@ enum ItemEnchantmentType enum ItemLimitCategoryMode { - ITEM_LIMIT_CATEGORY_MODE_HAVE = 0, // limit applied to amount items in inventory/bank - ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1 // limit applied to amount equipped items (including used gems) + ITEM_LIMIT_CATEGORY_MODE_HAVE = 0, // limit applied to amount items in inventory/bank + ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1 // limit applied to amount equipped items (including used gems) }; enum TotemCategoryType { - TOTEM_CATEGORY_TYPE_KNIFE = 1, - TOTEM_CATEGORY_TYPE_TOTEM = 2, - TOTEM_CATEGORY_TYPE_ROD = 3, - TOTEM_CATEGORY_TYPE_PICK = 21, - TOTEM_CATEGORY_TYPE_STONE = 22, - TOTEM_CATEGORY_TYPE_HAMMER = 23, - TOTEM_CATEGORY_TYPE_SPANNER = 24 + TOTEM_CATEGORY_TYPE_KNIFE = 1, + TOTEM_CATEGORY_TYPE_TOTEM = 2, + TOTEM_CATEGORY_TYPE_ROD = 3, + TOTEM_CATEGORY_TYPE_PICK = 21, + TOTEM_CATEGORY_TYPE_STONE = 22, + TOTEM_CATEGORY_TYPE_HAMMER = 23, + TOTEM_CATEGORY_TYPE_SPANNER = 24 }; // SummonProperties.dbc, col 1 diff --git a/src/server/game/DungeonFinding/LFG.h b/src/server/game/DungeonFinding/LFG.h index 6ad30547670..8477002279c 100755 --- a/src/server/game/DungeonFinding/LFG.h +++ b/src/server/game/DungeonFinding/LFG.h @@ -41,7 +41,7 @@ enum LfgUpdateType LFG_UPDATETYPE_DEFAULT = 0, // Internal Use LFG_UPDATETYPE_LEADER_UNK1 = 1, // FIXME: At group leave LFG_UPDATETYPE_ROLECHECK_ABORTED = 4, - LFG_UPDATETYPE_JOIN_PROPOSAL = 5, + LFG_UPDATETYPE_JOIN_QUEUE = 5, LFG_UPDATETYPE_ROLECHECK_FAILED = 6, LFG_UPDATETYPE_REMOVED_FROM_QUEUE = 7, LFG_UPDATETYPE_PROPOSAL_FAILED = 8, diff --git a/src/server/game/DungeonFinding/LFGGroupData.cpp b/src/server/game/DungeonFinding/LFGGroupData.cpp index a4ee230b5eb..c7cf6f23ce9 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.cpp +++ b/src/server/game/DungeonFinding/LFGGroupData.cpp @@ -37,7 +37,7 @@ void LfgGroupData::SetState(LfgState state) case LFG_STATE_FINISHED_DUNGEON: case LFG_STATE_NONE: case LFG_STATE_DUNGEON: - m_OldState = state; + m_OldState = m_State; // No break on purpose default: m_State = state; diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index c91be00080e..da279016255 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -21,6 +21,7 @@ #include "DisableMgr.h" #include "ObjectMgr.h" #include "SocialMgr.h" +#include "Language.h" #include "LFGMgr.h" #include "LFGScripts.h" #include "LFGGroupData.h" @@ -30,6 +31,7 @@ #include "Player.h" #include "GroupMgr.h" #include "GameEventMgr.h" +#include "WorldSession.h" LFGMgr::LFGMgr(): m_QueueTimer(0), m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)) @@ -551,14 +553,17 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const LfgDungeonSet const& playerDungeons = GetSelectedDungeons(guid); if (playerDungeons == dungeons) // Joining the same dungeons -- Send OK { - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment); player->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK if (grp) { + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment); for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) if (itr->getSource() && itr->getSource()->GetSession()) itr->getSource()->GetSession()->SendLfgUpdateParty(updateData); } + else + player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment)); + return; } else // Remove from queue and rejoin @@ -689,7 +694,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const SetState(gguid, LFG_STATE_ROLECHECK); // Send update to player - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment); + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment); for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { if (Player* plrg = itr->getSource()) @@ -726,7 +731,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const } // Send update to player player->GetSession()->SendLfgJoinResult(joinData); - player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment)); + player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment)); SetState(gguid, LFG_STATE_QUEUED); SetRoles(guid, roles); debugNames.append(player->GetName()); @@ -749,10 +754,10 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const */ void LFGMgr::LeaveLfg(uint64 guid) { - LfgState state = GetState(guid); - uint64 gguid = IS_GROUP(guid) ? guid : GetGroup(guid); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Leave: [" UI64FMTD "]", guid); + + uint64 gguid = IS_GROUP(guid) ? guid : GetGroup(guid); + LfgState state = GetState(guid); switch (state) { case LFG_STATE_QUEUED: @@ -1962,11 +1967,10 @@ void LFGMgr::SetOptions(uint32 options) m_options = options; } -LfgState LFGMgr::GetLfgStatus(uint64 guid, LfgUpdateData& data) +LfgUpdateData LFGMgr::GetLfgStatus(uint64 guid) { LfgPlayerData& playerData = PlayersStore[guid]; - data.dungeons = playerData.GetSelectedDungeons(); - return playerData.GetState(); + return LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS, playerData.GetState(), playerData.GetSelectedDungeons()); } bool LFGMgr::IsSeasonActive(uint32 dungeonId) diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index ba1cc251278..9c023d1daf8 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -18,8 +18,9 @@ #ifndef _LFGMGR_H #define _LFGMGR_H -#include "Common.h" #include <ace/Singleton.h> +#include "DBCStructure.h" +#include "Field.h" #include "LFG.h" #include "LFGQueue.h" #include "LFGGroupData.h" @@ -155,11 +156,14 @@ struct LfgJoinResultData // Data needed by SMSG_LFG_UPDATE_PARTY and SMSG_LFG_UPDATE_PLAYER struct LfgUpdateData { - LfgUpdateData(LfgUpdateType _type = LFG_UPDATETYPE_DEFAULT): updateType(_type), comment("") {} + LfgUpdateData(LfgUpdateType _type = LFG_UPDATETYPE_DEFAULT): updateType(_type), state(LFG_STATE_NONE), comment("") { } LfgUpdateData(LfgUpdateType _type, LfgDungeonSet const& _dungeons, std::string const& _comment): - updateType(_type), dungeons(_dungeons), comment(_comment) {} + updateType(_type), state(LFG_STATE_NONE), dungeons(_dungeons), comment(_comment) { } + LfgUpdateData(LfgUpdateType _type, LfgState _state, LfgDungeonSet const& _dungeons, std::string const& _comment = ""): + updateType(_type), state(_state), dungeons(_dungeons), comment(_comment) { } LfgUpdateType updateType; + LfgState state; LfgDungeonSet dungeons; std::string comment; }; @@ -361,7 +365,7 @@ class LFGMgr bool isOptionEnabled(uint32 option); uint32 GetOptions(); void SetOptions(uint32 options); - LfgState GetLfgStatus(uint64 guid, LfgUpdateData& data); + LfgUpdateData GetLfgStatus(uint64 guid); bool IsSeasonActive(uint32 dungeonId); std::string DumpQueueInfo(bool full = false); diff --git a/src/server/game/DungeonFinding/LFGPlayerData.cpp b/src/server/game/DungeonFinding/LFGPlayerData.cpp index e5645f0f0aa..f1281875598 100644 --- a/src/server/game/DungeonFinding/LFGPlayerData.cpp +++ b/src/server/game/DungeonFinding/LFGPlayerData.cpp @@ -35,7 +35,7 @@ void LfgPlayerData::SetState(LfgState state) m_SelectedDungeons.clear(); // No break on purpose case LFG_STATE_DUNGEON: - m_OldState = state; + m_OldState = m_State; // No break on purpose default: m_State = state; diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index cf600b0645f..3bcd1ee5643 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -639,7 +639,7 @@ void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueu std::string sguid = o.str(); for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr) - if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS && + if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS && std::string::npos != itr->first.find(sguid)) { UpdateBestCompatibleInQueue(itrQueue, itr->first, itr->second.roles); @@ -650,7 +650,7 @@ void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQu { LfgQueueData& queueData = itrQueue->second; - uint8 storedSize = queueData.bestCompatible.empty() ? 0 : + uint8 storedSize = queueData.bestCompatible.empty() ? 0 : std::count(queueData.bestCompatible.begin(), queueData.bestCompatible.end(), '|') + 1; uint8 size = std::count(key.begin(), key.end(), '|') + 1; diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index f937ac0d21a..e6ba038a9e6 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -42,7 +42,7 @@ struct LfgCompatibilityData compatibility(_compatibility), roles(_roles) { } LfgCompatibility compatibility; - LfgRolesMap roles; + LfgRolesMap roles; }; /// Stores player or group queue info diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 91314e64285..f9e3c02fe98 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -27,6 +27,7 @@ #include "LFGMgr.h" #include "ScriptMgr.h" #include "ObjectAccessor.h" +#include "WorldSession.h" LFGPlayerScript::LFGPlayerScript() : PlayerScript("LFGPlayerScript") { @@ -45,14 +46,11 @@ void LFGPlayerScript::OnLogout(Player* player) if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - uint64 guid = player->GetGUID(); - sLFGMgr->LeaveLfg(guid); - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE); - player->GetSession()->SendLfgUpdateParty(updateData); - player->GetSession()->SendLfgUpdatePlayer(updateData); - player->GetSession()->SendLfgLfrList(false); - // TODO - Do not remove, add timer before deleting - sLFGMgr->RemovePlayerData(guid); + if (!player->GetGroup()) + { + player->GetSession()->SendLfgLfrList(false); + sLFGMgr->LeaveLfg(player->GetGUID()); + } } void LFGPlayerScript::OnLogin(Player* player) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 9bcd4d9c1e2..911ccd25728 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -16,40 +16,42 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "BattlegroundMgr.h" +#include "CellImpl.h" #include "Common.h" -#include "DatabaseEnv.h" -#include "WorldPacket.h" -#include "World.h" -#include "ObjectMgr.h" -#include "GroupMgr.h" -#include "SpellMgr.h" -#include "Creature.h" -#include "QuestDef.h" -#include "GossipDef.h" -#include "Player.h" -#include "PoolMgr.h" -#include "Opcodes.h" -#include "Log.h" -#include "LootMgr.h" -#include "MapManager.h" #include "CreatureAI.h" #include "CreatureAISelector.h" +#include "CreatureGroups.h" +#include "Creature.h" +#include "DatabaseEnv.h" #include "Formulas.h" -#include "WaypointMovementGenerator.h" -#include "InstanceScript.h" -#include "BattlegroundMgr.h" -#include "Util.h" +#include "GameEventMgr.h" +#include "GossipDef.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "OutdoorPvPMgr.h" -#include "GameEventMgr.h" -#include "CreatureGroups.h" -#include "Vehicle.h" -#include "SpellAuraEffects.h" #include "Group.h" -#include "MoveSplineInit.h" +#include "GroupMgr.h" +#include "InstanceScript.h" +#include "Log.h" +#include "LootMgr.h" +#include "MapManager.h" #include "MoveSpline.h" +#include "MoveSplineInit.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "OutdoorPvPMgr.h" +#include "Player.h" +#include "PoolMgr.h" +#include "QuestDef.h" +#include "SpellAuraEffects.h" +#include "SpellMgr.h" +#include "TemporarySummon.h" +#include "Util.h" +#include "Vehicle.h" +#include "WaypointMovementGenerator.h" +#include "World.h" +#include "WorldPacket.h" + // apply implementation of the singletons TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const @@ -953,30 +955,6 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* player) const && player->getClass() == GetCreatureTemplate()->trainer_class; } -void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 /*MovementFlags*/, uint8 /*type*/) -{ - /* uint32 timeElap = getMSTime(); - if ((timeElap - m_startMove) < m_moveTime) - { - oX = (dX - oX) * ((timeElap - m_startMove) / m_moveTime); - oY = (dY - oY) * ((timeElap - m_startMove) / m_moveTime); - } - else - { - oX = dX; - oY = dY; - } - - dX = x; - dY = y; - m_orientation = atan2((oY - dY), (oX - dX)); - - m_startMove = getMSTime(); - m_moveTime = time;*/ - float speed = GetDistance(x, y, z) / ((float)time * 0.001f); - MonsterMoveWithSpeed(x, y, z, speed); -} - Player* Creature::GetLootRecipient() const { if (!m_lootRecipient) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index c0703196075..228485d001e 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -520,7 +520,6 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature bool AIM_Initialize(CreatureAI* ai = NULL); void Motion_Initialize(); - void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); CreatureAI* AI() const { return (CreatureAI*)i_AI; } bool SetWalk(bool enable); diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 43b29c600d6..a6b51a4d395 100755 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -21,6 +21,8 @@ #include "CreatureAI.h" #include "ObjectMgr.h" #include "TemporarySummon.h" +#include "Pet.h" +#include "Player.h" TempSummon::TempSummon(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject) : Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN), diff --git a/src/server/game/Entities/Item/Container/Bag.cpp b/src/server/game/Entities/Item/Container/Bag.cpp index db563c712cd..73b38c1da83 100755 --- a/src/server/game/Entities/Item/Container/Bag.cpp +++ b/src/server/game/Entities/Item/Container/Bag.cpp @@ -23,6 +23,7 @@ #include "Bag.h" #include "Log.h" #include "UpdateData.h" +#include "Player.h" Bag::Bag(): Item() { diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index f1a7d646fe4..a1ff6cf2ce8 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -26,6 +26,8 @@ #include "SpellInfo.h" #include "ScriptMgr.h" #include "ConditionMgr.h" +#include "Player.h" +#include "Opcodes.h" void AddItemsSetItem(Player* player, Item* item) { diff --git a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp index f85bf80e145..cfb8c880479 100755 --- a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp +++ b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp @@ -25,6 +25,7 @@ #include <list> #include <vector> #include "Util.h" +#include "DBCStores.h" struct EnchStoreItem { diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index d7e87cedbf8..ca32fd377e9 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1844,7 +1844,7 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const if (obj->IsAlwaysDetectableFor(seer)) return true; - if (!seer->CanDetectInvisibilityOf(obj)) + if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj)) return false; if (!ignoreStealth && !seer->CanDetectStealthOf(obj)) @@ -2360,119 +2360,6 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempS return NULL; } -Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration) -{ - Pet* pet = new Pet(this, petType); - - if (petType == SUMMON_PET && pet->LoadPetFromDB(this, entry)) - { - // Remove Demonic Sacrifice auras (known pet) - Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) - { - if ((*itr)->GetMiscValue() == 2228) - { - RemoveAurasDueToSpell((*itr)->GetId()); - itr = auraClassScripts.begin(); - } - else - ++itr; - } - - if (duration > 0) - pet->SetDuration(duration); - - return NULL; - } - - // petentry == 0 for hunter "call pet" (current pet summoned if any) - if (!entry) - { - delete pet; - return NULL; - } - - pet->Relocate(x, y, z, ang); - if (!pet->IsPositionValid()) - { - sLog->outError(LOG_FILTER_GENERAL, "Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); - delete pet; - return NULL; - } - - Map* map = GetMap(); - uint32 pet_number = sObjectMgr->GeneratePetNumber(); - if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number)) - { - sLog->outError(LOG_FILTER_GENERAL, "no such creature entry %u", entry); - delete pet; - return NULL; - } - - pet->SetCreatorGUID(GetGUID()); - pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); - - pet->setPowerType(POWER_MANA); - pet->SetUInt32Value(UNIT_NPC_FLAGS, 0); - pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pet->InitStatsForLevel(getLevel()); - - SetMinion(pet, true); - - switch (petType) - { - case SUMMON_PET: - // this enables pet details window (Shift+P) - pet->GetCharmInfo()->SetPetNumber(pet_number, true); - pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); - pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); - pet->SetFullHealth(); - pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); - pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case - break; - default: - break; - } - - map->AddToMap(pet->ToCreature()); - - switch (petType) - { - case SUMMON_PET: - pet->InitPetCreateSpells(); - pet->InitTalentForLevel(); - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - PetSpellInitialize(); - break; - default: - break; - } - - if (petType == SUMMON_PET) - { - // Remove Demonic Sacrifice auras (known pet) - Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) - { - if ((*itr)->GetMiscValue() == 2228) - { - RemoveAurasDueToSpell((*itr)->GetId()); - itr = auraClassScripts.begin(); - } - else - ++itr; - } - } - - if (duration > 0) - pet->SetDuration(duration); - - //ObjectAccessor::UpdateObjectVisibility(pet); - - return pet; -} - GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime) { if (!IsInWorld()) diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index d2d9bdac4b3..b6417681f4a 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -30,6 +30,7 @@ #include "Unit.h" #include "Util.h" #include "Group.h" +#include "Opcodes.h" #define PET_XP_FACTOR 0.05f @@ -1077,7 +1078,7 @@ bool Pet::HaveInDiet(ItemTemplate const* item) const return diet & FoodMask; } -uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) +uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) const { // -5 or greater food level if (getLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect @@ -1881,7 +1882,7 @@ void Pet::ToggleAutocast(SpellInfo const* spellInfo, bool apply) } } -bool Pet::IsPermanentPetFor(Player* owner) +bool Pet::IsPermanentPetFor(Player* owner) const { switch (getPetType()) { diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index f55d03ce081..a1dd57a26cc 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -19,50 +19,11 @@ #ifndef TRINITYCORE_PET_H #define TRINITYCORE_PET_H -#include "ObjectDefines.h" -#include "Unit.h" +#include "PetDefines.h" #include "TemporarySummon.h" -enum PetType -{ - SUMMON_PET = 0, - HUNTER_PET = 1, - MAX_PET_TYPE = 4 -}; - -#define MAX_PET_STABLES 4 - -// stored in character_pet.slot -enum PetSaveMode -{ - PET_SAVE_AS_DELETED = -1, // not saved in fact - PET_SAVE_AS_CURRENT = 0, // in current slot (with player) - PET_SAVE_FIRST_STABLE_SLOT = 1, - PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT - PET_SAVE_NOT_IN_SLOT = 100 // for avoid conflict with stable size grow will use 100 -}; - -enum HappinessState -{ - UNHAPPY = 1, - CONTENT = 2, - HAPPY = 3 -}; - -enum PetSpellState -{ - PETSPELL_UNCHANGED = 0, - PETSPELL_CHANGED = 1, - PETSPELL_NEW = 2, - PETSPELL_REMOVED = 3 -}; - -enum PetSpellType -{ - PETSPELL_NORMAL = 0, - PETSPELL_FAMILY = 1, - PETSPELL_TALENT = 2 -}; +#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS +#define HAPPINESS_LEVEL_SIZE 333000 struct PetSpell { @@ -71,51 +32,9 @@ struct PetSpell PetSpellType type; }; -enum ActionFeedback -{ - FEEDBACK_NONE = 0, - FEEDBACK_PET_DEAD = 1, - FEEDBACK_NOTHING_TO_ATT = 2, - FEEDBACK_CANT_ATT_TARGET = 3 -}; - -enum PetTalk -{ - PET_TALK_SPECIAL_SPELL = 0, - PET_TALK_ATTACK = 1 -}; - -enum PetNameInvalidReason -{ - // custom, not send - PET_NAME_SUCCESS = 0, - - PET_NAME_INVALID = 1, - PET_NAME_NO_NAME = 2, - PET_NAME_TOO_SHORT = 3, - PET_NAME_TOO_LONG = 4, - PET_NAME_MIXED_LANGUAGES = 6, - PET_NAME_PROFANE = 7, - PET_NAME_RESERVED = 8, - PET_NAME_THREE_CONSECUTIVE = 11, - PET_NAME_INVALID_SPACE = 12, - PET_NAME_CONSECUTIVE_SPACES = 13, - PET_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS = 14, - PET_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 15, - PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 16 -}; - typedef UNORDERED_MAP<uint32, PetSpell> PetSpellMap; typedef std::vector<uint32> AutoSpellList; -#define HAPPINESS_LEVEL_SIZE 333000 - -#define ACTIVE_SPELLS_MAX 4 - -#define PET_FOLLOW_DIST 1.0f -#define PET_FOLLOW_ANGLE (M_PI/2) -#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS - class Player; class Pet : public Guardian @@ -132,9 +51,9 @@ class Pet : public Guardian bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; } bool isTemporarySummoned() const { return m_duration > 0; } - bool IsPermanentPetFor(Player* owner); // pet have tab in character windows and set UNIT_FIELD_PETNUMBER + bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER - bool Create (uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); + bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); bool CreateBaseAtCreature(Creature* creature); bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner); bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask); @@ -162,9 +81,9 @@ class Pet : public Guardian void GivePetLevel(uint8 level); void SynchronizeLevelWithOwner(); bool HaveInDiet(ItemTemplate const* item) const; - uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel); + uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const; void SetDuration(int32 dur) { m_duration = dur; } - int32 GetDuration() { return m_duration; } + int32 GetDuration() const { return m_duration; } /* bool UpdateStats(Stats stat); diff --git a/src/server/game/Entities/Pet/PetDefines.h b/src/server/game/Entities/Pet/PetDefines.h new file mode 100644 index 00000000000..76de2647c8c --- /dev/null +++ b/src/server/game/Entities/Pet/PetDefines.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TRINITYCORE_PET_DEFINES_H +#define TRINITYCORE_PET_DEFINES_H + +enum PetType +{ + SUMMON_PET = 0, + HUNTER_PET = 1, + MAX_PET_TYPE = 4 +}; + +#define MAX_PET_STABLES 4 + +// stored in character_pet.slot +enum PetSaveMode +{ + PET_SAVE_AS_DELETED = -1, // not saved in fact + PET_SAVE_AS_CURRENT = 0, // in current slot (with player) + PET_SAVE_FIRST_STABLE_SLOT = 1, + PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT + PET_SAVE_NOT_IN_SLOT = 100 // for avoid conflict with stable size grow will use 100 +}; + +enum HappinessState +{ + UNHAPPY = 1, + CONTENT = 2, + HAPPY = 3 +}; + +enum PetSpellState +{ + PETSPELL_UNCHANGED = 0, + PETSPELL_CHANGED = 1, + PETSPELL_NEW = 2, + PETSPELL_REMOVED = 3 +}; + +enum PetSpellType +{ + PETSPELL_NORMAL = 0, + PETSPELL_FAMILY = 1, + PETSPELL_TALENT = 2 +}; + +enum ActionFeedback +{ + FEEDBACK_NONE = 0, + FEEDBACK_PET_DEAD = 1, + FEEDBACK_NOTHING_TO_ATT = 2, + FEEDBACK_CANT_ATT_TARGET = 3 +}; + +enum PetTalk +{ + PET_TALK_SPECIAL_SPELL = 0, + PET_TALK_ATTACK = 1 +}; + +#define PET_FOLLOW_DIST 1.0f +#define PET_FOLLOW_ANGLE (M_PI/2) + +#endif diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 46110a2cc11..dd9907d8c07 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -16,67 +16,68 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" -#include "Language.h" -#include "DatabaseEnv.h" -#include "Log.h" -#include "Opcodes.h" -#include "SpellMgr.h" -#include "World.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "UpdateMask.h" #include "Player.h" -#include "Vehicle.h" -#include "SkillDiscovery.h" -#include "QuestDef.h" -#include "GossipDef.h" -#include "UpdateData.h" +#include "AccountMgr.h" +#include "AchievementMgr.h" +#include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "Battlefield.h" +#include "BattlefieldMgr.h" +#include "BattlefieldWG.h" +#include "BattlegroundAV.h" +#include "Battleground.h" +#include "BattlegroundMgr.h" +#include "CellImpl.h" #include "Channel.h" #include "ChannelMgr.h" -#include "MapManager.h" -#include "MapInstanced.h" -#include "InstanceSaveMgr.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "GroupMgr.h" -#include "ObjectAccessor.h" +#include "CharacterDatabaseCleaner.h" +#include "Chat.h" +#include <cmath> +#include "Common.h" +#include "ConditionMgr.h" #include "CreatureAI.h" +#include "DatabaseEnv.h" +#include "DisableMgr.h" #include "Formulas.h" +#include "GameEventMgr.h" +#include "GossipDef.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" #include "Group.h" +#include "GroupMgr.h" #include "Guild.h" -#include "Pet.h" -#include "Util.h" -#include "Transport.h" -#include "Weather.h" -#include "Battleground.h" -#include "BattlegroundAV.h" -#include "BattlegroundMgr.h" +#include "GuildMgr.h" +#include "InstanceSaveMgr.h" +#include "InstanceScript.h" +#include "Language.h" +#include "LFGMgr.h" +#include "Log.h" +#include "MapInstanced.h" +#include "MapManager.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" +#include "Opcodes.h" #include "OutdoorPvP.h" #include "OutdoorPvPMgr.h" -#include "ArenaTeam.h" -#include "Chat.h" -#include "Spell.h" +#include "ReputationMgr.h" +#include "Pet.h" +#include "QuestDef.h" +#include "SkillDiscovery.h" #include "SocialMgr.h" -#include "GameEventMgr.h" -#include "AchievementMgr.h" -#include "SpellAuras.h" #include "SpellAuraEffects.h" -#include "ConditionMgr.h" -#include "DisableMgr.h" +#include "SpellAuras.h" +#include "Spell.h" +#include "SpellMgr.h" +#include "Transport.h" +#include "UpdateData.h" +#include "UpdateMask.h" +#include "Util.h" +#include "Vehicle.h" +#include "Weather.h" #include "WeatherMgr.h" -#include "LFGMgr.h" -#include "CharacterDatabaseCleaner.h" -#include "InstanceScript.h" -#include <cmath> -#include "AccountMgr.h" -#include "Battlefield.h" -#include "BattlefieldMgr.h" -#include "BattlefieldWG.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" #define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS) @@ -643,7 +644,7 @@ void KillRewarder::Reward() #ifdef _MSC_VER #pragma warning(disable:4355) #endif -Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_reputationMgr(this) +Player::Player(WorldSession* session): Unit(true) { #ifdef _MSC_VER #pragma warning(default:4355) @@ -869,6 +870,8 @@ Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_rep SetPendingBind(0, 0); _activeCheats = CHEAT_NONE; + m_achievementMgr = new AchievementMgr(this); + m_reputationMgr = new ReputationMgr(this); } Player::~Player() @@ -904,6 +907,8 @@ Player::~Player() delete m_declinedname; delete m_runes; + delete m_achievementMgr; + delete m_reputationMgr; sWorld->DecreasePlayerCount(); } @@ -1609,7 +1614,7 @@ void Player::Update(uint32 p_time) } } - m_achievementMgr.UpdateTimedAchievements(p_time); + m_achievementMgr->UpdateTimedAchievements(p_time); if (HasUnitState(UNIT_STATE_MELEE_ATTACKING) && !HasUnitState(UNIT_STATE_CASTING)) { @@ -5580,11 +5585,11 @@ void Player::CleanupChannels() { Channel* ch = *m_channels.begin(); m_channels.erase(m_channels.begin()); // remove from player's channel list - ch->Leave(GetGUID(), false); // not send to client, not remove from player's channel list + ch->LeaveChannel(this, false); // not send to client, not remove from player's channel list if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam())) cMgr->LeftChannel(ch->GetName()); // deleted channel if empty } - sLog->outDebug(LOG_FILTER_CHATSYS, "Player: channels cleaned up!"); + sLog->outDebug(LOG_FILTER_CHATSYS, "Player %s: channels cleaned up!", GetName().c_str()); } void Player::UpdateLocalChannels(uint32 newZone) @@ -5657,11 +5662,11 @@ void Player::UpdateLocalChannels(uint32 newZone) removeChannel = usedChannel; if (joinChannel) - joinChannel->Join(GetGUID(), ""); // Changed Channel: ... or Joined Channel: ... + joinChannel->JoinChannel(this, ""); // Changed Channel: ... or Joined Channel: ... if (removeChannel) { - removeChannel->Leave(GetGUID(), sendRemove); // Leave old channel + removeChannel->LeaveChannel(this, sendRemove); // Leave old channel std::string name = removeChannel->GetName(); // Store name, (*i)erase in LeftChannel LeftChannel(removeChannel); // Remove from player's channel list cMgr->LeftChannel(name); // Delete if empty @@ -5676,7 +5681,7 @@ void Player::LeaveLFGChannel() { if ((*i)->IsLFG()) { - (*i)->Leave(GetGUID()); + (*i)->LeaveChannel(this); break; } } @@ -5684,13 +5689,8 @@ void Player::LeaveLFGChannel() void Player::UpdateDefense() { - uint32 defense_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_DEFENSE); - - if (UpdateSkill(SKILL_DEFENSE, defense_skill_gain)) - { - // update dependent from defense skill part - UpdateDefenseBonusesMod(); - } + if (UpdateSkill(SKILL_DEFENSE, sWorld->getIntConfig(CONFIG_SKILL_GAIN_DEFENSE))) + UpdateDefenseBonusesMod(); // update dependent from defense skill part } void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply) @@ -7259,7 +7259,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto int32 count = sWorld->getIntConfig(CONFIG_PVP_TOKEN_COUNT); if (AddItem(itemId, count)) - ChatHandler(this).PSendSysMessage("You have been awarded a token for slaying another player."); + ChatHandler(GetSession()).PSendSysMessage("You have been awarded a token for slaying another player."); } } @@ -16648,6 +16648,11 @@ float Player::GetFloatValueFromArray(Tokenizer const& data, uint16 index) return result; } +bool Player::isBeingLoaded() const +{ + return GetSession()->PlayerLoading(); +} + bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) { //// 0 1 2 3 4 5 6 7 8 9 10 11 @@ -16732,7 +16737,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); // load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as loading does call UpdateAchievementCriteria) - m_achievementMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS)); + m_achievementMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS)); uint32 money = fields[8].GetUInt32(); if (money > MAX_MONEY_AMOUNT) @@ -17176,7 +17181,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) learnDefaultSpells(); // must be before inventory (some items required reputation check) - m_reputationMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADREPUTATION)); + m_reputationMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADREPUTATION)); _LoadInventory(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff); @@ -17284,7 +17289,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) _LoadDeclinedNames(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES)); - m_achievementMgr.CheckAllAchievementCriteria(); + m_achievementMgr->CheckAllAchievementCriteria(); _LoadEquipmentSets(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS)); @@ -18509,6 +18514,14 @@ bool Player::CheckInstanceLoginValid() return sMapMgr->CanPlayerEnter(GetMap()->GetId(), this, true); } +bool Player::CheckInstanceCount(uint32 instanceId) const +{ + if (_instanceResetTimes.size() < sWorld->getIntConfig(CONFIG_MAX_INSTANCES_PER_HOUR)) + return true; + return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end(); +} + + bool Player::_LoadHomeBind(PreparedQueryResult result) { PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); @@ -18828,8 +18841,8 @@ void Player::SaveToDB(bool create /*=false*/) _SaveActions(trans); _SaveAuras(trans); _SaveSkills(trans); - m_achievementMgr.SaveToDB(trans); - m_reputationMgr.SaveToDB(trans); + m_achievementMgr->SaveToDB(trans); + m_reputationMgr->SaveToDB(trans); _SaveEquipmentSets(trans); GetSession()->SaveTutorialsData(trans); // changed only while character in game _SaveGlyphs(trans); @@ -19967,7 +19980,7 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) } else if (!isAddonMessage) // announce to player that player he is whispering to is dnd and cannot receive his message - ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->dndMsg.c_str()); + ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->dndMsg.c_str()); // rest stuff shouldn't happen in case of addon message if (isAddonMessage) @@ -19976,12 +19989,12 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster()) { SetAcceptWhispers(true); - ChatHandler(this).SendSysMessage(LANG_COMMAND_WHISPERON); + ChatHandler(GetSession()).SendSysMessage(LANG_COMMAND_WHISPERON); } // announce to player that player he is whispering to is afk if (rPlayer->isAFK()) - ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->afkMsg.c_str()); + ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->afkMsg.c_str()); // if player whisper someone, auto turn of dnd to be able to receive an answer if (isDND() && !rPlayer->isGameMaster()) @@ -21702,7 +21715,7 @@ bool Player::IsAlwaysDetectableFor(WorldObject const* seer) const return false; } -bool Player::IsVisibleGloballyFor(Player* u) const +bool Player::IsVisibleGloballyFor(Player const* u) const { if (!u) return false; @@ -22077,8 +22090,8 @@ void Player::SendInitialPacketsBeforeAddToMap() GetSession()->SendPacket(&data); SendInitialActionButtons(); - m_reputationMgr.SendInitialReputations(); - m_achievementMgr.SendAllAchievementData(); + m_reputationMgr->SendInitialReputations(); + m_achievementMgr->SendAllAchievementData(); SendEquipmentSetList(); @@ -24189,42 +24202,42 @@ void Player::HandleFall(MovementInfo const& movementInfo) void Player::ResetAchievements() { - m_achievementMgr.Reset(); + m_achievementMgr->Reset(); } void Player::SendRespondInspectAchievements(Player* player) const { - m_achievementMgr.SendRespondInspectAchievements(player); + m_achievementMgr->SendRespondInspectAchievements(player); } bool Player::HasAchieved(uint32 achievementId) const { - return m_achievementMgr.HasAchieved(achievementId); + return m_achievementMgr->HasAchieved(achievementId); } void Player::StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost/* = 0*/) { - m_achievementMgr.StartTimedAchievement(type, entry, timeLost); + m_achievementMgr->StartTimedAchievement(type, entry, timeLost); } void Player::RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry) { - m_achievementMgr.RemoveTimedAchievement(type, entry); + m_achievementMgr->RemoveTimedAchievement(type, entry); } void Player::ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, bool evenIfCriteriaComplete /* = false*/) { - m_achievementMgr.ResetAchievementCriteria(type, miscValue1, miscValue2, evenIfCriteriaComplete); + m_achievementMgr->ResetAchievementCriteria(type, miscValue1, miscValue2, evenIfCriteriaComplete); } void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= NULL*/) { - m_achievementMgr.UpdateAchievementCriteria(type, miscValue1, miscValue2, unit); + m_achievementMgr->UpdateAchievementCriteria(type, miscValue1, miscValue2, unit); } void Player::CompletedAchievement(AchievementEntry const* entry) { - m_achievementMgr.CompletedAchievement(entry); + m_achievementMgr->CompletedAchievement(entry); } void Player::LearnTalent(uint32 talentId, uint32 talentRank) @@ -25330,7 +25343,7 @@ bool Player::AddItem(uint32 itemId, uint32 count) if (count == 0 || dest.empty()) { // -- TODO: Send to mailbox if no space - ChatHandler(this).PSendSysMessage("You don't have any space in your bags."); + ChatHandler(GetSession()).PSendSysMessage("You don't have any space in your bags."); return false; } @@ -25594,3 +25607,116 @@ Guild* Player::GetGuild() uint32 guildId = GetGuildId(); return guildId ? sGuildMgr->GetGuildById(guildId) : NULL; } + +Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration) +{ + Pet* pet = new Pet(this, petType); + + if (petType == SUMMON_PET && pet->LoadPetFromDB(this, entry)) + { + // Remove Demonic Sacrifice auras (known pet) + Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) + { + if ((*itr)->GetMiscValue() == 2228) + { + RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + + if (duration > 0) + pet->SetDuration(duration); + + return NULL; + } + + // petentry == 0 for hunter "call pet" (current pet summoned if any) + if (!entry) + { + delete pet; + return NULL; + } + + pet->Relocate(x, y, z, ang); + if (!pet->IsPositionValid()) + { + sLog->outError(LOG_FILTER_GENERAL, "Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); + delete pet; + return NULL; + } + + Map* map = GetMap(); + uint32 pet_number = sObjectMgr->GeneratePetNumber(); + if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number)) + { + sLog->outError(LOG_FILTER_GENERAL, "no such creature entry %u", entry); + delete pet; + return NULL; + } + + pet->SetCreatorGUID(GetGUID()); + pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); + + pet->setPowerType(POWER_MANA); + pet->SetUInt32Value(UNIT_NPC_FLAGS, 0); + pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pet->InitStatsForLevel(getLevel()); + + SetMinion(pet, true); + + switch (petType) + { + case SUMMON_PET: + // this enables pet details window (Shift+P) + pet->GetCharmInfo()->SetPetNumber(pet_number, true); + pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); + pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); + pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); + pet->SetFullHealth(); + pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case + break; + default: + break; + } + + map->AddToMap(pet->ToCreature()); + + switch (petType) + { + case SUMMON_PET: + pet->InitPetCreateSpells(); + pet->InitTalentForLevel(); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + PetSpellInitialize(); + break; + default: + break; + } + + if (petType == SUMMON_PET) + { + // Remove Demonic Sacrifice auras (known pet) + Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) + { + if ((*itr)->GetMiscValue() == 2228) + { + RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + } + + if (duration > 0) + pet->SetDuration(duration); + + //ObjectAccessor::UpdateObjectVisibility(pet); + + return pet; +} diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index fe1d1a5b798..3e4b3e8a971 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -19,30 +19,28 @@ #ifndef _PLAYER_H #define _PLAYER_H -#include "AchievementMgr.h" -#include "Battleground.h" -#include "Bag.h" -#include "Common.h" -#include "DatabaseEnv.h" -#include "DBCEnums.h" +#include "DBCStores.h" #include "GroupReference.h" -#include "ItemPrototype.h" -#include "Item.h" #include "MapReference.h" -#include "NPCHandler.h" -#include "Pet.h" + +#include "Item.h" +#include "PetDefines.h" #include "QuestDef.h" -#include "ReputationMgr.h" -#include "Unit.h" -#include "Util.h" // for Tokens typedef -#include "WorldSession.h" #include "SpellMgr.h" +#include "Unit.h" -#include<string> -#include<vector> +#include <string> +#include <vector> +struct CreatureTemplate; struct Mail; +struct TrainerSpell; +struct VendorItem; + +class AchievementMgr; +class ReputationMgr; class Channel; +class CharacterCreateInfo; class Creature; class DynamicObject; class Group; @@ -242,9 +240,7 @@ typedef std::list<PlayerCreateInfoAction> PlayerCreateInfoActions; struct PlayerInfo { // existence checked by displayId != 0 - PlayerInfo() : displayId_m(0), displayId_f(0), levelInfo(NULL) - { - } + PlayerInfo() : displayId_m(0), displayId_f(0), levelInfo(NULL) { } uint32 mapId; uint32 areaId; @@ -725,13 +721,6 @@ enum RestType REST_TYPE_IN_CITY = 2 }; -enum DuelCompleteType -{ - DUEL_INTERRUPTED = 0, - DUEL_WON = 1, - DUEL_FLED = 2 -}; - enum TeleportToOptions { TELE_TO_GM_MODE = 0x01, @@ -834,17 +823,6 @@ struct InstancePlayerBind InstancePlayerBind() : save(NULL), perm(false) {} }; -enum DungeonStatusFlag -{ - DUNGEON_STATUSFLAG_NORMAL = 0x01, - DUNGEON_STATUSFLAG_HEROIC = 0x02, - - RAID_STATUSFLAG_10MAN_NORMAL = 0x01, - RAID_STATUSFLAG_25MAN_NORMAL = 0x02, - RAID_STATUSFLAG_10MAN_HEROIC = 0x04, - RAID_STATUSFLAG_25MAN_HEROIC = 0x08 -}; - struct AccessRequirement { uint8 levelMin; @@ -1513,7 +1491,7 @@ class Player : public Unit, public GridObject<Player> /*********************************************************/ bool LoadFromDB(uint32 guid, SQLQueryHolder *holder); - bool isBeingLoaded() const { return GetSession()->PlayerLoading();} + bool isBeingLoaded() const; void Initialize(uint32 guid); static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); @@ -2037,8 +2015,8 @@ class Player : public Unit, public GridObject<Player> uint8 GetGrantableLevels() { return m_grantableLevels; } void SetGrantableLevels(uint8 val) { m_grantableLevels = val; } - ReputationMgr& GetReputationMgr() { return m_reputationMgr; } - ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; } + ReputationMgr& GetReputationMgr() { return *m_reputationMgr; } + ReputationMgr const& GetReputationMgr() const { return *m_reputationMgr; } ReputationRank GetReputationRank(uint32 faction_id) const; void RewardReputation(Unit* victim, float rate); void RewardReputation(Quest const* quest); @@ -2339,7 +2317,7 @@ class Player : public Unit, public GridObject<Player> bool IsNeverVisible() const; - bool IsVisibleGloballyFor(Player* player) const; + bool IsVisibleGloballyFor(Player const* player) const; void SendInitialVisiblePackets(Unit* target); void UpdateObjectVisibility(bool forced = true); @@ -2398,12 +2376,7 @@ class Player : public Unit, public GridObject<Player> static void ConvertInstancesToGroup(Player* player, Group* group, bool switchLeader); bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false); bool CheckInstanceLoginValid(); - bool CheckInstanceCount(uint32 instanceId) const - { - if (_instanceResetTimes.size() < sWorld->getIntConfig(CONFIG_MAX_INSTANCES_PER_HOUR)) - return true; - return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end(); - } + bool CheckInstanceCount(uint32 instanceId) const; void AddInstanceEnterTime(uint32 instanceId, time_t enterTime) { @@ -2860,8 +2833,8 @@ class Player : public Unit, public GridObject<Player> uint32 m_temporaryUnsummonedPetNumber; uint32 m_oldpetspell; - AchievementMgr m_achievementMgr; - ReputationMgr m_reputationMgr; + AchievementMgr* m_achievementMgr; + ReputationMgr* m_reputationMgr; SpellCooldowns m_spellCooldowns; diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index d5d1bd99277..4d726181c4f 100755 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -17,13 +17,14 @@ */ #include "Totem.h" -#include "WorldPacket.h" #include "Log.h" #include "Group.h" -#include "Player.h" #include "ObjectMgr.h" +#include "Opcodes.h" +#include "Player.h" #include "SpellMgr.h" #include "SpellInfo.h" +#include "WorldPacket.h" Totem::Totem(SummonPropertiesEntry const* properties, Unit* owner) : Minion(properties, owner, false) { diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index f52d0059a36..6de359c67dd 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -26,6 +26,7 @@ #include "DBCStores.h" #include "World.h" #include "GameObjectAI.h" +#include "Player.h" void MapManager::LoadTransports() { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 29afc0c1b36..0b168a1615b 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -16,49 +16,50 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "Unit.h" #include "Common.h" +#include "Battlefield.h" +#include "BattlefieldMgr.h" +#include "Battleground.h" +#include "CellImpl.h" +#include "ConditionMgr.h" +#include "CreatureAI.h" #include "CreatureAIImpl.h" -#include "Log.h" -#include "Opcodes.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Unit.h" -#include "QuestDef.h" -#include "Player.h" +#include "CreatureGroups.h" #include "Creature.h" -#include "Spell.h" +#include "Formulas.h" +#include "GridNotifiersImpl.h" #include "Group.h" -#include "SpellAuras.h" -#include "SpellAuraEffects.h" +#include "InstanceSaveMgr.h" +#include "InstanceScript.h" +#include "Log.h" #include "MapManager.h" +#include "MoveSpline.h" +#include "MoveSplineInit.h" #include "ObjectAccessor.h" -#include "CreatureAI.h" -#include "Formulas.h" -#include "Pet.h" -#include "Util.h" -#include "Totem.h" -#include "Battleground.h" +#include "ObjectMgr.h" +#include "Opcodes.h" #include "OutdoorPvP.h" -#include "InstanceSaveMgr.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "CreatureGroups.h" -#include "PetAI.h" #include "PassiveAI.h" +#include "PetAI.h" +#include "Pet.h" +#include "Player.h" +#include "QuestDef.h" +#include "ReputationMgr.h" +#include "SpellAuraEffects.h" +#include "SpellAuras.h" +#include "Spell.h" +#include "SpellInfo.h" +#include "SpellMgr.h" #include "TemporarySummon.h" -#include "Vehicle.h" +#include "Totem.h" #include "Transport.h" -#include "InstanceScript.h" -#include "SpellInfo.h" -#include "MoveSplineInit.h" -#include "MoveSpline.h" -#include "ConditionMgr.h" #include "UpdateFieldFlags.h" -#include "Battlefield.h" -#include "BattlefieldMgr.h" +#include "Util.h" +#include "Vehicle.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" #include <math.h> @@ -1328,7 +1329,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) // If this is a creature and it attacks from behind it has a probability to daze it's victim if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(M_PI, this) - && (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss())) + && (victim->GetTypeId() == TYPEID_PLAYER || !victim->ToCreature()->isWorldBoss())&& !victim->IsVehicle()) { // -probability is between 0% and 40% // 20% base chance @@ -1341,7 +1342,10 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) uint32 VictimDefense=victim->GetDefenseSkillValue(); uint32 AttackerMeleeSkill=GetUnitMeleeSkill(); - Probability *= AttackerMeleeSkill/(float)VictimDefense; + Probability *= AttackerMeleeSkill/(float)VictimDefense*0.16; + + if (Probability < 0) + Probability = 0; if (Probability > 40.0f) Probability = 40.0f; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index ce329098bc6..08fefe4c420 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -19,24 +19,14 @@ #ifndef __UNIT_H #define __UNIT_H -#include "Common.h" -#include "Object.h" -#include "Opcodes.h" -#include "SpellAuraDefines.h" -#include "UpdateFields.h" -#include "SharedDefines.h" -#include "ThreatManager.h" -#include "HostileRefManager.h" +#include "EventProcessor.h" #include "FollowerReference.h" #include "FollowerRefManager.h" -#include "EventProcessor.h" +#include "HostileRefManager.h" #include "MotionMaster.h" -#include "DBCStructure.h" -#include "SpellInfo.h" -#include "Path.h" -#include "WorldPacket.h" -#include "Timer.h" -#include <list> +#include "Object.h" +#include "SpellAuraDefines.h" +#include "ThreatManager.h" #define WORLD_TRIGGER 12999 @@ -342,6 +332,7 @@ class Totem; class Transport; class Vehicle; class TransportBase; +class SpellCastTargets; typedef std::list<Unit*> UnitList; typedef std::list< std::pair<Aura*, uint8> > DispelChargesList; diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 84274a9692d..f8f7a1a1b72 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -29,6 +29,7 @@ #include "SpellMgr.h" #include "SpellInfo.h" #include "MoveSplineInit.h" +#include "TemporarySummon.h" Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) : _me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry) { diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index b19abc778a9..cedb20eccf1 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -17,25 +17,25 @@ */ #include "ObjectAccessor.h" -#include "ObjectMgr.h" - -#include "Player.h" +#include "CellImpl.h" +#include "Corpse.h" #include "Creature.h" -#include "GameObject.h" #include "DynamicObject.h" -#include "Vehicle.h" -#include "WorldPacket.h" -#include "Item.h" -#include "Corpse.h" +#include "GameObject.h" #include "GridNotifiers.h" -#include "MapManager.h" -#include "Map.h" -#include "CellImpl.h" #include "GridNotifiersImpl.h" -#include "Opcodes.h" -#include "ObjectDefines.h" +#include "Item.h" +#include "Map.h" #include "MapInstanced.h" +#include "MapManager.h" +#include "ObjectDefines.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "Pet.h" +#include "Player.h" +#include "Vehicle.h" #include "World.h" +#include "WorldPacket.h" #include <cmath> @@ -47,6 +47,12 @@ ObjectAccessor::~ObjectAccessor() { } +Player* ObjectAccessor::GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/) +{ + Player* player = HashMapHolder<Player>::Find(guid); + return player && player->IsInWorld() ? player : NULL; +} + WorldObject* ObjectAccessor::GetWorldObject(WorldObject const& p, uint64 guid) { switch (GUID_HIPART(guid)) diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index 41a7abc9a24..d2b532c9f94 100755 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -28,7 +28,6 @@ #include "GridDefines.h" #include "Object.h" -#include "Player.h" #include <set> @@ -116,11 +115,7 @@ class ObjectAccessor } // Player may be not in world while in ObjectAccessor - static Player* GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/) - { - Player* player = HashMapHolder<Player>::Find(guid); - return player && player->IsInWorld() ? player : NULL; - } + static Player* GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/); static Unit* GetObjectInWorld(uint64 guid, Unit* /*typeSpecifier*/) { diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index db8a484ad76..ff734efe385 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -16,36 +16,38 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "AccountMgr.h" +#include "AchievementMgr.h" +#include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "Chat.h" #include "Common.h" #include "DatabaseEnv.h" +#include "DisableMgr.h" +#include "GameEventMgr.h" +#include "GossipDef.h" +#include "GroupMgr.h" +#include "GuildMgr.h" +#include "InstanceSaveMgr.h" +#include "Language.h" +#include "LFGMgr.h" #include "Log.h" #include "MapManager.h" #include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "GroupMgr.h" +#include "Pet.h" +#include "PoolMgr.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" +#include "SpellAuras.h" +#include "Spell.h" #include "SpellMgr.h" -#include "UpdateMask.h" -#include "World.h" -#include "ArenaTeam.h" +#include "SpellScript.h" #include "Transport.h" -#include "Language.h" -#include "GameEventMgr.h" -#include "Spell.h" -#include "Chat.h" -#include "AccountMgr.h" -#include "InstanceSaveMgr.h" -#include "SpellAuras.h" +#include "UpdateMask.h" #include "Util.h" -#include "WaypointManager.h" -#include "GossipDef.h" #include "Vehicle.h" -#include "AchievementMgr.h" -#include "DisableMgr.h" -#include "ScriptMgr.h" -#include "SpellScript.h" -#include "PoolMgr.h" -#include "LFGMgr.h" +#include "WaypointManager.h" +#include "World.h" ScriptMapMap sQuestEndScripts; ScriptMapMap sQuestStartScripts; @@ -227,11 +229,29 @@ bool SpellClickInfo::IsFitToRequirements(Unit const* clicker, Unit const* clicke return true; } -ObjectMgr::ObjectMgr(): _auctionId(1), _equipmentSetGuid(1), - _itemTextId(1), _mailId(1), _hiPetNumber(1), _hiCharGuid(1), - _hiCreatureGuid(1), _hiPetGuid(1), _hiVehicleGuid(1), _hiItemGuid(1), - _hiGoGuid(1), _hiDoGuid(1), _hiCorpseGuid(1), _hiMoTransGuid(1) -{} +ObjectMgr::ObjectMgr(): + _auctionId(1), + _equipmentSetGuid(1), + _itemTextId(1), + _mailId(1), + _hiPetNumber(1), + _hiCharGuid(1), + _hiCreatureGuid(1), + _hiPetGuid(1), + _hiVehicleGuid(1), + _hiItemGuid(1), + _hiGoGuid(1), + _hiDoGuid(1), + _hiCorpseGuid(1), + _hiMoTransGuid(1) +{ + for (uint8 i = 0; i < MAX_CLASSES; ++i) + { + _playerClassInfo[i] = NULL; + for (uint8 j = 0; j < MAX_RACES; ++j) + _playerInfo[j][i] = NULL; + } +} ObjectMgr::~ObjectMgr() { @@ -243,11 +263,21 @@ ObjectMgr::~ObjectMgr() // free only if loaded for (int class_ = 0; class_ < MAX_CLASSES; ++class_) - delete[] _playerClassInfo[class_].levelInfo; + { + if (_playerClassInfo[class_]) + delete[] _playerClassInfo[class_]->levelInfo; + delete _playerClassInfo[class_]; + } for (int race = 0; race < MAX_RACES; ++race) + { for (int class_ = 0; class_ < MAX_CLASSES; ++class_) - delete[] _playerInfo[race][class_].levelInfo; + { + if (_playerInfo[race][class_]) + delete[] _playerInfo[race][class_]->levelInfo; + delete _playerInfo[race][class_]; + } + } for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr) itr->second.Clear(); @@ -257,6 +287,9 @@ ObjectMgr::~ObjectMgr() for (DungeonEncounterContainer::iterator itr =_dungeonEncounterStore.begin(); itr != _dungeonEncounterStore.end(); ++itr) for (DungeonEncounterList::iterator encounterItr = itr->second.begin(); encounterItr != itr->second.end(); ++encounterItr) delete *encounterItr; + + for (AccessRequirementContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr) + delete itr->second; } void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data) @@ -2923,8 +2956,11 @@ PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint8 level) void ObjectMgr::PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count) { + if (!_playerInfo[race_][class_]) + return; + if (count > 0) - _playerInfo[race_][class_].item.push_back(PlayerCreateInfoItem(itemId, count)); + _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count)); else { if (count < -1) @@ -3031,17 +3067,16 @@ void ObjectMgr::LoadPlayerInfo() continue; } - PlayerInfo* pInfo = &_playerInfo[current_race][current_class]; - - pInfo->mapId = mapId; - pInfo->areaId = areaId; - pInfo->positionX = positionX; - pInfo->positionY = positionY; - pInfo->positionZ = positionZ; - pInfo->orientation = orientation; - - pInfo->displayId_m = rEntry->model_m; - pInfo->displayId_f = rEntry->model_f; + PlayerInfo* info = new PlayerInfo(); + info->mapId = mapId; + info->areaId = areaId; + info->positionX = positionX; + info->positionY = positionY; + info->positionZ = positionZ; + info->orientation = orientation; + info->displayId_m = rEntry->model_m; + info->displayId_f = rEntry->model_f; + _playerInfo[current_race][current_class] = info; ++count; } @@ -3164,10 +3199,16 @@ void ObjectMgr::LoadPlayerInfo() uint32 max_class = current_class ? current_class + 1 : MAX_CLASSES; for (uint32 r = min_race; r < max_race; ++r) for (uint32 c = min_class; c < max_class; ++c) - _playerInfo[r][c].spell.push_back(fields[2].GetUInt32()); + if (PlayerInfo * info = _playerInfo[r][c]) + info->spell.push_back(fields[2].GetUInt32()); } + else if (PlayerInfo * info = _playerInfo[current_race][current_class]) + info->spell.push_back(fields[2].GetUInt32()); else - _playerInfo[current_race][current_class].spell.push_back(fields[2].GetUInt32()); + { + sLog->outError(LOG_FILTER_SQL, "Wrong race: %u, class: %u combination in `playercreateinfo_spell` table, ignoring.", current_race, current_class); + continue; + } ++count; } @@ -3212,8 +3253,8 @@ void ObjectMgr::LoadPlayerInfo() continue; } - PlayerInfo* pInfo = &_playerInfo[current_race][current_class]; - pInfo->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt16(), fields[3].GetUInt32(), fields[4].GetUInt16())); + if (PlayerInfo* info = _playerInfo[current_race][current_class]) + info->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt16(), fields[3].GetUInt32(), fields[4].GetUInt16())); ++count; } @@ -3228,13 +3269,12 @@ void ObjectMgr::LoadPlayerInfo() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 + // 0 1 2 3 QueryResult result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats"); if (!result) { sLog->outError(LOG_FILTER_SQL, ">> Loaded 0 level health/mana definitions. DB table `game_event_condition` is empty."); - exit(1); } @@ -3259,15 +3299,18 @@ void ObjectMgr::LoadPlayerInfo() continue; } - PlayerClassInfo* pClassInfo = &_playerClassInfo[current_class]; - - if (!pClassInfo->levelInfo) - pClassInfo->levelInfo = new PlayerClassLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)]; + PlayerClassInfo* info = _playerClassInfo[current_class]; + if (!info) + { + info = new PlayerClassInfo(); + info->levelInfo = new PlayerClassLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)]; + _playerClassInfo[current_class] = info; + } - PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level-1]; + PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level-1]; - pClassLevelInfo->basehealth = fields[2].GetUInt16(); - pClassLevelInfo->basemana = fields[3].GetUInt16(); + levelInfo.basehealth = fields[2].GetUInt16(); + levelInfo.basemana = fields[3].GetUInt16(); ++count; } @@ -3280,7 +3323,7 @@ void ObjectMgr::LoadPlayerInfo() if (!sChrClassesStore.LookupEntry(class_)) continue; - PlayerClassInfo* pClassInfo = &_playerClassInfo[class_]; + PlayerClassInfo* pClassInfo = _playerClassInfo[class_]; // fatal error if no level 1 data if (!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0) @@ -3351,16 +3394,14 @@ void ObjectMgr::LoadPlayerInfo() continue; } - PlayerInfo* pInfo = &_playerInfo[current_race][current_class]; - - if (!pInfo->levelInfo) - pInfo->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)]; - - PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level-1]; - - for (int i = 0; i < MAX_STATS; i++) + if (PlayerInfo* info = _playerInfo[current_race][current_class]) { - pLevelInfo->stats[i] = fields[i+3].GetUInt8(); + if (!info->levelInfo) + info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)]; + + PlayerLevelInfo& levelInfo = info->levelInfo[current_level-1]; + for (int i = 0; i < MAX_STATS; i++) + levelInfo.stats[i] = fields[i+3].GetUInt8(); } ++count; @@ -3380,10 +3421,8 @@ void ObjectMgr::LoadPlayerInfo() if (!sChrClassesStore.LookupEntry(class_)) continue; - PlayerInfo* pInfo = &_playerInfo[race][class_]; - - // skip non loaded combinations - if (!pInfo->displayId_m || !pInfo->displayId_f) + PlayerInfo* info = _playerInfo[race][class_]; + if (!info) continue; // skip expansion races if not playing with expansion @@ -3395,7 +3434,7 @@ void ObjectMgr::LoadPlayerInfo() continue; // fatal error if no level 1 data - if (!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0) + if (!info->levelInfo || info->levelInfo[0].stats[0] == 0) { sLog->outError(LOG_FILTER_SQL, "Race %i Class %i Level 1 does not have stats data!", race, class_); exit(1); @@ -3404,10 +3443,10 @@ void ObjectMgr::LoadPlayerInfo() // fill level gaps for (uint8 level = 1; level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) { - if (pInfo->levelInfo[level].stats[0] == 0) + if (info->levelInfo[level].stats[0] == 0) { sLog->outError(LOG_FILTER_SQL, "Race %i Class %i Level %i does not have stats data. Using stats data of level %i.", race, class_, level+1, level); - pInfo->levelInfo[level] = pInfo->levelInfo[level-1]; + info->levelInfo[level] = info->levelInfo[level-1]; } } } @@ -3480,7 +3519,7 @@ void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassL if (level < 1 || class_ >= MAX_CLASSES) return; - PlayerClassInfo const* pInfo = &_playerClassInfo[class_]; + PlayerClassInfo const* pInfo = _playerClassInfo[class_]; if (level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); @@ -3493,8 +3532,8 @@ void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, Play if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) return; - PlayerInfo const* pInfo = &_playerInfo[race][class_]; - if (pInfo->displayId_m == 0 || pInfo->displayId_f == 0) + PlayerInfo const* pInfo = _playerInfo[race][class_]; + if (!pInfo) return; if (level <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) @@ -3506,7 +3545,7 @@ void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, Play void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, PlayerLevelInfo* info) const { // base data (last known level) - *info = _playerInfo[race][_class].levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)-1]; + *info = _playerInfo[race][_class]->levelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)-1]; // if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32 for (uint8 lvl = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl) @@ -5898,7 +5937,13 @@ void ObjectMgr::LoadAccessRequirements() { uint32 oldMSTime = getMSTime(); - _accessRequirementStore.clear(); // need for reload case + if (!_accessRequirementStore.empty()) + { + for (AccessRequirementContainer::iterator itr = _accessRequirementStore.begin(); itr != _accessRequirementStore.end(); ++itr) + delete itr->second; + + _accessRequirementStore.clear(); // need for reload case + } // 0 1 2 3 4 5 6 7 8 9 QueryResult result = WorldDatabase.Query("SELECT mapid, difficulty, level_min, level_max, item, item2, quest_done_A, quest_done_H, completed_achievement, quest_failed_text FROM access_requirement"); @@ -5920,61 +5965,61 @@ void ObjectMgr::LoadAccessRequirements() uint8 difficulty = fields[1].GetUInt8(); uint32 requirement_ID = MAKE_PAIR32(mapid, difficulty); - AccessRequirement ar; + AccessRequirement* ar = new AccessRequirement(); - ar.levelMin = fields[2].GetUInt8(); - ar.levelMax = fields[3].GetUInt8(); - ar.item = fields[4].GetUInt32(); - ar.item2 = fields[5].GetUInt32(); - ar.quest_A = fields[6].GetUInt32(); - ar.quest_H = fields[7].GetUInt32(); - ar.achievement = fields[8].GetUInt32(); - ar.questFailedText = fields[9].GetString(); + ar->levelMin = fields[2].GetUInt8(); + ar->levelMax = fields[3].GetUInt8(); + ar->item = fields[4].GetUInt32(); + ar->item2 = fields[5].GetUInt32(); + ar->quest_A = fields[6].GetUInt32(); + ar->quest_H = fields[7].GetUInt32(); + ar->achievement = fields[8].GetUInt32(); + ar->questFailedText = fields[9].GetString(); - if (ar.item) + if (ar->item) { - ItemTemplate const* pProto = GetItemTemplate(ar.item); + ItemTemplate const* pProto = GetItemTemplate(ar->item); if (!pProto) { - sLog->outError(LOG_FILTER_GENERAL, "Key item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item, mapid, difficulty); - ar.item = 0; + sLog->outError(LOG_FILTER_GENERAL, "Key item %u does not exist for map %u difficulty %u, removing key requirement.", ar->item, mapid, difficulty); + ar->item = 0; } } - if (ar.item2) + if (ar->item2) { - ItemTemplate const* pProto = GetItemTemplate(ar.item2); + ItemTemplate const* pProto = GetItemTemplate(ar->item2); if (!pProto) { - sLog->outError(LOG_FILTER_GENERAL, "Second item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item2, mapid, difficulty); - ar.item2 = 0; + sLog->outError(LOG_FILTER_GENERAL, "Second item %u does not exist for map %u difficulty %u, removing key requirement.", ar->item2, mapid, difficulty); + ar->item2 = 0; } } - if (ar.quest_A) + if (ar->quest_A) { - if (!GetQuestTemplate(ar.quest_A)) + if (!GetQuestTemplate(ar->quest_A)) { - sLog->outError(LOG_FILTER_SQL, "Required Alliance Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar.quest_A, mapid, difficulty); - ar.quest_A = 0; + sLog->outError(LOG_FILTER_SQL, "Required Alliance Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar->quest_A, mapid, difficulty); + ar->quest_A = 0; } } - if (ar.quest_H) + if (ar->quest_H) { - if (!GetQuestTemplate(ar.quest_H)) + if (!GetQuestTemplate(ar->quest_H)) { - sLog->outError(LOG_FILTER_SQL, "Required Horde Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar.quest_H, mapid, difficulty); - ar.quest_H = 0; + sLog->outError(LOG_FILTER_SQL, "Required Horde Quest %u not exist for map %u difficulty %u, remove quest done requirement.", ar->quest_H, mapid, difficulty); + ar->quest_H = 0; } } - if (ar.achievement) + if (ar->achievement) { - if (!sAchievementStore.LookupEntry(ar.achievement)) + if (!sAchievementStore.LookupEntry(ar->achievement)) { - sLog->outError(LOG_FILTER_SQL, "Required Achievement %u not exist for map %u difficulty %u, remove quest done requirement.", ar.achievement, mapid, difficulty); - ar.achievement = 0; + sLog->outError(LOG_FILTER_SQL, "Required Achievement %u not exist for map %u difficulty %u, remove quest done requirement.", ar->achievement, mapid, difficulty); + ar->achievement = 0; } } @@ -8202,7 +8247,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (!cInfo) { if (player) - ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION); + ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION); else sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: %u), ignore", vendor_entry); return false; @@ -8213,7 +8258,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (!skip_vendors || skip_vendors->count(vendor_entry) == 0) { if (player) - ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION); + ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION); else sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry); @@ -8226,7 +8271,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (!sObjectMgr->GetItemTemplate(item_id)) { if (player) - ChatHandler(player).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id); else sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore", vendor_entry, item_id); return false; @@ -8235,7 +8280,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) { if (player) - ChatHandler(player).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost); else sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore", item_id, ExtendedCost, vendor_entry); return false; @@ -8244,7 +8289,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (maxcount > 0 && incrtime == 0) { if (player) - ChatHandler(player).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount); + ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount); else sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` has `maxcount` (%u) for item %u of vendor (Entry: %u) but `incrtime`=0, ignore", maxcount, item_id, vendor_entry); return false; @@ -8252,7 +8297,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max else if (maxcount == 0 && incrtime > 0) { if (player) - ChatHandler(player).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0"); + ChatHandler(player->GetSession()).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0"); else sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignore", item_id, vendor_entry); return false; @@ -8265,7 +8310,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (vItems->FindItemCostPair(item_id, ExtendedCost)) { if (player) - ChatHandler(player).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost); else sLog->outError(LOG_FILTER_SQL, "Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, ExtendedCost, vendor_entry); return false; @@ -8274,7 +8319,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (vItems->GetItemCount() >= MAX_VENDOR_ITEMS) { if (player) - ChatHandler(player).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); + ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); else sLog->outError(LOG_FILTER_SQL, "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vItems->GetItemCount(), MAX_VENDOR_ITEMS, vendor_entry); return false; @@ -8695,3 +8740,15 @@ VehicleAccessoryList const* ObjectMgr::GetVehicleAccessoryList(Vehicle* veh) con return &itr->second; return NULL; } + +PlayerInfo const* ObjectMgr::GetPlayerInfo(uint32 race, uint32 class_) const +{ + if (race >= MAX_RACES) + return NULL; + if (class_ >= MAX_CLASSES) + return NULL; + PlayerInfo const* info = _playerInfo[race][class_]; + if (!info) + return NULL; + return info; +} diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 29ca353bdd7..3dcab3df951 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -23,7 +23,6 @@ #include "Object.h" #include "Bag.h" #include "Creature.h" -#include "Player.h" #include "DynamicObject.h" #include "GameObject.h" #include "Corpse.h" @@ -44,6 +43,11 @@ #include <functional> class Item; +struct AccessRequirement; +struct PlayerClassInfo; +struct PlayerClassLevelInfo; +struct PlayerInfo; +struct PlayerLevelInfo; // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform #if defined(__GNUC__) @@ -65,6 +69,41 @@ struct PageText #pragma pack(pop) #endif +// DB scripting commands +enum ScriptCommands +{ + SCRIPT_COMMAND_TALK = 0, // source/target = Creature, target = any, datalong = talk type (0=say, 1=whisper, 2=yell, 3=emote text, 4=boss emote text), datalong2 & 1 = player talk (instead of creature), dataint = string_id + SCRIPT_COMMAND_EMOTE = 1, // source/target = Creature, datalong = emote id, datalong2 = 0: set emote state; > 0: play emote state + SCRIPT_COMMAND_FIELD_SET = 2, // source/target = Creature, datalong = field id, datalog2 = value + SCRIPT_COMMAND_MOVE_TO = 3, // source/target = Creature, datalong2 = time to reach, x/y/z = destination + SCRIPT_COMMAND_FLAG_SET = 4, // source/target = Creature, datalong = field id, datalog2 = bitmask + SCRIPT_COMMAND_FLAG_REMOVE = 5, // source/target = Creature, datalong = field id, datalog2 = bitmask + SCRIPT_COMMAND_TELEPORT_TO = 6, // source/target = Creature/Player (see datalong2), datalong = map_id, datalong2 = 0: Player; 1: Creature, x/y/z = destination, o = orientation + SCRIPT_COMMAND_QUEST_EXPLORED = 7, // target/source = Player, target/source = GO/Creature, datalong = quest id, datalong2 = distance or 0 + SCRIPT_COMMAND_KILL_CREDIT = 8, // target/source = Player, datalong = creature entry, datalong2 = 0: personal credit, 1: group credit + SCRIPT_COMMAND_RESPAWN_GAMEOBJECT = 9, // source = WorldObject (summoner), datalong = GO guid, datalong2 = despawn delay + SCRIPT_COMMAND_TEMP_SUMMON_CREATURE = 10, // source = WorldObject (summoner), datalong = creature entry, datalong2 = despawn delay, x/y/z = summon position, o = orientation + SCRIPT_COMMAND_OPEN_DOOR = 11, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15) + SCRIPT_COMMAND_CLOSE_DOOR = 12, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15) + SCRIPT_COMMAND_ACTIVATE_OBJECT = 13, // source = Unit, target = GO + SCRIPT_COMMAND_REMOVE_AURA = 14, // source (datalong2 != 0) or target (datalong2 == 0) = Unit, datalong = spell id + SCRIPT_COMMAND_CAST_SPELL = 15, // source and/or target = Unit, datalong2 = cast direction (0: s->t 1: s->s 2: t->t 3: t->s 4: s->creature with dataint entry), dataint & 1 = triggered flag + SCRIPT_COMMAND_PLAY_SOUND = 16, // source = WorldObject, target = none/Player, datalong = sound id, datalong2 (bitmask: 0/1=anyone/player, 0/2=without/with distance dependency, so 1|2 = 3 is target with distance dependency) + SCRIPT_COMMAND_CREATE_ITEM = 17, // target/source = Player, datalong = item entry, datalong2 = amount + SCRIPT_COMMAND_DESPAWN_SELF = 18, // target/source = Creature, datalong = despawn delay + + SCRIPT_COMMAND_LOAD_PATH = 20, // source = Unit, datalong = path id, datalong2 = is repeatable + SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT = 21, // source = WorldObject (if present used as a search center), datalong = script id, datalong2 = unit lowguid, dataint = script table to use (see ScriptsType) + SCRIPT_COMMAND_KILL = 22, // source/target = Creature, dataint = remove corpse attribute + + // TrinityCore only + SCRIPT_COMMAND_ORIENTATION = 30, // source = Unit, target (datalong > 0) = Unit, datalong = > 0 turn source to face target, o = orientation + SCRIPT_COMMAND_EQUIP = 31, // soucre = Creature, datalong = equipment id + SCRIPT_COMMAND_MODEL = 32, // source = Creature, datalong = model id + SCRIPT_COMMAND_CLOSE_GOSSIP = 33, // source = Player + SCRIPT_COMMAND_PLAYMOVIE = 34 // source = Player, datalong = movie id +}; + // Benchmarked: Faster than UNORDERED_MAP (insert/find) typedef std::map<uint32, PageText> PageTextContainer; @@ -598,7 +637,7 @@ class ObjectMgr typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptContainer; - typedef UNORDERED_MAP<uint32, AccessRequirement> AccessRequirementContainer; + typedef UNORDERED_MAP<uint32, AccessRequirement*> AccessRequirementContainer; typedef UNORDERED_MAP<uint32, RepRewardRate > RepRewardRateContainer; typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillContainer; @@ -647,21 +686,11 @@ class ObjectMgr { if (class_ >= MAX_CLASSES) return NULL; - return &_playerClassInfo[class_]; + return _playerClassInfo[class_]; } void GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassLevelInfo* info) const; - PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const - { - if (race >= MAX_RACES) - return NULL; - if (class_ >= MAX_CLASSES) - return NULL; - PlayerInfo const* info = &_playerInfo[race][class_]; - if (info->displayId_m == 0 || info->displayId_f == 0) - return NULL; - return info; - } + PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const; void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const; @@ -722,7 +751,7 @@ class ObjectMgr { AccessRequirementContainer::const_iterator itr = _accessRequirementStore.find(MAKE_PAIR32(mapid, difficulty)); if (itr != _accessRequirementStore.end()) - return &itr->second; + return itr->second; return NULL; } @@ -1233,11 +1262,11 @@ class ObjectMgr // PetLevelInfoContainer[creature_id][level] PetLevelInfoContainer _petInfoStore; // [creature_id][level] - PlayerClassInfo _playerClassInfo[MAX_CLASSES]; + PlayerClassInfo* _playerClassInfo[MAX_CLASSES]; void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const; - PlayerInfo _playerInfo[MAX_RACES][MAX_CLASSES]; + PlayerInfo* _playerInfo[MAX_RACES][MAX_CLASSES]; typedef std::vector<uint32> PlayerXPperLevel; // [level] PlayerXPperLevel _playerXPperLevel; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index db4dc819557..752c6ec068e 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -31,6 +31,7 @@ #include "Unit.h" #include "CreatureAI.h" #include "Spell.h" +#include "WorldSession.h" class Player; //class Map; diff --git a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h index e3cda4dd76d..2d60678d4ff 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h +++ b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h @@ -26,6 +26,7 @@ #include "UpdateData.h" #include "CreatureAI.h" #include "SpellAuras.h" +#include "Opcodes.h" template<class T> inline void Trinity::VisibleNotifier::Visit(GridRefManager<T> &m) diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index a00b7e1ef3a..b20a1bd9dd4 100755 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -19,16 +19,14 @@ #ifndef TRINITYCORE_GROUP_H #define TRINITYCORE_GROUP_H -#include "Battleground.h" #include "DBCEnums.h" #include "GroupRefManager.h" #include "LootMgr.h" #include "QueryResult.h" #include "SharedDefines.h" -#include "Player.h" -#include "Battlefield.h" -#include "BattlefieldMgr.h" +class Battlefield; +class Battleground; class Creature; class GroupReference; class InstanceSave; diff --git a/src/server/game/Groups/GroupMgr.cpp b/src/server/game/Groups/GroupMgr.cpp index 77b3a304f6b..8283075a226 100644 --- a/src/server/game/Groups/GroupMgr.cpp +++ b/src/server/game/Groups/GroupMgr.cpp @@ -18,6 +18,8 @@ #include "Common.h" #include "GroupMgr.h" #include "InstanceSaveMgr.h" +#include "World.h" +#include "DBCStores.h" GroupMgr::GroupMgr() { diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 8f7359d9d44..a03e94ff190 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -16,19 +16,72 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "AccountMgr.h" +#include "CalendarMgr.h" +#include "Chat.h" +#include "Config.h" #include "DatabaseEnv.h" #include "Guild.h" #include "GuildMgr.h" +#include "Language.h" +#include "Log.h" #include "ScriptMgr.h" -#include "Chat.h" -#include "Config.h" #include "SocialMgr.h" -#include "Log.h" -#include "AccountMgr.h" +#include "Opcodes.h" #define MAX_GUILD_BANK_TAB_TEXT_LEN 500 #define EMBLEM_PRICE 10 * GOLD +std::string _GetGuildEventString(GuildEvents event) +{ + switch (event) + { + case GE_PROMOTION: + return "Member promotion"; + case GE_DEMOTION: + return "Member demotion"; + case GE_MOTD: + return "Guild MOTD"; + case GE_JOINED: + return "Member joined"; + case GE_LEFT: + return "Member left"; + case GE_REMOVED: + return "Member removed"; + case GE_LEADER_IS: + return "Leader is"; + case GE_LEADER_CHANGED: + return "Leader changed"; + case GE_DISBANDED: + return "Guild disbanded"; + case GE_TABARDCHANGE: + return "Tabard change"; + case GE_RANK_UPDATED: + return "Rank updated"; + case GE_RANK_DELETED: + return "Rank deleted"; + case GE_SIGNED_ON: + return "Member signed on"; + case GE_SIGNED_OFF: + return "Member signed off"; + case GE_GUILDBANKBAGSLOTS_CHANGED: + return "Bank bag slots changed"; + case GE_BANK_TAB_PURCHASED: + return "Bank tab purchased"; + case GE_BANK_TAB_UPDATED: + return "Bank tab updated"; + case GE_BANK_MONEY_SET: + return "Bank money set"; + case GE_BANK_MONEY_CHANGED: + return "Bank money changed"; + case GE_BANK_TEXT_CHANGED: + return "Bank tab text changed"; + default: + break; + } + return "<None>"; +} + inline uint32 _GetGuildBankTabPrice(uint8 tabId) { switch (tabId) @@ -240,9 +293,9 @@ void Guild::RankInfo::CreateMissingTabsIfNeeded(uint8 tabs, SQLTransaction& tran PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT); stmt->setUInt32(0, m_guildId); - stmt->setUInt8 (1, i); - stmt->setUInt8 (2, m_rankId); - stmt->setUInt32(3, rightsAndSlots.GetRights()); + stmt->setUInt8(1, i); + stmt->setUInt8(2, m_rankId); + stmt->setUInt8(3, rightsAndSlots.GetRights()); stmt->setUInt32(4, rightsAndSlots.GetSlots()); trans->Append(stmt); } @@ -1428,24 +1481,21 @@ void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId) if (_GetPurchasedTabsSize() >= GUILD_BANK_MAX_TABS) return; - if (tabId != _GetPurchasedTabsSize()) - return; + if (tabId != _GetPurchasedTabsSize()) + return; - uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD; - if (!tabCost) - return; + uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD; + if (!tabCost) + return; - if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client - return; + if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client + return; - player->ModifyMoney(-int32(tabCost)); + player->ModifyMoney(-int32(tabCost)); - uint8 rankId = member->GetRankId(); _CreateNewBankTab(); - _SetRankBankMoneyPerDay(rankId, uint32(GUILD_WITHDRAW_MONEY_UNLIMITED)); - GuildBankRightsAndSlots rightsAndSlots(tabId); - _SetRankBankTabRightsAndSlots(rankId, rightsAndSlots); - SendBankTabsInfo(session); + _BroadcastEvent(GE_BANK_TAB_PURCHASED, 0); + SendPermissions(session); /// Hack to force client to update permissions } void Guild::HandleInviteMember(WorldSession* session, std::string const& name) @@ -1532,6 +1582,8 @@ void Guild::HandleLeaveMember(WorldSession* session) SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name); } + + sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId()); } void Guild::HandleRemoveMember(WorldSession* session, std::string const& name) @@ -2091,6 +2143,39 @@ void Guild::BroadcastPacket(WorldPacket* packet) const player->GetSession()->SendPacket(packet); } +void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank) +{ + uint32 count = 0; + + WorldPacket data(SMSG_CALENDAR_FILTER_GUILD); + data << uint32(count); // count placeholder + + for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + { + // not sure if needed, maybe client checks it as well + if (count >= CALENDAR_MAX_INVITES) + { + if (Player* player = session->GetPlayer()) + sCalendarMgr->SendCalendarCommandResult(player->GetGUID(), CALENDAR_ERROR_INVITES_EXCEEDED); + return; + } + + Member* member = itr->second; + uint32 level = Player::GetLevelFromDB(member->GetGUID()); + + if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank)) + { + data.appendPackGUID(member->GetGUID()); + data << uint8(0); // unk + ++count; + } + } + + data.put<uint32>(0, count); + + session->SendPacket(&data); +} + // Members handling bool Guild::AddMember(uint64 guid, uint8 rankId) { @@ -2299,6 +2384,10 @@ void Guild::_CreateNewBankTab() stmt->setUInt8 (1, tabId); trans->Append(stmt); + ++tabId; + for (Ranks::iterator itr = m_ranks.begin(); itr != m_ranks.end(); ++itr) + (*itr).CreateMissingTabsIfNeeded(tabId, trans, false); + CharacterDatabase.CommitTransaction(trans); } @@ -2734,7 +2823,9 @@ void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* par data << uint64(guid); BroadcastPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_EVENT [Broadcast] Event: %u", guildEvent); + + if (sLog->ShouldLog(LOG_FILTER_GUILD, LOG_LEVEL_DEBUG)) + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_EVENT [Broadcast] Event: %s (%u)", _GetGuildEventString(guildEvent).c_str(), guildEvent); } void Guild::_SendBankList(WorldSession* session /* = NULL*/, uint8 tabId /*= 0*/, bool sendAllSlots /*= false*/, SlotIds *slots /*= NULL*/) const diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index a8bf5dcdb62..2f43245159b 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -711,6 +711,8 @@ public: void BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const; void BroadcastPacket(WorldPacket* packet) const; + void MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank); + template<class Do> void BroadcastWorker(Do& _do, Player* except = NULL) { diff --git a/src/server/game/Handlers/ArenaTeamHandler.cpp b/src/server/game/Handlers/ArenaTeamHandler.cpp index d3738883d6d..b8592fd846e 100755 --- a/src/server/game/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Handlers/ArenaTeamHandler.cpp @@ -27,6 +27,7 @@ #include "ObjectMgr.h" #include "SocialMgr.h" #include "ArenaTeamMgr.h" +#include "Opcodes.h" void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recvData) { diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 3c3a6978384..7e23429be2f 100755 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -24,6 +24,7 @@ #include "AuctionHouseMgr.h" #include "Log.h" +#include "Language.h" #include "Opcodes.h" #include "UpdateMask.h" #include "Util.h" diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 3a359704916..0a076dfaa34 100755 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -342,8 +342,6 @@ void WorldSession::HandleBattlefieldListOpcode(WorldPacket &recvData) void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message"); - uint8 type; // arenatype if arena uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1 uint32 bgTypeId_; // type id from dbc @@ -351,16 +349,17 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) uint8 action; // enter battle 0x1, leave queue 0x0 recvData >> type >> unk2 >> bgTypeId_ >> unk >> action; - if (!sBattlemasterListStore.LookupEntry(bgTypeId_)) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId_, _player->GetName().c_str(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Invalid BgType!", + GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action); return; } if (!_player->InBattlegroundQueue()) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (Name: %s, GUID: %u), he is not in bg_queue.", _player->GetName().c_str(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Player not in queue!", + GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action); return; } @@ -372,27 +371,39 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) GroupQueueInfo ginfo; if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo)) { - sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: itrplayerstatus not found."); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Player not in queue (No player Group Info)!", + GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action); return; } // if action == 1, then instanceId is required if (!ginfo.IsInvitedToBGInstanceGUID && action == 1) { - sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: instance not found."); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Player is not invited to any bg!", + GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action); return; } Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, bgTypeId); - - // bg template might and must be used in case of leaving queue, when instance is not created yet - if (!bg && action == 0) - bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId); if (!bg) { - sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: bg_template not found for type id %u.", bgTypeId); - return; + if (action) + { + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Cant find BG with id %u!", + GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action, ginfo.IsInvitedToBGInstanceGUID); + return; + } + + bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId); + if (!bg) + { + sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: bg_template not found for type id %u.", bgTypeId); + return; + } } + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u.", + GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action); + // expected bracket entry PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) @@ -409,86 +420,82 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data2, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS); _player->GetSession()->SendPacket(&data2); action = 0; - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow()); } //if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue if (_player->getLevel() > bg->GetMaxLevel()) { - sLog->outError(LOG_FILTER_NETWORKIO, "Battleground: Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!", + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID()); action = 0; } } uint32 queueSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId); WorldPacket data; - switch (action) + if (action) { - case 1: // port to battleground - if (!_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId)) - return; // cheating? + if (!_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId)) + return; // cheating? - if (!_player->InBattleground()) - _player->SetBattlegroundEntryPoint(); + if (!_player->InBattleground()) + _player->SetBattlegroundEntryPoint(); - // resurrect the player - if (!_player->isAlive()) - { - _player->ResurrectPlayer(1.0f); - _player->SpawnCorpseBones(); - } - // stop taxi flight at port - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } + // resurrect the player + if (!_player->isAlive()) + { + _player->ResurrectPlayer(1.0f); + _player->SpawnCorpseBones(); + } + // stop taxi flight at port + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType()); - _player->GetSession()->SendPacket(&data); - // remove battleground queue status from BGmgr - bgQueue.RemovePlayer(_player->GetGUID(), false); - // this is still needed here if battleground "jumping" shouldn't add deserter debuff - // also this is required to prevent stuck at old battleground after SetBattlegroundId set to new - if (Battleground* currentBg = _player->GetBattleground()) - currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true); - - // set the destination instance id - _player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId); - // set the destination team - _player->SetBGTeam(ginfo.Team); - // bg->HandleBeforeTeleportToBattleground(_player); - sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId); - // add only in HandleMoveWorldPortAck() - // bg->AddPlayer(_player, team); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId); - break; - case 0: // leave queue - if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE) - return; + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType()); + _player->GetSession()->SendPacket(&data); + // remove battleground queue status from BGmgr + bgQueue.RemovePlayer(_player->GetGUID(), false); + // this is still needed here if battleground "jumping" shouldn't add deserter debuff + // also this is required to prevent stuck at old battleground after SetBattlegroundId set to new + if (Battleground* currentBg = _player->GetBattleground()) + currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true); + + // set the destination instance id + _player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId); + // set the destination team + _player->SetBGTeam(ginfo.Team); + // bg->HandleBeforeTeleportToBattleground(_player); + sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId); + // add only in HandleMoveWorldPortAck() + // bg->AddPlayer(_player, team); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId); + } + else // leave queue + { + if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE) + return; - // if player leaves rated arena match before match start, it is counted as he played but he lost - if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID) + // if player leaves rated arena match before match start, it is counted as he played but he lost + if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID) + { + ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team); + if (at) { - ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team); - if (at) - { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), ginfo.OpponentsTeamRating); - at->MemberLost(_player, ginfo.OpponentsMatchmakerRating); - at->SaveToDB(); - } + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), ginfo.OpponentsTeamRating); + at->MemberLost(_player, ginfo.OpponentsMatchmakerRating); + at->SaveToDB(); } - _player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0); - bgQueue.RemovePlayer(_player->GetGUID(), true); - // player left queue, we should update it - do not update Arena Queue - if (!ginfo.ArenaType) - sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); - SendPacket(&data); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId); - break; - default: - sLog->outError(LOG_FILTER_NETWORKIO, "Battleground port: unknown action %u", action); - break; + } + _player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0); + bgQueue.RemovePlayer(_player->GetGUID(), true); + // player left queue, we should update it - do not update Arena Queue + if (!ginfo.ArenaType) + sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); + SendPacket(&data); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId); } } diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 0cecd3d615a..876a0fc4463 100755 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -19,131 +19,116 @@ /* ----- Opcodes Not Used yet ----- -SMSG_CALENDAR_CLEAR_PENDING_ACTION SendCalendarClearPendingAction() -SMSG_CALENDAR_RAID_LOCKOUT_UPDATED SendCalendarRaidLockoutUpdated(InstanceSave const* save) - ------ Opcodes without Sniffs ----- -SMSG_CALENDAR_FILTER_GUILD [ for (... uint32(count) { packguid(???), uint8(???) } ] -SMSG_CALENDAR_ARENA_TEAM [ for (... uint32(count) { packguid(???), uint8(???) } ] -CMSG_CALENDAR_EVENT_INVITE_NOTES [ packguid(Invitee), uint64(inviteId), string(Text), Boolean(Unk) ] -SMSG_CALENDAR_EVENT_INVITE_NOTES [ uint32(unk1), uint32(unk2), uint32(unk3), uint32(unk4), uint32(unk5) ] +SMSG_CALENDAR_EVENT_INVITE_NOTES [ packguid(Invitee), uint64(inviteId), string(Text), Boolean(Unk) ] +?CMSG_CALENDAR_EVENT_INVITE_NOTES [ uint32(unk1), uint32(unk2), uint32(unk3), uint32(unk4), uint32(unk5) ] SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT [ uint64(inviteId), string(Text) ] -SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT [ Structure unkown ] +SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT [ uint64(eventId), uint32(eventTime), uint32(unkFlag), uint8(deletePending) ] +SMSG_CALENDAR_RAID_LOCKOUT_UPDATED SendCalendarRaidLockoutUpdated(InstanceSave const* save) -*/ +----- TODO ----- -#include "Common.h" -#include "WorldPacket.h" -#include "WorldSession.h" +Finish complains' handling - what to do with received complains and how to respond? +Find out what to do with all "not used yet" opcodes +Correct errors sending (event/invite not found, invites exceeded, event already passed, permissions etc.) +Fix locked events to be displayed properly and response time shouldn't be shown for people that haven't respond yet +Copied events should probably have a new owner + +*/ #include "InstanceSaveMgr.h" #include "Log.h" #include "Opcodes.h" #include "Player.h" +#include "SocialMgr.h" #include "CalendarMgr.h" #include "ObjectMgr.h" #include "ObjectAccessor.h" #include "DatabaseEnv.h" +#include "GuildMgr.h" +#include "ArenaTeamMgr.h" +#include "WorldSession.h" void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) { uint64 guid = _player->GetGUID(); sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid); - time_t cur_time = time_t(time(NULL)); + time_t currTime = time(NULL); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR [" UI64FMTD "]", guid); - WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Impossible to get the correct size without doing a double iteration of some elements + WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance - CalendarInviteIdList const& invites = sCalendarMgr->GetPlayerInvites(guid); + std::vector<CalendarInvite*> invites = sCalendarMgr->GetPlayerInvites(guid); data << uint32(invites.size()); - for (CalendarInviteIdList::const_iterator it = invites.begin(); it != invites.end(); ++it) + for (std::vector<CalendarInvite*>::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) { - CalendarInvite* invite = sCalendarMgr->GetInvite(*it); - CalendarEvent* calendarEvent = invite ? sCalendarMgr->GetEvent(invite->GetEventId()) : NULL; + data << uint64((*itr)->GetEventId()); + data << uint64((*itr)->GetInviteId()); + data << uint8((*itr)->GetStatus()); + data << uint8((*itr)->GetRank()); - if (calendarEvent) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId())) { - data << uint64(invite->GetEventId()); - data << uint64(invite->GetInviteId()); - data << uint8(invite->GetStatus()); - data << uint8(invite->GetRank()); - data << uint8(calendarEvent->GetGuildId() != 0); + data << uint8(calendarEvent->IsGuildEvent()); data.appendPackGUID(calendarEvent->GetCreatorGUID()); } else { - sLog->outError(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR: No Invite found with id [" UI64FMTD "]", *it); - data << uint64(0); - data << uint64(0); - data << uint8(0); data << uint8(0); - data << uint8(0); - data.appendPackGUID(0); + data.appendPackGUID((*itr)->GetSenderGUID()); } } - CalendarEventIdList const& events = sCalendarMgr->GetPlayerEvents(guid); - data << uint32(events.size()); - for (CalendarEventIdList::const_iterator it = events.begin(); it != events.end(); ++it) + CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid); + data << uint32(playerEvents.size()); + for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr) { - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(*it)) - { - data << uint64(*it); - data << calendarEvent->GetTitle(); - data << uint32(calendarEvent->GetType()); - data.AppendPackedTime(calendarEvent->GetTime()); - data << uint32(calendarEvent->GetFlags()); - data << uint32(calendarEvent->GetDungeonId()); - data.appendPackGUID(calendarEvent->GetCreatorGUID()); - } - else - { - sLog->outError(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR: No Event found with id [" UI64FMTD "]", *it); - data << uint64(0); - data << uint8(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data.appendPackGUID(0); - } + CalendarEvent* calendarEvent = *itr; + + data << uint64(calendarEvent->GetEventId()); + data << calendarEvent->GetTitle(); + data << uint32(calendarEvent->GetType()); + data.AppendPackedTime(calendarEvent->GetEventTime()); + data << uint32(calendarEvent->GetFlags()); + data << int32(calendarEvent->GetDungeonId()); + data.appendPackGUID(calendarEvent->GetCreatorGUID()); } - data << uint32(cur_time); // server time - data.AppendPackedTime(cur_time); // server time - - uint32 counter = 0; - size_t p_counter = data.wpos(); - data << uint32(counter); // instance save count + data << uint32(currTime); // server time + data.AppendPackedTime(currTime); // zone time + ByteBuffer dataBuffer; + uint32 boundCounter = 0; for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) - for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr) + { + Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i)); + for (Player::BoundInstancesMap::const_iterator itr = boundInstances.begin(); itr != boundInstances.end(); ++itr) + { if (itr->second.perm) { InstanceSave const* save = itr->second.save; - data << uint32(save->GetMapId()); - data << uint32(save->GetDifficulty()); - data << uint32(save->GetResetTime() - cur_time); - data << uint64(save->GetInstanceId()); // instance save id as unique instance copy id - ++counter; + dataBuffer << uint32(save->GetMapId()); + dataBuffer << uint32(save->GetDifficulty()); + dataBuffer << uint32(save->GetResetTime() - currTime); + dataBuffer << uint64(save->GetInstanceId()); // instance save id as unique instance copy id + ++boundCounter; } + } + } - data.put<uint32>(p_counter, counter); - - data << uint32(1135753200); // unk (28.12.2005 07:00) + data << uint32(boundCounter); + data.append(dataBuffer); - counter = 0; - p_counter = data.wpos(); - data << uint32(counter); // raid reset count + data << uint32(1135753200); // Constant date, unk (28.12.2005 07:00) + // Reuse variables + boundCounter = 0; std::set<uint32> sentMaps; + dataBuffer.clear(); ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap(); for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr) { uint32 mapId = PAIR32_LOPART(itr->first); - if (sentMaps.find(mapId) != sentMaps.end()) continue; @@ -153,12 +138,14 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) sentMaps.insert(mapId); - data << uint32(mapId); - data << uint32(itr->second - cur_time); - data << uint32(mapEntry->unk_time); - ++counter; + dataBuffer << int32(mapId); + dataBuffer << int32(itr->second - currTime); + dataBuffer << int32(0); // Never seen anything else in sniffs - still unknown + ++boundCounter; } - data.put<uint32>(p_counter, counter); + + data << uint32(boundCounter); + data.append(dataBuffer); // TODO: Fix this, how we do know how many and what holidays to send? uint32 holidayCount = 0; @@ -174,7 +161,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) data << uint32(holiday->CalendarFilterType); // m_calendarFilterType for (uint8 j = 0; j < MAX_HOLIDAY_DATES; ++j) - data << uint32(holiday->Date[j]); // 26 * m_date + data << uint32(holiday->Date[j]); // 26 * m_date -- WritePackedTime ? for (uint8 j = 0; j < MAX_HOLIDAY_DURATIONS; ++j) data << uint32(holiday->Duration[j]); // 10 * m_duration @@ -193,133 +180,114 @@ void WorldSession::HandleCalendarGetEvent(WorldPacket& recvData) uint64 eventId; recvData >> eventId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_EVENT. Event: [" + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_EVENT. Player [" UI64FMTD "] Event [" UI64FMTD "]", _player->GetGUID(), eventId); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) - SendCalendarEvent(*calendarEvent, CALENDAR_SENDTYPE_GET); + sCalendarMgr->SendCalendarEvent(_player->GetGUID(), *calendarEvent, CALENDAR_SENDTYPE_GET); + else + sCalendarMgr->SendCalendarCommandResult(_player->GetGUID(), CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarGuildFilter(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GUILD_FILTER [" UI64FMTD "]", _player->GetGUID()); - int32 unk1, unk2, unk3; - recvData >> unk1; - recvData >> unk2; - recvData >> unk3; + uint32 minLevel; + uint32 maxLevel; + uint32 minRank; + + recvData >> minLevel >> maxLevel >> minRank; + + if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId())) + guild->MassInviteToEvent(this, minLevel, maxLevel, minRank); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Calendar: CMSG_CALENDAR_GUILD_FILTER - unk1: %d unk2: %d unk3: %d", unk1, unk2, unk3); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GUILD_FILTER: Min level [%d], Max level [%d], Min rank [%d]", minLevel, maxLevel, minRank); } void WorldSession::HandleCalendarArenaTeam(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_ARENA_TEAM [" UI64FMTD "]", _player->GetGUID()); - int32 unk1; - recvData >> unk1; + uint32 arenaTeamId; + recvData >> arenaTeamId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "Calendar: CMSG_CALENDAR_ARENA_TEAM - unk1: %d", unk1); + if (ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(arenaTeamId)) + team->MassInviteToEvent(this); } void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); + std::string title; std::string description; uint8 type; - bool repeatable; + uint8 repeatable; uint32 maxInvites; int32 dungeonId; uint32 eventPackedTime; uint32 unkPackedTime; uint32 flags; - uint64 inviteId = 0; - uint64 invitee = 0; - uint8 status; - uint8 rank; - recvData >> title >> description >> type >> repeatable >> maxInvites; - recvData >> dungeonId; + recvData >> title >> description >> type >> repeatable >> maxInvites >> dungeonId; recvData.ReadPackedTime(eventPackedTime); recvData.ReadPackedTime(unkPackedTime); recvData >> flags; - if (!(flags & CALENDAR_FLAG_WITHOUT_INVITES)) + CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId, + time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description); + + if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement()) + if (Player* creator = ObjectAccessor::FindPlayer(guid)) + calendarEvent->SetGuildId(creator->GetGuildId()); + + if (calendarEvent->IsGuildAnnouncement()) + { + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(0, calendarEvent->GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->AddInvite(calendarEvent, invite); + } + else { uint32 inviteCount; recvData >> inviteCount; - recvData.readPackGUID(invitee); - recvData >> status >> rank; - if (inviteCount != 1 || invitee != guid) + for (uint32 i = 0; i < inviteCount; ++i) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandleCalendarAddEvent: [" UI64FMTD - "]: More than one invite (%d) or Invitee [" UI64FMTD - "] differs", guid, inviteCount, invitee); - return; + uint64 invitee = 0; + uint8 status = 0; + uint8 rank = 0; + recvData.readPackGUID(invitee); + recvData >> status >> rank; + + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); + sCalendarMgr->AddInvite(calendarEvent, invite); } - - inviteId = sCalendarMgr->GetFreeInviteId(); - } - else - { - inviteId = 0; - status = CALENDAR_STATUS_NO_OWNER; - rank = CALENDAR_RANK_PLAYER; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_ADD_EVENT: [" UI64FMTD "] " - "Title %s, Description %s, type %u, Repeatable %u, MaxInvites %u, " - "Dungeon ID %d, Time %u, Time2 %u, Flags %u, Invitee [" UI64FMTD "] " - "Status %d, Rank %d", guid, title.c_str(), description.c_str(), - type, repeatable, maxInvites, dungeonId, eventPackedTime, - unkPackedTime, flags, invitee, status, rank); - - CalendarAction action; - - action.SetAction(CALENDAR_ACTION_ADD_EVENT); - action.SetPlayer(_player); - action.Event.SetEventId(sCalendarMgr->GetFreeEventId()); - action.Event.SetCreatorGUID(guid); - action.Event.SetType((CalendarEventType) type); - action.Event.SetFlags(flags); - action.Event.SetTime(eventPackedTime); - action.Event.SetTimeZoneTime(unkPackedTime); - action.Event.SetRepeatable(repeatable); - action.Event.SetMaxInvites(maxInvites); - action.Event.SetDungeonId(dungeonId); - action.Event.SetGuildId((flags & CALENDAR_FLAG_GUILD_ONLY) ? GetPlayer()->GetGuildId() : 0); - action.Event.SetTitle(title); - action.Event.SetDescription(description); - action.Event.AddInvite(inviteId); - action.Invite.SetEventId(action.Event.GetEventId()); - action.Invite.SetInviteId(inviteId); - action.Invite.SetInvitee(invitee); - action.Invite.SetStatus((CalendarInviteStatus) status); - action.Invite.SetRank((CalendarModerationRank) rank); - action.Invite.SetSenderGUID(guid); - - sCalendarMgr->AddAction(action); + sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD); } void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); + time_t oldEventTime; + uint64 eventId; uint64 inviteId; std::string title; std::string description; uint8 type; - bool repeatable; + uint8 repetitionType; uint32 maxInvites; int32 dungeonId; uint32 eventPackedTime; uint32 timeZoneTime; uint32 flags; - recvData >> eventId >> inviteId >> title >> description >> type; - recvData >> repeatable >> maxInvites >> dungeonId; + recvData >> eventId >> inviteId >> title >> description >> type >> repetitionType >> maxInvites >> dungeonId; recvData.ReadPackedTime(eventPackedTime); recvData.ReadPackedTime(timeZoneTime); recvData >> flags; @@ -328,46 +296,37 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u " "Repeatable %u, MaxInvites %u, Dungeon ID %d, Time %u " "Time2 %u, Flags %u", guid, eventId, inviteId, title.c_str(), - description.c_str(), type, repeatable, maxInvites, dungeonId, + description.c_str(), type, repetitionType, maxInvites, dungeonId, eventPackedTime, timeZoneTime, flags); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_EVENT); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Event.SetEventId(eventId); - action.Event.SetType((CalendarEventType) type); - action.Event.SetFlags((CalendarFlags) flags); - action.Event.SetTime(eventPackedTime); - action.Event.SetTimeZoneTime(timeZoneTime); - action.Event.SetRepeatable(repeatable); - action.Event.SetDungeonId(dungeonId); - action.Event.SetTitle(title); - action.Event.SetDescription(description); - action.Event.SetMaxInvites(maxInvites); - - sCalendarMgr->AddAction(action); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + oldEventTime = calendarEvent->GetEventTime(); + + calendarEvent->SetType(CalendarEventType(type)); + calendarEvent->SetFlags(flags); + calendarEvent->SetEventTime(time_t(eventPackedTime)); + calendarEvent->SetTimeZoneTime(time_t(timeZoneTime)); // Not sure, seems constant from the little sniffs we have + calendarEvent->SetDungeonId(dungeonId); + calendarEvent->SetTitle(title); + calendarEvent->SetDescription(description); + + sCalendarMgr->UpdateEvent(calendarEvent); + sCalendarMgr->SendCalendarEventUpdateAlert(*calendarEvent, oldEventTime); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); uint64 eventId; - uint64 inviteId; - uint32 flags; - recvData >> eventId >> inviteId >> flags; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_REMOVE_EVENT [" UI64FMTD "], EventId [" UI64FMTD - "] inviteId [" UI64FMTD "] Flags?: %u", guid, eventId, inviteId, flags); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_REMOVE_EVENT); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Event.SetEventId(eventId); - action.Event.SetFlags((CalendarFlags) flags); + recvData >> eventId; + recvData.rfinish(); // Skip flags & invite ID, we don't use them - sCalendarMgr->AddAction(action); + sCalendarMgr->RemoveEvent(eventId, guid); } void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) @@ -382,94 +341,140 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_COPY_EVENT); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Event.SetEventId(eventId); - action.Event.SetTime(time); + if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(eventId)) + { + CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId()); + newEvent->SetEventTime(time_t(time)); + sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); + + std::vector<CalendarInvite*> invites = sCalendarMgr->GetEventInvites(eventId); + + for (std::vector<CalendarInvite*>::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) + sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId())); - sCalendarMgr->AddAction(action); + // should we change owner when somebody makes a copy of event owned by another person? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_INVITE"); + + uint64 playerGuid = _player->GetGUID(); + uint64 eventId; uint64 inviteId; std::string name; - uint8 status; - uint8 rank; - uint64 invitee = 0; - uint32 team = 0; + bool isPreInvite; + bool isGuildEvent; + + uint64 inviteeGuid = 0; + uint32 inviteeTeam = 0; + uint32 inviteeGuildId = 0; - recvData >> eventId >> inviteId >> name >> status >> rank; - if (Player* player = sObjectAccessor->FindPlayerByName(name)) + recvData >> eventId >> inviteId >> name >> isPreInvite >> isGuildEvent; + + if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) { - invitee = player->GetGUID(); - team = player->GetTeam(); + // Invitee is online + inviteeGuid = player->GetGUID(); + inviteeTeam = player->GetTeam(); + inviteeGuildId = player->GetGuildId(); } else { + // Invitee offline, get data from database PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME); stmt->setString(0, name); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { Field* fields = result->Fetch(); - invitee = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); - team = Player::TeamForRace(fields[1].GetUInt8()); + inviteeGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); + inviteeTeam = Player::TeamForRace(fields[1].GetUInt8()); + inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid); } } - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_INVITE [" UI64FMTD "], EventId [" - UI64FMTD "] InviteId [" UI64FMTD "] Name %s ([" UI64FMTD "]), status %u, " - "Rank %u", guid, eventId, inviteId, name.c_str(), invitee, status, rank); - - if (!invitee) + if (!inviteeGuid) { - SendCalendarCommandResult(CALENDAR_ERROR_PLAYER_NOT_FOUND); + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_PLAYER_NOT_FOUND); return; } - if (_player->GetTeam() != team && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR)) + if (_player->GetTeam() != inviteeTeam && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR)) { - SendCalendarCommandResult(CALENDAR_ERROR_NOT_ALLIED); + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NOT_ALLIED); return; } - // TODO: Check ignore, even if offline (db query) + if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = " UI64FMTD " AND friend = " UI64FMTD, inviteeGuid, playerGuid)) + { + Field* fields = result->Fetch(); + if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED) + { + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str()); + return; + } + } + + if (!isPreInvite) + { + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == inviteeGuildId) + { + // we can't invite guild members to guild events + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES); + return; + } - CalendarAction action; - action.SetAction(CALENDAR_ACTION_ADD_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInviteId(sCalendarMgr->GetFreeInviteId()); - action.Invite.SetSenderGUID(_player->GetGUID()); - action.Invite.SetInvitee(invitee); - action.Invite.SetRank((CalendarModerationRank) rank); - action.Invite.SetStatus((CalendarInviteStatus) status); + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->AddInvite(calendarEvent, invite); + } + else + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_EVENT_INVALID); + } + else + { + if (isGuildEvent && inviteeGuildId == _player->GetGuildId()) + { + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES); + return; + } - sCalendarMgr->AddAction(action); + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(inviteId, 0, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->SendCalendarEventInvite(*invite); + } } void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); uint64 eventId; - uint8 status; + bool tentative; + + recvData >> eventId >> tentative; + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_SIGNUP [" UI64FMTD "] EventId [" UI64FMTD "] Tentative %u", guid, eventId, tentative); - recvData >> eventId >> status; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_SIGNUP [" UI64FMTD "] EventId [" - UI64FMTD "] Status %u", guid, eventId, status); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_SIGNUP_TO_EVENT); - action.SetPlayer(_player); - action.SetExtraData(GetPlayer()->GetGuildId()); - action.Event.SetEventId(eventId); - action.Invite.SetStatus((CalendarInviteStatus) status); - sCalendarMgr->AddAction(action); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() != _player->GetGuildId()) + { + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD); + return; + } + + CalendarInviteStatus status = tentative ? CALENDAR_STATUS_TENTATIVE : CALENDAR_STATUS_SIGNED_UP; + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, guid, guid, time(NULL), status, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->AddInvite(calendarEvent, invite); + sCalendarMgr->SendCalendarClearPendingAction(guid); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) @@ -477,22 +482,36 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) uint64 guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; - uint8 status; + uint32 status; recvData >> eventId >> inviteId >> status; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_RSVP [" UI64FMTD"] EventId [" UI64FMTD "], InviteId [" UI64FMTD "], status %u", guid, eventId, inviteId, status); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetStatus((CalendarInviteStatus) status); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + // i think we still should be able to remove self from locked events + if (status != CALENDAR_STATUS_REMOVED && calendarEvent->GetFlags() & CALENDAR_FLAG_INVITES_LOCKED) + { + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_LOCKED); + return; + } + + if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + { + invite->SetStatus(CalendarInviteStatus(status)); + invite->SetStatusTime(time(NULL)); - sCalendarMgr->AddAction(action); + sCalendarMgr->UpdateInvite(invite); + sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); + sCalendarMgr->SendCalendarClearPendingAction(guid); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData) @@ -500,26 +519,29 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData) uint64 guid = _player->GetGUID(); uint64 invitee; uint64 eventId; - uint64 owninviteId; + uint64 ownerInviteId; // isn't it sender's inviteId? uint64 inviteId; recvData.readPackGUID(invitee); - recvData >> inviteId >> owninviteId >> eventId; + recvData >> inviteId >> ownerInviteId >> eventId; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_REMOVE_INVITE [" - UI64FMTD "] EventId [" UI64FMTD "], OwnInviteId [" + UI64FMTD "] EventId [" UI64FMTD "], ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" UI64FMTD "])", - guid, eventId, owninviteId, invitee, inviteId); + guid, eventId, ownerInviteId, invitee, inviteId); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_REMOVE_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(owninviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInvitee(invitee); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (calendarEvent->GetCreatorGUID() == invitee) + { + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_DELETE_CREATOR_FAILED); + return; + } - sCalendarMgr->AddAction(action); + sCalendarMgr->RemoveInvite(inviteId, eventId, guid); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); } void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) @@ -528,25 +550,32 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) uint64 invitee; uint64 eventId; uint64 inviteId; - uint64 owninviteId; + uint64 ownerInviteId; // isn't it sender's inviteId? uint8 status; recvData.readPackGUID(invitee); - recvData >> eventId >> inviteId >> owninviteId >> status; + recvData >> eventId >> inviteId >> ownerInviteId >> status; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_STATUS [" UI64FMTD"] EventId [" - UI64FMTD "] OwnInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" - UI64FMTD "], status %u", guid, eventId, owninviteId, invitee, inviteId, status); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(owninviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInvitee(invitee); - action.Invite.SetStatus((CalendarInviteStatus) status); - - sCalendarMgr->AddAction(action); + UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" + UI64FMTD "], status %u", guid, eventId, ownerInviteId, invitee, inviteId, status); + + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + { + invite->SetStatus((CalendarInviteStatus)status); + // not sure if we should set response time when moderator changes invite status + //invite->SetStatusTime(time(NULL)); + + sCalendarMgr->UpdateInvite(invite); + sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); + sCalendarMgr->SendCalendarClearPendingAction(invitee); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData) @@ -555,25 +584,28 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData) uint64 invitee; uint64 eventId; uint64 inviteId; - uint64 owninviteId; - uint8 status; + uint64 ownerInviteId; // isn't it sender's inviteId? + uint8 rank; recvData.readPackGUID(invitee); - recvData >> eventId >> inviteId >> owninviteId >> status; + recvData >> eventId >> inviteId >> ownerInviteId >> rank; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [" UI64FMTD "] EventId [" - UI64FMTD "] OwnInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" - UI64FMTD "], status %u", guid, eventId, owninviteId, invitee, inviteId, status); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(owninviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInvitee(invitee); - action.Invite.SetStatus((CalendarInviteStatus) status); - - sCalendarMgr->AddAction(action); + UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" + UI64FMTD "], rank %u", guid, eventId, ownerInviteId, invitee, inviteId, rank); + + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + { + invite->SetRank(CalendarModerationRank(rank)); + sCalendarMgr->UpdateInvite(invite); + sCalendarMgr->SendCalendarEventModeratorStatusAlert(*calendarEvent, *invite); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarComplain(WorldPacket& recvData) @@ -585,6 +617,8 @@ void WorldSession::HandleCalendarComplain(WorldPacket& recvData) recvData >> eventId >> complainGUID; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COMPLAIN [" UI64FMTD "] EventId [" UI64FMTD "] guid [" UI64FMTD "]", guid, eventId, complainGUID); + + // what to do with complains? } void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recvData*/) @@ -600,279 +634,25 @@ void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recvData*/) SendPacket(&data); } -// ----------------------------------- SEND ------------------------------------ - -void WorldSession::SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType) -{ - uint64 eventId = calendarEvent.GetEventId(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_EVENT [" UI64FMTD "] EventId [" - UI64FMTD "] SendType %u", _player->GetGUID(), eventId, sendEventType); - - WorldPacket data(SMSG_CALENDAR_SEND_EVENT); - data << uint8(sendEventType); - data.appendPackGUID(calendarEvent.GetCreatorGUID()); - data << uint64(eventId); - data << calendarEvent.GetTitle(); - data << calendarEvent.GetDescription(); - data << uint8(calendarEvent.GetType()); - data << uint8(calendarEvent.GetRepeatable()); - data << uint32(calendarEvent.GetMaxInvites()); - data << int32(calendarEvent.GetDungeonId()); - data << uint32(calendarEvent.GetFlags()); - data.AppendPackedTime(calendarEvent.GetTime()); - data.AppendPackedTime(calendarEvent.GetTimeZoneTime()); - data << uint32(calendarEvent.GetGuildId()); - - CalendarInviteIdList const& invites = calendarEvent.GetInviteIdList(); - data << uint32(invites.size()); - for (CalendarInviteIdList::const_iterator it = invites.begin(); it != invites.end(); ++it) - { - if (CalendarInvite* invite = sCalendarMgr->GetInvite(*it)) - { - uint64 guid = invite->GetInvitee(); - Player* player = ObjectAccessor::FindPlayer(guid); - uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(guid); - - data.appendPackGUID(guid); - data << uint8(level); - data << uint8(invite->GetStatus()); - data << uint8(invite->GetRank()); - data << uint8(calendarEvent.GetGuildId() != 0); - data << uint64(invite->GetInviteId()); - data << uint32(invite->GetStatusTime()); - data << invite->GetText(); - } - else - { - data.appendPackGUID(_player->GetGUID()); - data << uint8(0) << uint8(0) << uint8(0) << uint8(0) - << uint64(0) << uint32(0) << uint8(0); - - sLog->outError(LOG_FILTER_NETWORKIO, "SendCalendarEvent: No Invite found with id [" UI64FMTD "]", *it); - } - } - SendPacket(&data); -} - -void WorldSession::SendCalendarEventInvite(CalendarInvite const& invite, bool pending) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = invite.GetEventId(); - uint64 inviteId = invite.GetInviteId(); - uint64 invitee = invite.GetInvitee(); - uint8 status = invite.GetStatus(); - uint32 statusTime = invite.GetStatusTime(); - Player* player = ObjectAccessor::FindPlayer(invitee); - uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(invitee); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE [" UI64FMTD "] EventId [" - UI64FMTD "] InviteId [" UI64FMTD "] Invitee [" UI64FMTD "] " - " Level %u, Status %u, StatusTime %u" , guid, eventId, inviteId, - invitee, level, status, statusTime); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1); - data.appendPackGUID(invitee); - data << uint64(eventId); - data << uint64(inviteId); - data << uint8(level); - data << uint8(status); - if (statusTime) - data << uint8(1) << uint32(statusTime); - else - data << uint8(0); - data << uint8(pending); - - SendPacket(&data); -} - -void WorldSession::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint64 inviteId = invite.GetInviteId(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_ALERT [" UI64FMTD "] EventId [" - UI64FMTD "] InviteId [" UI64FMTD "]", guid, eventId, inviteId); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT); - data << uint64(eventId); - data << calendarEvent.GetTitle().c_str(); - data.AppendPackedTime(calendarEvent.GetTime()); - data << uint32(calendarEvent.GetFlags()); - data << uint32(calendarEvent.GetType()); - data << uint32(calendarEvent.GetDungeonId()); - data << uint64(inviteId); - data << uint8(invite.GetStatus()); - data << uint8(invite.GetRank()); - data.appendPackGUID(calendarEvent.GetCreatorGUID()); - data.appendPackGUID(invite.GetSenderGUID()); - SendPacket(&data); -} - -void WorldSession::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType) +void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_UPDATED_ALERT [" - UI64FMTD "] EventId [" UI64FMTD "]", guid, eventId); - - - WorldPacket data(SMSG_CALENDAR_EVENT_UPDATED_ALERT, 1 + 8 + 4 + 4 + 4 + 1 + 4 + - calendarEvent.GetTitle().size() + calendarEvent.GetDescription().size() + 1 + 4 + 4); - data << uint8(sendEventType); - data << uint64(eventId); - data.AppendPackedTime(calendarEvent.GetTime()); - data << uint32(calendarEvent.GetFlags()); - data.AppendPackedTime(calendarEvent.GetTime()); - data << uint8(calendarEvent.GetType()); - data << uint32(calendarEvent.GetDungeonId()); - data << calendarEvent.GetTitle().c_str(); - data << calendarEvent.GetDescription().c_str(); - data << uint8(calendarEvent.GetRepeatable()); - data << uint32(calendarEvent.GetMaxInvites()); - data << uint32(0); // FIXME - SendPacket(&data); -} - -void WorldSession::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint32 eventTime = calendarEvent.GetTime(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_REMOVED_ALERT [" UI64FMTD "] EventId [" - UI64FMTD "] Time %u", guid, eventId, eventTime); - - WorldPacket data(SMSG_CALENDAR_EVENT_REMOVED_ALERT, 1 + 8 + 1); - data << uint8(1); // FIXME: If true does not SignalEvent(EVENT_CALENDAR_ACTION_PENDING) - data << uint64(eventId); - data.AppendPackedTime(eventTime); - SendPacket(&data); -} - -void WorldSession::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint64 inviteId = invite.GetInviteId(); - uint64 invitee = invite.GetInvitee(); - uint32 eventTime = calendarEvent.GetTime(); - uint32 flags = calendarEvent.GetFlags(); - uint8 status = invite.GetStatus(); - uint8 rank = invite.GetRank(); - uint32 statusTime = invite.GetStatusTime(); - - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_STATUS [" UI64FMTD "] EventId [" - UI64FMTD "] InviteId [" UI64FMTD "] Invitee [" UI64FMTD "] Time %u " - "Flags %u, Status %u, Rank %u, StatusTime %u", - guid, eventId, inviteId, invitee, eventTime, flags, status, rank, - statusTime); - - WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); - data.appendPackGUID(invitee); - data << uint64(eventId); - data.AppendPackedTime(eventTime); - data << uint32(flags); - data << uint8(status); - data << uint8(rank); - data.AppendPackedTime(statusTime); - SendPacket(&data); -} - -void WorldSession::SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = invite.GetEventId(); - uint64 invitee = invite.GetInvitee(); - uint8 status = invite.GetStatus(); - - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT [" UI64FMTD - "] Invitee [" UI64FMTD "] EventId [" UI64FMTD "] Status %u ", guid, - invitee, eventId, status); - - - WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1); - data.appendPackGUID(invitee); - data << uint64(eventId); - data << uint8(status); - data << uint8(1); // FIXME - SendPacket(&data); -} - -void WorldSession::SendCalendarEventInviteRemoveAlert(CalendarEvent const& calendarEvent, CalendarInviteStatus status) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint32 eventTime = calendarEvent.GetTime(); - uint32 flags = calendarEvent.GetFlags(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT [" - UI64FMTD "] EventId [" UI64FMTD "] Time %u, Flags %u, Status %u", - guid, eventId, eventTime, flags, status); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 8 + 4 + 4 + 1); - data << uint64(eventId); - data.AppendPackedTime(eventTime); - data << uint32(flags); - data << uint8(status); - SendPacket(&data); -} - -void WorldSession::SendCalendarEventInviteRemove(CalendarInvite const& invite, uint32 flags) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = invite.GetEventId(); - uint64 invitee = invite.GetInvitee(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_REMOVED [" - UI64FMTD "] Invitee [" UI64FMTD "] EventId [" UI64FMTD - "] Flags %u", guid, invitee, eventId, flags); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1); - data.appendPackGUID(invitee); - data << uint32(eventId); - data << uint32(flags); - data << uint8(1); // FIXME - SendPacket(&data); -} - -void WorldSession::SendCalendarClearPendingAction() -{ - uint64 guid = _player->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_CLEAR_PENDING_ACTION [" UI64FMTD "]", guid); + uint32 mapId, difficulty; + uint8 toggleExtend; + recvData >> mapId >> difficulty>> toggleExtend; + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SET_SAVED_INSTANCE_EXTEND - MapId: %u, Difficulty: %u, ToggleExtend: %s", mapId, difficulty, toggleExtend ? "On" : "Off"); + + /* + InstancePlayerBind* instanceBind = _player->GetBoundInstance(mapId, Difficulty(difficulty)); + if (!instanceBind || !instanceBind->save) + return; - WorldPacket data(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0); - SendPacket(&data); + InstanceSave* save = instanceBind->save; + // http://www.wowwiki.com/Instance_Lock_Extension + // SendCalendarRaidLockoutUpdated(save); + */ } -void WorldSession::SendCalendarCommandResult(CalendarError err, char const* param /*= NULL*/) -{ - uint64 guid = _player->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_COMMAND_RESULT [" UI64FMTD "] Value: %u", guid, err); - - WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0); - data << uint32(0); - data << uint8(0); - switch (err) - { - case CALENDAR_ERROR_OTHER_INVITES_EXCEEDED: - case CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S: - case CALENDAR_ERROR_IGNORING_YOU_S: - data << param; - break; - default: - data << uint8(0); - break; - } - - data << uint32(err); - - SendPacket(&data); -} +// ----------------------------------- SEND ------------------------------------ void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add) { @@ -902,13 +682,13 @@ void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save) sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_RAID_LOCKOUT_UPDATED [" UI64FMTD "] Map: %u, Difficulty %u", guid, save->GetMapId(), save->GetDifficulty()); - time_t cur_time = time_t(time(NULL)); + time_t currTime = time(NULL); WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8); - data.AppendPackedTime(cur_time); + data.AppendPackedTime(currTime); data << uint32(save->GetMapId()); data << uint32(save->GetDifficulty()); data << uint32(0); // Amount of seconds that has changed to the reset time - data << uint32(save->GetResetTime() - cur_time); + data << uint32(save->GetResetTime() - currTime); SendPacket(&data); } diff --git a/src/server/game/Handlers/ChannelHandler.cpp b/src/server/game/Handlers/ChannelHandler.cpp index a65e3830a81..462bc7fff0b 100755 --- a/src/server/game/Handlers/ChannelHandler.cpp +++ b/src/server/game/Handlers/ChannelHandler.cpp @@ -18,252 +18,256 @@ #include "ObjectMgr.h" // for normalizePlayerName #include "ChannelMgr.h" +#include "Player.h" void WorldSession::HandleJoinChannel(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - - uint32 channel_id; + uint32 channelId; uint8 unknown1, unknown2; - std::string channelname, pass; + std::string channelName, password; + + recvPacket >> channelId >> unknown1 >> unknown2 >> channelName >> password; - recvPacket >> channel_id; - recvPacket >> unknown1 >> unknown2; - recvPacket >> channelname; - recvPacket >> pass; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_JOIN_CHANNEL %s Channel: %u, unk1: %u, unk2: %u, channel: %s, password: %s", + GetPlayerInfo().c_str(), channelId, unknown1, unknown2, channelName.c_str(), password.c_str()); - if (channel_id) + if (channelId) { - ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(channel_id); + ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(channelId); if (!channel) return; - AreaTableEntry const* current_zone = GetAreaEntryByAreaID(_player->GetZoneId()); - if (!current_zone) - return; - - if (!_player->CanJoinConstantChannelInZone(channel, current_zone)) + AreaTableEntry const* zone = GetAreaEntryByAreaID(GetPlayer()->GetZoneId()); + if (!zone || !GetPlayer()->CanJoinConstantChannelInZone(channel, zone)) return; } - if (channelname.empty()) + if (channelName.empty()) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) { - cMgr->setTeam(_player->GetTeam()); - if (Channel* chn = cMgr->GetJoinChannel(channelname, channel_id)) - chn->Join(_player->GetGUID(), pass.c_str()); + cMgr->setTeam(GetPlayer()->GetTeam()); + if (Channel* channel = cMgr->GetJoinChannel(channelName, channelId)) + channel->JoinChannel(GetPlayer(), password); } } void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - uint32 unk; - std::string channelname; - recvPacket >> unk; // channel id? - recvPacket >> channelname; + std::string channelName; + recvPacket >> unk >> channelName; - if (channelname.empty()) + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_LEAVE_CHANNEL %s Channel: %s, unk1: %u", + GetPlayerInfo().c_str(), channelName.c_str(), unk); + + if (channelName.empty()) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) { - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->Leave(_player->GetGUID(), true); - cMgr->LeftChannel(channelname); + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->LeaveChannel(GetPlayer(), true); + cMgr->LeftChannel(channelName); } } void WorldSession::HandleChannelList(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname; - recvPacket >> channelname; + std::string channelName; + recvPacket >> channelName; + + sLog->outDebug(LOG_FILTER_CHATSYS, "%s %s Channel: %s", + recvPacket.GetOpcode() == CMSG_CHANNEL_DISPLAY_LIST ? "CMSG_CHANNEL_DISPLAY_LIST" : "CMSG_CHANNEL_LIST", + GetPlayerInfo().c_str(), channelName.c_str()); - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->List(_player); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->List(GetPlayer()); } void WorldSession::HandleChannelPassword(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, pass; - recvPacket >> channelname; + std::string channelName, password; + recvPacket >> channelName >> password; - recvPacket >> pass; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_PASSWORD %s Channel: %s, Password: %s", + GetPlayerInfo().c_str(), channelName.c_str(), password.c_str()); - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->Password(_player->GetGUID(), pass.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->Password(GetPlayer(), password); } void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, newp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> newp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_SET_OWNER %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(newp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->SetOwner(_player->GetGUID(), newp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->SetOwner(GetPlayer(), targetName); } void WorldSession::HandleChannelOwner(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname; - recvPacket >> channelname; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->SendWhoOwner(_player->GetGUID()); + std::string channelName; + recvPacket >> channelName; + + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_OWNER %s Channel: %s", + GetPlayerInfo().c_str(), channelName.c_str()); + + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->SendWhoOwner(GetPlayer()->GetGUID()); } void WorldSession::HandleChannelModerator(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_MODERATOR %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(otp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->SetModerator(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->SetModerator(GetPlayer(), targetName); } void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_UNMODERATOR %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(otp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->UnsetModerator(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->UnsetModerator(GetPlayer(), targetName); } void WorldSession::HandleChannelMute(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_MUTE %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(otp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->SetMute(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->SetMute(GetPlayer(), targetName); } void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_UNMUTE %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(otp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->UnsetMute(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->UnsetMute(GetPlayer(), targetName); } void WorldSession::HandleChannelInvite(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_INVITE %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(otp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->Invite(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->Invite(GetPlayer(), targetName); } void WorldSession::HandleChannelKick(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; - if (!normalizePlayerName(otp)) + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_KICK %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); + + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->Kick(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->Kick(GetPlayer(), targetName); } void WorldSession::HandleChannelBan(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_BAN %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(otp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->Ban(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->Ban(GetPlayer(), targetName); } void WorldSession::HandleChannelUnban(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - - std::string channelname, otp; - recvPacket >> channelname; + std::string channelName, targetName; + recvPacket >> channelName >> targetName; - recvPacket >> otp; + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_UNBAN %s Channel: %s, Target: %s", + GetPlayerInfo().c_str(), channelName.c_str(), targetName.c_str()); - if (!normalizePlayerName(otp)) + if (!normalizePlayerName(targetName)) return; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->UnBan(_player->GetGUID(), otp.c_str()); + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->UnBan(GetPlayer(), targetName); } void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname; - recvPacket >> channelname; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->Announce(_player->GetGUID()); + std::string channelName; + recvPacket >> channelName; + + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_CHANNEL_ANNOUNCEMENTS %s Channel: %s", + GetPlayerInfo().c_str(), channelName.c_str()); + + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->Announce(GetPlayer()); } void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket) @@ -274,17 +278,23 @@ void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket) void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname; - recvPacket >> channelname; - if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) + std::string channelName; + recvPacket >> channelName; + + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_GET_CHANNEL_MEMBER_COUNT %s Channel: %s", + GetPlayerInfo().c_str(), channelName.c_str()); + + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam())) { - if (Channel* chn = cMgr->GetChannel(channelname, _player)) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) { - WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size()+1+1+4); - data << chn->GetName(); - data << uint8(chn->GetFlags()); - data << uint32(chn->GetNumPlayers()); + sLog->outDebug(LOG_FILTER_CHATSYS, "SMSG_CHANNEL_MEMBER_COUNT %s Channel: %s Count: %u", + GetPlayerInfo().c_str(), channelName.c_str(), channel->GetNumPlayers()); + + WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, channel->GetName().size() + 1 + 4); + data << channel->GetName(); + data << uint8(channel->GetFlags()); + data << uint32(channel->GetNumPlayers()); SendPacket(&data); } } @@ -292,10 +302,15 @@ void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket) void WorldSession::HandleSetChannelWatch(WorldPacket &recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); - std::string channelname; - recvPacket >> channelname; - /*if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) - if (Channel* chn = cMgr->GetChannel(channelname, _player)) - chn->JoinNotify(_player->GetGUID());*/ + std::string channelName; + recvPacket >> channelName; + + sLog->outDebug(LOG_FILTER_CHATSYS, "CMSG_SET_CHANNEL_WATCH %s Channel: %s", + GetPlayerInfo().c_str(), channelName.c_str()); + + /* + if (ChannelMgr* cMgr = channelMgr(GetPlayer()->GetTeam())) + if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer())) + channel->JoinNotify(GetPlayer()); + */ } diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 258878b1f87..0b01c796511 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -16,34 +16,37 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" -#include "ObjectAccessor.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "SystemConfig.h" -#include "World.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "DatabaseEnv.h" - +#include "AccountMgr.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "Battleground.h" +#include "CalendarMgr.h" #include "Chat.h" +#include "Common.h" +#include "DatabaseEnv.h" #include "Group.h" #include "Guild.h" +#include "GuildMgr.h" #include "Language.h" +#include "LFGMgr.h" #include "Log.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" #include "Opcodes.h" -#include "Player.h" +#include "Pet.h" #include "PlayerDump.h" +#include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" #include "SharedDefines.h" #include "SocialMgr.h" +#include "SystemConfig.h" #include "UpdateMask.h" #include "Util.h" -#include "ScriptMgr.h" -#include "Battleground.h" -#include "AccountMgr.h" -#include "LFGMgr.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" + class LoginQueryHolder : public SQLQueryHolder { @@ -726,6 +729,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recvData) sLog->outCharDump(dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str()); } + sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid); Player::DeleteFromDB(guid, GetAccountId()); WorldPacket data(SMSG_CHAR_DELETE, 1); @@ -772,7 +776,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) Player* pCurrChar = new Player(this); // for send server info and strings (config) - ChatHandler chH = ChatHandler(pCurrChar); + ChatHandler chH = ChatHandler(pCurrChar->GetSession()); // "GetAccountId() == db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools) if (!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder)) diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index 8b7fc5542ab..e4989816998 100755 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -114,7 +114,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) return; break; default: - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) sent a chatmessage with an invalid language/message type combination", + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) sent a chatmessage with an invalid language/message type combination", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); recvData.rfinish(); @@ -561,8 +561,8 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) // Only allow text-emotes for "dead" entities (feign death included) if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) break; - GetPlayer()->HandleEmoteCommand(emote_anim); - break; + GetPlayer()->HandleEmoteCommand(emote_anim); + break; } Unit* unit = ObjectAccessor::GetUnit(*_player, guid); diff --git a/src/server/game/Handlers/CombatHandler.cpp b/src/server/game/Handlers/CombatHandler.cpp index 1cd86afc6d2..d30164b2592 100755 --- a/src/server/game/Handlers/CombatHandler.cpp +++ b/src/server/game/Handlers/CombatHandler.cpp @@ -25,6 +25,8 @@ #include "ObjectDefines.h" #include "Vehicle.h" #include "VehicleDefines.h" +#include "Player.h" +#include "Opcodes.h" void WorldSession::HandleAttackSwingOpcode(WorldPacket& recvData) { diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index 223a5316c7a..8555b4a6a1f 100755 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -18,19 +18,20 @@ #include "Common.h" #include "DatabaseEnv.h" -#include "Opcodes.h" +#include "Group.h" +#include "GroupMgr.h" #include "Log.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" #include "ObjectMgr.h" -#include "GroupMgr.h" +#include "Opcodes.h" +#include "Pet.h" #include "Player.h" -#include "Group.h" #include "SocialMgr.h" -#include "Util.h" #include "SpellAuras.h" +#include "Util.h" #include "Vehicle.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" class Aura; diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 9926c75eb2a..3f33b60329b 100755 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -15,14 +15,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "WorldSession.h" -#include "WorldPacket.h" -#include "DBCStores.h" -#include "Player.h" -#include "Group.h" #include "LFGMgr.h" #include "ObjectMgr.h" -#include "GroupMgr.h" +#include "Group.h" +#include "Player.h" +#include "Opcodes.h" +#include "WorldPacket.h" +#include "WorldSession.h" void BuildPlayerLockDungeonBlock(WorldPacket& data, const LfgLockMap& lock) { @@ -59,11 +58,11 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) uint32 roles; recvData >> roles; - recvData.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0) + recvData.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0) recvData >> numDungeons; if (!numDungeons) { - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN %s no dungeons selected", GetPlayerInfo().c_str()); recvData.rfinish(); return; } @@ -72,14 +71,15 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) for (int8 i = 0; i < numDungeons; ++i) { recvData >> dungeon; - newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry + newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry } - recvData.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) } + recvData.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) } std::string comment; recvData >> comment; - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN %s roles: %u, Dungeons: %u, Comment: %s", + GetPlayerInfo().c_str(), roles, uint8(newDungeons.size()), comment.c_str()); sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); } @@ -89,7 +89,8 @@ void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/) uint64 guid = GetPlayer()->GetGUID(); uint64 gguid = grp ? grp->GetGUID() : guid; - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE %s in group: %u", + GetPlayerInfo().c_str(), grp ? 1 : 0); // Check cheating - only leader can leave the queue if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID()) @@ -98,28 +99,31 @@ void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/) void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recvData) { - uint32 lfgGroupID; // Internal lfgGroupID + uint32 lfgGroupID; // Internal lfgGroupID bool accept; // Accept to join? recvData >> lfgGroupID; recvData >> accept; - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PROPOSAL_RESULT %s proposal: %u accept: %u", + GetPlayerInfo().c_str(), lfgGroupID, accept ? 1 : 0); sLFGMgr->UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept); } void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recvData) { uint8 roles; - recvData >> roles; // Player Group Roles + recvData >> roles; // Player Group Roles uint64 guid = GetPlayer()->GetGUID(); Group* grp = GetPlayer()->GetGroup(); if (!grp) { - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES %s Not in group", + GetPlayerInfo().c_str()); return; } uint64 gguid = grp->GetGUID(); - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group %u, Player %s, Roles: %u", + GUID_LOPART(gguid), GetPlayerInfo().c_str(), roles); sLFGMgr->UpdateRoleCheck(gguid, guid, roles); } @@ -128,7 +132,8 @@ void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recvData) std::string comment; recvData >> comment; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT %s comment: %s", + GetPlayerInfo().c_str(), comment.c_str()); sLFGMgr->SetComment(guid, comment); } @@ -139,7 +144,8 @@ void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recvData) recvData >> agree; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE %s agree: %u", + GetPlayerInfo().c_str(), agree ? 1 : 0); sLFGMgr->UpdateBoot(guid, agree); } @@ -148,14 +154,16 @@ void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recvData) bool out; recvData >> out; - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_TELEPORT %s out: %u", + GetPlayerInfo().c_str(), out ? 1 : 0); sLFGMgr->TeleportPlayer(GetPlayer(), out, true); } void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST %s", + GetPlayerInfo().c_str()); // Get Random dungeons that can be done at a certain level and expansion LfgDungeonSet randomDungeons; @@ -176,7 +184,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData* uint32 rsize = uint32(randomDungeons.size()); uint32 lsize = uint32(lock.size()); - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_INFO %s", GetPlayerInfo().c_str()); WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4)); data << uint8(randomDungeons.size()); // Random Dungeon count @@ -234,7 +242,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData* void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST %s", GetPlayerInfo().c_str()); Group* grp = GetPlayer()->GetGroup(); if (!grp) @@ -259,7 +267,7 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData* for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PARTY_INFO %s", GetPlayerInfo().c_str()); WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size); BuildPartyLockDungeonBlock(data, lockMap); SendPacket(&data); @@ -269,7 +277,8 @@ void WorldSession::HandleLfrJoinOpcode(WorldPacket& recvData) { uint32 entry; // Raid id to search recvData >> entry; - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_JOIN %s dungeon entry: %u", + GetPlayerInfo().c_str(), entry); //SendLfrUpdateListOpcode(entry); } @@ -277,48 +286,64 @@ void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recvData) { uint32 dungeonId; // Raid id queue to leave recvData >> dungeonId; - sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_LEAVE %s dungeonId: %u", + GetPlayerInfo().c_str(), dungeonId); //sLFGMgr->LeaveLfr(GetPlayer(), dungeonId); } +void WorldSession::HandleLfgGetStatus(WorldPacket& /*recvData*/) +{ + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_GET_STATUS %s", GetPlayerInfo().c_str()); + + uint64 guid = GetPlayer()->GetGUID(); + LfgUpdateData updateData = sLFGMgr->GetLfgStatus(guid); + + if (GetPlayer()->GetGroup()) + { + SendLfgUpdateParty(updateData); + updateData.dungeons.clear(); + SendLfgUpdatePlayer(updateData); + } + else + { + SendLfgUpdatePlayer(updateData); + updateData.dungeons.clear(); + SendLfgUpdateParty(updateData); + } +} + void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) { bool queued = false; - bool extrainfo = false; - uint64 guid = GetPlayer()->GetGUID(); uint8 size = uint8(updateData.dungeons.size()); switch (updateData.updateType) { - case LFG_UPDATETYPE_JOIN_PROPOSAL: + case LFG_UPDATETYPE_JOIN_QUEUE: case LFG_UPDATETYPE_ADDED_TO_QUEUE: queued = true; - extrainfo = true; break; case LFG_UPDATETYPE_UPDATE_STATUS: - extrainfo = size > 0; - break; - case LFG_UPDATETYPE_PROPOSAL_BEGIN: - extrainfo = true; + queued = updateData.state == LFG_STATE_QUEUED; break; default: break; } - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); - WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); - data << uint8(updateData.updateType); // Lfg Update type - data << uint8(extrainfo); // Extra info - if (extrainfo) + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PLAYER %s updatetype: %u", + GetPlayerInfo().c_str(), updateData.updateType); + WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (size > 0 ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); + data << uint8(updateData.updateType); // Lfg Update type + data << uint8(size > 0); // Extra info + if (size) { - data << uint8(queued); // Join the queue - data << uint8(0); // unk - Always 0 - data << uint8(0); // unk - Always 0 + data << uint8(queued); // Join the queue + data << uint8(0); // unk - Always 0 + data << uint8(0); // unk - Always 0 data << uint8(size); - if (size) - for (LfgDungeonSet::const_iterator it = updateData.dungeons.begin(); it != updateData.dungeons.end(); ++it) - data << uint32(*it); + for (LfgDungeonSet::const_iterator it = updateData.dungeons.begin(); it != updateData.dungeons.end(); ++it) + data << uint32(*it); data << updateData.comment; } SendPacket(&data); @@ -327,51 +352,42 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) { bool join = false; - bool extrainfo = false; bool queued = false; - uint64 guid = GetPlayer()->GetGUID(); uint8 size = uint8(updateData.dungeons.size()); switch (updateData.updateType) { - case LFG_UPDATETYPE_JOIN_PROPOSAL: - extrainfo = true; - break; - case LFG_UPDATETYPE_ADDED_TO_QUEUE: - extrainfo = true; - join = true; + case LFG_UPDATETYPE_ADDED_TO_QUEUE: // Rolecheck Success queued = true; - break; - case LFG_UPDATETYPE_UPDATE_STATUS: - extrainfo = size > 0; - join = true; - queued = true; - break; + // no break on purpose case LFG_UPDATETYPE_PROPOSAL_BEGIN: - extrainfo = true; join = true; break; + case LFG_UPDATETYPE_UPDATE_STATUS: + join = updateData.state != LFG_STATE_ROLECHECK && updateData.state != LFG_STATE_NONE; + queued = updateData.state == LFG_STATE_QUEUED; + break; default: break; } - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); - WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); - data << uint8(updateData.updateType); // Lfg Update type - data << uint8(extrainfo); // Extra info - if (extrainfo) + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PARTY %s updatetype: %u", + GetPlayerInfo().c_str(), updateData.updateType); + WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (size > 0 ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); + data << uint8(updateData.updateType); // Lfg Update type + data << uint8(size > 0); // Extra info + if (size) { - data << uint8(join); // LFG Join - data << uint8(queued); // Join the queue - data << uint8(0); // unk - Always 0 - data << uint8(0); // unk - Always 0 + data << uint8(join); // LFG Join + data << uint8(queued); // Join the queue + data << uint8(0); // unk - Always 0 + data << uint8(0); // unk - Always 0 for (uint8 i = 0; i < 3; ++i) - data << uint8(0); // unk - Always 0 + data << uint8(0); // unk - Always 0 data << uint8(size); - if (size) - for (LfgDungeonSet::const_iterator it = updateData.dungeons.begin(); it != updateData.dungeons.end(); ++it) - data << uint32(*it); + for (LfgDungeonSet::const_iterator it = updateData.dungeons.begin(); it != updateData.dungeons.end(); ++it) + data << uint32(*it); data << updateData.comment; } SendPacket(&data); @@ -379,7 +395,8 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles) { - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHOSEN %s guid: %u roles: %u", + GetPlayerInfo().c_str(), GUID_LOPART(guid), roles); WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4); data << uint64(guid); // Guid @@ -396,7 +413,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck) else dungeons = roleCheck.dungeons; - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHECK_UPDATE %s", GetPlayerInfo().c_str()); WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1)); data << uint32(roleCheck.state); // Check result @@ -421,7 +438,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck) data << uint8(roles > 0); // Ready data << uint32(roles); // Roles Player* player = ObjectAccessor::FindPlayer(guid); - data << uint8(player ? player->getLevel() : 0); // Level + data << uint8(player ? player->getLevel() : 0); // Level for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it) { @@ -434,7 +451,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck) data << uint8(roles > 0); // Ready data << uint32(roles); // Roles player = ObjectAccessor::FindPlayer(guid); - data << uint8(player ? player->getLevel() : 0); // Level + data << uint8(player ? player->getLevel() : 0);// Level } } SendPacket(&data); @@ -446,7 +463,8 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT %s checkResult: %u checkValue: %u", + GetPlayerInfo().c_str(), joinData.result, joinData.state); WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size); data << uint32(joinData.result); // Check Result data << uint32(joinData.state); // Check Value @@ -457,8 +475,8 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData) { - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", - GetPlayer()->GetGUID(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS %s dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", + GetPlayerInfo().c_str(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4); data << uint32(queueData.dungeonId); // Dungeon @@ -481,7 +499,8 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr uint8 itemNum = uint8(quest ? quest->GetRewItemsCount() : 0); - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD %s rdungeonEntry: %u - sdungeonEntry: %u - done: %u", + GetPlayerInfo().c_str(), rdungeonEntry, sdungeonEntry, done); WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4)); data << uint32(rdungeonEntry); // Random Dungeon Finished data << uint32(sdungeonEntry); // Dungeon Finished @@ -522,8 +541,12 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot) ++agreeNum; } } - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", - guid, uint8(boot.inProgress), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), boot.victim, votesNum, agreeNum, secsleft, LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_BOOT_PROPOSAL_UPDATE %s inProgress: %u - " + "didVote: %u - agree: %u - victim: %u votes: %u - agrees: %u - left: %u - " + "needed: %u - reason %s", + GetPlayerInfo().c_str(), uint8(boot.inProgress), uint8(playerVote != LFG_ANSWER_PENDING), + uint8(playerVote == LFG_ANSWER_AGREE), GUID_LOPART(boot.victim), votesNum, agreeNum, + secsleft, LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); WorldPacket data(SMSG_LFG_BOOT_PROPOSAL_UPDATE, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length()); data << uint8(boot.inProgress); // Vote in progress data << uint8(playerVote != LFG_ANSWER_PENDING); // Did Vote @@ -544,7 +567,8 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p bool silent = !proposal.isNew && gguid == proposal.group; uint32 dungeonEntry = proposal.dungeonId; - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE %s state: %u", + GetPlayerInfo().c_str(), proposal.state); WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1)); // show random dungeon if player selected random dungeon and it's not lfg group @@ -577,18 +601,19 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p } else { - data << uint8(player.group == proposal.group); // In dungeon (silent) - data << uint8(player.group == gguid); // Same Group than player + data << uint8(player.group == proposal.group); // In dungeon (silent) + data << uint8(player.group == gguid); // Same Group than player } - data << uint8(player.accept != LFG_ANSWER_PENDING); // Answered - data << uint8(player.accept == LFG_ANSWER_AGREE); // Accepted + data << uint8(player.accept != LFG_ANSWER_PENDING);// Answered + data << uint8(player.accept == LFG_ANSWER_AGREE); // Accepted } SendPacket(&data); } void WorldSession::SendLfgLfrList(bool update) { - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_LFR_LIST %s update: %u", + GetPlayerInfo().c_str(), update ? 1 : 0); WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1); data << uint8(update); // In Lfg Queue? SendPacket(&data); @@ -596,14 +621,15 @@ void WorldSession::SendLfgLfrList(bool update) void WorldSession::SendLfgDisabled() { - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_DISABLED %s", GetPlayerInfo().c_str()); WorldPacket data(SMSG_LFG_DISABLED, 0); SendPacket(&data); } void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) { - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_OFFER_CONTINUE %s dungeon entry: %u", + GetPlayerInfo().c_str(), dungeonEntry); WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4); data << uint32(dungeonEntry); SendPacket(&data); @@ -611,48 +637,18 @@ void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) void WorldSession::SendLfgTeleportError(uint8 err) { - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_TELEPORT_DENIED %s reason: %u", + GetPlayerInfo().c_str(), err); WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4); data << uint32(err); // Error SendPacket(&data); } -void WorldSession::HandleLfgGetStatus(WorldPacket& /*recvData*/) -{ - uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_GET_STATUS [" UI64FMTD "]", guid); - - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); - LfgState state = sLFGMgr->GetLfgStatus(guid, updateData); - - if (state == LFG_STATE_NONE || updateData.dungeons.empty()) - { - SendLfgUpdatePlayer(updateData); - SendLfgUpdateParty(updateData); - return; - } - - if (state != LFG_STATE_QUEUED) - return; - - if (GetPlayer()->GetGroup()) - { - SendLfgUpdateParty(updateData); - updateData.dungeons.clear(); - SendLfgUpdatePlayer(updateData); - } - else - { - SendLfgUpdatePlayer(updateData); - updateData.dungeons.clear(); - SendLfgUpdateParty(updateData); - } -} - /* void WorldSession::SendLfrUpdateListOpcode(uint32 dungeonEntry) { - sLog->outDebug(LOG_FILTER_PACKETIO, "SMSG_LFG_UPDATE_LIST [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); + sLog->outDebug(LOG_FILTER_PACKETIO, "SMSG_LFG_UPDATE_LIST %s dungeon entry: %u", + GetPlayerInfo().c_str(), dungeonEntry); WorldPacket data(SMSG_LFG_UPDATE_LIST); SendPacket(&data); } diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 83deaaa1bc6..1c9719a210f 100755 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -17,18 +17,19 @@ */ #include "Common.h" -#include "WorldPacket.h" #include "Log.h" #include "Corpse.h" +#include "Creature.h" #include "GameObject.h" -#include "Player.h" -#include "ObjectAccessor.h" -#include "WorldSession.h" +#include "Group.h" #include "LootMgr.h" +#include "ObjectAccessor.h" #include "Object.h" -#include "Group.h" +#include "Opcodes.h" +#include "Player.h" #include "World.h" -#include "Util.h" +#include "WorldPacket.h" +#include "WorldSession.h" void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recvData) { diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index 5a7a3b52b56..cb3a6d920b8 100755 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -607,10 +607,8 @@ void WorldSession::HandleGetMailList(WorldPacket & recvData) case MAIL_CREATURE: case MAIL_GAMEOBJECT: case MAIL_AUCTION: - data << uint32((*itr)->sender); // creature/gameobject entry, auction id - break; - case MAIL_ITEM: // item entry (?) sender = "Unknown", NYI - data << uint32(0); // item entry + case MAIL_CALENDAR: + data << uint32((*itr)->sender); // creature/gameobject entry, auction id, calendar event id? break; } diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 8928a7c15a1..aa182a16d91 100755 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -888,7 +888,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) } if (player->isDebugAreaTriggers) - ChatHandler(player).PSendSysMessage(LANG_DEBUG_AREATRIGGER_REACHED, triggerId); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_DEBUG_AREATRIGGER_REACHED, triggerId); if (sScriptMgr->OnAreaTrigger(player, atEntry)) return; @@ -1382,25 +1382,21 @@ void WorldSession::HandleFarSightOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_FAR_SIGHT"); - uint8 apply; + bool apply; recvData >> apply; - switch (apply) + if (apply) { - case 0: - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player %u set vision to self", _player->GetGUIDLow()); - _player->SetSeer(_player); - break; - case 1: - sLog->outDebug(LOG_FILTER_NETWORKIO, "Added FarSight " UI64FMTD " to player %u", _player->GetUInt64Value(PLAYER_FARSIGHT), _player->GetGUIDLow()); - if (WorldObject* target = _player->GetViewpoint()) - _player->SetSeer(target); - else - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s requests non-existing seer " UI64FMTD, _player->GetName().c_str(), _player->GetUInt64Value(PLAYER_FARSIGHT)); - break; - default: - sLog->outDebug(LOG_FILTER_NETWORKIO, "Unhandled mode in CMSG_FAR_SIGHT: %u", apply); - return; + sLog->outDebug(LOG_FILTER_NETWORKIO, "Added FarSight " UI64FMTD " to player %u", _player->GetUInt64Value(PLAYER_FARSIGHT), _player->GetGUIDLow()); + if (WorldObject* target = _player->GetViewpoint()) + _player->SetSeer(target); + else + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s requests non-existing seer " UI64FMTD, _player->GetName().c_str(), _player->GetUInt64Value(PLAYER_FARSIGHT)); + } + else + { + sLog->outDebug(LOG_FILTER_NETWORKIO, "Player %u set vision to self", _player->GetGUIDLow()); + _player->SetSeer(_player); } GetPlayer()->UpdateVisibilityForPlayer(); @@ -1467,7 +1463,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) if (mode >= MAX_DUNGEON_DIFFICULTY) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode); return; } @@ -1478,7 +1474,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) Map* map = _player->FindMap(); if (map && map->IsDungeon()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!", + sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!", _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -1499,7 +1495,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) if (groupGuy->GetMap()->IsNonRaidDungeon()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", + sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", _player->GetGUIDLow(), groupGuy->GetName().c_str(), groupGuy->GetGUIDLow()); return; } @@ -1534,7 +1530,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recvData) Map* map = _player->FindMap(); if (map && map->IsDungeon()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); return; } @@ -1557,7 +1553,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recvData) if (groupGuy->GetMap()->IsRaid()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); return; } } diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 0265d1e6f60..ef0f8e130b6 100755 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -31,6 +31,7 @@ #include "ObjectAccessor.h" #include "Creature.h" #include "Pet.h" +#include "ReputationMgr.h" #include "BattlegroundMgr.h" #include "Battleground.h" #include "ScriptMgr.h" diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 7ed5e3846ef..97a2765b4df 100755 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -31,8 +31,9 @@ #include "World.h" #include "Group.h" #include "SpellInfo.h" +#include "Player.h" -void WorldSession::HandleDismissCritter(WorldPacket &recvData) +void WorldSession::HandleDismissCritter(WorldPacket& recvData) { uint64 guid; recvData >> guid; @@ -138,7 +139,7 @@ void WorldSession::HandlePetStopAttack(WorldPacket &recvData) pet->AttackStop(); } -void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2) +void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint32 spellid, uint16 flag, uint64 guid2) { CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) @@ -848,15 +849,15 @@ void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, Dec SendPacket(&data); } -void WorldSession::HandlePetLearnTalent(WorldPacket & recvData) +void WorldSession::HandlePetLearnTalent(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_PET_LEARN_TALENT"); uint64 guid; - uint32 talent_id, requested_rank; - recvData >> guid >> talent_id >> requested_rank; + uint32 talentId, requestedRank; + recvData >> guid >> talentId >> requestedRank; - _player->LearnPetTalent(guid, talent_id, requested_rank); + _player->LearnPetTalent(guid, talentId, requestedRank); _player->SendTalentsInfoData(true); } diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp index 88ae01f59be..ec389142182 100755 --- a/src/server/game/Handlers/SkillHandler.cpp +++ b/src/server/game/Handlers/SkillHandler.cpp @@ -18,13 +18,14 @@ #include "Common.h" #include "DatabaseEnv.h" -#include "Opcodes.h" #include "Log.h" +#include "ObjectAccessor.h" +#include "Opcodes.h" #include "Player.h" +#include "Pet.h" +#include "UpdateMask.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "ObjectAccessor.h" -#include "UpdateMask.h" void WorldSession::HandleLearnTalentOpcode(WorldPacket & recvData) { diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index 1c834b323ac..270980c8e7c 100755 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -32,6 +32,7 @@ #include "ScriptMgr.h" #include "GameObjectAI.h" #include "SpellAuraEffects.h" +#include "Player.h" void WorldSession::HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets) { diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index 41e834d84e8..1571d857f41 100755 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -17,15 +17,16 @@ */ #include "zlib.h" -#include "Language.h" -#include "WorldPacket.h" #include "Common.h" +#include "Language.h" #include "ObjectMgr.h" -#include "TicketMgr.h" +#include "Opcodes.h" #include "Player.h" +#include "TicketMgr.h" +#include "Util.h" #include "World.h" +#include "WorldPacket.h" #include "WorldSession.h" -#include "Util.h" void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) { diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index f8df5862df0..a370cf25d97 100755 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -16,15 +16,18 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "InstanceScript.h" -#include "DatabaseEnv.h" -#include "Map.h" -#include "Player.h" -#include "GameObject.h" #include "Creature.h" #include "CreatureAI.h" -#include "Log.h" +#include "DatabaseEnv.h" +#include "GameObject.h" +#include "InstanceScript.h" #include "LFGMgr.h" +#include "Log.h" +#include "Map.h" +#include "Player.h" +#include "Pet.h" +#include "WorldSession.h" +#include "Opcodes.h" void InstanceScript::SaveToDB() { diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index fca8d78a3de..ef3d2b9fbd6 100755 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -25,6 +25,7 @@ #include "SpellMgr.h" #include "SpellInfo.h" #include "Group.h" +#include "Player.h" static Rates const qualityToRate[MAX_ITEM_QUALITY] = { diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index 929a1d81d57..108856d81b6 100755 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -26,6 +26,7 @@ #include "BattlegroundMgr.h" #include "Item.h" #include "AuctionHouseMgr.h" +#include "CalendarMgr.h" MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery(stationery) { @@ -39,10 +40,10 @@ MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery m_messageType = MAIL_GAMEOBJECT; m_senderId = sender->GetEntry(); break; - case TYPEID_ITEM: + /*case TYPEID_ITEM: m_messageType = MAIL_ITEM; m_senderId = sender->GetEntry(); - break; + break;*/ case TYPEID_PLAYER: m_messageType = MAIL_NORMAL; m_senderId = sender->GetGUIDLow(); @@ -55,6 +56,11 @@ MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery } } +MailSender::MailSender(CalendarEvent* sender) + : m_messageType(MAIL_CALENDAR), m_senderId(sender->GetEventId()), m_stationery(MAIL_STATIONERY_DEFAULT) // what stationery we should use here? +{ +} + MailSender::MailSender(AuctionEntry* sender) : m_messageType(MAIL_AUCTION), m_senderId(sender->GetHouseId()), m_stationery(MAIL_STATIONERY_AUCTION) { diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index 7c12ac1a1c6..c2771f4b57c 100755 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -23,6 +23,7 @@ #include <map> struct AuctionEntry; +struct CalendarEvent; class Item; class Object; class Player; @@ -36,7 +37,7 @@ enum MailMessageType MAIL_AUCTION = 2, MAIL_CREATURE = 3, // client send CMSG_CREATURE_QUERY on this mailmessagetype MAIL_GAMEOBJECT = 4, // client send CMSG_GAMEOBJECT_QUERY on this mailmessagetype - MAIL_ITEM = 5 // client send CMSG_ITEM_QUERY on this mailmessagetype + MAIL_CALENDAR = 5 }; enum MailCheckMask @@ -85,6 +86,7 @@ class MailSender { } MailSender(Object* sender, MailStationery stationery = MAIL_STATIONERY_DEFAULT); + MailSender(CalendarEvent* sender); MailSender(AuctionEntry* sender); MailSender(Player* sender); public: // Accessors diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index b1200252c54..1bb651831c7 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -17,23 +17,25 @@ */ #include "Map.h" -#include "GridStates.h" -#include "ScriptMgr.h" -#include "VMapFactory.h" +#include "Battleground.h" #include "MMapFactory.h" -#include "MapInstanced.h" #include "CellImpl.h" +#include "DynamicTree.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "Transport.h" +#include "GridStates.h" +#include "Group.h" #include "InstanceScript.h" -#include "ObjectAccessor.h" +#include "LFGMgr.h" +#include "MapInstanced.h" #include "MapManager.h" +#include "ObjectAccessor.h" #include "ObjectMgr.h" -#include "Group.h" -#include "LFGMgr.h" -#include "DynamicTree.h" +#include "Pet.h" +#include "ScriptMgr.h" +#include "Transport.h" #include "Vehicle.h" +#include "VMapFactory.h" union u_map_magic { @@ -157,7 +159,7 @@ void Map::LoadMap(int gx, int gy, bool reload) // load grid map for base map if (!m_parentMap->GridMaps[gx][gy]) - m_parentMap->EnsureGridCreated(GridCoord(63-gx, 63-gy)); + m_parentMap->EnsureGridCreated_i(GridCoord(63-gx, 63-gy)); ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridCoord(gx, gy)); GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy]; @@ -322,32 +324,34 @@ void Map::DeleteFromWorld(Player* player) delete player; } +void Map::EnsureGridCreated(const GridCoord &p) +{ + TRINITY_GUARD(ACE_Thread_Mutex, Lock); + EnsureGridCreated_i(p); +} + //Create NGrid so the object can be added to it //But object data is not loaded here -void Map::EnsureGridCreated(const GridCoord &p) +void Map::EnsureGridCreated_i(const GridCoord &p) { if (!getNGrid(p.x_coord, p.y_coord)) { - TRINITY_GUARD(ACE_Thread_Mutex, Lock); - if (!getNGrid(p.x_coord, p.y_coord)) - { - sLog->outDebug(LOG_FILTER_MAPS, "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId); + sLog->outDebug(LOG_FILTER_MAPS, "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId); - setNGrid(new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld->getBoolConfig(CONFIG_GRID_UNLOAD)), - p.x_coord, p.y_coord); + setNGrid(new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld->getBoolConfig(CONFIG_GRID_UNLOAD)), + p.x_coord, p.y_coord); - // build a linkage between this map and NGridType - buildNGridLinkage(getNGrid(p.x_coord, p.y_coord)); + // build a linkage between this map and NGridType + buildNGridLinkage(getNGrid(p.x_coord, p.y_coord)); - getNGrid(p.x_coord, p.y_coord)->SetGridState(GRID_STATE_IDLE); + getNGrid(p.x_coord, p.y_coord)->SetGridState(GRID_STATE_IDLE); - //z coord - int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord; - int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord; + //z coord + int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord; + int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord; - if (!GridMaps[gx][gy]) - LoadMapAndVMap(gx, gy); - } + if (!GridMaps[gx][gy]) + LoadMapAndVMap(gx, gy); } } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 126d0855352..e35f430b638 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -502,6 +502,7 @@ class Map : public GridRefManager<NGridType> bool IsGridLoaded(const GridCoord &) const; void EnsureGridCreated(const GridCoord &); + void EnsureGridCreated_i(const GridCoord &); bool EnsureGridLoaded(Cell const&); void EnsureGridLoadedForActiveObject(Cell const&, WorldObject* object); diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index e0dbc19aff4..f45105c324a 100755 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -25,6 +25,7 @@ #include "InstanceSaveMgr.h" #include "World.h" #include "Group.h" +#include "Player.h" MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, DUNGEON_DIFFICULTY_NORMAL) { @@ -282,4 +283,4 @@ bool MapInstanced::CanEnter(Player* /*player*/) { //ASSERT(false); return true; -}
\ No newline at end of file +} diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index f6aa6ff7dc3..96a2a44655d 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -33,6 +33,9 @@ #include "Language.h" #include "WorldPacket.h" #include "Group.h" +#include "Player.h" +#include "WorldSession.h" +#include "Opcodes.h" extern GridState* si_GridStates[]; // debugging code, should be deleted some day @@ -439,4 +442,4 @@ void MapManager::FreeInstanceId(uint32 instanceId) SetNextInstanceId(instanceId); _instanceIds[instanceId] = false; -}
\ No newline at end of file +} diff --git a/src/server/game/Maps/MapUpdater.cpp b/src/server/game/Maps/MapUpdater.cpp index b747d065a14..5e5f520505c 100644 --- a/src/server/game/Maps/MapUpdater.cpp +++ b/src/server/game/Maps/MapUpdater.cpp @@ -69,7 +69,7 @@ MapUpdater::~MapUpdater() int MapUpdater::activate(size_t num_threads) { - return m_executor.activate((int)num_threads, new WDBThreadStartReq1, new WDBThreadEndReq1); + return m_executor.start((int)num_threads, new WDBThreadStartReq1, new WDBThreadEndReq1); } int MapUpdater::deactivate() diff --git a/src/server/game/Maps/ZoneScript.h b/src/server/game/Maps/ZoneScript.h index df6349a7664..7b20b0ee676 100755 --- a/src/server/game/Maps/ZoneScript.h +++ b/src/server/game/Maps/ZoneScript.h @@ -32,19 +32,20 @@ class ZoneScript virtual uint32 GetCreatureEntry(uint32 /*guidlow*/, CreatureData const* data) { return data->id; } virtual uint32 GetGameObjectEntry(uint32 /*guidlow*/, uint32 entry) { return entry; } - virtual void OnCreatureCreate(Creature* /*creature*/) {} - virtual void OnCreatureRemove(Creature* /*creature*/) {} - virtual void OnGameObjectCreate(GameObject* /*go*/) {} - virtual void OnGameObjectRemove(GameObject* /*go*/) {} + virtual void OnCreatureCreate(Creature *) { } + virtual void OnCreatureRemove(Creature *) { } - virtual void OnUnitDeath(Unit* /*unit*/) {} + virtual void OnGameObjectCreate(GameObject *) { } + virtual void OnGameObjectRemove(GameObject *) { } + + virtual void OnUnitDeath(Unit*) { } //All-purpose data storage 64 bit - virtual uint64 GetData64(uint32 /*DataId*/) { return 0; } + virtual uint64 GetData64(uint32 /*DataId*/) const { return 0; } virtual void SetData64(uint32 /*DataId*/, uint64 /*Value*/) {} //All-purpose data storage 32 bit - virtual uint32 GetData(uint32 /*DataId*/) { return 0; } + virtual uint32 GetData(uint32 /*DataId*/) const { return 0; } virtual void SetData(uint32 /*DataId*/, uint32 /*Value*/) {} virtual void ProcessEvent(WorldObject* /*obj*/, uint32 /*eventId*/) {} diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index dac5b1ef9a2..4f358d7a145 100755 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -22,6 +22,7 @@ #include "World.h" #include "SharedDefines.h" #include "ScriptMgr.h" +#include "Player.h" namespace Trinity { diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 07bfd284a7d..5321202b256 100755 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -950,8 +950,8 @@ enum TrinityStrings LANG_BATTLEGROUND = 5015, LANG_ARENA = 5016, LANG_RAID = 5017, - LANG_HEROIC = 5018, - LANG_MOUNTABLE = 5019, + //= 5018, + //= 5019, LANG_NPCINFO_PHASEMASK = 5020, LANG_NPCINFO_ARMOR = 5021, LANG_CHANNEL_ENABLE_OWNERSHIP = 5022, diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index ae594f555e7..7d69753b287 100755 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -3423,106 +3423,113 @@ enum ActivateTaxiReply ERR_TAXINOTSTANDING = 12 }; -// Calendar - start - -enum CalendarFlags -{ - CALENDAR_FLAG_ALL_ALLOWED = 0x001, - CALENDAR_FLAG_INVITES_LOCKED = 0x010, - CALENDAR_FLAG_WITHOUT_INVITES = 0x040, - CALENDAR_FLAG_GUILD_ONLY = 0x400 -}; - -enum CalendarActionData -{ - CALENDAR_ACTION_NONE, - CALENDAR_ACTION_ADD_EVENT, - CALENDAR_ACTION_MODIFY_EVENT, - CALENDAR_ACTION_REMOVE_EVENT, - CALENDAR_ACTION_COPY_EVENT, - CALENDAR_ACTION_ADD_EVENT_INVITE, - CALENDAR_ACTION_MODIFY_EVENT_INVITE, - CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE, - CALENDAR_ACTION_REMOVE_EVENT_INVITE, - CALENDAR_ACTION_SIGNUP_TO_EVENT -}; - -enum CalendarModerationRank -{ - CALENDAR_RANK_PLAYER, - CALENDAR_RANK_MODERATOR, - CALENDAR_RANK_OWNER -}; - -enum CalendarSendEventType -{ - CALENDAR_SENDTYPE_GET, - CALENDAR_SENDTYPE_ADD, - CALENDAR_SENDTYPE_COPY -}; - -enum CalendarEventType -{ - CALENDAR_TYPE_RAID, - CALENDAR_TYPE_DUNGEON, - CALENDAR_TYPE_PVP, - CALENDAR_TYPE_MEETING, - CALENDAR_TYPE_OTHER -}; - -enum CalendarInviteStatus -{ - CALENDAR_STATUS_INVITED, - CALENDAR_STATUS_ACCEPTED, - CALENDAR_STATUS_DECLINED, - CALENDAR_STATUS_TENTATIVE, - CALENDAR_STATUS_OUT, - CALENDAR_STATUS_STANDBY, - CALENDAR_STATUS_CONFIRMED, - CALENDAR_STATUS_NO_OWNER, - CALENDAR_STATUS_8, - CALENDAR_STATUS_9 -}; - -enum CalendarError -{ - CALENDAR_OK = 0, - CALENDAR_ERROR_GUILD_EVENTS_EXCEEDED = 1, - CALENDAR_ERROR_EVENTS_EXCEEDED = 2, - CALENDAR_ERROR_SELF_INVITES_EXCEEDED = 3, - CALENDAR_ERROR_OTHER_INVITES_EXCEEDED = 4, - CALENDAR_ERROR_PERMISSIONS = 5, - CALENDAR_ERROR_EVENT_INVALID = 6, - CALENDAR_ERROR_NOT_INVITED = 7, - CALENDAR_ERROR_INTERNAL = 8, - CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD = 9, - CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S = 10, - CALENDAR_ERROR_PLAYER_NOT_FOUND = 11, - CALENDAR_ERROR_NOT_ALLIED = 12, - CALENDAR_ERROR_IGNORING_YOU_S = 13, - CALENDAR_ERROR_INVITES_EXCEEDED = 14, - CALENDAR_ERROR_INVALID_DATE = 16, - CALENDAR_ERROR_INVALID_TIME = 17, - - CALENDAR_ERROR_NEEDS_TITLE = 19, - CALENDAR_ERROR_EVENT_PASSED = 20, - CALENDAR_ERROR_EVENT_LOCKED = 21, - CALENDAR_ERROR_DELETE_CREATOR_FAILED = 22, - CALENDAR_ERROR_SYSTEM_DISABLED = 24, - CALENDAR_ERROR_RESTRICTED_ACCOUNT = 25, - CALENDAR_ERROR_ARENA_EVENTS_EXCEEDED = 26, - CALENDAR_ERROR_RESTRICTED_LEVEL = 27, - CALENDAR_ERROR_USER_SQUELCHED = 28, - CALENDAR_ERROR_NO_INVITE = 29, - - CALENDAR_ERROR_EVENT_WRONG_SERVER = 36, - CALENDAR_ERROR_INVITE_WRONG_SERVER = 37, - CALENDAR_ERROR_NO_GUILD_INVITES = 38, - CALENDAR_ERROR_INVALID_SIGNUP = 39, - CALENDAR_ERROR_NO_MODERATOR = 40 -}; - -// Calendar - end +enum DuelCompleteType +{ + DUEL_INTERRUPTED = 0, + DUEL_WON = 1, + DUEL_FLED = 2 +}; +// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time +enum BattlegroundQueueTypeId +{ + BATTLEGROUND_QUEUE_NONE = 0, + BATTLEGROUND_QUEUE_AV = 1, + BATTLEGROUND_QUEUE_WS = 2, + BATTLEGROUND_QUEUE_AB = 3, + BATTLEGROUND_QUEUE_EY = 4, + BATTLEGROUND_QUEUE_SA = 5, + BATTLEGROUND_QUEUE_IC = 6, + BATTLEGROUND_QUEUE_RB = 7, + BATTLEGROUND_QUEUE_2v2 = 8, + BATTLEGROUND_QUEUE_3v3 = 9, + BATTLEGROUND_QUEUE_5v5 = 10, + MAX_BATTLEGROUND_QUEUE_TYPES +}; + +enum GroupJoinBattlegroundResult +{ + // positive values are indexes in BattlemasterList.dbc + ERR_GROUP_JOIN_BATTLEGROUND_FAIL = 0, // Your group has joined a battleground queue, but you are not eligible (showed for non existing BattlemasterList.dbc indexes) + ERR_BATTLEGROUND_NONE = -1, // not show anything + ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS = -2, // You cannot join the battleground yet because you or one of your party members is flagged as a Deserter. + ERR_ARENA_TEAM_PARTY_SIZE = -3, // Incorrect party size for this arena. + ERR_BATTLEGROUND_TOO_MANY_QUEUES = -4, // You can only be queued for 2 battles at once + ERR_BATTLEGROUND_CANNOT_QUEUE_FOR_RATED = -5, // You cannot queue for a rated match while queued for other battles + ERR_BATTLEDGROUND_QUEUED_FOR_RATED = -6, // You cannot queue for another battle while queued for a rated arena match + ERR_BATTLEGROUND_TEAM_LEFT_QUEUE = -7, // Your team has left the arena queue + ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND = -8, // You can't do that in a battleground. + ERR_BATTLEGROUND_JOIN_XP_GAIN = -9, // wtf, doesn't exist in client... + ERR_BATTLEGROUND_JOIN_RANGE_INDEX = -10, // Cannot join the queue unless all members of your party are in the same battleground level range. + ERR_BATTLEGROUND_JOIN_TIMED_OUT = -11, // %s was unavailable to join the queue. (uint64 guid exist in client cache) + ERR_BATTLEGROUND_JOIN_FAILED = -12, // Join as a group failed (uint64 guid doesn't exist in client cache) + ERR_LFG_CANT_USE_BATTLEGROUND = -13, // You cannot queue for a battleground or arena while using the dungeon system. + ERR_IN_RANDOM_BG = -14, // Can't do that while in a Random Battleground queue. + ERR_IN_NON_RANDOM_BG = -15 // Can't queue for Random Battleground while in another Battleground queue. +}; + +enum PetNameInvalidReason +{ + // custom, not send + PET_NAME_SUCCESS = 0, + + PET_NAME_INVALID = 1, + PET_NAME_NO_NAME = 2, + PET_NAME_TOO_SHORT = 3, + PET_NAME_TOO_LONG = 4, + PET_NAME_MIXED_LANGUAGES = 6, + PET_NAME_PROFANE = 7, + PET_NAME_RESERVED = 8, + PET_NAME_THREE_CONSECUTIVE = 11, + PET_NAME_INVALID_SPACE = 12, + PET_NAME_CONSECUTIVE_SPACES = 13, + PET_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS = 14, + PET_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 15, + PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 16 +}; + +enum DungeonStatusFlag +{ + DUNGEON_STATUSFLAG_NORMAL = 0x01, + DUNGEON_STATUSFLAG_HEROIC = 0x02, + + RAID_STATUSFLAG_10MAN_NORMAL = 0x01, + RAID_STATUSFLAG_25MAN_NORMAL = 0x02, + RAID_STATUSFLAG_10MAN_HEROIC = 0x04, + RAID_STATUSFLAG_25MAN_HEROIC = 0x08 +}; + +enum PartyResult +{ + ERR_PARTY_RESULT_OK = 0, + ERR_BAD_PLAYER_NAME_S = 1, + ERR_TARGET_NOT_IN_GROUP_S = 2, + ERR_TARGET_NOT_IN_INSTANCE_S = 3, + ERR_GROUP_FULL = 4, + ERR_ALREADY_IN_GROUP_S = 5, + ERR_NOT_IN_GROUP = 6, + ERR_NOT_LEADER = 7, + ERR_PLAYER_WRONG_FACTION = 8, + ERR_IGNORING_YOU_S = 9, + ERR_LFG_PENDING = 12, + ERR_INVITE_RESTRICTED = 13, + ERR_GROUP_SWAP_FAILED = 14, // if (PartyOperation == PARTY_OP_SWAP) ERR_GROUP_SWAP_FAILED else ERR_INVITE_IN_COMBAT + ERR_INVITE_UNKNOWN_REALM = 15, + ERR_INVITE_NO_PARTY_SERVER = 16, + ERR_INVITE_PARTY_BUSY = 17, + ERR_PARTY_TARGET_AMBIGUOUS = 18, + ERR_PARTY_LFG_INVITE_RAID_LOCKED = 19, + ERR_PARTY_LFG_BOOT_LIMIT = 20, + ERR_PARTY_LFG_BOOT_COOLDOWN_S = 21, + ERR_PARTY_LFG_BOOT_IN_PROGRESS = 22, + ERR_PARTY_LFG_BOOT_TOO_FEW_PLAYERS = 23, + ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S = 24, + ERR_RAID_DISALLOWED_BY_LEVEL = 25, + ERR_PARTY_LFG_BOOT_IN_COMBAT = 26, + ERR_VOTE_KICK_REASON_NEEDED = 27, + ERR_PARTY_LFG_BOOT_DUNGEON_COMPLETE = 28, + ERR_PARTY_LFG_BOOT_LOOT_ROLLS = 29, + ERR_PARTY_LFG_TELEPORT_IN_COMBAT = 30 +}; #define MMAP_MAGIC 0x4d4d4150 // 'MMAP' #define MMAP_VERSION 3 diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index 578654ca162..3d75e384e93 100644 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -24,6 +24,7 @@ #include "ObjectAccessor.h" #include "MoveSplineInit.h" #include "MoveSpline.h" +#include "Player.h" #define MIN_QUIET_DISTANCE 28.0f #define MAX_QUIET_DISTANCE 43.0f diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index dc6cc55b855..554e38d7efd 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -49,8 +49,19 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T* owner, bool upd } else { + float size; + + // Pets need special handling. + // We need to subtract GetObjectSize() because it gets added back further down the chain + // and that makes pets too far away. Subtracting it allows pets to properly + // be (GetCombatReach() + i_offset) away. + if (owner.isPet()) + size = i_target->GetCombatReach() - i_target->GetObjectSize(); + else + size = owner.GetObjectSize(); + // to at i_offset distance from target and i_angle from target facing - i_target->GetClosePoint(x, y, z, owner->GetObjectSize(), i_offset, i_angle); + i_target->GetClosePoint(x, y, z, size, i_offset, i_angle); } } else diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 7160f64c0fb..1821a78d993 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -201,7 +201,7 @@ bool MoveSplineInitArgs::Validate(Unit* unit) const #define CHECK(exp) \ if (!(exp))\ {\ - sLog->outError(LOG_FILTER_GENERAL, "MoveSplineInitArgs::Validate: expression '%s' failed for GUID: %u", #exp, unit->GetTypeId() == TYPEID_PLAYER ? unit->GetGUIDLow() : unit->ToCreature()->GetDBTableGUIDLow());\ + sLog->outError(LOG_FILTER_GENERAL, "MoveSplineInitArgs::Validate: expression '%s' failed for GUID: %u Entry: %u", #exp, unit->GetTypeId() == TYPEID_PLAYER ? unit->GetGUIDLow() : unit->ToCreature()->GetDBTableGUIDLow(), unit->GetEntry());\ return false;\ } CHECK(path.size() > 1); diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index b6cd1391ca3..e2a18d21ff2 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -22,6 +22,8 @@ #include "Unit.h" #include "Transport.h" #include "Vehicle.h" +#include "WorldPacket.h" +#include "Opcodes.h" namespace Movement { diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 356a70ba6a5..3a8dc7c5e63 100755 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -24,6 +24,7 @@ #include "World.h" #include "ObjectMgr.h" #include "ScriptMgr.h" +#include "Opcodes.h" const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000}; diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 517ea6cb6bd..069ae71b7cb 100755 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -16,19 +16,20 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Map.h" -#include "World.h" #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "Transport.h" -#include "ScriptedCreature.h" -#include "WaypointManager.h" #include "GossipDef.h" +#include "Map.h" #include "MapManager.h" -#include "ObjectMgr.h" #include "MapRefManager.h" +#include "ObjectMgr.h" +#include "Pet.h" +#include "ScriptedCreature.h" #include "ScriptMgr.h" +#include "Transport.h" +#include "WaypointManager.h" +#include "World.h" /// Put scripts in the execution queue void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, Object* target) diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 47ce6c17b28..6682d3c11e3 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -30,6 +30,8 @@ #include "SpellScript.h" #include "GossipDef.h" #include "CreatureAI.h" +#include "Player.h" +#include "WorldPacket.h" // This is the global static registry of scripts. template<class TScript> @@ -1186,12 +1188,12 @@ void ScriptMgr::OnShutdown() FOREACH_SCRIPT(WorldScript)->OnShutdown(); } -bool ScriptMgr::OnCriteriaCheck(AchievementCriteriaData const* data, Player* source, Unit* target) +bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target) { ASSERT(source); // target can be NULL. - GET_SCRIPT_RET(AchievementCriteriaScript, data->ScriptId, tmpscript, false); + GET_SCRIPT_RET(AchievementCriteriaScript, scriptId, tmpscript, false); return tmpscript->OnCheck(source, target); } diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 270182509f9..947be2b73fe 100755 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -24,7 +24,6 @@ #include <ace/Atomic_Op.h> #include "DBCStores.h" -#include "Player.h" #include "SharedDefines.h" #include "World.h" #include "Weather.h" @@ -980,7 +979,7 @@ class ScriptMgr public: /* AchievementCriteriaScript */ - bool OnCriteriaCheck(AchievementCriteriaData const* data, Player* source, Unit* target); + bool OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target); public: /* PlayerScript */ diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 9078f6720a0..0821be2abb9 100755 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -684,7 +684,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x28F*/ { "CMSG_GROUP_ASSISTANT_LEADER", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupAssistantLeaderOpcode}, /*0x290*/ { "CMSG_BUYBACK_ITEM", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBuybackItem }, /*0x291*/ { "SMSG_SERVER_MESSAGE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x292*/ { "CMSG_SET_SAVED_INSTANCE_EXTEND", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x292*/ { "CMSG_SET_SAVED_INSTANCE_EXTEND", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetSavedInstanceExtend }, /*0x293*/ { "SMSG_LFG_OFFER_CONTINUE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x294*/ { "CMSG_TEST_DROP_RATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x295*/ { "SMSG_TEST_DROP_RATE_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 18ff3b32d67..0185d4adc9f 100755 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -225,7 +225,10 @@ void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, /// Logging helper for unexpected opcodes void WorldSession::LogUnprocessedTail(WorldPacket* packet) { - sLog->outError(LOG_FILTER_OPCODES, "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s", + if (!sLog->ShouldLog(LOG_FILTER_OPCODES, LOG_LEVEL_TRACE) || packet->rpos() >= packet->wpos()) + return; + + sLog->outTrace(LOG_FILTER_OPCODES, "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s", uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerInfo().c_str()); packet->print_storage(); } @@ -293,8 +296,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) { sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle.handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); } // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer break; @@ -307,8 +309,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) // not expected _player or must checked in packet handler sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle.handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); } break; case STATUS_TRANSFER: @@ -320,8 +321,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) { sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle.handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); } break; case STATUS_AUTHED: @@ -339,8 +339,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet)); (this->*opHandle.handler)(*packet); - if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos()) - LogUnprocessedTail(packet); + LogUnprocessedTail(packet); break; case STATUS_NEVER: sLog->outError(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 7d5dba847d4..a442bb45a69 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -31,8 +31,6 @@ #include "WorldPacket.h" #include "Cryptography/BigNumber.h" -class CalendarEvent; -class CalendarInvite; class Creature; class GameObject; class InstanceSave; @@ -93,40 +91,6 @@ enum PartyOperation PARTY_OP_SWAP = 4 }; -enum PartyResult -{ - ERR_PARTY_RESULT_OK = 0, - ERR_BAD_PLAYER_NAME_S = 1, - ERR_TARGET_NOT_IN_GROUP_S = 2, - ERR_TARGET_NOT_IN_INSTANCE_S = 3, - ERR_GROUP_FULL = 4, - ERR_ALREADY_IN_GROUP_S = 5, - ERR_NOT_IN_GROUP = 6, - ERR_NOT_LEADER = 7, - ERR_PLAYER_WRONG_FACTION = 8, - ERR_IGNORING_YOU_S = 9, - ERR_LFG_PENDING = 12, - ERR_INVITE_RESTRICTED = 13, - ERR_GROUP_SWAP_FAILED = 14, // if (PartyOperation == PARTY_OP_SWAP) ERR_GROUP_SWAP_FAILED else ERR_INVITE_IN_COMBAT - ERR_INVITE_UNKNOWN_REALM = 15, - ERR_INVITE_NO_PARTY_SERVER = 16, - ERR_INVITE_PARTY_BUSY = 17, - ERR_PARTY_TARGET_AMBIGUOUS = 18, - ERR_PARTY_LFG_INVITE_RAID_LOCKED = 19, - ERR_PARTY_LFG_BOOT_LIMIT = 20, - ERR_PARTY_LFG_BOOT_COOLDOWN_S = 21, - ERR_PARTY_LFG_BOOT_IN_PROGRESS = 22, - ERR_PARTY_LFG_BOOT_TOO_FEW_PLAYERS = 23, - ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S = 24, - ERR_RAID_DISALLOWED_BY_LEVEL = 25, - ERR_PARTY_LFG_BOOT_IN_COMBAT = 26, - ERR_VOTE_KICK_REASON_NEEDED = 27, - ERR_PARTY_LFG_BOOT_DUNGEON_COMPLETE = 28, - ERR_PARTY_LFG_BOOT_LOOT_ROLLS = 29, - ERR_PARTY_LFG_TELEPORT_IN_COMBAT = 30 -}; - - enum BFLeaveReason { BF_LEAVE_REASON_CLOSE = 0x00000001, @@ -750,7 +714,7 @@ class WorldSession //Pet void HandlePetAction(WorldPacket& recvData); void HandlePetStopAttack(WorldPacket& recvData); - void HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2); + void HandlePetActionHelper(Unit* pet, uint64 guid1, uint32 spellid, uint16 flag, uint64 guid2); void HandlePetNameQuery(WorldPacket& recvData); void HandlePetSetAction(WorldPacket& recvData); void HandlePetAbandon(WorldPacket& recvData); @@ -904,19 +868,9 @@ class WorldSession void HandleCalendarGetNumPending(WorldPacket& recvData); void HandleCalendarEventSignup(WorldPacket& recvData); - void SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType); - void SendCalendarEventInvite(CalendarInvite const& invite, bool pending); - void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& calendarInvite); - void SendCalendarEventInviteRemove(CalendarInvite const& invite, uint32 flags); - void SendCalendarEventInviteRemoveAlert(CalendarEvent const& calendarEvent, CalendarInviteStatus status); - void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent); - void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType); - void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite); - void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite); - void SendCalendarClearPendingAction(); void SendCalendarRaidLockout(InstanceSave const* save, bool add); void SendCalendarRaidLockoutUpdated(InstanceSave const* save); - void SendCalendarCommandResult(CalendarError err, char const* param = NULL); + void HandleSetSavedInstanceExtend(WorldPacket& recvData); void HandleSpellClick(WorldPacket& recvData); void HandleMirrorImageDataRequest(WorldPacket& recvData); diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index ee54c8d662c..8b034299ad6 100755 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -29,7 +29,7 @@ #include "WorldSocket.h" #include "Common.h" - +#include "Player.h" #include "Util.h" #include "World.h" #include "WorldPacket.h" @@ -163,6 +163,9 @@ int WorldSocket::SendPacket(WorldPacket const& pct) if (sPacketLog->CanLogPacket()) sPacketLog->LogPacket(pct, SERVER_TO_CLIENT); + if (m_Session) + sLog->outTrace(LOG_FILTER_OPCODES, "S->C %s %s", m_Session->GetPlayerInfo().c_str(), GetOpcodeNameForLogging(pct.GetOpcode()).c_str()); + // Create a copy of the original packet; this is to avoid issues if a hook modifies it. sScriptMgr->OnPacketSend(this, WorldPacket(pct)); @@ -674,6 +677,9 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) if (sPacketLog->CanLogPacket()) sPacketLog->LogPacket(*new_pct, CLIENT_TO_SERVER); + if (m_Session) + sLog->outTrace(LOG_FILTER_OPCODES, "C->S %s %s", m_Session->GetPlayerInfo().c_str(), GetOpcodeNameForLogging(new_pct->GetOpcode()).c_str()); + try { switch (opcode) @@ -857,6 +863,17 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) uint32 recruiter = fields[9].GetUInt32(); std::string os = fields[10].GetString(); + // Must be done before WorldSession is created + if (sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED) && os != "Win" && os != "OSX") + { + packet.Initialize(SMSG_AUTH_RESPONSE, 1); + packet << uint8(AUTH_REJECT); + SendPacket(packet); + + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::HandleAuthSession: Client %s attempted to log in using invalid client OS (%s).", GetRemoteAddress().c_str(), os.c_str()); + return -1; + } + // Checks gmlevel per Realm stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_GMLEVEL_BY_REALMID); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 5e9e8cc090b..b29f1498152 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -38,6 +38,8 @@ #include "Vehicle.h" #include "Battlefield.h" #include "BattlefieldMgr.h" +#include "Pet.h" +#include "ReputationMgr.h" class Aura; // diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 77adece17b4..97f0f350ab0 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5456,6 +5456,9 @@ SpellCastResult Spell::CheckCast(bool strict) if (target->GetCharmerGUID()) return SPELL_FAILED_CHARMED; + if (target->GetOwner() && target->GetOwner()->GetTypeId() == TYPEID_PLAYER) + return SPELL_FAILED_TARGET_IS_PLAYER_CONTROLLED; + int32 damage = CalculateDamage(i, target); if (damage && int32(target->getLevel()) > damage) return SPELL_FAILED_HIGHLEVEL; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index cdb9490c10d..622f3e1517b 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -64,6 +64,7 @@ #include "AccountMgr.h" #include "InstanceScript.h" #include "PathGenerator.h" +#include "ReputationMgr.h" pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= { diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 27b4f22bbcf..be4c522956c 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -21,6 +21,8 @@ #include "Spell.h" #include "DBCStores.h" #include "ConditionMgr.h" +#include "Player.h" +#include "Battleground.h" uint32 GetTargetFlagMask(SpellTargetObjectTypes objType) { diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 4ffbab6cb63..1edb8eab103 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -32,6 +32,7 @@ #include "BattlegroundIC.h" #include "BattlefieldWG.h" #include "BattlefieldMgr.h" +#include "Player.h" bool IsPrimaryProfessionSkill(uint32 skill) { @@ -80,6 +81,9 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, // Gnaw else if (spellproto->Id == 47481) return DIMINISHING_CONTROLLED_STUN; + // ToC Icehowl Arctic Breath + else if (spellproto->SpellVisual[0] == 14153) + return DIMINISHING_NONE; break; } // Event spells @@ -373,7 +377,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg if (msg) { if (player) - ChatHandler(player).PSendSysMessage("Craft spell %u not have create item entry.", spellInfo->Id); + ChatHandler(player->GetSession()).PSendSysMessage("Craft spell %u not have create item entry.", spellInfo->Id); else sLog->outError(LOG_FILTER_SQL, "Craft spell %u not have create item entry.", spellInfo->Id); } @@ -387,7 +391,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg if (msg) { if (player) - ChatHandler(player).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType); + ChatHandler(player->GetSession()).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType); else sLog->outError(LOG_FILTER_SQL, "Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType); } @@ -405,7 +409,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg if (msg) { if (player) - ChatHandler(player).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell); + ChatHandler(player->GetSession()).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell); else sLog->outError(LOG_FILTER_SQL, "Spell %u learn to invalid spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell); } @@ -425,7 +429,7 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg if (msg) { if (player) - ChatHandler(player).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]); + ChatHandler(player->GetSession()).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]); else sLog->outError(LOG_FILTER_SQL, "Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]); } diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 5c2639175d2..89b75fd1695 100755 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -65,6 +65,47 @@ class CreatureTextBuilder uint64 _targetGUID; }; +class PlayerTextBuilder +{ + public: + PlayerTextBuilder(WorldObject* obj, WorldObject* speaker, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, uint64 targetGUID) + : _source(obj), _talker(speaker), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _targetGUID(targetGUID) + { + } + + size_t operator()(WorldPacket* data, LocaleConstant locale) const + { + std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale); + + *data << uint8(_msgType); + *data << uint32(_language); + *data << uint64(_talker->GetGUID()); + *data << uint32(1); // 2.1.0 + *data << uint32(_talker->GetName().size() + 1); + *data << _talker->GetName(); + size_t whisperGUIDpos = data->wpos(); + *data << uint64(_targetGUID); // Unit Target + if (_targetGUID && !IS_PLAYER_GUID(_targetGUID)) + { + *data << uint32(1); // target name length + *data << uint8(0); // target name + } + *data << uint32(text.length() + 1); + *data << text; + *data << uint8(0); // ChatTag + + return whisperGUIDpos; + } + + WorldObject* _source; + WorldObject* _talker; + ChatMsg _msgType; + uint8 _textGroup; + uint32 _textId; + uint32 _language; + uint64 _targetGUID; +}; + void CreatureTextMgr::LoadCreatureTexts() { uint32 oldMSTime = getMSTime(); @@ -170,7 +211,7 @@ void CreatureTextMgr::LoadCreatureTextLocales() } -uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid /*= 0*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, TextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= NULL*/) +uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid /*= 0*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= NULL*/) { if (!source) return 0; @@ -261,8 +302,16 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp if (iter->emote) SendEmote(finalSource, iter->emote); - CreatureTextBuilder builder(finalSource, finalType, iter->group, iter->id, finalLang, whisperGuid); - SendChatPacket(finalSource, builder, finalType, whisperGuid, range, team, gmOnly); + if (srcPlr) + { + PlayerTextBuilder builder(source, finalSource, finalType, iter->group, iter->id, finalLang, whisperGuid); + SendChatPacket(finalSource, builder, finalType, whisperGuid, range, team, gmOnly); + } + else + { + CreatureTextBuilder builder(finalSource, finalType, iter->group, iter->id, finalLang, whisperGuid); + SendChatPacket(finalSource, builder, finalType, whisperGuid, range, team, gmOnly); + } if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f)) SetRepeatId(source, textGroup, iter->id); @@ -288,7 +337,7 @@ float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) const return dist; } -void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) +void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, CreatureTextRange range, Team team, bool gmOnly) { if (!sound || !source) return; @@ -298,7 +347,7 @@ void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, SendNonChatPacket(source, &data, msgType, whisperGuid, range, team, gmOnly); } -void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const +void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, CreatureTextRange range, Team team, bool gmOnly) const { float dist = GetRangeForChatType(msgType); diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index 8ed0b01fcd5..df6dd7fe4f3 100755 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -22,6 +22,7 @@ #include "GridNotifiers.h" #include "ObjectAccessor.h" #include "SharedDefines.h" +#include "Opcodes.h" struct CreatureTextEntry { @@ -37,7 +38,7 @@ struct CreatureTextEntry uint32 sound; }; -enum TextRange +enum CreatureTextRange { TEXT_RANGE_NORMAL = 0, TEXT_RANGE_AREA = 1, @@ -89,21 +90,21 @@ class CreatureTextMgr void LoadCreatureTextLocales(); CreatureTextMap const& GetTextMap() const { return mTextMap; } - void SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly); + void SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, CreatureTextRange range, Team team, bool gmOnly); void SendEmote(Unit* source, uint32 emote); //if sent, returns the 'duration' of the text else 0 if error - uint32 SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid = 0, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, TextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = NULL); + uint32 SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid = 0, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, CreatureTextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = NULL); bool TextExist(uint32 sourceEntry, uint8 textGroup); std::string GetLocalizedChatString(uint32 entry, uint8 textGroup, uint32 id, LocaleConstant locale) const; template<class Builder> - void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, uint64 whisperGuid = 0, TextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const; + void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, uint64 whisperGuid = 0, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const; private: CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup); void SetRepeatId(Creature* source, uint8 textGroup, uint8 id); - void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const; + void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, CreatureTextRange range, Team team, bool gmOnly) const; float GetRangeForChatType(ChatMsg msgType) const; CreatureTextMap mTextMap; @@ -172,7 +173,7 @@ class CreatureTextLocalizer }; template<class Builder> -void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const +void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, uint64 whisperGuid, CreatureTextRange range, Team team, bool gmOnly) const { if (!source) return; diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index 51e17cb9076..3f0e608ec14 100755 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -20,10 +20,13 @@ #include "TicketMgr.h" #include "DatabaseEnv.h" #include "Log.h" +#include "Language.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Chat.h" #include "World.h" +#include "Player.h" +#include "Opcodes.h" inline float GetAge(uint64 t) { return float(time(NULL) - t) / DAY; } diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index ec7d2e08001..57986243879 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -22,6 +22,7 @@ #include "UpdateFields.h" #include "ObjectMgr.h" #include "AccountMgr.h" +#include "World.h" #define DUMP_TABLE_COUNT 27 struct DumpTable diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index ce64dbd1a94..06f8454fda7 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -151,13 +151,28 @@ bool Warden::IsValidCheckSum(uint32 checksum, const uint8* data, const uint16 le } } +struct keyData { + union + { + struct + { + uint8 bytes[20]; + } bytes; + + struct + { + uint32 ints[5]; + } ints; + }; +}; + uint32 Warden::BuildChecksum(const uint8* data, uint32 length) { - uint8 hash[20]; - SHA1(data, length, hash); + keyData hash; + SHA1(data, length, hash.bytes.bytes); uint32 checkSum = 0; for (uint8 i = 0; i < 5; ++i) - checkSum = checkSum ^ *(uint32*)(&hash[0] + i * 4); + checkSum = checkSum ^ hash.ints.ints[i]; return checkSum; } diff --git a/src/server/game/Warden/WardenMac.cpp b/src/server/game/Warden/WardenMac.cpp index e08d24ecbcd..c6ce33fe131 100644 --- a/src/server/game/Warden/WardenMac.cpp +++ b/src/server/game/Warden/WardenMac.cpp @@ -114,17 +114,32 @@ void WardenMac::RequestHash() _session->SendPacket(&pkt); } +struct keyData { + union + { + struct + { + uint8 bytes[16]; + } bytes; + + struct + { + int ints[4]; + } ints; + }; +}; + void WardenMac::HandleHashResult(ByteBuffer &buff) { // test int keyIn[4]; - uint8 mod_seed[16] = { 0x4D, 0x80, 0x8D, 0x2C, 0x77, 0xD9, 0x05, 0xC4, 0x1A, 0x63, 0x80, 0xEC, 0x08, 0x58, 0x6A, 0xFE }; + keyData mod_seed = { { { { 0x4D, 0x80, 0x8D, 0x2C, 0x77, 0xD9, 0x05, 0xC4, 0x1A, 0x63, 0x80, 0xEC, 0x08, 0x58, 0x6A, 0xFE } } } }; for (int i = 0; i < 4; ++i) { - keyIn[i] = *(int*)(&mod_seed[0] + i * 4); + keyIn[i] = mod_seed.ints.ints[i]; } int keyOut[4]; diff --git a/src/server/game/Weather/Weather.cpp b/src/server/game/Weather/Weather.cpp index 896e7161606..e119ebf5f2e 100755 --- a/src/server/game/Weather/Weather.cpp +++ b/src/server/game/Weather/Weather.cpp @@ -28,6 +28,7 @@ #include "ObjectMgr.h" #include "Util.h" #include "ScriptMgr.h" +#include "Opcodes.h" /// Create the Weather object Weather::Weather(uint32 zone, WeatherData const* weatherChances) diff --git a/src/server/game/Weather/WeatherMgr.cpp b/src/server/game/Weather/WeatherMgr.cpp index da62122d7a3..c96ec1742cf 100755 --- a/src/server/game/Weather/WeatherMgr.cpp +++ b/src/server/game/Weather/WeatherMgr.cpp @@ -25,6 +25,9 @@ #include "Log.h" #include "ObjectMgr.h" #include "AutoPtr.h" +#include "Player.h" +#include "WorldPacket.h" +#include "Opcodes.h" namespace WeatherMgr { diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index e19f0b56f4b..be5b005dc27 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1668,9 +1668,6 @@ void World::SetInitialWorldSettings() sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading CreatureEventAI Texts..."); sEventAIMgr->LoadCreatureEventAI_Texts(); - sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading CreatureEventAI Summons..."); - sEventAIMgr->LoadCreatureEventAI_Summons(); - sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading CreatureEventAI Scripts..."); sEventAIMgr->LoadCreatureEventAI_Scripts(); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 7342c76f619..37c35c58c29 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -474,41 +474,6 @@ enum WorldStates WS_GUILD_DAILY_RESET_TIME = 20006, // Next guild cap reset time }; -// DB scripting commands -enum ScriptCommands -{ - SCRIPT_COMMAND_TALK = 0, // source/target = Creature, target = any, datalong = talk type (0=say, 1=whisper, 2=yell, 3=emote text, 4=boss emote text), datalong2 & 1 = player talk (instead of creature), dataint = string_id - SCRIPT_COMMAND_EMOTE = 1, // source/target = Creature, datalong = emote id, datalong2 = 0: set emote state; > 0: play emote state - SCRIPT_COMMAND_FIELD_SET = 2, // source/target = Creature, datalong = field id, datalog2 = value - SCRIPT_COMMAND_MOVE_TO = 3, // source/target = Creature, datalong2 = time to reach, x/y/z = destination - SCRIPT_COMMAND_FLAG_SET = 4, // source/target = Creature, datalong = field id, datalog2 = bitmask - SCRIPT_COMMAND_FLAG_REMOVE = 5, // source/target = Creature, datalong = field id, datalog2 = bitmask - SCRIPT_COMMAND_TELEPORT_TO = 6, // source/target = Creature/Player (see datalong2), datalong = map_id, datalong2 = 0: Player; 1: Creature, x/y/z = destination, o = orientation - SCRIPT_COMMAND_QUEST_EXPLORED = 7, // target/source = Player, target/source = GO/Creature, datalong = quest id, datalong2 = distance or 0 - SCRIPT_COMMAND_KILL_CREDIT = 8, // target/source = Player, datalong = creature entry, datalong2 = 0: personal credit, 1: group credit - SCRIPT_COMMAND_RESPAWN_GAMEOBJECT = 9, // source = WorldObject (summoner), datalong = GO guid, datalong2 = despawn delay - SCRIPT_COMMAND_TEMP_SUMMON_CREATURE = 10, // source = WorldObject (summoner), datalong = creature entry, datalong2 = despawn delay, x/y/z = summon position, o = orientation - SCRIPT_COMMAND_OPEN_DOOR = 11, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15) - SCRIPT_COMMAND_CLOSE_DOOR = 12, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15) - SCRIPT_COMMAND_ACTIVATE_OBJECT = 13, // source = Unit, target = GO - SCRIPT_COMMAND_REMOVE_AURA = 14, // source (datalong2 != 0) or target (datalong2 == 0) = Unit, datalong = spell id - SCRIPT_COMMAND_CAST_SPELL = 15, // source and/or target = Unit, datalong2 = cast direction (0: s->t 1: s->s 2: t->t 3: t->s 4: s->creature with dataint entry), dataint & 1 = triggered flag - SCRIPT_COMMAND_PLAY_SOUND = 16, // source = WorldObject, target = none/Player, datalong = sound id, datalong2 (bitmask: 0/1=anyone/player, 0/2=without/with distance dependency, so 1|2 = 3 is target with distance dependency) - SCRIPT_COMMAND_CREATE_ITEM = 17, // target/source = Player, datalong = item entry, datalong2 = amount - SCRIPT_COMMAND_DESPAWN_SELF = 18, // target/source = Creature, datalong = despawn delay - - SCRIPT_COMMAND_LOAD_PATH = 20, // source = Unit, datalong = path id, datalong2 = is repeatable - SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT = 21, // source = WorldObject (if present used as a search center), datalong = script id, datalong2 = unit lowguid, dataint = script table to use (see ScriptsType) - SCRIPT_COMMAND_KILL = 22, // source/target = Creature, dataint = remove corpse attribute - - // TrinityCore only - SCRIPT_COMMAND_ORIENTATION = 30, // source = Unit, target (datalong > 0) = Unit, datalong = > 0 turn source to face target, o = orientation - SCRIPT_COMMAND_EQUIP = 31, // soucre = Creature, datalong = equipment id - SCRIPT_COMMAND_MODEL = 32, // source = Creature, datalong = model id - SCRIPT_COMMAND_CLOSE_GOSSIP = 33, // source = Player - SCRIPT_COMMAND_PLAYMOVIE = 34 // source = Player, datalong = movie id -}; - /// Storage class for commands issued for delayed execution struct CliCommandHolder { diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 2d15dfb3081..b41c3790392 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -9,18 +9,11 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # Enable precompiled headers when using the GCC compiler. -if( USE_SCRIPTPCH ) - include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ) -endif() -if( USE_SCRIPTPCH AND MSVC ) - set(scripts_STAT_SRCS - PrecompiledHeaders/ScriptPCH.cpp - PrecompiledHeaders/ScriptPCH.h - ) -endif() +if (USE_SCRIPTPCH) + set(scripts_STAT_PCH_HDR PrecompiledHeaders/ScriptPCH.h) + set(scripts_STAT_PCH_SRC PrecompiledHeaders/ScriptPCH.cpp) +endif () message(STATUS "SCRIPT PREPARATIONS") include(Spells/CMakeLists.txt) @@ -150,15 +143,14 @@ include_directories( ${MYSQL_INCLUDE_DIR} ) -add_library(scripts STATIC ${scripts_STAT_SRCS}) +add_library(scripts STATIC + ${scripts_STAT_SRCS} + ${scripts_STAT_PCH_SRC} +) add_dependencies(scripts revision.h) # Generate precompiled header -if( USE_SCRIPTPCH ) - if(CMAKE_COMPILER_IS_GNUCXX) - add_precompiled_header(scripts ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/ScriptPCH.h) - elseif(MSVC) - add_native_precompiled_header(scripts ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/ScriptPCH) - endif() +if (USE_SCRIPTPCH) + add_cxx_pch(scripts ${scripts_STAT_PCH_HDR} ${scripts_STAT_PCH_SRC}) endif() diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 15a724e69d1..9269bbb07ee 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -22,9 +22,11 @@ Comment: All account related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "AccountMgr.h" #include "Chat.h" +#include "Language.h" +#include "Player.h" +#include "ScriptMgr.h" class account_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp index 7667e79ece7..9f5c861c52f 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -22,8 +22,10 @@ Comment: All achievement related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "Chat.h" +#include "Language.h" +#include "Player.h" +#include "ScriptMgr.h" class achievement_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index bfb52d342e1..3d340f3aaea 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -22,11 +22,13 @@ Comment: All ban related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" +#include "Language.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "Player.h" +#include "ScriptMgr.h" class ban_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_cast.cpp b/src/server/scripts/Commands/cs_cast.cpp index 70cfb8cb830..7539ebd2b0c 100644 --- a/src/server/scripts/Commands/cs_cast.cpp +++ b/src/server/scripts/Commands/cs_cast.cpp @@ -24,6 +24,9 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" +#include "Creature.h" +#include "Language.h" +#include "Player.h" class cast_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 2202edbe4aa..f8db39e0338 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -22,11 +22,13 @@ Comment: All character related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" #include "ObjectMgr.h" #include "PlayerDump.h" +#include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" class character_commandscript : public CommandScript { @@ -238,11 +240,11 @@ public: if (handler->needReportToTarget(player)) { if (oldLevel == newLevel) - ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, handler->GetNameLink().c_str()); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, handler->GetNameLink().c_str()); else if (oldLevel < newLevel) - ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink().c_str(), newLevel); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink().c_str(), newLevel); else // if (oldlevel > newlevel) - ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink().c_str(), newLevel); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink().c_str(), newLevel); } } else diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp index 4f503fdbb76..026177ece6d 100644 --- a/src/server/scripts/Commands/cs_cheat.cpp +++ b/src/server/scripts/Commands/cs_cheat.cpp @@ -22,9 +22,11 @@ Comment: All cheat related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "Language.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ScriptMgr.h" class cheat_commandscript : public CommandScript { @@ -233,7 +235,7 @@ public: chr->SetTaxiCheater(true); handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str()); if (handler->needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str()); return true; } @@ -242,7 +244,7 @@ public: chr->SetTaxiCheater(false); handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str()); if (handler->needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str()); return true; } @@ -271,13 +273,13 @@ public: { handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(chr).c_str()); if (handler->needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink().c_str()); } else { handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(chr).c_str()); if (handler->needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink().c_str()); } for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 99ed8cc4301..956d9ac3376 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -31,6 +31,7 @@ EndScriptData */ #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "GossipDef.h" +#include "Language.h" #include <fstream> diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 0bb376b08dd..73ed341a21c 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -22,11 +22,14 @@ Comment: All disable related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" #include "DisableMgr.h" +#include "Language.h" +#include "ObjectMgr.h" #include "OutdoorPvP.h" +#include "Player.h" +#include "ScriptMgr.h" +#include "SpellMgr.h" class disable_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index 4f6acd7b629..b0a646b7288 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -22,9 +22,11 @@ Comment: All event related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "GameEventMgr.h" #include "Chat.h" +#include "GameEventMgr.h" +#include "Language.h" +#include "Player.h" +#include "ScriptMgr.h" class event_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 4c6e36d3f71..b46f99eaa8f 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -26,7 +26,10 @@ EndScriptData */ #include "ObjectMgr.h" #include "Chat.h" #include "AccountMgr.h" +#include "Language.h" #include "World.h" +#include "Player.h" +#include "Opcodes.h" class gm_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index f7371884da2..6d75e63d053 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -27,6 +27,8 @@ EndScriptData */ #include "MapManager.h" #include "TicketMgr.h" #include "Chat.h" +#include "Language.h" +#include "Player.h" class go_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 6803354d29b..c9f07c90259 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -28,6 +28,9 @@ EndScriptData */ #include "PoolMgr.h" #include "MapManager.h" #include "Chat.h" +#include "Language.h" +#include "Player.h" +#include "Opcodes.h" class gobject_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index a453122aef6..73955a6b9b2 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -22,11 +22,12 @@ Comment: All guild related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "Chat.h" +#include "Language.h" #include "Guild.h" #include "GuildMgr.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" class guild_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index 4edc5f6fea0..c1d9229ccd3 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -22,9 +22,11 @@ Comment: All honor related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "Language.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ScriptMgr.h" class honor_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp index f51727af2ef..ffd8a5a7cf7 100644 --- a/src/server/scripts/Commands/cs_instance.cpp +++ b/src/server/scripts/Commands/cs_instance.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "InstanceSaveMgr.h" #include "InstanceScript.h" #include "MapManager.h" +#include "Player.h" class instance_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index cfdfc66f991..9c383153d46 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -25,8 +25,11 @@ EndScriptData */ #include "Chat.h" #include "ScriptMgr.h" #include "ObjectMgr.h" +#include "Language.h" #include "SpellMgr.h" #include "SpellInfo.h" +#include "Player.h" +#include "Pet.h" class learn_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 5f1ed59176f..c4da37d032c 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -17,8 +17,10 @@ #include "ScriptMgr.h" #include "Chat.h" +#include "Language.h" #include "LFGMgr.h" #include "Group.h" +#include "Player.h" void GetPlayerInfo(ChatHandler* handler, Player* player) { diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index 5c16a0963d3..977369d1405 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -25,8 +25,10 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "SpellAuraEffects.h" +#include "Language.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "Player.h" class list_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 8f7e3ed3247..c265cd1faa5 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -22,12 +22,15 @@ Comment: All lookup related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" #include "GameEventMgr.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" +#include "SpellInfo.h" class lookup_commandscript : public CommandScript { @@ -1156,109 +1159,72 @@ public: return true; } - static bool HandleLookupMapCommand(ChatHandler* /*handler*/, char const* args) + static bool HandleLookupMapCommand(ChatHandler* handler, char const* args) { if (!*args) return false; - /* + std::string namePart = args; std::wstring wNamePart; - // converting string that we try to find to lower case if (!Utf8toWStr(namePart, wNamePart)) return false; wstrToLower(wNamePart); - bool found = false; + uint32 counter = 0; + uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); + uint8 locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale(); // search in Map.dbc for (uint32 id = 0; id < sMapStore.GetNumRows(); id++) { - MapEntry const* MapInfo = sMapStore.LookupEntry(id); - if (MapInfo) + if (MapEntry const* mapInfo = sMapStore.LookupEntry(id)) { - uint8 locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale(); - - std::string name = MapInfo->name[locale]; + std::string name = mapInfo->name[locale]; if (name.empty()) continue; - if (!Utf8FitTo(name, wNamePart)) + if (Utf8FitTo(name, wNamePart) && locale < TOTAL_LOCALES) { - locale = LOCALE_enUS; - for (; locale < TOTAL_LOCALES; locale++) + if (maxResults && counter == maxResults) { - if (handler->GetSession() && locale == handler->GetSession()->GetSessionDbcLocale()) - continue; - - name = MapInfo->name[locale]; - if (name.empty()) - continue; - - if (Utf8FitTo(name, wNamePart)) - break; + handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; } - } - if (locale < TOTAL_LOCALES) - { - // send map in "id - [name][Continent][Instance/Battleground/Arena][Raid reset time:][Heroic reset time:][Mountable]" format std::ostringstream ss; + ss << id << " - [" << name << ']'; - if (handler->GetSession()) - ss << id << " - |cffffffff|Hmap:" << id << "|h[" << name << ']'; - else // console - ss << id << " - [" << name << ']'; - - if (MapInfo->IsContinent()) + if (mapInfo->IsContinent()) ss << handler->GetTrinityString(LANG_CONTINENT); - switch (MapInfo->map_type) + switch (mapInfo->map_type) { - case MAP_INSTANCE: ss << handler->GetTrinityString(LANG_INSTANCE); break; - case MAP_BATTLEGROUND: ss << handler->GetTrinityString(LANG_BATTLEGROUND); break; - case MAP_ARENA: ss << handler->GetTrinityString(LANG_ARENA); break; + case MAP_INSTANCE: + ss << handler->GetTrinityString(LANG_INSTANCE); + break; + case MAP_RAID: + ss << handler->GetTrinityString(LANG_RAID); + break; + case MAP_BATTLEGROUND: + ss << handler->GetTrinityString(LANG_BATTLEGROUND); + break; + case MAP_ARENA: + ss << handler->GetTrinityString(LANG_ARENA); + break; } - if (MapInfo->IsRaid()) - ss << handler->GetTrinityString(LANG_RAID); - - if (MapInfo->SupportsHeroicMode()) - ss << handler->GetTrinityString(LANG_HEROIC); - - uint32 ResetTimeRaid = MapInfo->resetTimeRaid; - - std::string ResetTimeRaidStr; - if (ResetTimeRaid) - ResetTimeRaidStr = secsToTimeString(ResetTimeRaid, true, false); - - uint32 ResetTimeHeroic = MapInfo->resetTimeHeroic; - std::string ResetTimeHeroicStr; - if (ResetTimeHeroic) - ResetTimeHeroicStr = secsToTimeString(ResetTimeHeroic, true, false); - - if (MapInfo->IsMountAllowed()) - ss << handler->GetTrinityString(LANG_MOUNTABLE); - - if (ResetTimeRaid && !ResetTimeHeroic) - handler->PSendSysMessage(ss.str().c_str(), ResetTimeRaidStr.c_str()); - else if (!ResetTimeRaid && ResetTimeHeroic) - handler->PSendSysMessage(ss.str().c_str(), ResetTimeHeroicStr.c_str()); - else if (ResetTimeRaid && ResetTimeHeroic) - handler->PSendSysMessage(ss.str().c_str(), ResetTimeRaidStr.c_str(), ResetTimeHeroicStr.c_str()); - else - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str().c_str()); - if (!found) - found = true; + ++counter; } } } - if (!found) + if (!counter) handler->SendSysMessage(LANG_COMMAND_NOMAPFOUND); - */ + return true; } diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index de2fcf26943..30c94442c51 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -25,6 +25,8 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "ChannelMgr.h" +#include "Language.h" +#include "Player.h" class message_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 7e460c7482f..5e54778b14a 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -23,12 +23,16 @@ #include "GridNotifiers.h" #include "Group.h" #include "InstanceSaveMgr.h" +#include "Language.h" #include "MovementGenerator.h" #include "ObjectAccessor.h" +#include "Opcodes.h" #include "SpellAuras.h" #include "TargetedMovementGenerator.h" #include "WeatherMgr.h" #include "ace/INET_Addr.h" +#include "Player.h" +#include "Pet.h" class misc_commandscript : public CommandScript { @@ -495,7 +499,7 @@ public: handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), ""); if (handler->needReportToTarget(target)) - ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str()); // stop flight if need if (target->isInFlight()) @@ -606,7 +610,7 @@ public: handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), ""); if (handler->needReportToTarget(player)) - ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str()); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str()); // stop flight if need if (player->isInFlight()) @@ -1804,7 +1808,7 @@ public: int64 muteTime = time(NULL) + notSpeakTime * MINUTE; target->GetSession()->m_muteTime = muteTime; stmt->setInt64(0, muteTime); - ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteReasonStr.c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteReasonStr.c_str()); } else { @@ -1860,7 +1864,7 @@ public: LoginDatabase.Execute(stmt); if (target) - ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); std::string nameLink = handler->playerLink(targetName); @@ -2137,7 +2141,7 @@ public: handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, handler->GetNameLink().c_str()); return true; } diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index ff74ae83c20..16599e5d892 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -22,9 +22,14 @@ Comment: All modify related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "Pet.h" +#include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" + class modify_commandscript : public CommandScript { @@ -106,7 +111,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target).c_str(), hp, hpm); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_HP_CHANGED, handler->GetNameLink().c_str(), hp, hpm); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_HP_CHANGED, handler->GetNameLink().c_str(), hp, hpm); target->SetMaxHealth(hpm); target->SetHealth(hp); @@ -144,7 +149,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target).c_str(), mana, manam); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MANA_CHANGED, handler->GetNameLink().c_str(), mana, manam); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MANA_CHANGED, handler->GetNameLink().c_str(), mana, manam); target->SetMaxPower(POWER_MANA, manam); target->SetPower(POWER_MANA, mana); @@ -193,7 +198,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target).c_str(), energy/10, energym/10); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, handler->GetNameLink().c_str(), energy/10, energym/10); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, handler->GetNameLink().c_str(), energy/10, energym/10); target->SetMaxPower(POWER_ENERGY, energym); target->SetPower(POWER_ENERGY, energy); @@ -244,7 +249,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target).c_str(), rage/10, ragem/10); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, handler->GetNameLink().c_str(), rage/10, ragem/10); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, handler->GetNameLink().c_str(), rage/10, ragem/10); target->SetMaxPower(POWER_RAGE, ragem); target->SetPower(POWER_RAGE, rage); @@ -278,7 +283,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, handler->GetNameLink(target).c_str(), rune/10, runem/10); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, handler->GetNameLink().c_str(), rune/10, runem/10); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, handler->GetNameLink().c_str(), rune/10, runem/10); target->SetMaxPower(POWER_RUNIC_POWER, runem); target->SetPower(POWER_RUNIC_POWER, rune); @@ -408,7 +413,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, handler->GetNameLink().c_str(), spellflatid, val, mark); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, handler->GetNameLink().c_str(), spellflatid, val, mark); WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2)); data << uint8(spellflatid); @@ -504,7 +509,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, targetNameLink.c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, handler->GetNameLink().c_str(), ASpeed); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, handler->GetNameLink().c_str(), ASpeed); target->SetSpeed(MOVE_WALK, ASpeed, true); target->SetSpeed(MOVE_RUN, ASpeed, true); @@ -552,7 +557,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, targetNameLink.c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, handler->GetNameLink().c_str(), Speed); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, handler->GetNameLink().c_str(), Speed); target->SetSpeed(MOVE_RUN, Speed, true); @@ -597,7 +602,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, targetNameLink.c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, handler->GetNameLink().c_str(), Swim); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, handler->GetNameLink().c_str(), Swim); target->SetSpeed(MOVE_SWIM, Swim, true); @@ -642,7 +647,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, targetNameLink.c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, handler->GetNameLink().c_str(), BSpeed); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, handler->GetNameLink().c_str(), BSpeed); target->SetSpeed(MOVE_RUN_BACK, BSpeed, true); @@ -678,7 +683,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, handler->GetNameLink().c_str(), FSpeed); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, handler->GetNameLink().c_str(), FSpeed); target->SetSpeed(MOVE_FLIGHT, FSpeed, true); @@ -715,7 +720,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, handler->GetNameLink(player).c_str()); if (handler->needReportToTarget(player)) - (ChatHandler(player)).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink().c_str(), Scale); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink().c_str(), Scale); } target->SetObjectScale(Scale); @@ -963,7 +968,7 @@ public: handler->PSendSysMessage(LANG_YOU_GIVE_MOUNT, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_MOUNT_GIVED, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_MOUNT_GIVED, handler->GetNameLink().c_str()); target->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); target->Mount(mId); @@ -1019,7 +1024,7 @@ public: { handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, handler->GetNameLink().c_str()); target->SetMoney(0); } @@ -1030,7 +1035,7 @@ public: handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(moneyToAdd), handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(moneyToAdd)); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(moneyToAdd)); target->SetMoney(newmoney); } } @@ -1038,7 +1043,7 @@ public: { handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, moneyToAdd, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), moneyToAdd); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), moneyToAdd); if (moneyToAdd >= MAX_MONEY_AMOUNT) target->SetMoney(MAX_MONEY_AMOUNT); @@ -1378,7 +1383,7 @@ public: handler->PSendSysMessage(LANG_YOU_CHANGE_GENDER, handler->GetNameLink(target).c_str(), gender_full); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, handler->GetNameLink().c_str()); return true; } diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index ba7342caa80..28e0744c29d 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -27,8 +27,11 @@ EndScriptData */ #include "Chat.h" #include "Transport.h" #include "CreatureGroups.h" +#include "Language.h" #include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand #include "CreatureAI.h" +#include "Player.h" +#include "Pet.h" class npc_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index c2ec563b3c7..22d6e0831d6 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -22,9 +22,11 @@ Comment: All quest related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" class quest_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 25f4c176bfc..c2791c815ad 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -22,22 +22,24 @@ Comment: All reload related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "TicketMgr.h" -#include "MapManager.h" +#include "AchievementMgr.h" +#include "AuctionHouseMgr.h" +#include "Chat.h" #include "CreatureEventAIMgr.h" +#include "CreatureTextMgr.h" #include "DisableMgr.h" +#include "Language.h" #include "LFGMgr.h" -#include "AuctionHouseMgr.h" -#include "CreatureTextMgr.h" -#include "SmartAI.h" +#include "MapManager.h" +#include "ObjectMgr.h" +#include "ScriptMgr.h" #include "SkillDiscovery.h" #include "SkillExtraItems.h" -#include "Chat.h" -#include "WaypointManager.h" +#include "SmartAI.h" +#include "SpellMgr.h" +#include "TicketMgr.h" #include "WardenCheckMgr.h" +#include "WaypointManager.h" class reload_commandscript : public CommandScript { @@ -78,7 +80,6 @@ public: { "config", SEC_ADMINISTRATOR, true, &HandleReloadConfigCommand, "", NULL }, { "creature_text", SEC_ADMINISTRATOR, true, &HandleReloadCreatureText, "", NULL }, { "creature_ai_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventAIScriptsCommand, "", NULL }, - { "creature_ai_summons", SEC_ADMINISTRATOR, true, &HandleReloadEventAISummonsCommand, "", NULL }, { "creature_ai_texts", SEC_ADMINISTRATOR, true, &HandleReloadEventAITextsCommand, "", NULL }, { "creature_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadCreatureQuestInvRelationsCommand, "", NULL }, { "creature_linked_respawn", SEC_GAMEMASTER, true, &HandleReloadLinkedRespawnCommand, "", NULL }, @@ -276,7 +277,6 @@ public: static bool HandleReloadAllEventAICommand(ChatHandler* handler, const char* /*args*/) { HandleReloadEventAITextsCommand(handler, "a"); - HandleReloadEventAISummonsCommand(handler, "a"); HandleReloadEventAIScriptsCommand(handler, "a"); return true; } @@ -1037,14 +1037,6 @@ public: return true; } - static bool HandleReloadEventAISummonsCommand(ChatHandler* handler, const char* /*args*/) - { - sLog->outInfo(LOG_FILTER_GENERAL, "Re-Loading Summons from `creature_ai_summons`..."); - sEventAIMgr->LoadCreatureEventAI_Summons(); - handler->SendGlobalGMSysMessage("DB table `creature_ai_summons` reloaded."); - return true; - } - static bool HandleReloadEventAIScriptsCommand(ChatHandler* handler, const char* /*args*/) { sLog->outInfo(LOG_FILTER_GENERAL, "Re-Loading Scripts from `creature_ai_scripts`..."); diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index 76a4eb5d943..21a22381ae0 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -22,9 +22,13 @@ Comment: All reset related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" +#include "AchievementMgr.h" #include "Chat.h" +#include "Language.h" #include "ObjectAccessor.h" +#include "Player.h" +#include "Pet.h" +#include "ScriptMgr.h" class reset_commandscript : public CommandScript { @@ -168,7 +172,7 @@ public: { target->resetSpells(/* bool myClassOnly */); - ChatHandler(target).SendSysMessage(LANG_RESET_SPELLS); + ChatHandler(target->GetSession()).SendSysMessage(LANG_RESET_SPELLS); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) handler->PSendSysMessage(LANG_RESET_SPELLS_ONLINE, handler->GetNameLink(target).c_str()); } @@ -220,7 +224,7 @@ public: creature->ToPet()->resetTalents(); owner->ToPlayer()->SendTalentsInfoData(true); - ChatHandler(owner->ToPlayer()).SendSysMessage(LANG_RESET_PET_TALENTS); + ChatHandler(owner->ToPlayer()->GetSession()).SendSysMessage(LANG_RESET_PET_TALENTS); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != owner->ToPlayer()) handler->PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE, handler->GetNameLink(owner->ToPlayer()).c_str()); } @@ -236,7 +240,7 @@ public: { target->resetTalents(true); target->SendTalentsInfoData(false); - ChatHandler(target).SendSysMessage(LANG_RESET_TALENTS); + ChatHandler(target->GetSession()).SendSysMessage(LANG_RESET_TALENTS); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) handler->PSendSysMessage(LANG_RESET_TALENTS_ONLINE, handler->GetNameLink(target).c_str()); diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index db1995ebb6e..bb4f9be5ffe 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -22,11 +22,13 @@ Comment: All server related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "Chat.h" -#include "SystemConfig.h" #include "Config.h" +#include "Language.h" #include "ObjectAccessor.h" +#include "Player.h" +#include "ScriptMgr.h" +#include "SystemConfig.h" class server_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index 8f390d17cd4..756bd75387b 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -22,11 +22,13 @@ Comment: All tele related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" -#include "MapManager.h" #include "Chat.h" #include "Group.h" +#include "Language.h" +#include "MapManager.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ScriptMgr.h" class tele_commandscript : public CommandScript { @@ -178,7 +180,7 @@ public: handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(), "", tele->name.c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str()); // stop flight if need if (target->isInFlight()) @@ -274,7 +276,7 @@ public: handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str()); if (handler->needReportToTarget(player)) - (ChatHandler(player)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); // stop flight if need if (player->isInFlight()) diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index c99931a90fb..c2c5a0909d6 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -22,11 +22,14 @@ Comment: All ticket related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" +#include "Language.h" #include "ObjectMgr.h" +#include "Opcodes.h" +#include "Player.h" #include "TicketMgr.h" +#include "ScriptMgr.h" class ticket_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index e1b30d122de..c6e11c930fb 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -22,9 +22,11 @@ Comment: All titles related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "Language.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ScriptMgr.h" class titles_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index e3cd185e4a3..c0b2938c156 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -22,10 +22,12 @@ Comment: All wp related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" +#include "Chat.h" +#include "Language.h" #include "ObjectMgr.h" +#include "Player.h" +#include "ScriptMgr.h" #include "WaypointManager.h" -#include "Chat.h" class wp_commandscript : public CommandScript { @@ -941,7 +943,7 @@ public: { wpCreature->SetDisplayId(target->GetDisplayId()); wpCreature->SetObjectScale(0.5f); - wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point); + wpCreature->SetLevel(std::min<uint32>(point, STRONG_MAX_LEVEL)); } } while (result->NextRow()); diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp index b2b4083f9c6..cef95b607c7 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/alterac_valley.cpp @@ -24,8 +24,8 @@ enum Spells SPELL_CLEAVE = 40504, SPELL_DEMORALIZING_SHOUT = 23511, SPELL_ENRAGE = 8599, - SPELL_WHIRLWIND1 = 15589, - SPELL_WHIRLWIND2 = 13736, + SPELL_WHIRLWIND = 13736, + SPELL_NORTH_MARSHAL = 45828, SPELL_SOUTH_MARSHAL = 45829, SPELL_STONEHEARTH_MARSHAL = 45830, @@ -48,38 +48,55 @@ enum Creatures NPC_WEST_FROSTWOLF_WARMASTER = 14777 }; +enum Events +{ + EVENT_CHARGE_TARGET = 1, + EVENT_CLEAVE = 2, + EVENT_DEMORALIZING_SHOUT = 3, + EVENT_WHIRLWIND = 4, + EVENT_ENRAGE = 5, + EVENT_CHECK_RESET = 6 +}; + +struct SpellPair +{ + uint32 npcEntry; + uint32 spellId; +}; + +uint8 const MAX_SPELL_PAIRS = 8; +SpellPair const _auraPairs[MAX_SPELL_PAIRS] = +{ + { NPC_NORTH_MARSHAL, SPELL_NORTH_MARSHAL }, + { NPC_SOUTH_MARSHAL, SPELL_SOUTH_MARSHAL }, + { NPC_STONEHEARTH_MARSHAL, SPELL_STONEHEARTH_MARSHAL }, + { NPC_ICEWING_MARSHAL, SPELL_ICEWING_MARSHAL }, + { NPC_EAST_FROSTWOLF_WARMASTER, SPELL_EAST_FROSTWOLF_WARMASTER }, + { NPC_WEST_FROSTWOLF_WARMASTER, SPELL_WEST_FROSTWOLF_WARMASTER }, + { NPC_TOWER_POINT_WARMASTER, SPELL_TOWER_POINT_WARMASTER }, + { NPC_ICEBLOOD_WARMASTER, SPELL_ICEBLOOD_WARMASTER } +}; + class mob_av_marshal_or_warmaster : public CreatureScript { public: - - mob_av_marshal_or_warmaster() - : CreatureScript("mob_av_marshal_or_warmaster") {} + mob_av_marshal_or_warmaster() : CreatureScript("mob_av_marshal_or_warmaster") { } struct mob_av_marshal_or_warmasterAI : public ScriptedAI { - mob_av_marshal_or_warmasterAI(Creature* creature) : ScriptedAI(creature) {} - - uint32 ChargeTimer; - uint32 CleaveTimer; - uint32 DemoralizingShoutTimer; - uint32 Whirlwind1Timer; - uint32 Whirlwind2Timer; - uint32 EnrageTimer; - uint32 ResetTimer; - - bool bHasAura; + mob_av_marshal_or_warmasterAI(Creature* creature) : ScriptedAI(creature) { } void Reset() { - ChargeTimer = urand(2 * IN_MILLISECONDS, 12 * IN_MILLISECONDS); - CleaveTimer = urand(1 * IN_MILLISECONDS, 11 * IN_MILLISECONDS); - DemoralizingShoutTimer = urand(2 * IN_MILLISECONDS, 2 * IN_MILLISECONDS); - Whirlwind1Timer = urand(1 * IN_MILLISECONDS, 12 * IN_MILLISECONDS); - Whirlwind2Timer = urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); - EnrageTimer = urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); - ResetTimer = 5 * IN_MILLISECONDS; - - bHasAura = false; + events.Reset(); + events.ScheduleEvent(EVENT_CHARGE_TARGET, urand(2 * IN_MILLISECONDS, 12 * IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_CLEAVE, urand(1 * IN_MILLISECONDS, 11 * IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DEMORALIZING_SHOUT, 2000); + events.ScheduleEvent(EVENT_WHIRLWIND, urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ENRAGE, urand(5 * IN_MILLISECONDS, 20 * IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_CHECK_RESET, 5000); + + _hasAura = false; } void JustRespawned() @@ -87,90 +104,70 @@ class mob_av_marshal_or_warmaster : public CreatureScript Reset(); } - void UpdateAI(const uint32 diff) + void UpdateAI(uint32 const diff) { - if (!bHasAura) + // I have a feeling this isn't blizzlike, but owell, I'm only passing by and cleaning up. + if (!_hasAura) { - switch (me->GetEntry()) - { - case NPC_NORTH_MARSHAL: - DoCast(me, SPELL_NORTH_MARSHAL); - break; - case NPC_SOUTH_MARSHAL: - DoCast(me, SPELL_SOUTH_MARSHAL); - break; - case NPC_STONEHEARTH_MARSHAL: - DoCast(me, SPELL_STONEHEARTH_MARSHAL); - break; - case NPC_ICEWING_MARSHAL: - DoCast(me, SPELL_ICEWING_MARSHAL); - break; - case NPC_EAST_FROSTWOLF_WARMASTER: - DoCast(me, SPELL_EAST_FROSTWOLF_WARMASTER); - break; - case NPC_WEST_FROSTWOLF_WARMASTER: - DoCast(me, SPELL_WEST_FROSTWOLF_WARMASTER); - break; - case NPC_ICEBLOOD_WARMASTER: - DoCast(me, SPELL_ICEBLOOD_WARMASTER); - break; - case NPC_TOWER_POINT_WARMASTER: - DoCast(me, SPELL_TOWER_POINT_WARMASTER); - break; - } + for (uint8 i = 0; i < MAX_SPELL_PAIRS; ++i) + if (_auraPairs[i].npcEntry == me->GetEntry()) + DoCast(me, _auraPairs[i].spellId); - bHasAura = true; + _hasAura = true; } if (!UpdateVictim()) return; - if (ChargeTimer <= diff) - { - DoCast(me->getVictim(), SPELL_CHARGE); - ChargeTimer = urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS); - } else ChargeTimer -= diff; - - if (CleaveTimer <= diff) - { - DoCast(me->getVictim(), SPELL_CLEAVE); - CleaveTimer = urand(10 * IN_MILLISECONDS, 16 * IN_MILLISECONDS); - } else CleaveTimer -= diff; - - if (DemoralizingShoutTimer <= diff) - { - DoCast(me->getVictim(), SPELL_DEMORALIZING_SHOUT); - DemoralizingShoutTimer = urand(10 * IN_MILLISECONDS, 15 * IN_MILLISECONDS); - } else DemoralizingShoutTimer -= diff; + events.Update(diff); - if (Whirlwind1Timer <= diff) - { - DoCast(me->getVictim(), SPELL_WHIRLWIND1); - Whirlwind1Timer = urand(6 * IN_MILLISECONDS, 20 * IN_MILLISECONDS); - } else Whirlwind1Timer -= diff; - - if (Whirlwind2Timer <= diff) - { - DoCast(me->getVictim(), SPELL_WHIRLWIND2); - Whirlwind2Timer = urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS); - } else Whirlwind2Timer -= diff; - - if (EnrageTimer <= diff) - { - DoCast(me->getVictim(), SPELL_ENRAGE); - EnrageTimer = urand(10 * IN_MILLISECONDS, 30 * IN_MILLISECONDS); - }else EnrageTimer -= diff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - // check if creature is not outside of building - if (ResetTimer <= diff) + while (uint32 eventId = events.ExecuteEvent()) { - if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 50) - EnterEvadeMode(); - ResetTimer = 5 * IN_MILLISECONDS; - } else ResetTimer -= diff; + switch (eventId) + { + case EVENT_CHARGE_TARGET: + DoCast(me->getVictim(), SPELL_CHARGE); + events.ScheduleEvent(EVENT_CHARGE, urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS)); + break; + case EVENT_CLEAVE: + DoCast(me->getVictim(), SPELL_CLEAVE); + events.ScheduleEvent(EVENT_CLEAVE, urand(10 * IN_MILLISECONDS, 16 * IN_MILLISECONDS)); + break; + case EVENT_DEMORALIZING_SHOUT: + DoCast(me, SPELL_DEMORALIZING_SHOUT); + events.ScheduleEvent(EVENT_DEMORALIZING_SHOUT, urand(10 * IN_MILLISECONDS, 15 * IN_MILLISECONDS)); + break; + case EVENT_WHIRLWIND: + DoCast(me, SPELL_WHIRLWIND); + events.ScheduleEvent(EVENT_WHIRLWIND, urand(10 * IN_MILLISECONDS, 25 * IN_MILLISECONDS)); + break; + case EVENT_ENRAGE: + DoCast(me, SPELL_ENRAGE); + events.ScheduleEvent(EVENT_ENRAGE, urand(10 * IN_MILLISECONDS, 30 * IN_MILLISECONDS)); + break; + case EVENT_CHECK_RESET: + { + Position const& _homePosition = me->GetHomePosition(); + if (me->GetDistance2d(_homePosition.GetPositionX(), _homePosition.GetPositionY()) > 50.0f) + { + EnterEvadeMode(); + return; + } + events.ScheduleEvent(EVENT_CHECK_RESET, 5000); + break; + } + } + } DoMeleeAttackIfReady(); } + + private: + EventMap events; + bool _hasAura; }; CreatureAI* GetAI(Creature* creature) const diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp index fdb6a5da320..af61c723ca3 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_vanndar.cpp @@ -22,8 +22,8 @@ enum Yells { YELL_AGGRO = 0, YELL_EVADE = 1, - YELL_RESPAWN1 = -1810010, // no creature_text - YELL_RESPAWN2 = -1810011, // no creature_text + //YELL_RESPAWN1 = -1810010, // Missing in database + //YELL_RESPAWN2 = -1810011, // Missing in database YELL_RANDOM = 2, YELL_SPELL = 3, }; @@ -64,12 +64,6 @@ public: Talk(YELL_AGGRO); } - void JustRespawned() - { - Reset(); - DoScriptText(RAND(YELL_RESPAWN1, YELL_RESPAWN2), me); - } - void UpdateAI(const uint32 diff) { if (!UpdateVictim()) diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp index 263897edfad..5b5787b2ab8 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp @@ -20,6 +20,8 @@ #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "blackrock_depths.h" +#include "Player.h" +#include "WorldSession.h" //go_shadowforge_brazier class go_shadowforge_brazier : public GameObjectScript @@ -99,12 +101,12 @@ public: // npc_grimstone enum GrimstoneTexts { - SCRIPT_TEXT1 = -1230003, - SCRIPT_TEXT2 = -1230004, - SCRIPT_TEXT3 = -1230005, - SCRIPT_TEXT4 = -1230006, - SCRIPT_TEXT5 = -1230007, - SCRIPT_TEXT6 = -1230008 + SAY_TEXT1 = 0, + SAY_TEXT2 = 1, + SAY_TEXT3 = 2, + SAY_TEXT4 = 3, + SAY_TEXT5 = 4, + SAY_TEXT6 = 5 }; //TODO: implement quest part of event (different end boss) @@ -184,12 +186,12 @@ public: switch (waypointId) { case 0: - DoScriptText(SCRIPT_TEXT1, me);//2 + Talk(SAY_TEXT1); CanWalk = false; Event_Timer = 5000; break; case 1: - DoScriptText(SCRIPT_TEXT2, me);//4 + Talk(SAY_TEXT2); CanWalk = false; Event_Timer = 5000; break; @@ -197,10 +199,10 @@ public: CanWalk = false; break; case 3: - DoScriptText(SCRIPT_TEXT3, me);//5 + Talk(SAY_TEXT3); break; case 4: - DoScriptText(SCRIPT_TEXT4, me);//6 + Talk(SAY_TEXT4); CanWalk = false; Event_Timer = 5000; break; @@ -270,7 +272,7 @@ public: switch (EventPhase) { case 0: - DoScriptText(SCRIPT_TEXT5, me);//1 + Talk(SAY_TEXT5); HandleGameObject(DATA_ARENA4, false); Start(false, false); CanWalk = true; @@ -305,7 +307,7 @@ public: case 7: me->SetVisible(true); HandleGameObject(DATA_ARENA1, false); - DoScriptText(SCRIPT_TEXT6, me);//4 + Talk(SAY_TEXT6); CanWalk = true; Event_Timer = 0; break; @@ -1176,7 +1178,7 @@ public: // npc_rocknot enum RocknotSays { - SAY_GOT_BEER = -1230000 + SAY_GOT_BEER = 0 }; enum RocknotSpells @@ -1213,7 +1215,7 @@ public: //keep track of amount in instance script, returns SPECIAL if amount ok and event in progress if (instance->GetData(TYPE_BAR) == SPECIAL) { - DoScriptText(SAY_GOT_BEER, creature); + creature->AI()->Talk(SAY_GOT_BEER); creature->CastSpell(creature, SPELL_DRUNKEN_RAGE, false); if (npc_escortAI* escortAI = CAST_AI(npc_rocknot::npc_rocknotAI, creature->AI())) diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp index 204fa3177e7..bad4d8735b7 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp @@ -22,8 +22,8 @@ enum Yells { - SAY_AGGRO = -1230001, - SAY_SLAY = -1230002 + SAY_AGGRO = 0, + SAY_SLAY = 1 }; enum Spells @@ -63,13 +63,13 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); me->CallForHelp(VISIBLE_RANGE); } void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_SLAY, me); + Talk(SAY_SLAY); } void JustDied(Unit* /*killer*/) diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp index 40f8b2507e3..2aab7739d8d 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp @@ -19,10 +19,11 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" -enum Spells +enum Grizzle { - SPELL_GROUNDTREMOR = 6524, - SPELL_FRENZY = 28371 + SPELL_GROUNDTREMOR = 6524, + SPELL_FRENZY = 28371, + EMOTE_FRENZY_KILL = 0 }; class boss_grizzle : public CreatureScript @@ -69,7 +70,7 @@ public: if (Frenzy_Timer <= diff) { DoCast(me, SPELL_FRENZY); - DoScriptText(EMOTE_GENERIC_FRENZY_KILL, me); + Talk(EMOTE_FRENZY_KILL); Frenzy_Timer = 15000; } else Frenzy_Timer -= diff; diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp index 347aff2ce0b..ecdcb4b0b82 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp @@ -20,6 +20,7 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "blackrock_depths.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp index 0d02e4495a5..2c2ae3a79c5 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp @@ -273,7 +273,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -298,7 +298,7 @@ public: return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp index fdb73fe1196..124743174b6 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/instance_blackrock_spire.cpp @@ -222,7 +222,7 @@ public: } } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_broodlord_lashlayer.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_broodlord_lashlayer.cpp index ceca6330152..d05b6220441 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_broodlord_lashlayer.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_broodlord_lashlayer.cpp @@ -28,8 +28,8 @@ EndScriptData */ enum Say { - SAY_AGGRO = -1469000, - SAY_LEASH = -1469001 + SAY_AGGRO = 0, + SAY_LEASH = 1, }; enum Spells @@ -69,7 +69,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); DoZoneInCombat(); } @@ -110,7 +110,7 @@ public: } else KnockBack_Timer -= diff; if (EnterEvadeIfOutOfCombatArea(diff)) - DoScriptText(SAY_LEASH, me); + Talk(SAY_LEASH); DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 9beb3bb10fe..8f12ab3f2e8 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -28,8 +28,8 @@ EndScriptData */ enum Emotes { - EMOTE_FRENZY = -1469002, - EMOTE_SHIMMER = -1469003 + EMOTE_FRENZY = 0, + EMOTE_SHIMMER = 1, }; enum Spells @@ -219,7 +219,7 @@ public: DoCast(me, spell); CurrentVurln_Spell = spell; - DoScriptText(EMOTE_SHIMMER, me); + Talk(EMOTE_SHIMMER); Shimmer_Timer = 45000; } else Shimmer_Timer -= diff; @@ -280,7 +280,7 @@ public: if (Frenzy_Timer <= diff) { DoCast(me, SPELL_FRENZY); - DoScriptText(EMOTE_FRENZY, me); + Talk(EMOTE_FRENZY); Frenzy_Timer = urand(10000, 15000); } else Frenzy_Timer -= diff; diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_flamegor.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_flamegor.cpp index e84ccd0e160..b191d2fbb02 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_flamegor.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_flamegor.cpp @@ -28,7 +28,7 @@ EndScriptData */ enum Emotes { - EMOTE_FRENZY = -1469031 + EMOTE_FRENZY = 0, }; enum Spells @@ -93,7 +93,7 @@ public: //Frenzy_Timer if (Frenzy_Timer <= diff) { - DoScriptText(EMOTE_FRENZY, me); + Talk(EMOTE_FRENZY); DoCast(me, SPELL_FRENZY); Frenzy_Timer = urand(8000, 10000); } else Frenzy_Timer -= diff; diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp index 787fbe5312b..5a3c72054b4 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp @@ -28,22 +28,20 @@ EndScriptData */ enum Say { - SAY_AGGRO = -1469007, - SAY_XHEALTH = -1469008, - SAY_SHADOWFLAME = -1469009, - SAY_RAISE_SKELETONS = -1469010, - SAY_SLAY = -1469011, - SAY_DEATH = -1469012, - - SAY_MAGE = -1469013, - SAY_WARRIOR = -1469014, - SAY_DRUID = -1469015, - SAY_PRIEST = -1469016, - SAY_PALADIN = -1469017, - SAY_SHAMAN = -1469018, - SAY_WARLOCK = -1469019, - SAY_HUNTER = -1469020, - SAY_ROGUE = -1469021 + SAY_RANDOM = 0, + SAY_RAISE_SKELETONS = 1, + SAY_SLAY = 2, + SAY_DEATH = 3, + + SAY_MAGE = 4, + SAY_WARRIOR = 5, + SAY_DRUID = 6, + SAY_PRIEST = 7, + SAY_PALADIN = 8, + SAY_SHAMAN = 9, + SAY_WARLOCK = 10, + SAY_HUNTER = 11, + SAY_ROGUE = 12, }; enum Spells @@ -109,17 +107,17 @@ public: if (rand()%5) return; - DoScriptText(SAY_SLAY, me, Victim); + Talk(SAY_SLAY, Victim->GetGUID()); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); } void EnterCombat(Unit* who) { - DoScriptText(RAND(SAY_XHEALTH, SAY_AGGRO, SAY_SHADOWFLAME), me); + Talk(SAY_RANDOM); DoCast(who, SPELL_SHADOWFLAME_INITIAL); DoZoneInCombat(); @@ -184,39 +182,39 @@ public: switch (urand(0, 8)) { case 0: - DoScriptText(SAY_MAGE, me); + Talk(SAY_MAGE); DoCast(me, SPELL_MAGE); break; case 1: - DoScriptText(SAY_WARRIOR, me); + Talk(SAY_WARRIOR); DoCast(me, SPELL_WARRIOR); break; case 2: - DoScriptText(SAY_DRUID, me); + Talk(SAY_DRUID); DoCast(me, SPELL_DRUID); break; case 3: - DoScriptText(SAY_PRIEST, me); + Talk(SAY_PRIEST); DoCast(me, SPELL_PRIEST); break; case 4: - DoScriptText(SAY_PALADIN, me); + Talk(SAY_PALADIN); DoCast(me, SPELL_PALADIN); break; case 5: - DoScriptText(SAY_SHAMAN, me); + Talk(SAY_SHAMAN); DoCast(me, SPELL_SHAMAN); break; case 6: - DoScriptText(SAY_WARLOCK, me); + Talk(SAY_WARLOCK); DoCast(me, SPELL_WARLOCK); break; case 7: - DoScriptText(SAY_HUNTER, me); + Talk(SAY_HUNTER); DoCast(me, SPELL_HUNTER); break; case 8: - DoScriptText(SAY_ROGUE, me); + Talk(SAY_ROGUE); DoCast(me, SPELL_ROGUE); break; } @@ -228,7 +226,7 @@ public: if (!Phase3 && HealthBelowPct(20)) { Phase3 = true; - DoScriptText(SAY_RAISE_SKELETONS, me); + Talk(SAY_RAISE_SKELETONS); } DoMeleeAttackIfReady(); diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_razorgore.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_razorgore.cpp index 04eca3586cc..577516383b2 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_razorgore.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_razorgore.cpp @@ -30,10 +30,10 @@ EndScriptData */ enum Say { - SAY_EGGS_BROKEN1 = -1469022, - SAY_EGGS_BROKEN2 = -1469023, - SAY_EGGS_BROKEN3 = -1469024, - SAY_DEATH = -1469025 + SAY_EGGS_BROKEN1 = 0, + SAY_EGGS_BROKEN2 = 1, + SAY_EGGS_BROKEN3 = 2, + SAY_DEATH = 3, }; enum Spells diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp index 8cc42baff8e..6ffe30d2c50 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp @@ -26,14 +26,15 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" enum Says { - SAY_LINE1 = -1469026, - SAY_LINE2 = -1469027, - SAY_LINE3 = -1469028, - SAY_HALFLIFE = -1469029, - SAY_KILLTARGET = -1469030 + SAY_LINE1 = 0, + SAY_LINE2 = 1, + SAY_LINE3 = 2, + SAY_HALFLIFE = 3, + SAY_KILLTARGET = 4 }; #define GOSSIP_ITEM "Start Event <Needs Gossip Text>" @@ -129,7 +130,7 @@ public: PlayerGUID = target->GetGUID(); //10 seconds - DoScriptText(SAY_LINE1, me); + Talk(SAY_LINE1); SpeechTimer = 10000; SpeechNum = 0; @@ -143,7 +144,7 @@ public: if (rand()%5) return; - DoScriptText(SAY_KILLTARGET, me, victim); + Talk(SAY_KILLTARGET, victim->GetGUID()); } void EnterCombat(Unit* /*who*/) @@ -166,13 +167,13 @@ public: { case 0: //16 seconds till next line - DoScriptText(SAY_LINE2, me); + Talk(SAY_LINE2); SpeechTimer = 16000; ++SpeechNum; break; case 1: //This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!" - DoScriptText(SAY_LINE3, me); + Talk(SAY_LINE3); SpeechTimer = 10000; ++SpeechNum; break; @@ -197,7 +198,7 @@ public: // Yell if hp lower than 15% if (HealthBelowPct(15) && !HasYelled) { - DoScriptText(SAY_HALFLIFE, me); + Talk(SAY_HALFLIFE); HasYelled = true; } diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp index 30638e9edeb..1335f189286 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp @@ -26,12 +26,13 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" enum Says { - SAY_GAMESBEGIN_1 = -1469004, - SAY_GAMESBEGIN_2 = -1469005, - SAY_VAEL_INTRO = -1469006 //when he corrupts Vaelastrasz + SAY_GAMESBEGIN_1 = 0, + SAY_GAMESBEGIN_2 = 1, + //SAY_VAEL_INTRO = 2, Not used - when he corrupts Vaelastrasz }; #define GOSSIP_ITEM_1 "I've made no mistakes." @@ -100,7 +101,7 @@ public: break; case GOSSIP_ACTION_INFO_DEF+3: player->CLOSE_GOSSIP_MENU(); - DoScriptText(SAY_GAMESBEGIN_1, creature); + creature->AI()->Talk(SAY_GAMESBEGIN_1); CAST_AI(boss_victor_nefarius::boss_victor_nefariusAI, creature->AI())->BeginEvent(player); break; } @@ -237,7 +238,7 @@ public: void BeginEvent(Player* target) { - DoScriptText(SAY_GAMESBEGIN_2, me); + Talk(SAY_GAMESBEGIN_2); //Trinity::Singleton<MapManager>::Instance().GetMap(me->GetMapId(), me)->GetPlayers().begin(); /* diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp index f107fd7c5ec..712f7fbe8c5 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp @@ -35,7 +35,7 @@ enum eSpels EQUIP_SWORD = 5191, EQUIP_MACE = 7230, - SAY_AGGRO = -1036001 + SAY_AGGRO = 0, }; class boss_mr_smite : public CreatureScript @@ -82,7 +82,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } bool bCheckChances() diff --git a/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp b/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp index 888171c5415..5ce55307675 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp @@ -27,6 +27,8 @@ EndScriptData */ #include "ScriptedCreature.h" #include "deadmines.h" #include "Spell.h" +#include "Player.h" +#include "WorldSession.h" /*##### # item_Defias_Gunpowder diff --git a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp index 8e0fb9ff411..1b2beb11351 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp @@ -26,6 +26,9 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "deadmines.h" +#include "TemporarySummon.h" +#include "WorldPacket.h" +#include "Opcodes.h" enum Sounds { @@ -213,7 +216,7 @@ class instance_deadmines : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -224,7 +227,7 @@ class instance_deadmines : public InstanceMapScript return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { @@ -237,16 +240,7 @@ class instance_deadmines : public InstanceMapScript void DoPlaySound(GameObject* unit, uint32 sound) { - WorldPacket data(4); - data.SetOpcode(SMSG_PLAY_SOUND); - data << uint32(sound); - unit->SendMessageToSet(&data, false); - } - - void DoPlaySoundCreature(Unit* unit, uint32 sound) - { - WorldPacket data(4); - data.SetOpcode(SMSG_PLAY_SOUND); + WorldPacket data(SMSG_PLAY_SOUND, 4); data << uint32(sound); unit->SendMessageToSet(&data, false); } diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index 8f79c4973f7..71cd69caeb5 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -27,6 +27,7 @@ Script Data End */ #include "ScriptedGossip.h" #include "gnomeregan.h" #include "ScriptedEscortAI.h" +#include "Player.h" #define GOSSIP_START_EVENT "I am ready to being" diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp index 931c0bb90fc..8e126fae588 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/instance_gnomeregan.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "gnomeregan.h" +#include "Player.h" #define MAX_ENCOUNTER 1 @@ -113,7 +114,7 @@ public: } } - uint32 GetData(uint32 uiType) + uint32 GetData(uint32 uiType) const { switch (uiType) { @@ -122,7 +123,7 @@ public: return 0; } - uint64 GetData64(uint32 uiType) + uint64 GetData64(uint32 uiType) const { switch (uiType) { diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp index 2c7e1b9c48a..13c70630c7a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp @@ -26,23 +26,27 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" -#define SAY_AGGRO -1532057 -#define SAY_SUMMON1 -1532058 -#define SAY_SUMMON2 -1532059 -#define SAY_EVOCATE -1532060 -#define SAY_ENRAGE -1532061 -#define SAY_KILL1 -1532062 -#define SAY_KILL2 -1532063 -#define SAY_DEATH -1532064 - -//Flare spell info -#define SPELL_ASTRAL_FLARE_PASSIVE 30234 //Visual effect + Flare damage - -//Curator spell info -#define SPELL_HATEFUL_BOLT 30383 -#define SPELL_EVOCATION 30254 -#define SPELL_ENRAGE 30403 //Arcane Infusion: Transforms Curator and adds damage. -#define SPELL_BERSERK 26662 +enum Curator +{ + SAY_AGGRO = 0, + SAY_SUMMON = 1, + SAY_EVOCATE = 2, + SAY_ENRAGE = 3, + SAY_KILL = 4, + SAY_DEATH = 5, + + //Flare spell info + SPELL_ASTRAL_FLARE_PASSIVE = 30234, //Visual effect + Flare damage + + //Curator spell info + SPELL_HATEFUL_BOLT = 30383, + SPELL_EVOCATION = 30254, + SPELL_ENRAGE = 30403, //Arcane Infusion: Transforms Curator and adds damage. + SPELL_BERSERK = 26662, +}; + + + class boss_curator : public CreatureScript { @@ -78,17 +82,17 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_KILL1, SAY_KILL2), me); + Talk(SAY_KILL); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); } void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void UpdateAI(const uint32 diff) @@ -109,7 +113,7 @@ public: } //may not be correct SAY (generic hard enrage) - DoScriptText(SAY_ENRAGE, me); + Talk(SAY_ENRAGE); me->InterruptNonMeleeSpells(true); DoCast(me, SPELL_BERSERK); @@ -151,7 +155,7 @@ public: //if this get's us below 10%, then we evocate (the 10th should be summoned now) if (me->GetPower(POWER_MANA)*100 / me->GetMaxPower(POWER_MANA) < 10) { - DoScriptText(SAY_EVOCATE, me); + Talk(SAY_EVOCATE); me->InterruptNonMeleeSpells(false); DoCast(me, SPELL_EVOCATION); Evocating = true; @@ -162,7 +166,7 @@ public: { if (urand(0, 1) == 0) { - DoScriptText(RAND(SAY_SUMMON1, SAY_SUMMON2), me); + Talk(SAY_SUMMON); } } } @@ -174,7 +178,7 @@ public: { Enraged = true; DoCast(me, SPELL_ENRAGE); - DoScriptText(SAY_ENRAGE, me); + Talk(SAY_ENRAGE); } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp index 5f974a890bf..026524108b3 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp @@ -26,19 +26,19 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" -#define SAY_AGGRO -1532018 -#define SAY_SLAY1 -1532019 -#define SAY_SLAY2 -1532020 -#define SAY_SLAY3 -1532021 -#define SAY_REPENTANCE1 -1532022 -#define SAY_REPENTANCE2 -1532023 -#define SAY_DEATH -1532024 - -#define SPELL_REPENTANCE 29511 -#define SPELL_HOLYFIRE 29522 -#define SPELL_HOLYWRATH 32445 -#define SPELL_HOLYGROUND 29512 -#define SPELL_BERSERK 26662 +enum MaidenOfVirtue +{ + SAY_AGGRO = 0, + SAY_SLAY = 1, + SAY_REPENTANCE = 2, + SAY_DEATH = 3, + + SPELL_REPENTANCE = 29511, + SPELL_HOLYFIRE = 29522, + SPELL_HOLYWRATH = 32445, + SPELL_HOLYGROUND = 29512, + SPELL_BERSERK = 26662, +}; class boss_maiden_of_virtue : public CreatureScript { @@ -76,17 +76,17 @@ public: void KilledUnit(Unit* /*Victim*/) { if (urand(0, 1) == 0) - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2, SAY_SLAY3), me); + Talk(SAY_SLAY); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); } void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void UpdateAI(const uint32 diff) @@ -109,7 +109,7 @@ public: if (Repentance_Timer <= diff) { DoCast(me->getVictim(), SPELL_REPENTANCE); - DoScriptText(RAND(SAY_REPENTANCE1, SAY_REPENTANCE2), me); + Talk(SAY_REPENTANCE); Repentance_Timer = urand(25000, 35000); //A little randomness on that spell } else Repentance_Timer -= diff; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index 7eeced1d970..73fefe210df 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -25,27 +25,27 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "SpellInfo.h" -#define SAY_MIDNIGHT_KILL -1532000 -#define SAY_APPEAR1 -1532001 -#define SAY_APPEAR2 -1532002 -#define SAY_APPEAR3 -1532003 -#define SAY_MOUNT -1532004 -#define SAY_KILL1 -1532005 -#define SAY_KILL2 -1532006 -#define SAY_DISARMED -1532007 -#define SAY_DEATH -1532008 -#define SAY_RANDOM1 -1532009 -#define SAY_RANDOM2 -1532010 - -#define SPELL_SHADOWCLEAVE 29832 -#define SPELL_INTANGIBLE_PRESENCE 29833 -#define SPELL_BERSERKER_CHARGE 26561 //Only when mounted - -#define MOUNTED_DISPLAYID 16040 - -//Attumen (TODO: Use the summoning spell instead of Creature id. It works, but is not convenient for us) -#define SUMMON_ATTUMEN 15550 +enum Midnight +{ + SAY_MIDNIGHT_KILL = 0, + SAY_APPEAR = 1, + SAY_MOUNT = 2, + SAY_KILL = 3, + SAY_DISARMED = 4, + SAY_DEATH = 5, + SAY_RANDOM = 6, + + SPELL_SHADOWCLEAVE = 29832, + SPELL_INTANGIBLE_PRESENCE = 29833, + SPELL_BERSERKER_CHARGE = 26561, //Only when mounted + + MOUNTED_DISPLAYID = 16040, + + //Attumen (TODO: Use the summoning spell instead of Creature id. It works, but is not convenient for us) + SUMMON_ATTUMEN = 15550, +}; class boss_attumen : public CreatureScript { @@ -93,14 +93,14 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_KILL1, SAY_KILL2), me); + Talk(SAY_KILL); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); - if (Unit* pMidnight = Unit::GetUnit(*me, Midnight)) - pMidnight->Kill(pMidnight); + Talk(SAY_DEATH); + if (Unit* midnight = Unit::GetUnit(*me, Midnight)) + midnight->Kill(midnight); } void UpdateAI(const uint32 diff); @@ -108,7 +108,7 @@ public: void SpellHit(Unit* /*source*/, const SpellInfo* spell) { if (spell->Mechanic == MECHANIC_DISARM) - DoScriptText(SAY_DISARMED, me); + Talk(SAY_DISARMED); } }; }; @@ -148,7 +148,7 @@ public: if (Phase == 2) { if (Unit* unit = Unit::GetUnit(*me, Attumen)) - DoScriptText(SAY_MIDNIGHT_KILL, unit); + Talk(SAY_MIDNIGHT_KILL, unit->GetGUID()); } } @@ -160,12 +160,12 @@ public: if (Phase == 1 && HealthBelowPct(95)) { Phase = 2; - if (Creature* pAttumen = me->SummonCreature(SUMMON_ATTUMEN, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000)) + if (Creature* attumen = me->SummonCreature(SUMMON_ATTUMEN, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000)) { - Attumen = pAttumen->GetGUID(); - pAttumen->AI()->AttackStart(me->getVictim()); - SetMidnight(pAttumen, me->GetGUID()); - DoScriptText(RAND(SAY_APPEAR1, SAY_APPEAR2, SAY_APPEAR3), pAttumen); + Attumen = attumen->GetGUID(); + attumen->AI()->AttackStart(me->getVictim()); + SetMidnight(attumen, me->GetGUID()); + Talk(SAY_APPEAR, Attumen); } } else if (Phase == 2 && HealthBelowPct(25)) @@ -203,7 +203,7 @@ public: void Mount(Unit* pAttumen) { - DoScriptText(SAY_MOUNT, pAttumen); + Talk(SAY_MOUNT, pAttumen->GetGUID()); Phase = 3; me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pAttumen->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -273,7 +273,7 @@ void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) if (RandomYellTimer <= diff) { - DoScriptText(RAND(SAY_RANDOM1, SAY_RANDOM2), me); + Talk(SAY_RANDOM); RandomYellTimer = urand(30000, 60000); } else RandomYellTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 99f2cb51c85..38eb3289ec4 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -27,19 +27,20 @@ EndScriptData */ #include "ScriptedCreature.h" #include "karazhan.h" -#define SAY_AGGRO -1532011 -#define SAY_SPECIAL_1 -1532012 -#define SAY_SPECIAL_2 -1532013 -#define SAY_KILL_1 -1532014 -#define SAY_KILL_2 -1532015 -#define SAY_KILL_3 -1532016 -#define SAY_DEATH -1532017 - -#define SPELL_VANISH 29448 -#define SPELL_GARROTE 37066 -#define SPELL_BLIND 34694 -#define SPELL_GOUGE 29425 -#define SPELL_FRENZY 37023 +enum Moroes +{ + SAY_AGGRO = 0, + SAY_SPECIAL = 1, + SAY_KILL = 2, + SAY_DEATH = 3, + + SPELL_VANISH = 29448, + SPELL_GARROTE = 37066, + SPELL_BLIND = 34694, + SPELL_GOUGE = 29425, + SPELL_FRENZY = 37023, +}; + #define POS_Z 81.73f @@ -124,19 +125,19 @@ public: { StartEvent(); - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); AddsAttack(); DoZoneInCombat(); } void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2, SAY_KILL_3), me); + Talk(SAY_KILL); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (instance) instance->SetData(TYPE_MOROES, DONE); @@ -294,7 +295,7 @@ public: { if (Wait_Timer <= diff) { - DoScriptText(RAND(SAY_SPECIAL_1, SAY_SPECIAL_2), me); + Talk(SAY_SPECIAL); if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) target->CastSpell(target, SPELL_GARROTE, true); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index c6587c3cd8a..37506d9fd0e 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -26,18 +26,23 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "karazhan.h" +#include "Player.h" -#define EMOTE_PHASE_PORTAL -1532089 -#define EMOTE_PHASE_BANISH -1532090 +enum Netherspite +{ + EMOTE_PHASE_PORTAL = 0, + EMOTE_PHASE_BANISH = 1, + + SPELL_NETHERBURN_AURA = 30522, + SPELL_VOIDZONE = 37063, + SPELL_NETHER_INFUSION = 38688, + SPELL_NETHERBREATH = 38523, + SPELL_BANISH_VISUAL = 39833, + SPELL_BANISH_ROOT = 42716, + SPELL_EMPOWERMENT = 38549, + SPELL_NETHERSPITE_ROAR = 38684, +}; -#define SPELL_NETHERBURN_AURA 30522 -#define SPELL_VOIDZONE 37063 -#define SPELL_NETHER_INFUSION 38688 -#define SPELL_NETHERBREATH 38523 -#define SPELL_BANISH_VISUAL 39833 -#define SPELL_BANISH_ROOT 42716 -#define SPELL_EMPOWERMENT 38549 -#define SPELL_NETHERSPITE_ROAR 38684 const float PortalCoord[3][3] = { @@ -228,7 +233,7 @@ public: PortalPhase = true; PortalTimer = 10000; EmpowermentTimer = 10000; - DoScriptText(EMOTE_PHASE_PORTAL, me); + Talk(EMOTE_PHASE_PORTAL); } void SwitchToBanishPhase() @@ -240,7 +245,7 @@ public: DestroyPortals(); PhaseTimer = 30000; PortalPhase = false; - DoScriptText(EMOTE_PHASE_BANISH, me); + Talk(EMOTE_PHASE_BANISH); for (int i=0; i<3; ++i) me->RemoveAurasDueToSpell(NetherBuff[i]); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index d1c4790d705..845a773c108 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -26,19 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "karazhan.h" - -#define SAY_AGGRO -1532091 -#define SAY_AXE_TOSS1 -1532092 -#define SAY_AXE_TOSS2 -1532093 -#define SAY_SPECIAL1 -1532094 -#define SAY_SPECIAL2 -1532095 -#define SAY_SPECIAL3 -1532096 -#define SAY_SLAY1 -1532097 -#define SAY_SLAY2 -1532098 -#define SAY_SLAY3 -1532099 -#define SAY_SUMMON1 -1532100 -#define SAY_SUMMON2 -1532101 -#define SAY_DEATH -1532102 +#include "SpellInfo.h" // 18 Coordinates for Infernal spawns struct InfernalPoint @@ -70,31 +58,43 @@ static InfernalPoint InfernalPoints[] = {-10935.7f, -1996.0f} }; -#define TOTAL_INFERNAL_POINTS 18 - //Enfeeble is supposed to reduce hp to 1 and then heal player back to full when it ends //Along with reducing healing and regen while enfeebled to 0% //This spell effect will only reduce healing - -#define SPELL_ENFEEBLE 30843 //Enfeeble during phase 1 and 2 -#define SPELL_ENFEEBLE_EFFECT 41624 - -#define SPELL_SHADOWNOVA 30852 //Shadownova used during all phases -#define SPELL_SW_PAIN 30854 //Shadow word pain during phase 1 and 3 (different targeting rules though) -#define SPELL_THRASH_PASSIVE 12787 //Extra attack chance during phase 2 -#define SPELL_SUNDER_ARMOR 30901 //Sunder armor during phase 2 -#define SPELL_THRASH_AURA 12787 //Passive proc chance for thrash -#define SPELL_EQUIP_AXES 30857 //Visual for axe equiping -#define SPELL_AMPLIFY_DAMAGE 39095 //Amplifiy during phase 3 -#define SPELL_CLEAVE 30131 //Same as Nightbane. -#define SPELL_HELLFIRE 30859 //Infenals' hellfire aura -#define NETHERSPITE_INFERNAL 17646 //The netherspite infernal creature -#define MALCHEZARS_AXE 17650 //Malchezar's axes (creatures), summoned during phase 3 - -#define INFERNAL_MODEL_INVISIBLE 11686 //Infernal Effects -#define SPELL_INFERNAL_RELAY 30834 - -#define EQUIP_ID_AXE 33542 //Axes info +enum PrinceMalchezaar +{ + SAY_AGGRO = 0, + SAY_AXE_TOSS1 = 1, + SAY_AXE_TOSS2 = 2, +// SAY_SPECIAL1 = 3, Not used, needs to be implemented, but I don't know where it should be used. +// SAY_SPECIAL2 = 4, Not used, needs to be implemented, but I don't know where it should be used. +// SAY_SPECIAL3 = 5, Not used, needs to be implemented, but I don't know where it should be used. + SAY_SLAY = 6, + SAY_SUMMON = 7, + SAY_DEATH = 8, + + TOTAL_INFERNAL_POINTS = 18, + + SPELL_ENFEEBLE = 30843, //Enfeeble during phase 1 and 2 + SPELL_ENFEEBLE_EFFECT = 41624, + + SPELL_SHADOWNOVA = 30852, //Shadownova used during all phases + SPELL_SW_PAIN = 30854, //Shadow word pain during phase 1 and 3 (different targeting rules though) + SPELL_THRASH_PASSIVE = 12787, //Extra attack chance during phase 2 + SPELL_SUNDER_ARMOR = 30901, //Sunder armor during phase 2 + SPELL_THRASH_AURA = 12787, //Passive proc chance for thrash + SPELL_EQUIP_AXES = 30857, //Visual for axe equiping + SPELL_AMPLIFY_DAMAGE = 39095, //Amplifiy during phase 3 + SPELL_CLEAVE = 30131, //Same as Nightbane. + SPELL_HELLFIRE = 30859, //Infenals' hellfire aura + NETHERSPITE_INFERNAL = 17646, //The netherspite infernal creature + MALCHEZARS_AXE = 17650, //Malchezar's axes (creatures), summoned during phase 3 + + INFERNAL_MODEL_INVISIBLE = 11686, //Infernal Effects + SPELL_INFERNAL_RELAY = 30834, + + EQUIP_ID_AXE = 33542, //Axes info +}; //---------Infernal code first class netherspite_infernal : public CreatureScript @@ -244,12 +244,12 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2, SAY_SLAY3), me); + Talk(SAY_SLAY); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); AxesCleanup(); ClearWeapons(); @@ -265,7 +265,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); if (instance) instance->HandleGameObject(instance->GetData64(DATA_GO_NETHER_DOOR), false); // Open the door leading further in @@ -383,7 +383,7 @@ public: DoCast(Infernal, SPELL_INFERNAL_RELAY); } - DoScriptText(RAND(SAY_SUMMON1, SAY_SUMMON2), me); + Talk(SAY_SUMMON); } void UpdateAI(const uint32 diff) @@ -415,7 +415,7 @@ public: DoCast(me, SPELL_EQUIP_AXES); //text - DoScriptText(SAY_AXE_TOSS1, me); + Talk(SAY_AXE_TOSS1); //passive thrash aura DoCast(me, SPELL_THRASH_AURA, true); @@ -451,7 +451,7 @@ public: //remove thrash me->RemoveAurasDueToSpell(SPELL_THRASH_AURA); - DoScriptText(SAY_AXE_TOSS2, me); + Talk(SAY_AXE_TOSS2); Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true); for (uint8 i = 0; i < 2; ++i) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 25fafdfcd0d..843220663b7 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -27,52 +27,50 @@ EndScriptData */ #include "ScriptedCreature.h" #include "karazhan.h" #include "GameObject.h" +#include "SpellInfo.h" -#define SAY_AGGRO1 -1532073 -#define SAY_AGGRO2 -1532074 -#define SAY_AGGRO3 -1532075 -#define SAY_FLAMEWREATH1 -1532076 -#define SAY_FLAMEWREATH2 -1532077 -#define SAY_BLIZZARD1 -1532078 -#define SAY_BLIZZARD2 -1532079 -#define SAY_EXPLOSION1 -1532080 -#define SAY_EXPLOSION2 -1532081 -#define SAY_DRINK -1532082 //Low Mana / AoE Pyroblast -#define SAY_ELEMENTALS -1532083 -#define SAY_KILL1 -1532084 -#define SAY_KILL2 -1532085 -#define SAY_TIMEOVER -1532086 -#define SAY_DEATH -1532087 -#define SAY_ATIESH -1532088 //Atiesh is equipped by a raid member - -//Spells -#define SPELL_FROSTBOLT 29954 -#define SPELL_FIREBALL 29953 -#define SPELL_ARCMISSLE 29955 -#define SPELL_CHAINSOFICE 29991 -#define SPELL_DRAGONSBREATH 29964 -#define SPELL_MASSSLOW 30035 -#define SPELL_FLAME_WREATH 29946 -#define SPELL_AOE_CS 29961 -#define SPELL_PLAYERPULL 32265 -#define SPELL_AEXPLOSION 29973 -#define SPELL_MASS_POLY 29963 -#define SPELL_BLINK_CENTER 29967 -#define SPELL_ELEMENTALS 29962 -#define SPELL_CONJURE 29975 -#define SPELL_DRINK 30024 -#define SPELL_POTION 32453 -#define SPELL_AOE_PYROBLAST 29978 - -//Creature Spells -#define SPELL_CIRCULAR_BLIZZARD 29951 //29952 is the REAL circular blizzard that leaves persistant blizzards that last for 10 seconds -#define SPELL_WATERBOLT 31012 -#define SPELL_SHADOW_PYRO 29978 - -//Creatures -#define CREATURE_WATER_ELEMENTAL 17167 -#define CREATURE_SHADOW_OF_ARAN 18254 -#define CREATURE_ARAN_BLIZZARD 17161 +enum ShadeOfAran +{ + SAY_AGGRO = 0, + SAY_FLAMEWREATH = 1, + SAY_BLIZZARD = 2, + SAY_EXPLOSION = 3, + SAY_DRINK = 4, + SAY_ELEMENTALS = 5, + SAY_KILL = 6, + SAY_TIMEOVER = 7, + SAY_DEATH = 8, +// SAY_ATIESH = 9, Unused + + //Spells + SPELL_FROSTBOLT = 29954, + SPELL_FIREBALL = 29953, + SPELL_ARCMISSLE = 29955, + SPELL_CHAINSOFICE = 29991, + SPELL_DRAGONSBREATH = 29964, + SPELL_MASSSLOW = 30035, + SPELL_FLAME_WREATH = 29946, + SPELL_AOE_CS = 29961, + SPELL_PLAYERPULL = 32265, + SPELL_AEXPLOSION = 29973, + SPELL_MASS_POLY = 29963, + SPELL_BLINK_CENTER = 29967, + SPELL_ELEMENTALS = 29962, + SPELL_CONJURE = 29975, + SPELL_DRINK = 30024, + SPELL_POTION = 32453, + SPELL_AOE_PYROBLAST = 29978, + + //Creature Spells + SPELL_CIRCULAR_BLIZZARD = 29951, + SPELL_WATERBOLT = 31012, + SPELL_SHADOW_PYRO = 29978, + + //Creatures + CREATURE_WATER_ELEMENTAL = 17167, + CREATURE_SHADOW_OF_ARAN = 18254, + CREATURE_ARAN_BLIZZARD = 17161, +}; enum SuperSpell { @@ -159,12 +157,12 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_KILL1, SAY_KILL2), me); + Talk(SAY_KILL); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (instance) { @@ -175,7 +173,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3), me); + Talk(SAY_AGGRO); if (instance) { @@ -263,7 +261,7 @@ public: Drinking = true; me->InterruptNonMeleeSpells(false); - DoScriptText(SAY_DRINK, me); + Talk(SAY_DRINK); if (!DrinkInturrupted) { @@ -383,7 +381,7 @@ public: switch (LastSuperSpell) { case SUPER_AE: - DoScriptText(RAND(SAY_EXPLOSION1, SAY_EXPLOSION2), me); + Talk(SAY_EXPLOSION); DoCast(me, SPELL_BLINK_CENTER, true); DoCast(me, SPELL_PLAYERPULL, true); @@ -392,7 +390,7 @@ public: break; case SUPER_FLAME: - DoScriptText(RAND(SAY_FLAMEWREATH1, SAY_FLAMEWREATH2), me); + Talk(SAY_FLAMEWREATH); FlameWreathTimer = 20000; FlameWreathCheckTime = 500; @@ -405,7 +403,7 @@ public: break; case SUPER_BLIZZARD: - DoScriptText(RAND(SAY_BLIZZARD1, SAY_BLIZZARD2), me); + Talk(SAY_BLIZZARD); if (Creature* pSpawn = me->SummonCreature(CREATURE_ARAN_BLIZZARD, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 25000)) { @@ -431,7 +429,7 @@ public: } } - DoScriptText(SAY_ELEMENTALS, me); + Talk(SAY_ELEMENTALS); } if (BerserkTimer <= diff) @@ -445,7 +443,7 @@ public: } } - DoScriptText(SAY_TIMEOVER, me); + Talk(SAY_TIMEOVER); BerserkTimer = 60000; } else BerserkTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp index 688a678060f..cb5a1b7b914 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp @@ -28,35 +28,36 @@ EndScriptData */ #include "karazhan.h" #include "PassiveAI.h" -#define SAY_SLAY1 -1532065 -#define SAY_SLAY2 -1532066 -#define SAY_DEATH -1532067 -#define SAY_AGGRO -1532068 -#define SAY_SACRIFICE1 -1532069 -#define SAY_SACRIFICE2 -1532070 -#define SAY_SUMMON1 -1532071 -#define SAY_SUMMON2 -1532072 - -#define SPELL_SUMMON_DEMONCHAINS 30120 // Summons demonic chains that maintain the ritual of sacrifice. -#define SPELL_DEMON_CHAINS 30206 // Instant - Visual Effect -#define SPELL_ENRAGE 23537 // Increases the caster's attack speed by 50% and the Physical damage it deals by 219 to 281 for 10 min. -#define SPELL_SHADOW_BOLT 30055 // Hurls a bolt of dark magic at an enemy, inflicting Shadow damage. -#define SPELL_SACRIFICE 30115 // Teleports and adds the debuff -#define SPELL_BERSERK 32965 // Increases attack speed by 75%. Periodically casts Shadow Bolt Volley. -#define SPELL_SUMMON_FIENDISIMP 30184 // Summons a Fiendish Imp. -#define SPELL_SUMMON_IMP 30066 // Summons Kil'rek - -#define SPELL_FIENDISH_PORTAL 30171 // Opens portal and summons Fiendish Portal, 2 sec cast -#define SPELL_FIENDISH_PORTAL_1 30179 // Opens portal and summons Fiendish Portal, instant cast - -#define SPELL_FIREBOLT 30050 // Blasts a target for 150 Fire damage. -#define SPELL_BROKEN_PACT 30065 // All damage taken increased by 25%. -#define SPELL_AMPLIFY_FLAMES 30053 // Increases the Fire damage taken by an enemy by 500 for 25 sec. - -#define CREATURE_DEMONCHAINS 17248 -#define CREATURE_FIENDISHIMP 17267 -#define CREATURE_PORTAL 17265 -#define CREATURE_KILREK 17229 +enum TerestianIllhoof +{ + SAY_SLAY = 1, + SAY_DEATH = 2, + SAY_AGGRO = 3, + SAY_SACRIFICE = 4, + SAY_SUMMON = 5, + + SPELL_SUMMON_DEMONCHAINS = 30120, // Summons demonic chains that maintain the ritual of sacrifice. + SPELL_DEMON_CHAINS = 30206, // Instant - Visual Effect + SPELL_ENRAGE = 23537, // Increases the caster's attack speed by 50% and the Physical damage it deals by 219 to 281 for 10 min. + SPELL_SHADOW_BOLT = 30055, // Hurls a bolt of dark magic at an enemy, inflicting Shadow damage. + SPELL_SACRIFICE = 30115, // Teleports and adds the debuff + SPELL_BERSERK = 32965, // Increases attack speed by 75%. Periodically casts Shadow Bolt Volley. + SPELL_SUMMON_FIENDISIMP = 30184, // Summons a Fiendish Imp. + SPELL_SUMMON_IMP = 30066, // Summons Kil'rek + + SPELL_FIENDISH_PORTAL = 30171, // Opens portal and summons Fiendish Portal, 2 sec cast + SPELL_FIENDISH_PORTAL_1 = 30179, // Opens portal and summons Fiendish Portal, instant cast + + SPELL_FIREBOLT = 30050, // Blasts a target for 150 Fire damage. + SPELL_BROKEN_PACT = 30065, // All damage taken increased by 25%. + SPELL_AMPLIFY_FLAMES = 30053, // Increases the Fire damage taken by an enemy by 500 for 25 sec. + + CREATURE_DEMONCHAINS = 17248, + CREATURE_FIENDISHIMP = 17267, + CREATURE_PORTAL = 17265, + CREATURE_KILREK = 17229, +}; + class mob_kilrek : public CreatureScript { @@ -319,7 +320,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void JustSummoned(Creature* summoned) @@ -331,7 +332,7 @@ public: if (summoned->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SPELL_FIENDISH_PORTAL_1) { - DoScriptText(RAND(SAY_SUMMON1, SAY_SUMMON2), me); + Talk(SAY_SUMMON); SummonedPortals = true; } } @@ -339,7 +340,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2), me); + Talk(SAY_SLAY); } void JustDied(Unit* /*killer*/) @@ -355,7 +356,7 @@ public: } } - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (instance) instance->SetData(TYPE_TERESTIAN, DONE); @@ -378,7 +379,7 @@ public: { CAST_AI(mob_demon_chain::mob_demon_chainAI, Chains->AI())->SacrificeGUID = target->GetGUID(); Chains->CastSpell(Chains, SPELL_DEMON_CHAINS, true); - DoScriptText(RAND(SAY_SACRIFICE1, SAY_SACRIFICE2), me); + Talk(SAY_SACRIFICE); SacrificeTimer = 30000; } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index a4f4f603206..7053cbb3ed7 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -27,68 +27,75 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "karazhan.h" +#include "Player.h" +#include "SpellInfo.h" /***********************************/ /*** OPERA WIZARD OF OZ EVENT *****/ /*********************************/ +enum Says +{ + SAY_DOROTHEE_DEATH = 0, + SAY_DOROTHEE_SUMMON = 1, + SAY_DOROTHEE_TITO_DEATH = 2, + SAY_DOROTHEE_AGGRO = 3, + + SAY_ROAR_AGGRO = 0, + SAY_ROAR_DEATH = 1, + SAY_ROAR_SLAY = 2, + + SAY_STRAWMAN_AGGRO = 0, + SAY_STRAWMAN_DEATH = 1, + SAY_STRAWMAN_SLAY = 2, + + SAY_TINHEAD_AGGRO = 0, + SAY_TINHEAD_DEATH = 1, + SAY_TINHEAD_SLAY = 2, + EMOTE_RUST = 3, + + SAY_CRONE_AGGRO = 0, + SAY_CRONE_DEATH = 1, + SAY_CRONE_SLAY = 2, +}; -#define SAY_DOROTHEE_DEATH -1532025 -#define SAY_DOROTHEE_SUMMON -1532026 -#define SAY_DOROTHEE_TITO_DEATH -1532027 -#define SAY_DOROTHEE_AGGRO -1532028 - -#define SAY_ROAR_AGGRO -1532029 -#define SAY_ROAR_DEATH -1532030 -#define SAY_ROAR_SLAY -1532031 - -#define SAY_STRAWMAN_AGGRO -1532032 -#define SAY_STRAWMAN_DEATH -1532033 -#define SAY_STRAWMAN_SLAY -1532034 - -#define SAY_TINHEAD_AGGRO -1532035 -#define SAY_TINHEAD_DEATH -1532036 -#define SAY_TINHEAD_SLAY -1532037 -#define EMOTE_RUST -1532038 - -#define SAY_CRONE_AGGRO -1532039 -#define SAY_CRONE_AGGRO2 -1532040 -#define SAY_CRONE_DEATH -1532041 -#define SAY_CRONE_SLAY -1532042 - -/**** Spells ****/ -// Dorothee -#define SPELL_WATERBOLT 31012 -#define SPELL_SCREAM 31013 -#define SPELL_SUMMONTITO 31014 - -// Tito -#define SPELL_YIPPING 31015 - -// Strawman -#define SPELL_BRAIN_BASH 31046 -#define SPELL_BRAIN_WIPE 31069 -#define SPELL_BURNING_STRAW 31075 - -// Tinhead -#define SPELL_CLEAVE 31043 -#define SPELL_RUST 31086 - -// Roar -#define SPELL_MANGLE 31041 -#define SPELL_SHRED 31042 -#define SPELL_FRIGHTENED_SCREAM 31013 - -// Crone -#define SPELL_CHAIN_LIGHTNING 32337 - -// Cyclone -#define SPELL_KNOCKBACK 32334 -#define SPELL_CYCLONE_VISUAL 32332 +enum Spells +{ + // Dorothee + SPELL_WATERBOLT = 31012, + SPELL_SCREAM = 31013, + SPELL_SUMMONTITO = 31014, + + // Tito + SPELL_YIPPING = 31015, + + // Strawman + SPELL_BRAIN_BASH = 31046, + SPELL_BRAIN_WIPE = 31069, + SPELL_BURNING_STRAW = 31075, + + // Tinhead + SPELL_CLEAVE = 31043, + SPELL_RUST = 31086, + + // Roar + SPELL_MANGLE = 31041, + SPELL_SHRED = 31042, + SPELL_FRIGHTENED_SCREAM = 31013, + + // Crone + SPELL_CHAIN_LIGHTNING = 32337, + + // Cyclone + SPELL_KNOCKBACK = 32334, + SPELL_CYCLONE_VISUAL = 32332, +}; -/** Creature Entries **/ -#define CREATURE_TITO 17548 -#define CREATURE_CYCLONE 18412 -#define CREATURE_CRONE 18168 +enum Creatures +{ + CREATURE_TITO = 17548, + CREATURE_CYCLONE = 18412, + CREATURE_CRONE = 18168, +}; void SummonCroneIfReady(InstanceScript* instance, Creature* creature) { @@ -146,7 +153,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_DOROTHEE_AGGRO, me); + Talk(SAY_DOROTHEE_AGGRO); } void JustReachedHome() @@ -158,7 +165,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DOROTHEE_DEATH, me); + Talk(SAY_DOROTHEE_DEATH); if (instance) SummonCroneIfReady(instance, me); @@ -251,7 +258,7 @@ public: if (Dorothee && Dorothee->isAlive()) { CAST_AI(boss_dorothee::boss_dorotheeAI, Dorothee->AI())->TitoDied = true; - DoScriptText(SAY_DOROTHEE_TITO_DEATH, Dorothee); + Talk(SAY_DOROTHEE_TITO_DEATH, Dorothee->GetGUID()); } } } @@ -276,7 +283,7 @@ void boss_dorothee::boss_dorotheeAI::SummonTito() { if (Creature* pTito = me->SummonCreature(CREATURE_TITO, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) { - DoScriptText(SAY_DOROTHEE_SUMMON, me); + Talk(SAY_DOROTHEE_SUMMON); CAST_AI(mob_tito::mob_titoAI, pTito->AI())->DorotheeGUID = me->GetGUID(); pTito->AI()->AttackStart(me->getVictim()); SummonedTito = true; @@ -332,7 +339,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_STRAWMAN_AGGRO, me); + Talk(SAY_STRAWMAN_AGGRO); } void JustReachedHome() @@ -355,7 +362,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_STRAWMAN_DEATH, me); + Talk(SAY_STRAWMAN_DEATH); if (instance) SummonCroneIfReady(instance, me); @@ -363,7 +370,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_STRAWMAN_SLAY, me); + Talk(SAY_STRAWMAN_SLAY); } void UpdateAI(const uint32 diff) @@ -434,7 +441,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_TINHEAD_AGGRO, me); + Talk(SAY_TINHEAD_AGGRO); } void JustReachedHome() @@ -460,7 +467,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_TINHEAD_DEATH, me); + Talk(SAY_TINHEAD_DEATH); if (instance) SummonCroneIfReady(instance, me); @@ -468,7 +475,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_TINHEAD_SLAY, me); + Talk(SAY_TINHEAD_SLAY); } void UpdateAI(const uint32 diff) @@ -496,7 +503,7 @@ public: if (RustTimer <= diff) { ++RustCount; - DoScriptText(EMOTE_RUST, me); + Talk(EMOTE_RUST); DoCast(me, SPELL_RUST); RustTimer = 6000; } else RustTimer -= diff; @@ -557,7 +564,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_ROAR_AGGRO, me); + Talk(SAY_ROAR_AGGRO); } void JustReachedHome() @@ -567,7 +574,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_ROAR_DEATH, me); + Talk(SAY_ROAR_DEATH); if (instance) SummonCroneIfReady(instance, me); @@ -575,7 +582,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_ROAR_SLAY, me); + Talk(SAY_ROAR_SLAY); } void UpdateAI(const uint32 diff) @@ -648,16 +655,21 @@ public: me->DespawnOrUnsummon(); } + void KilledUnit(Unit* /*victim*/) + { + Talk(SAY_CRONE_SLAY); + } + void EnterCombat(Unit* /*who*/) { - DoScriptText(RAND(SAY_CRONE_AGGRO, SAY_CRONE_AGGRO2), me); + Talk(SAY_CRONE_AGGRO); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_CRONE_DEATH, me); + Talk(SAY_CRONE_DEATH); if (instance) { @@ -742,22 +754,24 @@ public: /**************************************/ /**** Opera Red Riding Hood Event* ***/ /************************************/ +enum RedRidingHood +{ + SAY_WOLF_AGGRO = 0, + SAY_WOLF_SLAY = 1, + SAY_WOLF_HOOD = 2, + SOUND_WOLF_DEATH = 9275, -/**** Yells for the Wolf ****/ -#define SAY_WOLF_AGGRO -1532043 -#define SAY_WOLF_SLAY -1532044 -#define SAY_WOLF_HOOD -1532045 -#define SOUND_WOLF_DEATH 9275 //Only sound on death, no text. + SPELL_LITTLE_RED_RIDING_HOOD = 30768, + SPELL_TERRIFYING_HOWL = 30752, + SPELL_WIDE_SWIPE = 30761, + + CREATURE_BIG_BAD_WOLF = 17521, +}; -/**** Spells For The Wolf ****/ -#define SPELL_LITTLE_RED_RIDING_HOOD 30768 -#define SPELL_TERRIFYING_HOWL 30752 -#define SPELL_WIDE_SWIPE 30761 #define GOSSIP_GRANDMA "What phat lewtz you have grandmother?" -/**** The Wolf's Entry* ***/ -#define CREATURE_BIG_BAD_WOLF 17521 + class npc_grandmother : public CreatureScript { @@ -829,7 +843,12 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_WOLF_AGGRO, me); + Talk(SAY_WOLF_AGGRO); + } + + void KilledUnit(Unit* /*victim*/) + { + Talk(SAY_WOLF_SLAY); } void JustReachedHome() @@ -865,7 +884,7 @@ public: { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) { - DoScriptText(SAY_WOLF_HOOD, me); + Talk(SAY_WOLF_HOOD); DoCast(target, SPELL_LITTLE_RED_RIDING_HOOD, true); TempThreat = DoGetThreat(target); if (TempThreat) @@ -915,41 +934,41 @@ public: /******** Opera Romeo and Juliet Event* ******/ /********************************************/ -/**** Speech *****/ -#define SAY_JULIANNE_AGGRO -1532046 -#define SAY_JULIANNE_ENTER -1532047 -#define SAY_JULIANNE_DEATH01 -1532048 -#define SAY_JULIANNE_DEATH02 -1532049 -#define SAY_JULIANNE_RESURRECT -1532050 -#define SAY_JULIANNE_SLAY -1532051 - -#define SAY_ROMULO_AGGRO -1532052 -#define SAY_ROMULO_DEATH -1532053 -#define SAY_ROMULO_ENTER -1532054 -#define SAY_ROMULO_RESURRECT -1532055 -#define SAY_ROMULO_SLAY -1532056 - -/***** Spells For Julianne *****/ -#define SPELL_BLINDING_PASSION 30890 -#define SPELL_DEVOTION 30887 -#define SPELL_ETERNAL_AFFECTION 30878 -#define SPELL_POWERFUL_ATTRACTION 30889 -#define SPELL_DRINK_POISON 30907 - -/***** Spells For Romulo ****/ -#define SPELL_BACKWARD_LUNGE 30815 -#define SPELL_DARING 30841 -#define SPELL_DEADLY_SWATHE 30817 -#define SPELL_POISON_THRUST 30822 - -/**** Other Misc. Spells ****/ -#define SPELL_UNDYING_LOVE 30951 -#define SPELL_RES_VISUAL 24171 - -/*** Misc. Information ****/ -#define CREATURE_ROMULO 17533 -#define ROMULO_X -10900 -#define ROMULO_Y -1758 +enum JulianneRomulo +{ + /**** Speech *****/ + SAY_JULIANNE_AGGRO = 0, + SAY_JULIANNE_ENTER = 1, + SAY_JULIANNE_DEATH01 = 2, + SAY_JULIANNE_DEATH02 = 3, + SAY_JULIANNE_RESURRECT = 4, + SAY_JULIANNE_SLAY = 5, + + SAY_ROMULO_AGGRO = 0, + SAY_ROMULO_DEATH = 1, + SAY_ROMULO_ENTER = 2, + SAY_ROMULO_RESURRECT = 3, + SAY_ROMULO_SLAY = 4, + + SPELL_BLINDING_PASSION = 30890, + SPELL_DEVOTION = 30887, + SPELL_ETERNAL_AFFECTION = 30878, + SPELL_POWERFUL_ATTRACTION = 30889, + SPELL_DRINK_POISON = 30907, + + SPELL_BACKWARD_LUNGE = 30815, + SPELL_DARING = 30841, + SPELL_DEADLY_SWATHE = 30817, + SPELL_POISON_THRUST = 30822, + + SPELL_UNDYING_LOVE = 30951, + SPELL_RES_VISUAL = 24171, + + CREATURE_ROMULO = 17533, + ROMULO_X = -10900, + ROMULO_Y = -1758, +}; + enum RAJPhase { @@ -1076,7 +1095,7 @@ public: { if (Spell->Id == SPELL_DRINK_POISON) { - DoScriptText(SAY_JULIANNE_DEATH01, me); + Talk(SAY_JULIANNE_DEATH01); DrinkPoisonTimer = 2500; } } @@ -1085,7 +1104,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_JULIANNE_DEATH02, me); + Talk(SAY_JULIANNE_DEATH02); if (instance) { @@ -1099,7 +1118,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_JULIANNE_SLAY, me); + Talk(SAY_JULIANNE_SLAY); } void UpdateAI(const uint32 diff); @@ -1170,7 +1189,7 @@ public: if (Phase == PHASE_ROMULO) { - DoScriptText(SAY_ROMULO_DEATH, me); + Talk(SAY_ROMULO_DEATH); PretendToDie(me); IsFakingDeath = true; Phase = PHASE_BOTH; @@ -1217,7 +1236,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_ROMULO_AGGRO, me); + Talk(SAY_ROMULO_AGGRO); if (JulianneGUID) { Creature* Julianne = (Unit::GetCreature((*me), JulianneGUID)); @@ -1239,7 +1258,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_ROMULO_DEATH, me); + Talk(SAY_ROMULO_DEATH); if (instance) { @@ -1254,7 +1273,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_ROMULO_SLAY, me); + Talk(SAY_ROMULO_SLAY); } void UpdateAI(const uint32 diff) @@ -1269,7 +1288,7 @@ public: Creature* Julianne = (Unit::GetCreature((*me), JulianneGUID)); if (Julianne && CAST_AI(boss_julianne::boss_julianneAI, Julianne->AI())->IsFakingDeath) { - DoScriptText(SAY_ROMULO_RESURRECT, me); + Talk(SAY_ROMULO_RESURRECT); Resurrect(Julianne); CAST_AI(boss_julianne::boss_julianneAI, Julianne->AI())->IsFakingDeath = false; JulianneDead = false; @@ -1318,7 +1337,7 @@ void boss_julianne::boss_julianneAI::UpdateAI(const uint32 diff) { if (EntryYellTimer <= diff) { - DoScriptText(SAY_JULIANNE_ENTER, me); + Talk(SAY_JULIANNE_ENTER); EntryYellTimer = 0; } else EntryYellTimer -= diff; } @@ -1327,7 +1346,7 @@ void boss_julianne::boss_julianneAI::UpdateAI(const uint32 diff) { if (AggroYellTimer <= diff) { - DoScriptText(SAY_JULIANNE_AGGRO, me); + Talk(SAY_JULIANNE_AGGRO); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->setFaction(16); AggroYellTimer = 0; @@ -1389,7 +1408,7 @@ void boss_julianne::boss_julianneAI::UpdateAI(const uint32 diff) Creature* Romulo = (Unit::GetCreature((*me), RomuloGUID)); if (Romulo && CAST_AI(boss_romulo::boss_romuloAI, Romulo->AI())->IsFakingDeath) { - DoScriptText(SAY_JULIANNE_RESURRECT, me); + Talk(SAY_JULIANNE_RESURRECT); Resurrect(Romulo); CAST_AI(boss_romulo::boss_romuloAI, Romulo->AI())->IsFakingDeath = false; RomuloDead = false; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp index 2ecd98cbc4c..2937d0ab700 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp @@ -241,7 +241,7 @@ public: return strSaveData; } - uint32 GetData(uint32 uiData) + uint32 GetData(uint32 uiData) const { switch (uiData) { @@ -264,7 +264,7 @@ public: return 0; } - uint64 GetData64(uint32 uiData) + uint64 GetData64(uint32 uiData) const { switch (uiData) { diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index 3bdfeab30da..660b8f6c460 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "karazhan.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### # npc_barnesAI @@ -62,26 +63,26 @@ struct Dialogue static Dialogue OzDialogue[]= { - {-1532103, 6000}, - {-1532104, 18000}, - {-1532105, 9000}, - {-1532106, 15000} + {0, 6000}, + {1, 18000}, + {2, 9000}, + {3, 15000} }; static Dialogue HoodDialogue[]= { - {-1532107, 6000}, - {-1532108, 10000}, - {-1532109, 14000}, - {-1532110, 15000} + {4, 6000}, + {5, 10000}, + {6, 14000}, + {7, 15000} }; static Dialogue RAJDialogue[]= { - {-1532111, 5000}, - {-1532112, 7000}, - {-1532113, 14000}, - {-1532114, 14000} + {8, 5000}, + {9, 7000}, + {10, 14000}, + {11, 14000} }; // Entries and spawn locations for creatures in Oz event @@ -224,7 +225,8 @@ public: } if (text) - DoScriptText(text, me); + CreatureAI::Talk(text); + } void PrepareEncounter() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index e21a84d9499..22a26fd4389 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -27,46 +27,57 @@ EndScriptData */ #include "ScriptedCreature.h" #include "magisters_terrace.h" #include "WorldPacket.h" +#include "Opcodes.h" -#define SAY_AGGRO -1585023 //This yell should be done when the room is cleared. For now, set it as a movelineofsight yell. -#define SAY_PHOENIX -1585024 -#define SAY_FLAMESTRIKE -1585025 -#define SAY_GRAVITY_LAPSE -1585026 -#define SAY_TIRED -1585027 -#define SAY_RECAST_GRAVITY -1585028 -#define SAY_DEATH -1585029 +enum Says +{ + SAY_AGGRO = 0, //This yell should be done when the room is cleared. For now, set it as a movelineofsight yell. + SAY_PHOENIX = 1, + SAY_FLAMESTRIKE = 2, + SAY_GRAVITY_LAPSE = 3, + SAY_TIRED = 4, + SAY_RECAST_GRAVITY = 5, + SAY_DEATH = 6 +}; -/*** Spells ***/ -// Phase 1 spells -#define SPELL_FIREBALL_NORMAL 44189 // Deals 2700-3300 damage at current target -#define SPELL_FIREBALL_HEROIC 46164 // 4950-6050 +enum Spells +{ + // Phase 1 spells + SPELL_FIREBALL_NORMAL = 44189, // Deals 2700-3300 damage at current target + SPELL_FIREBALL_HEROIC = 46164, // 4950-6050 -#define SPELL_PHOENIX 44194 // Summons a phoenix (Doesn't work?) -#define SPELL_PHOENIX_BURN 44197 // A spell Phoenix uses to damage everything around -#define SPELL_REBIRTH_DMG 44196 // DMG if a Phoenix rebirth happen + SPELL_PHOENIX = 44194, // Summons a phoenix (Doesn't work?) + SPELL_PHOENIX_BURN = 44197, // A spell Phoenix uses to damage everything around + SPELL_REBIRTH_DMG = 44196, // DMG if a Phoenix rebirth happen -#define SPELL_FLAMESTRIKE1_NORMAL 44190 // Damage part -#define SPELL_FLAMESTRIKE1_HEROIC 46163 // Heroic damage part -#define SPELL_FLAMESTRIKE2 44191 // Flamestrike indicator before the damage -#define SPELL_FLAMESTRIKE3 44192 // Summons the trigger + animation (projectile) + SPELL_FLAMESTRIKE1_NORMAL = 44190, // Damage part + SPELL_FLAMESTRIKE1_HEROIC = 46163, // Heroic damage part + SPELL_FLAMESTRIKE2 = 44191, // Flamestrike indicator before the damage + SPELL_FLAMESTRIKE3 = 44192, // Summons the trigger + animation (projectile) -#define SPELL_SHOCK_BARRIER 46165 // Heroic only; 10k damage shield, followed by Pyroblast -#define SPELL_PYROBLAST 36819 // Heroic only; 45-55k fire damage + SPELL_SHOCK_BARRIER = 46165, // Heroic only; 10k damage shield, followed by Pyroblast + SPELL_PYROBLAST = 36819, // Heroic only; 45-55k fire damage // Phase 2 spells -#define SPELL_GRAVITY_LAPSE_INITIAL 44224 // Cast at the beginning of every Gravity Lapse -#define SPELL_GRAVITY_LAPSE_CHANNEL 44251 // Channeled; blue beam animation to every enemy in range -#define SPELL_TELEPORT_CENTER 44218 // Should teleport people to the center. Requires DB entry in spell_target_position. -#define SPELL_GRAVITY_LAPSE_FLY 44227 // Hastens flyspeed and allows flying for 1 minute. For some reason removes 44226. -#define SPELL_GRAVITY_LAPSE_DOT 44226 // Knocks up in the air and applies a 300 DPS DoT. -#define SPELL_ARCANE_SPHERE_PASSIVE 44263 // Passive auras on Arcane Spheres -#define SPELL_POWER_FEEDBACK 44233 // Stuns him, making him take 50% more damage for 10 seconds. Cast after Gravity Lapse - -/*** Creatures ***/ -#define CREATURE_PHOENIX 24674 -#define CREATURE_PHOENIX_EGG 24675 -#define CREATURE_ARCANE_SPHERE 24708 + SPELL_GRAVITY_LAPSE_INITIAL = 44224, // Cast at the beginning of every Gravity Lapse + SPELL_GRAVITY_LAPSE_CHANNEL = 44251, // Channeled; blue beam animation to every enemy in range + SPELL_TELEPORT_CENTER = 44218, // Should teleport people to the center. Requires DB entry in spell_target_position. + SPELL_GRAVITY_LAPSE_FLY = 44227, // Hastens flyspeed and allows flying for 1 minute. For some reason removes 44226. + SPELL_GRAVITY_LAPSE_DOT = 44226, // Knocks up in the air and applies a 300 DPS DoT. + SPELL_ARCANE_SPHERE_PASSIVE = 44263, // Passive auras on Arcane Spheres + SPELL_POWER_FEEDBACK = 44233 // Stuns him, making him take 50% more damage for 10 seconds. Cast after Gravity Lapse +}; + + + +enum Creatures +{ + CREATURE_PHOENIX = 24674, + CREATURE_PHOENIX_EGG = 24675, + CREATURE_ARCANE_SPHERE = 24708 +}; + /** Locations **/ float KaelLocations[3][2]= @@ -140,27 +151,21 @@ public: Phase = 0; if (instance) - { instance->SetData(DATA_KAELTHAS_EVENT, NOT_STARTED); - instance->HandleGameObject(instance->GetData64(DATA_KAEL_DOOR), true); - // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here) - // Small door opened after event are expected to be closed by default - } } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (!instance) return; - // Open the encounter door - instance->HandleGameObject(instance->GetData64(DATA_KAEL_DOOR), true); + instance->SetData(DATA_KAELTHAS_EVENT, DONE); // Enable the Translocation Orb Exit if (GameObject* escapeOrb = ObjectAccessor::GetGameObject(*me, instance->GetData64(DATA_ESCAPE_ORB))) - escapeOrb->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); + escapeOrb->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } void DamageTaken(Unit* /*done_by*/, uint32 &damage) @@ -173,16 +178,15 @@ public: { if (!instance) return; - - //Close the encounter door, open it in JustDied/Reset - instance->HandleGameObject(instance->GetData64(DATA_KAEL_DOOR), false); + + instance->SetData(DATA_KAELTHAS_EVENT, IN_PROGRESS); } void MoveInLineOfSight(Unit* who) { if (!HasTaunted && me->IsWithinDistInMap(who, 40.0f)) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); HasTaunted = true; } @@ -248,8 +252,7 @@ public: // Also needs an exception in spell system. unit->CastSpell(unit, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, me->GetGUID()); // Use packet hack - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); + WorldPacket data(SMSG_MOVE_SET_CAN_FLY, 12); data.append(unit->GetPackGUID()); data << uint32(0); unit->SendMessageToSet(&data, true); @@ -269,8 +272,7 @@ public: unit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); unit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); + WorldPacket data(SMSG_MOVE_UNSET_CAN_FLY, 12); data.append(unit->GetPackGUID()); data << uint32(0); unit->SendMessageToSet(&data, true); @@ -323,7 +325,7 @@ public: Phoenix->AI()->AttackStart(target); } - DoScriptText(SAY_PHOENIX, me); + Talk(SAY_PHOENIX); PhoenixTimer = 60000; } else PhoenixTimer -= diff; @@ -335,7 +337,7 @@ public: me->InterruptSpell(CURRENT_CHANNELED_SPELL); me->InterruptSpell(CURRENT_GENERIC_SPELL); DoCast(target, SPELL_FLAMESTRIKE3, true); - DoScriptText(SAY_FLAMESTRIKE, me); + Talk(SAY_FLAMESTRIKE); } FlameStrikeTimer = urand(15000, 25000); } else FlameStrikeTimer -= diff; @@ -365,18 +367,14 @@ public: case 0: if (FirstGravityLapse) // Different yells at 50%, and at every following Gravity Lapse { - DoScriptText(SAY_GRAVITY_LAPSE, me); + Talk(SAY_GRAVITY_LAPSE); FirstGravityLapse = false; if (instance) - { - instance->HandleGameObject(instance->GetData64(DATA_KAEL_STATUE_LEFT), true); - instance->HandleGameObject(instance->GetData64(DATA_KAEL_STATUE_RIGHT), true); - } - }else - { - DoScriptText(SAY_RECAST_GRAVITY, me); + instance->SetData(DATA_KAELTHAS_STATUES, 1); } + else + Talk(SAY_RECAST_GRAVITY); DoCast(me, SPELL_GRAVITY_LAPSE_INITIAL); GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell @@ -419,7 +417,7 @@ public: case 4: me->InterruptNonMeleeSpells(false); - DoScriptText(SAY_TIRED, me); + Talk(SAY_TIRED); DoCast(me, SPELL_POWER_FEEDBACK); RemoveGravityLapse(); GravityLapseTimer = 10000; diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 2af417381a5..b2cf2336024 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -34,25 +34,25 @@ struct Speech static Speech LackeyDeath[]= { - {-1585013}, - {-1585014}, - {-1585015}, - {-1585016}, + {1}, + {2}, + {3}, + {4}, }; static Speech PlayerDeath[]= { - {-1585017}, - {-1585018}, - {-1585019}, - {-1585020}, - {-1585021}, + {5}, + {6}, + {7}, + {8}, + {9}, }; enum eEnums { - SAY_AGGRO = -1585012, - SAY_DEATH = -1585022, + SAY_AGGRO = 0, + SAY_DEATH = 10, SPELL_DISPEL_MAGIC = 27609, SPELL_FLASH_HEAL = 17843, @@ -144,7 +144,7 @@ public: void EnterCombat(Unit* who) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); for (uint8 i = 0; i < MAX_ACTIVE_LACKEY; ++i) { @@ -216,7 +216,7 @@ public: if (victim->GetTypeId() != TYPEID_PLAYER) return; - DoScriptText(PlayerDeath[PlayersKilled].id, me); + Talk(PlayerDeath[PlayersKilled].id); if (PlayersKilled < 4) ++PlayersKilled; @@ -224,7 +224,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (!instance) return; @@ -415,7 +415,7 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI return; //should delrissa really yell if dead? - DoScriptText(LackeyDeath[uiLackeyDeathCount].id, pDelrissa); + pDelrissa->AI()->Talk(LackeyDeath[uiLackeyDeathCount].id); instance->SetData(DATA_DELRISSA_DEATH_COUNT, SPECIAL); diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp index 430bbb79bde..4d9bd1f2192 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp @@ -27,30 +27,37 @@ EndScriptData */ #include "ScriptedCreature.h" #include "magisters_terrace.h" -#define SAY_AGGRO -1585000 -#define SAY_ENERGY -1585001 -#define SAY_EMPOWERED -1585002 -#define SAY_KILL_1 -1585003 -#define SAY_KILL_2 -1585004 -#define SAY_DEATH -1585005 -#define EMOTE_CRYSTAL -1585006 - -//Crystal effect spells -#define SPELL_FEL_CRYSTAL_COSMETIC 44374 -#define SPELL_FEL_CRYSTAL_DUMMY 44329 -#define SPELL_FEL_CRYSTAL_VISUAL 44355 -#define SPELL_MANA_RAGE 44320 // This spell triggers 44321, which changes scale and regens mana Requires an entry in spell_script_target +enum Says +{ + SAY_AGGRO = 0, + SAY_ENERGY = 1, + SAY_EMPOWERED = 2, + SAY_KILL = 3, + SAY_DEATH = 4, + EMOTE_CRYSTAL = 5 +}; -//Selin's spells -#define SPELL_DRAIN_LIFE 44294 -#define SPELL_FEL_EXPLOSION 44314 +enum Spells +{ + //Crystal effect spells + SPELL_FEL_CRYSTAL_COSMETIC = 44374, + SPELL_FEL_CRYSTAL_DUMMY = 44329, + SPELL_FEL_CRYSTAL_VISUAL = 44355, + SPELL_MANA_RAGE = 44320, // This spell triggers 44321, which changes scale and regens mana Requires an entry in spell_script_target -#define SPELL_DRAIN_MANA 46153 // Heroic only + //Selin's spells + SPELL_DRAIN_LIFE = 44294, + SPELL_FEL_EXPLOSION = 44314, -#define CRYSTALS_NUMBER 5 -#define DATA_CRYSTALS 6 + SPELL_DRAIN_MANA = 46153 // Heroic only +}; -#define CREATURE_FEL_CRYSTAL 24722 +enum Misc +{ + CRYSTALS_NUMBER = 5, + DATA_CRYSTALS = 6, + CREATURE_FEL_CRYSTAL = 24722 +}; class boss_selin_fireheart : public CreatureScript { @@ -75,6 +82,7 @@ public: uint32 size = instance->GetData(DATA_FEL_CRYSTAL_SIZE); for (uint8 i = 0; i < size; ++i) { + instance->SetData64(DATA_FEL_CRYSTAL, i); uint64 guid = instance->GetData64(DATA_FEL_CRYSTAL); sLog->outDebug(LOG_FILTER_TSCR, "Selin: Adding Fel Crystal " UI64FMTD " to list", guid); Crystals.push_back(guid); @@ -115,10 +123,6 @@ public: } } - instance->HandleGameObject(instance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), true); - // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here) - // Small door opened after event are expected to be closed by default - // Set Inst data for encounter instance->SetData(DATA_SELIN_EVENT, NOT_STARTED); } else sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); @@ -164,8 +168,8 @@ public: } if (CrystalChosen) { - DoScriptText(SAY_ENERGY, me); - DoScriptText(EMOTE_CRYSTAL, me); + Talk(SAY_ENERGY); + Talk(EMOTE_CRYSTAL); CrystalChosen->CastSpell(CrystalChosen, SPELL_FEL_CRYSTAL_COSMETIC, true); @@ -195,16 +199,14 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); - + Talk(SAY_AGGRO); if (instance) - instance->HandleGameObject(instance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), false); - //Close the encounter door, open it in JustDied/Reset + instance->SetData(DATA_SELIN_EVENT, IN_PROGRESS); } void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), me); + Talk(SAY_KILL); } void MovementInform(uint32 type, uint32 id) @@ -231,14 +233,12 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (!instance) return; instance->SetData(DATA_SELIN_EVENT, DONE); // Encounter complete! - instance->HandleGameObject(instance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), true); // Open the encounter door - instance->HandleGameObject(instance->GetData64(DATA_SELIN_DOOR), true); // Open the door leading further in ShatterRemainingCrystals(); } @@ -300,7 +300,7 @@ public: IsDraining = false; DrainingCrystal = false; - DoScriptText(SAY_EMPOWERED, me); + Talk(SAY_EMPOWERED); Unit* CrystalChosen = Unit::GetUnit(*me, CrystalGUID); if (CrystalChosen && CrystalChosen->isAlive()) diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp index 34682683ee3..31821623878 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp @@ -29,11 +29,11 @@ EndScriptData */ enum eEnums { - SAY_AGGRO = -1585007, - SAY_ENERGY = -1585008, - SAY_OVERLOAD = -1585009, - SAY_KILL = -1585010, - EMOTE_DISCHARGE_ENERGY = -1585011, + SAY_AGGRO = 0, + SAY_ENERGY = 1, + SAY_OVERLOAD = 2, + SAY_KILL = 3, + EMOTE_DISCHARGE_ENERGY = 4, //is this text for real? //#define SAY_DEATH "What...happen...ed." @@ -99,7 +99,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_KILL, me); + Talk(SAY_KILL); } void JustDied(Unit* /*killer*/) @@ -110,7 +110,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); if (instance) instance->SetData(DATA_VEXALLUS_EVENT, IN_PROGRESS); @@ -144,8 +144,8 @@ public: else ++IntervalHealthAmount; - DoScriptText(SAY_ENERGY, me); - DoScriptText(EMOTE_DISCHARGE_ENERGY, me); + Talk(SAY_ENERGY); + Talk(EMOTE_DISCHARGE_ENERGY); if (IsHeroic()) { diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index da8b24c3985..c8bf50c0bcc 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -72,8 +72,7 @@ public: uint32 Encounter[MAX_ENCOUNTER]; uint32 DelrissaDeathCount; - std::list<uint64> FelCrystals; - std::list<uint64>::const_iterator CrystalItr; + std::vector<uint64> FelCrystals; uint64 SelinGUID; uint64 DelrissaGUID; @@ -84,8 +83,8 @@ public: uint64 KaelDoorGUID; uint64 KaelStatue[2]; uint64 EscapeOrbGUID; - - bool InitializedItr; + uint32 StatuesState; + uint8 felCristalIndex; void Initialize() { @@ -105,8 +104,8 @@ public: KaelStatue[0] = 0; KaelStatue[1] = 0; EscapeOrbGUID = 0; - - InitializedItr = false; + StatuesState = 0; + felCristalIndex = 0; } bool IsEncounterInProgress() const @@ -117,7 +116,7 @@ public: return false; } - uint32 GetData(uint32 identifier) + uint32 GetData(uint32 identifier) const { switch (identifier) { @@ -142,21 +141,35 @@ public: switch (identifier) { case DATA_SELIN_EVENT: + if (data == DONE) + { + HandleGameObject(SelinEncounterDoorGUID, true); + HandleGameObject(SelinDoorGUID, true); + } + else if (data == IN_PROGRESS) + HandleGameObject(SelinEncounterDoorGUID, false); + else if (data == NOT_STARTED) + HandleGameObject(SelinEncounterDoorGUID, true); + Encounter[0] = data; break; case DATA_VEXALLUS_EVENT: if (data == DONE) - DoUseDoorOrButton(VexallusDoorGUID); + HandleGameObject(VexallusDoorGUID, true); Encounter[1] = data; break; case DATA_DELRISSA_EVENT: if (data == DONE) - DoUseDoorOrButton(DelrissaDoorGUID); + HandleGameObject(DelrissaDoorGUID, true); if (data == IN_PROGRESS) DelrissaDeathCount = 0; Encounter[2] = data; break; case DATA_KAELTHAS_EVENT: + if (data == NOT_STARTED || data == DONE) + HandleGameObject(KaelDoorGUID, true); + else if (data == IN_PROGRESS) + HandleGameObject(KaelDoorGUID, false); Encounter[3] = data; break; case DATA_DELRISSA_DEATH_COUNT: @@ -165,7 +178,14 @@ public: else DelrissaDeathCount = 0; break; + case DATA_KAELTHAS_STATUES: + HandleGameObject(KaelStatue[0], data); + HandleGameObject(KaelStatue[1], data); + StatuesState = data; + break; } + + SaveToDB(); } void OnCreatureCreate(Creature* creature) @@ -215,7 +235,45 @@ public: } } - uint64 GetData64(uint32 identifier) + std::string GetSaveData() + { + OUT_SAVE_INST_DATA; + + std::ostringstream saveStream; + saveStream << Encounter[0] << ' ' << Encounter[1] << ' ' << Encounter[2] << ' ' << Encounter[3] << ' ' << StatuesState; + + OUT_SAVE_INST_DATA_COMPLETE; + return saveStream.str(); + } + + void Load(const char* str) + { + if (!str) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(str); + + std::istringstream loadStream(str); + + for (uint32 i = 0; i < MAX_ENCOUNTER; ++i) + { + uint32 tmpState; + loadStream >> tmpState; + if (tmpState == IN_PROGRESS || tmpState > SPECIAL) + tmpState = NOT_STARTED; + SetData(i, tmpState); + } + + loadStream >> StatuesState; + SetData(DATA_KAELTHAS_STATUES, StatuesState); + + OUT_LOAD_INST_DATA_COMPLETE; + } + + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -225,10 +283,6 @@ public: return DelrissaGUID; case DATA_VEXALLUS_DOOR: return VexallusDoorGUID; - case DATA_SELIN_DOOR: - return SelinDoorGUID; - case DATA_SELIN_ENCOUNTER_DOOR: - return SelinEncounterDoorGUID; case DATA_DELRISSA_DOOR: return DelrissaDoorGUID; case DATA_KAEL_DOOR: @@ -239,28 +293,23 @@ public: return KaelStatue[1]; case DATA_ESCAPE_ORB: return EscapeOrbGUID; - case DATA_FEL_CRYSTAL: - { - if (FelCrystals.empty()) + if (FelCrystals.size() < felCristalIndex) { sLog->outError(LOG_FILTER_TSCR, "Magisters Terrace: No Fel Crystals loaded in Inst Data"); return 0; } - if (!InitializedItr) - { - CrystalItr = FelCrystals.begin(); - InitializedItr = true; - } - - uint64 guid = *CrystalItr; - ++CrystalItr; - return guid; - } + return FelCrystals.at(felCristalIndex); } return 0; } + + void SetData64(uint32 identifier, uint64 value) + { + if (identifier == DATA_FEL_CRYSTAL) + felCristalIndex = value; + } }; }; diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp index 64b6c8d75b2..5925be5f415 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp @@ -30,6 +30,8 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## npc_kalecgos diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h index 660e58d325a..41b847635d7 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h @@ -23,28 +23,26 @@ enum Data { - DATA_SELIN_EVENT = 0, - DATA_VEXALLUS_EVENT = 1, - DATA_DELRISSA_EVENT = 2, - DATA_KAELTHAS_EVENT = 3, - - DATA_SELIN = 4, - DATA_FEL_CRYSTAL = 5, - DATA_FEL_CRYSTAL_SIZE = 6, - - DATA_VEXALLUS_DOOR = 7, - DATA_SELIN_DOOR = 8, - DATA_DELRISSA = 9, - DATA_DELRISSA_DOOR = 10, - DATA_SELIN_ENCOUNTER_DOOR = 11, - - DATA_KAEL_DOOR = 12, - DATA_KAEL_STATUE_LEFT = 13, - DATA_KAEL_STATUE_RIGHT = 14, - - DATA_DELRISSA_DEATH_COUNT = 15, - - DATA_ESCAPE_ORB = 16 + DATA_SELIN_EVENT, + DATA_VEXALLUS_EVENT, + DATA_DELRISSA_EVENT, + DATA_KAELTHAS_EVENT, + + DATA_SELIN, + DATA_FEL_CRYSTAL, + DATA_FEL_CRYSTAL_SIZE, + + DATA_VEXALLUS_DOOR, + DATA_DELRISSA, + DATA_DELRISSA_DOOR, + + DATA_KAEL_DOOR, + DATA_KAEL_STATUE_LEFT, + DATA_KAEL_STATUE_RIGHT, + + DATA_DELRISSA_DEATH_COUNT, + DATA_KAELTHAS_STATUES, + DATA_ESCAPE_ORB }; #endif diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp index fa99078cedb..5e5cc0ffab8 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp @@ -30,7 +30,7 @@ EndScriptData */ enum Texts { - EMOTE_LOWHP = -1409002, + EMOTE_LOWHP = 0, }; enum Spells @@ -149,7 +149,7 @@ class mob_core_rager : public CreatureScript if (pGolemagg->isAlive()) { me->AddAura(SPELL_GOLEMAGG_TRUST, me); - DoScriptText(EMOTE_LOWHP, me); + Talk(EMOTE_LOWHP); me->SetFullHealth(); } } diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp index f085e15fcb7..c7d6b31d2ea 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "molten_core.h" +#include "Player.h" enum Texts { diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp index 9d48d04cf07..edd8905ff4a 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp @@ -29,17 +29,17 @@ EndScriptData */ enum Texts { - SAY_REINFORCEMENTS1 = -1409013, - SAY_REINFORCEMENTS2 = -1409014, - SAY_HAND = -1409015, - SAY_WRATH = -1409016, - SAY_KILL = -1409017, - SAY_MAGMABURST = -1409018, - SAY_SUMMON_MAJ = -1409008, - SAY_ARRIVAL1_RAG = -1409009, - SAY_ARRIVAL2_MAJ = -1409010, - SAY_ARRIVAL3_RAG = -1409011, - SAY_ARRIVAL5_RAG = -1409012, + SAY_SUMMON_MAJ = 0, + SAY_ARRIVAL1_RAG = 1, + SAY_ARRIVAL2_MAJ = 2, + SAY_ARRIVAL3_RAG = 3, + SAY_ARRIVAL5_RAG = 4, + SAY_REINFORCEMENTS1 = 5, + SAY_REINFORCEMENTS2 = 6, + SAY_HAND = 7, + SAY_WRATH = 8, + SAY_KILL = 9, + SAY_MAGMABURST = 10 }; enum Spells @@ -112,7 +112,7 @@ class boss_ragnaros : public CreatureScript void KilledUnit(Unit* /*victim*/) { if (urand(0, 99) < 25) - DoScriptText(SAY_KILL, me); + Talk(SAY_KILL); } void UpdateAI(const uint32 diff) @@ -137,16 +137,16 @@ class boss_ragnaros : public CreatureScript switch (eventId) { case EVENT_INTRO_1: - DoScriptText(SAY_ARRIVAL1_RAG, me); + Talk(SAY_ARRIVAL1_RAG); break; case EVENT_INTRO_2: - DoScriptText(SAY_ARRIVAL3_RAG, me); + Talk(SAY_ARRIVAL3_RAG); break; case EVENT_INTRO_3: me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H); break; case EVENT_INTRO_4: - DoScriptText(SAY_ARRIVAL5_RAG, me); + Talk(SAY_ARRIVAL5_RAG); if (instance) if (Creature* executus = Unit::GetCreature(*me, instance->GetData64(BOSS_MAJORDOMO_EXECUTUS))) me->Kill(executus); @@ -205,13 +205,13 @@ class boss_ragnaros : public CreatureScript case EVENT_WRATH_OF_RAGNAROS: DoCastVictim(SPELL_WRATH_OF_RAGNAROS); if (urand(0, 1)) - DoScriptText(SAY_WRATH, me); + Talk(SAY_WRATH); events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 25000); break; case EVENT_HAND_OF_RAGNAROS: DoCast(me, SPELL_HAND_OF_RAGNAROS); if (urand(0, 1)) - DoScriptText(SAY_HAND, me); + Talk(SAY_HAND); events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 20000); break; case EVENT_LAVA_BURST: @@ -229,7 +229,7 @@ class boss_ragnaros : public CreatureScript if (!_hasYelledMagmaBurst) { //Say our dialog - DoScriptText(SAY_MAGMABURST, me); + Talk(SAY_MAGMABURST); _hasYelledMagmaBurst = true; } } @@ -256,7 +256,7 @@ class boss_ragnaros : public CreatureScript if (!_hasSubmergedOnce) { - DoScriptText(SAY_REINFORCEMENTS1, me); + Talk(SAY_REINFORCEMENTS1); // summon 8 elementals for (uint8 i = 0; i < 8; ++i) @@ -272,7 +272,7 @@ class boss_ragnaros : public CreatureScript } else { - DoScriptText(SAY_REINFORCEMENTS2, me); + Talk(SAY_REINFORCEMENTS2); for (uint8 i = 0; i < 8; ++i) if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/instance_molten_core.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/instance_molten_core.cpp index f6a6e647a1d..1a055b9bce0 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/instance_molten_core.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/instance_molten_core.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "InstanceScript.h" #include "CreatureAI.h" #include "molten_core.h" +#include "TemporarySummon.h" Position const SummonPositions[10] = { @@ -116,7 +117,7 @@ class instance_molten_core : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -127,7 +128,7 @@ class instance_molten_core : public InstanceMapScript return 0; } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index c17a059d007..0cb2bd7f7bc 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -23,6 +23,8 @@ #include "ScriptedEscortAI.h" #include "CombatAI.h" #include "PassiveAI.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ##Quest 12848 @@ -307,7 +309,7 @@ public: prisonerGUID = guid; } - uint64 GetGUID(int32 /*id*/) + uint64 GetGUID(int32 /*id*/) const { return prisonerGUID; } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp index b4c6268a43e..78fc8d127b2 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -18,33 +18,34 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "SpellInfo.h" //How to win friends and influence enemies // texts signed for creature 28939 but used for 28939, 28940, 28610 enum win_friends { - SAY_PERSUADE1 = -1609501, - SAY_PERSUADE2 = -1609502, - SAY_PERSUADE3 = -1609503, - SAY_PERSUADE4 = -1609504, - SAY_PERSUADE5 = -1609505, - SAY_PERSUADE6 = -1609506, - SAY_PERSUADE7 = -1609507, - SAY_CRUSADER1 = -1609508, - SAY_CRUSADER2 = -1609509, - SAY_CRUSADER3 = -1609510, - SAY_CRUSADER4 = -1609511, - SAY_CRUSADER5 = -1609512, - SAY_CRUSADER6 = -1609513, - SAY_PERSUADED1 = -1609514, - SAY_PERSUADED2 = -1609515, - SAY_PERSUADED3 = -1609516, - SAY_PERSUADED4 = -1609517, - SAY_PERSUADED5 = -1609518, - SAY_PERSUADED6 = -1609519, - SPELL_PERSUASIVE_STRIKE = 52781 + SAY_CRUSADER = 1, + SAY_PERSUADED1 = 2, + SAY_PERSUADED2 = 3, + SAY_PERSUADED3 = 4, + SAY_PERSUADED4 = 5, + SAY_PERSUADED6 = 6, + SPELL_PERSUASIVE_STRIKE = 52781, + SPELL_THREAT_PULSE = 58111, + QUEST_HOW_TO_WIN_FRIENDS = 12720, }; +#define SAY_PERSUADED5 "LIES! The pain you are about to endure will be talked about for years to come!" + +#define SAY_PERSUADE1 "I'll tear the secrets from your soul! Tell me about the \"Crimson Dawn\" and your life may be spared!" +#define SAY_PERSUADE2 "Tell me what you know about \"Crimson Dawn\" or the beatings will continue!" +#define SAY_PERSUADE3 "I'm through being courteous with your kind, human! What is the \"Crimson Dawn\"?" +#define SAY_PERSUADE4 "Is your life worth so little? Just tell me what I need to know about \"Crimson Dawn\" and I'll end your suffering quickly." +#define SAY_PERSUADE5 "I can keep this up for a very long time, Scarlet dog! Tell me about the \"Crimson Dawn\"!" +#define SAY_PERSUADE6 "What is the \"Crimson Dawn\"?" +#define SAY_PERSUADE7 "\"Crimson Dawn\"! What is it! Speak!" + class npc_crusade_persuaded : public CreatureScript { public: @@ -59,97 +60,119 @@ public: { npc_crusade_persuadedAI(Creature* creature) : ScriptedAI(creature) {} - uint32 uiSpeech_timer; - uint32 uiSpeech_counter; - uint64 uiPlayerGUID; + uint32 speechTimer; + uint32 speechCounter; + uint64 playerGUID; void Reset() { - uiSpeech_timer = 0; - uiSpeech_counter = 0; - uiPlayerGUID = 0; + speechTimer = 0; + speechCounter = 0; + playerGUID = 0; me->SetReactState(REACT_AGGRESSIVE); me->RestoreFaction(); } void SpellHit(Unit* caster, const SpellInfo* spell) { - if (spell->Id == SPELL_PERSUASIVE_STRIKE && caster->GetTypeId() == TYPEID_PLAYER && me->isAlive() && !uiSpeech_counter) + if (spell->Id == SPELL_PERSUASIVE_STRIKE && caster->GetTypeId() == TYPEID_PLAYER && me->isAlive() && !speechCounter) { - if (CAST_PLR(caster)->GetQuestStatus(12720) == QUEST_STATUS_INCOMPLETE) + if (Player* player = caster->ToPlayer()) { - uiPlayerGUID = caster->GetGUID(); - uiSpeech_timer = 1000; - uiSpeech_counter = 1; - me->setFaction(caster->getFaction()); - me->CombatStop(true); - me->GetMotionMaster()->MoveIdle(); - me->SetReactState(REACT_PASSIVE); - DoCastAOE(58111, true); - - DoScriptText(RAND(SAY_PERSUADE1, SAY_PERSUADE2, SAY_PERSUADE3, - SAY_PERSUADE4, SAY_PERSUADE5, SAY_PERSUADE6, - SAY_PERSUADE7), caster); - - DoScriptText(RAND(SAY_CRUSADER1, SAY_CRUSADER2, SAY_CRUSADER3, - SAY_CRUSADER4, SAY_CRUSADER5, SAY_CRUSADER6), me); + if (player->GetQuestStatus(QUEST_HOW_TO_WIN_FRIENDS) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + speechTimer = 1000; + speechCounter = 1; + me->setFaction(player->getFaction()); + me->CombatStop(true); + me->GetMotionMaster()->MoveIdle(); + me->SetReactState(REACT_PASSIVE); + DoCastAOE(SPELL_THREAT_PULSE, true); + + switch (urand(1, 7)) + { + case 1: + player->Say(SAY_PERSUADE1, LANG_UNIVERSAL); + break; + case 2: + player->Say(SAY_PERSUADE2, LANG_UNIVERSAL); + break; + case 3: + player->Say(SAY_PERSUADE3, LANG_UNIVERSAL); + break; + case 4: + player->Say(SAY_PERSUADE4, LANG_UNIVERSAL); + break; + case 5: + player->Say(SAY_PERSUADE5, LANG_UNIVERSAL); + break; + case 6: + player->Say(SAY_PERSUADE6, LANG_UNIVERSAL); + break; + case 7: + player->Say(SAY_PERSUADE7, LANG_UNIVERSAL); + break; + } + Talk(SAY_CRUSADER); + } } } } void UpdateAI(const uint32 diff) { - if (uiSpeech_counter) + if (speechCounter) { - if (uiSpeech_timer <= diff) + if (speechTimer <= diff) { - Player* player = Unit::GetPlayer(*me, uiPlayerGUID); + Player* player = Unit::GetPlayer(*me, playerGUID); if (!player) { EnterEvadeMode(); return; } - switch (uiSpeech_counter) + switch (speechCounter) { case 1: - DoScriptText(SAY_PERSUADED1, me); - uiSpeech_timer = 8000; + Talk(SAY_PERSUADED1); + speechTimer = 8000; break; case 2: - DoScriptText(SAY_PERSUADED2, me); - uiSpeech_timer = 8000; + Talk(SAY_PERSUADED2); + speechTimer = 8000; break; case 3: - DoScriptText(SAY_PERSUADED3, me); - uiSpeech_timer = 8000; + Talk(SAY_PERSUADED3); + speechTimer = 8000; break; case 4: - DoScriptText(SAY_PERSUADED4, me); - uiSpeech_timer = 8000; + Talk(SAY_PERSUADED4); + speechTimer = 8000; break; case 5: - DoScriptText(SAY_PERSUADED5, player); - uiSpeech_timer = 8000; + player->Say(SAY_PERSUADED5, LANG_UNIVERSAL); + speechTimer = 8000; break; case 6: - DoScriptText(SAY_PERSUADED6, me); + Talk(SAY_PERSUADED6); player->Kill(me); - //me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - //me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - uiSpeech_counter = 0; - player->GroupEventHappens(12720, me); + speechCounter = 0; + player->GroupEventHappens(QUEST_HOW_TO_WIN_FRIENDS, me); return; } - ++uiSpeech_counter; - DoCastAOE(58111, true); - } else uiSpeech_timer -= diff; + ++speechCounter; + DoCastAOE(SPELL_THREAT_PULSE, true); + + } else + speechTimer -= diff; return; } @@ -169,16 +192,16 @@ public: enum eKoltira { - SAY_BREAKOUT1 = -1609561, - SAY_BREAKOUT2 = -1609562, - SAY_BREAKOUT3 = -1609563, - SAY_BREAKOUT4 = -1609564, - SAY_BREAKOUT5 = -1609565, - SAY_BREAKOUT6 = -1609566, - SAY_BREAKOUT7 = -1609567, - SAY_BREAKOUT8 = -1609568, - SAY_BREAKOUT9 = -1609569, - SAY_BREAKOUT10 = -1609570, + SAY_BREAKOUT1 = 0, + SAY_BREAKOUT2 = 1, + SAY_BREAKOUT3 = 2, + SAY_BREAKOUT4 = 3, + SAY_BREAKOUT5 = 4, + SAY_BREAKOUT6 = 5, + SAY_BREAKOUT7 = 6, + SAY_BREAKOUT8 = 7, + SAY_BREAKOUT9 = 8, + SAY_BREAKOUT10 = 9, SPELL_KOLTIRA_TRANSFORM = 52899, SPELL_ANTI_MAGIC_ZONE = 52894, @@ -245,7 +268,7 @@ public: switch (waypointId) { case 0: - DoScriptText(SAY_BREAKOUT1, me); + Talk(SAY_BREAKOUT1); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); break; case 1: @@ -260,7 +283,7 @@ public: case 3: SetEscortPaused(true); me->SetStandState(UNIT_STAND_STATE_KNEEL); - DoScriptText(SAY_BREAKOUT2, me); + Talk(SAY_BREAKOUT2); DoCast(me, SPELL_ANTI_MAGIC_ZONE); // cast again that makes bubble up break; case 4: @@ -304,22 +327,22 @@ public: switch (m_uiWave) { case 0: - DoScriptText(SAY_BREAKOUT3, me); + Talk(SAY_BREAKOUT3); SummonAcolyte(3); m_uiWave_Timer = 20000; break; case 1: - DoScriptText(SAY_BREAKOUT4, me); + Talk(SAY_BREAKOUT4); SummonAcolyte(3); m_uiWave_Timer = 20000; break; case 2: - DoScriptText(SAY_BREAKOUT5, me); + Talk(SAY_BREAKOUT5); SummonAcolyte(4); m_uiWave_Timer = 20000; break; case 3: - DoScriptText(SAY_BREAKOUT6, me); + Talk(SAY_BREAKOUT6); me->SummonCreature(NPC_HIGH_INQUISITOR_VALROTH, 1642.329f, -6045.818f, 127.583f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); m_uiWave_Timer = 1000; break; @@ -329,7 +352,7 @@ public: if (!temp || !temp->isAlive()) { - DoScriptText(SAY_BREAKOUT8, me); + Talk(SAY_BREAKOUT8); m_uiWave_Timer = 5000; } else @@ -340,13 +363,13 @@ public: break; } case 5: - DoScriptText(SAY_BREAKOUT9, me); + Talk(SAY_BREAKOUT9); me->RemoveAurasDueToSpell(SPELL_ANTI_MAGIC_ZONE); // i do not know why the armor will also be removed m_uiWave_Timer = 2500; break; case 6: - DoScriptText(SAY_BREAKOUT10, me); + Talk(SAY_BREAKOUT10); SetEscortPaused(false); break; } @@ -364,8 +387,8 @@ public: //Scarlet courier enum ScarletCourierEnum { - SAY_TREE1 = -1609531, - SAY_TREE2 = -1609532, + SAY_TREE1 = 0, + SAY_TREE2 = 1, SPELL_SHOOT = 52818, GO_INCONSPICUOUS_TREE = 191144, NPC_SCARLET_COURIER = 29076 @@ -397,7 +420,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_TREE2, me); + Talk(SAY_TREE2); me->Dismount(); uiStage = 0; } @@ -423,7 +446,7 @@ public: me->SetWalk(true); if (GameObject* tree = me->FindNearestGameObject(GO_INCONSPICUOUS_TREE, 40.0f)) { - DoScriptText(SAY_TREE1, me); + Talk(SAY_TREE1); float x, y, z; tree->GetContactPoint(me, x, y, z); me->GetMotionMaster()->MovePoint(1, x, y, z); @@ -453,12 +476,10 @@ public: enum valroth { - SAY_VALROTH1 = -1609581, - SAY_VALROTH2 = -1609582, - SAY_VALROTH3 = -1609583, - SAY_VALROTH4 = -1609584, - SAY_VALROTH5 = -1609585, - SAY_VALROTH6 = -1609586, + //SAY_VALROTH1 = 0, Unused + SAY_VALROTH_AGGRO = 1, + SAY_VALROTH_RAND = 2, + SAY_VALROTH_DEATH = 3, SPELL_RENEW = 38210, SPELL_INQUISITOR_PENANCE = 52922, SPELL_VALROTH_SMITE = 52926, @@ -492,7 +513,7 @@ public: void EnterCombat(Unit* who) { - DoScriptText(SAY_VALROTH2, me); + Talk(SAY_VALROTH_AGGRO); DoCast(who, SPELL_VALROTH_SMITE); } @@ -525,12 +546,12 @@ public: void Shout() { if (rand()%100 < 15) - DoScriptText(RAND(SAY_VALROTH3, SAY_VALROTH4, SAY_VALROTH5), me); + Talk(SAY_VALROTH_RAND); } void JustDied(Unit* killer) { - DoScriptText(SAY_VALROTH6, me); + Talk(SAY_VALROTH_DEATH); killer->CastSpell(me, SPELL_SUMMON_VALROTH_REMAINS, true); } }; @@ -543,60 +564,60 @@ public: //used by 29032, 29061, 29065, 29067, 29068, 29070, 29074, 29072, 29073, 29071 but signed for 29032 enum SpecialSurprise { - SAY_EXEC_START_1 = -1609025, // speech for all - SAY_EXEC_START_2 = -1609026, - SAY_EXEC_START_3 = -1609027, - SAY_EXEC_PROG_1 = -1609028, - SAY_EXEC_PROG_2 = -1609029, - SAY_EXEC_PROG_3 = -1609030, - SAY_EXEC_PROG_4 = -1609031, - SAY_EXEC_PROG_5 = -1609032, - SAY_EXEC_PROG_6 = -1609033, - SAY_EXEC_PROG_7 = -1609034, - SAY_EXEC_NAME_1 = -1609035, - SAY_EXEC_NAME_2 = -1609036, - SAY_EXEC_RECOG_1 = -1609037, - SAY_EXEC_RECOG_2 = -1609038, - SAY_EXEC_RECOG_3 = -1609039, - SAY_EXEC_RECOG_4 = -1609040, - SAY_EXEC_RECOG_5 = -1609041, - SAY_EXEC_RECOG_6 = -1609042, - SAY_EXEC_NOREM_1 = -1609043, - SAY_EXEC_NOREM_2 = -1609044, - SAY_EXEC_NOREM_3 = -1609045, - SAY_EXEC_NOREM_4 = -1609046, - SAY_EXEC_NOREM_5 = -1609047, - SAY_EXEC_NOREM_6 = -1609048, - SAY_EXEC_NOREM_7 = -1609049, - SAY_EXEC_NOREM_8 = -1609050, - SAY_EXEC_NOREM_9 = -1609051, - SAY_EXEC_THINK_1 = -1609052, - SAY_EXEC_THINK_2 = -1609053, - SAY_EXEC_THINK_3 = -1609054, - SAY_EXEC_THINK_4 = -1609055, - SAY_EXEC_THINK_5 = -1609056, - SAY_EXEC_THINK_6 = -1609057, - SAY_EXEC_THINK_7 = -1609058, - SAY_EXEC_THINK_8 = -1609059, - SAY_EXEC_THINK_9 = -1609060, - SAY_EXEC_THINK_10 = -1609061, - SAY_EXEC_LISTEN_1 = -1609062, - SAY_EXEC_LISTEN_2 = -1609063, - SAY_EXEC_LISTEN_3 = -1609064, - SAY_EXEC_LISTEN_4 = -1609065, - SAY_PLAGUEFIST = -1609066, - SAY_EXEC_TIME_1 = -1609067, - SAY_EXEC_TIME_2 = -1609068, - SAY_EXEC_TIME_3 = -1609069, - SAY_EXEC_TIME_4 = -1609070, - SAY_EXEC_TIME_5 = -1609071, - SAY_EXEC_TIME_6 = -1609072, - SAY_EXEC_TIME_7 = -1609073, - SAY_EXEC_TIME_8 = -1609074, - SAY_EXEC_TIME_9 = -1609075, - SAY_EXEC_TIME_10 = -1609076, - SAY_EXEC_WAITING = -1609077, - EMOTE_DIES = -1609078, + SAY_EXEC_START_1 = 0, // speech for all + SAY_EXEC_START_2 = 1, + SAY_EXEC_START_3 = 2, + SAY_EXEC_PROG_1 = 3, + SAY_EXEC_PROG_2 = 4, + SAY_EXEC_PROG_3 = 5, + SAY_EXEC_PROG_4 = 6, + SAY_EXEC_PROG_5 = 7, + SAY_EXEC_PROG_6 = 8, + SAY_EXEC_PROG_7 = 9, + SAY_EXEC_NAME_1 = 10, + SAY_EXEC_NAME_2 = 11, + SAY_EXEC_RECOG_1 = 12, + SAY_EXEC_RECOG_2 = 13, + SAY_EXEC_RECOG_3 = 14, + SAY_EXEC_RECOG_4 = 15, + SAY_EXEC_RECOG_5 = 16, + SAY_EXEC_RECOG_6 = 17, + SAY_EXEC_NOREM_1 = 18, + SAY_EXEC_NOREM_2 = 19, + SAY_EXEC_NOREM_3 = 20, + SAY_EXEC_NOREM_4 = 21, + SAY_EXEC_NOREM_5 = 22, + SAY_EXEC_NOREM_6 = 23, + SAY_EXEC_NOREM_7 = 24, + SAY_EXEC_NOREM_8 = 25, + SAY_EXEC_NOREM_9 = 26, + SAY_EXEC_THINK_1 = 27, + SAY_EXEC_THINK_2 = 28, + SAY_EXEC_THINK_3 = 29, + SAY_EXEC_THINK_4 = 30, + SAY_EXEC_THINK_5 = 31, + SAY_EXEC_THINK_6 = 32, + SAY_EXEC_THINK_7 = 33, + SAY_EXEC_THINK_8 = 34, + SAY_EXEC_THINK_9 = 35, + SAY_EXEC_THINK_10 = 36, + SAY_EXEC_LISTEN_1 = 37, + SAY_EXEC_LISTEN_2 = 38, + SAY_EXEC_LISTEN_3 = 39, + SAY_EXEC_LISTEN_4 = 40, + SAY_PLAGUEFIST = 41, + SAY_EXEC_TIME_1 = 42, + SAY_EXEC_TIME_2 = 43, + SAY_EXEC_TIME_3 = 44, + SAY_EXEC_TIME_4 = 45, + SAY_EXEC_TIME_5 = 46, + SAY_EXEC_TIME_6 = 47, + SAY_EXEC_TIME_7 = 48, + SAY_EXEC_TIME_8 = 49, + SAY_EXEC_TIME_9 = 50, + SAY_EXEC_TIME_10 = 51, + SAY_EXEC_WAITING = 52, + EMOTE_DIES = 53, NPC_PLAGUEFIST = 29053 }; @@ -707,28 +728,28 @@ public: case RACE_HUMAN: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_5, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_5, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_7, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; + case 2: Talk(SAY_EXEC_PROG_5, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_1, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_5, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_7, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_1, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_6, me, player); + Talk(SAY_EXEC_TIME_6, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -737,28 +758,28 @@ public: case RACE_ORC: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_6, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_7, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_8, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; + case 2: Talk(SAY_EXEC_PROG_6, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_1, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_7, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_8, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_1, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_8, me, player); + Talk(SAY_EXEC_TIME_8, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -767,28 +788,28 @@ public: case RACE_DWARF: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_2, me, player); break; + case 0: Talk(SAY_EXEC_START_2, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_2, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_3, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_2, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_5, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_2, me, player); break; + case 2: Talk(SAY_EXEC_PROG_2, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_3, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_2, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_5, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_2, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_3, me, player); + Talk(SAY_EXEC_TIME_3, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -797,28 +818,28 @@ public: case RACE_NIGHTELF: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_5, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_6, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_2, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; + case 2: Talk(SAY_EXEC_PROG_5, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_1, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_6, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_2, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_1, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_7, me, player); + Talk(SAY_EXEC_TIME_7, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -827,28 +848,28 @@ public: case RACE_UNDEAD_PLAYER: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_3, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_4, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_3, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_1, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_3, me, player); break; + case 2: Talk(SAY_EXEC_PROG_3, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_4, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_3, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_1, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_3, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_4, me, player); + Talk(SAY_EXEC_TIME_4, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -857,28 +878,28 @@ public: case RACE_TAUREN: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_1, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_5, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_8, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_9, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; + case 2: Talk(SAY_EXEC_PROG_1, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_5, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_8, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_9, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_1, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_9, me, player); + Talk(SAY_EXEC_TIME_9, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -887,28 +908,28 @@ public: case RACE_GNOME: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_4, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_4, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_6, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; + case 2: Talk(SAY_EXEC_PROG_4, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_1, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_4, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_6, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_1, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_5, me, player); + Talk(SAY_EXEC_TIME_5, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -917,28 +938,28 @@ public: case RACE_TROLL: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_3, me, player); break; + case 0: Talk(SAY_EXEC_START_3, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_7, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_2, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_6, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_9, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_10, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_4, me, player); break; + case 2: Talk(SAY_EXEC_PROG_7, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_2, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_6, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_9, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_10, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_4, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_10, me, player); + Talk(SAY_EXEC_TIME_10, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -947,28 +968,28 @@ public: case RACE_BLOODELF: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_1, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_1, me, player); break; + case 2: Talk(SAY_EXEC_PROG_1, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_1, player->GetGUID()); break; //case 5: //unknown - case 6: DoScriptText(SAY_EXEC_THINK_3, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; + case 6: Talk(SAY_EXEC_THINK_3, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_1, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_1, me, player); + Talk(SAY_EXEC_TIME_1, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; @@ -977,28 +998,28 @@ public: case RACE_DRAENEI: switch (ExecuteSpeech_Counter) { - case 0: DoScriptText(SAY_EXEC_START_1, me, player); break; + case 0: Talk(SAY_EXEC_START_1, player->GetGUID()); break; case 1: me->SetStandState(UNIT_STAND_STATE_STAND); break; - case 2: DoScriptText(SAY_EXEC_PROG_1, me, player); break; - case 3: DoScriptText(SAY_EXEC_NAME_1, me, player); break; - case 4: DoScriptText(SAY_EXEC_RECOG_2, me, player); break; - case 5: DoScriptText(SAY_EXEC_NOREM_1, me, player); break; - case 6: DoScriptText(SAY_EXEC_THINK_4, me, player); break; - case 7: DoScriptText(SAY_EXEC_LISTEN_1, me, player); break; + case 2: Talk(SAY_EXEC_PROG_1, player->GetGUID()); break; + case 3: Talk(SAY_EXEC_NAME_1, player->GetGUID()); break; + case 4: Talk(SAY_EXEC_RECOG_2, player->GetGUID()); break; + case 5: Talk(SAY_EXEC_NOREM_1, player->GetGUID()); break; + case 6: Talk(SAY_EXEC_THINK_4, player->GetGUID()); break; + case 7: Talk(SAY_EXEC_LISTEN_1, player->GetGUID()); break; case 8: if (Creature* Plaguefist = GetClosestCreatureWithEntry(me, NPC_PLAGUEFIST, 85.0f)) - DoScriptText(SAY_PLAGUEFIST, Plaguefist, player); + Plaguefist->AI()->Talk(SAY_PLAGUEFIST, player->GetGUID()); break; case 9: - DoScriptText(SAY_EXEC_TIME_2, me, player); + Talk(SAY_EXEC_TIME_2, player->GetGUID()); me->SetStandState(UNIT_STAND_STATE_KNEEL); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); break; case 10: - DoScriptText(SAY_EXEC_WAITING, me, player); + Talk(SAY_EXEC_WAITING, player->GetGUID()); break; case 11: - DoScriptText(EMOTE_DIES, me); + Talk(EMOTE_DIES); me->setDeathState(JUST_DIED); me->SetHealth(0); return; diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 4d1552b932e..77c1e3bc066 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" #define LESS_MOB // if you do not have a good server and do not want it to be laggy as hell //Light of Dawn @@ -50,93 +51,78 @@ enum mograine WORLD_STATE_COUNTDOWN = 3603, WORLD_STATE_EVENT_BEGIN = 3605, - SAY_LIGHT_OF_DAWN01 = -1609201, // pre text - SAY_LIGHT_OF_DAWN02 = -1609202, - SAY_LIGHT_OF_DAWN03 = -1609203, - SAY_LIGHT_OF_DAWN04 = -1609204, // intro - SAY_LIGHT_OF_DAWN05 = -1609205, - SAY_LIGHT_OF_DAWN06 = -1609206, - SAY_LIGHT_OF_DAWN07 = -1609207, // During the fight - Korfax, Champion of the Light - SAY_LIGHT_OF_DAWN08 = -1609208, // Lord Maxwell Tyrosus - SAY_LIGHT_OF_DAWN09 = -1609209, // Highlord Darion Mograine - SAY_LIGHT_OF_DAWN10 = -1609210, - SAY_LIGHT_OF_DAWN11 = -1609211, - SAY_LIGHT_OF_DAWN12 = -1609212, - SAY_LIGHT_OF_DAWN13 = -1609213, - SAY_LIGHT_OF_DAWN14 = -1609214, - SAY_LIGHT_OF_DAWN15 = -1609215, - SAY_LIGHT_OF_DAWN16 = -1609216, - SAY_LIGHT_OF_DAWN17 = -1609217, - SAY_LIGHT_OF_DAWN18 = -1609218, - SAY_LIGHT_OF_DAWN19 = -1609219, - SAY_LIGHT_OF_DAWN20 = -1609220, - SAY_LIGHT_OF_DAWN21 = -1609221, - SAY_LIGHT_OF_DAWN22 = -1609222, - SAY_LIGHT_OF_DAWN23 = -1609223, - SAY_LIGHT_OF_DAWN24 = -1609224, - SAY_LIGHT_OF_DAWN25 = -1609225, // After the fight - SAY_LIGHT_OF_DAWN26 = -1609226, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN27 = -1609227, // Highlord Darion Mograine - SAY_LIGHT_OF_DAWN28 = -1609228, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN29 = -1609229, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN30 = -1609230, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN31 = -1609231, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN32 = -1609232, // Highlord Alexandros Mograine - SAY_LIGHT_OF_DAWN33 = -1609233, // Highlord Darion Mograine - SAY_LIGHT_OF_DAWN34 = -1609234, // Highlord Darion Mograine - SAY_LIGHT_OF_DAWN35 = -1609235, // Darion Mograine - SAY_LIGHT_OF_DAWN36 = -1609236, // Darion Mograine - SAY_LIGHT_OF_DAWN37 = -1609237, // Highlord Alexandros Mograine - SAY_LIGHT_OF_DAWN38 = -1609238, // Darion Mograine - SAY_LIGHT_OF_DAWN39 = -1609239, // Highlord Alexandros Mograine - SAY_LIGHT_OF_DAWN40 = -1609240, // Darion Mograine - SAY_LIGHT_OF_DAWN41 = -1609241, // Highlord Alexandros Mograine - SAY_LIGHT_OF_DAWN42 = -1609242, // Highlord Alexandros Mograine - SAY_LIGHT_OF_DAWN43 = -1609243, // The Lich King - SAY_LIGHT_OF_DAWN44 = -1609244, // Highlord Darion Mograine - SAY_LIGHT_OF_DAWN45 = -1609245, // The Lich King - SAY_LIGHT_OF_DAWN46 = -1609246, // The Lich King - SAY_LIGHT_OF_DAWN47 = -1609247, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN48 = -1609248, // The Lich King - SAY_LIGHT_OF_DAWN49 = -1609249, // The Lich King - SAY_LIGHT_OF_DAWN50 = -1609250, // Lord Maxwell Tyrosus - SAY_LIGHT_OF_DAWN51 = -1609251, // The Lich King - SAY_LIGHT_OF_DAWN52 = -1609252, // Highlord Darion Mograine - SAY_LIGHT_OF_DAWN53 = -1609253, // Highlord Darion Mograine - SAY_LIGHT_OF_DAWN54 = -1609254, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN55 = -1609255, // The Lich King - SAY_LIGHT_OF_DAWN56 = -1609256, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN57 = -1609257, // The Lich King - SAY_LIGHT_OF_DAWN58 = -1609258, // The Lich King - SAY_LIGHT_OF_DAWN59 = -1609259, // The Lich King - SAY_LIGHT_OF_DAWN60 = -1609260, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN61 = -1609261, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN62 = -1609262, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN63 = -1609263, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN64 = -1609264, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN65 = -1609265, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN66 = -1609266, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN67 = -1609267, // Highlord Tirion Fordring - SAY_LIGHT_OF_DAWN68 = -1609268, // Highlord Darion Mograine - - EMOTE_LIGHT_OF_DAWN01 = -1609269, // Emotes - EMOTE_LIGHT_OF_DAWN02 = -1609270, - EMOTE_LIGHT_OF_DAWN03 = -1609271, - EMOTE_LIGHT_OF_DAWN04 = -1609272, - EMOTE_LIGHT_OF_DAWN05 = -1609273, - EMOTE_LIGHT_OF_DAWN06 = -1609274, - EMOTE_LIGHT_OF_DAWN07 = -1609275, - EMOTE_LIGHT_OF_DAWN08 = -1609276, - EMOTE_LIGHT_OF_DAWN09 = -1609277, - EMOTE_LIGHT_OF_DAWN10 = -1609278, - EMOTE_LIGHT_OF_DAWN11 = -1609279, - EMOTE_LIGHT_OF_DAWN12 = -1609280, - EMOTE_LIGHT_OF_DAWN13 = -1609281, - EMOTE_LIGHT_OF_DAWN14 = -1609282, - EMOTE_LIGHT_OF_DAWN15 = -1609283, - EMOTE_LIGHT_OF_DAWN16 = -1609284, - EMOTE_LIGHT_OF_DAWN17 = -1609285, - EMOTE_LIGHT_OF_DAWN18 = -1609286, + SAY_LIGHT_OF_DAWN01 = 0, // pre text + SAY_LIGHT_OF_DAWN02 = 1, + SAY_LIGHT_OF_DAWN03 = 2, + SAY_LIGHT_OF_DAWN04 = 3, // intro + SAY_LIGHT_OF_DAWN05 = 4, + SAY_LIGHT_OF_DAWN06 = 5, + SAY_LIGHT_OF_DAWN07 = 6, // During the fight - Korfax, Champion of the Light + SAY_LIGHT_OF_DAWN08 = 7, // Lord Maxwell Tyrosus + SAY_LIGHT_OF_DAWN09 = 8, // Highlord Darion Mograine + SAY_LIGHT_OF_DAWN25 = 24, // After the fight + SAY_LIGHT_OF_DAWN26 = 25, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN27 = 26, // Highlord Darion Mograine + SAY_LIGHT_OF_DAWN28 = 27, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN29 = 28, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN30 = 29, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN31 = 30, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN32 = 31, // Highlord Alexandros Mograine + SAY_LIGHT_OF_DAWN33 = 32, // Highlord Darion Mograine + SAY_LIGHT_OF_DAWN34 = 33, // Highlord Darion Mograine + SAY_LIGHT_OF_DAWN35 = 34, // Darion Mograine + SAY_LIGHT_OF_DAWN36 = 35, // Darion Mograine + SAY_LIGHT_OF_DAWN37 = 36, // Highlord Alexandros Mograine + SAY_LIGHT_OF_DAWN38 = 37, // Darion Mograine + SAY_LIGHT_OF_DAWN39 = 38, // Highlord Alexandros Mograine + SAY_LIGHT_OF_DAWN40 = 39, // Darion Mograine + SAY_LIGHT_OF_DAWN41 = 40, // Highlord Alexandros Mograine + SAY_LIGHT_OF_DAWN42 = 41, // Highlord Alexandros Mograine + SAY_LIGHT_OF_DAWN43 = 42, // The Lich King + SAY_LIGHT_OF_DAWN44 = 43, // Highlord Darion Mograine + SAY_LIGHT_OF_DAWN45 = 44, // The Lich King + SAY_LIGHT_OF_DAWN46 = 45, // The Lich King + SAY_LIGHT_OF_DAWN47 = 46, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN48 = 47, // The Lich King + SAY_LIGHT_OF_DAWN49 = 48, // The Lich King + SAY_LIGHT_OF_DAWN50 = 49, // Lord Maxwell Tyrosus + SAY_LIGHT_OF_DAWN51 = 50, // The Lich King + SAY_LIGHT_OF_DAWN52 = 51, // Highlord Darion Mograine + SAY_LIGHT_OF_DAWN53 = 52, // Highlord Darion Mograine + SAY_LIGHT_OF_DAWN54 = 53, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN55 = 54, // The Lich King + SAY_LIGHT_OF_DAWN56 = 55, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN57 = 56, // The Lich King + SAY_LIGHT_OF_DAWN58 = 57, // The Lich King + SAY_LIGHT_OF_DAWN59 = 58, // The Lich King + SAY_LIGHT_OF_DAWN60 = 59, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN61 = 60, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN62 = 61, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN63 = 62, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN64 = 63, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN65 = 64, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN66 = 65, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN67 = 66, // Highlord Tirion Fordring + SAY_LIGHT_OF_DAWN68 = 67, // Highlord Darion Mograine + + EMOTE_LIGHT_OF_DAWN01 = 68, // Emotes + EMOTE_LIGHT_OF_DAWN02 = 69, + EMOTE_LIGHT_OF_DAWN03 = 70, + EMOTE_LIGHT_OF_DAWN04 = 71, + EMOTE_LIGHT_OF_DAWN05 = 72, + EMOTE_LIGHT_OF_DAWN06 = 73, + EMOTE_LIGHT_OF_DAWN07 = 74, + EMOTE_LIGHT_OF_DAWN08 = 75, + EMOTE_LIGHT_OF_DAWN09 = 76, + EMOTE_LIGHT_OF_DAWN10 = 77, + EMOTE_LIGHT_OF_DAWN11 = 78, + EMOTE_LIGHT_OF_DAWN12 = 79, + EMOTE_LIGHT_OF_DAWN13 = 80, + EMOTE_LIGHT_OF_DAWN14 = 81, + EMOTE_LIGHT_OF_DAWN15 = 82, + EMOTE_LIGHT_OF_DAWN16 = 83, + EMOTE_LIGHT_OF_DAWN17 = 84, + EMOTE_LIGHT_OF_DAWN18 = 85, GO_LIGHT_OF_DAWN = 191330, SPELL_THE_LIGHT_OF_DAWN_Q = 53606, // quest credit @@ -511,9 +497,9 @@ public: SetHoldState(true); SpawnNPC(); if (Creature* temp = Unit::GetCreature(*me, uiKorfaxGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN07, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN07); if (Creature* temp = Unit::GetCreature(*me, uiMaxwellGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN08, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN08); for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i) NPCChangeTarget(uiGhoulGUID[i]); @@ -545,7 +531,7 @@ public: { //Unit* pTirion = Unit::GetCreature(*me, uiTirionGUID); - DoScriptText(EMOTE_LIGHT_OF_DAWN05, me); + Talk(EMOTE_LIGHT_OF_DAWN05); if (me->HasAura(SPELL_THE_LIGHT_OF_DAWN, 0)) me->RemoveAurasDueToSpell(SPELL_THE_LIGHT_OF_DAWN); if (Creature* temp = Unit::GetCreature(*me, uiKoltiraGUID)) @@ -582,7 +568,7 @@ public: } break; case 4: - DoScriptText(SAY_LIGHT_OF_DAWN27, me); + Talk(SAY_LIGHT_OF_DAWN27); me->SetStandState(UNIT_STAND_STATE_KNEEL); if (Creature* temp = Unit::GetCreature(*me, uiKoltiraGUID)) @@ -592,7 +578,7 @@ public: SetHoldState(true); break; case 5: - DoScriptText(SAY_LIGHT_OF_DAWN33, me); + Talk(SAY_LIGHT_OF_DAWN33); SetHoldState(true); break; case 6: @@ -608,7 +594,7 @@ public: me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(EQUIP_UNEQUIP)); if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) me->CastSpell(temp, SPELL_ASHBRINGER, true); - DoScriptText(EMOTE_LIGHT_OF_DAWN14, me); + Talk(EMOTE_LIGHT_OF_DAWN14); SetHoldState(true); break; } @@ -644,7 +630,7 @@ public: break; case 2: - DoScriptText(SAY_LIGHT_OF_DAWN04, me); + Talk(SAY_LIGHT_OF_DAWN04); if (Creature* pKoltira = GetClosestCreatureWithEntry(me, NPC_KOLTIRA_DEATHWEAVER, 50.0f)) uiKoltiraGUID = pKoltira->GetGUID(); if (Creature* pOrbaz = GetClosestCreatureWithEntry(me, NPC_ORBAZ_BLOODBANE, 50.0f)) @@ -655,7 +641,7 @@ public: break; case 3: // rise - DoScriptText(SAY_LIGHT_OF_DAWN05, me); + Talk(SAY_LIGHT_OF_DAWN05); JumpToNextStep(3000); break; @@ -733,7 +719,7 @@ public: break; case 8: // summon announce - DoScriptText(SAY_LIGHT_OF_DAWN06, me); + Talk(SAY_LIGHT_OF_DAWN06); JumpToNextStep(5000); break; @@ -772,34 +758,34 @@ public: // ******* After battle ***************************************************************** case 11: // Tirion starts to speak if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN28, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN28); JumpToNextStep(21000); break; case 12: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN29, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN29); JumpToNextStep(13000); break; case 13: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN30, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN30); JumpToNextStep(13000); break; case 14: me->SetStandState(UNIT_STAND_STATE_STAND); - DoScriptText(SAY_LIGHT_OF_DAWN31, me); + Talk(SAY_LIGHT_OF_DAWN31); JumpToNextStep(7000); break; case 15: // summon gate - if (Unit* temp = me->SummonCreature(NPC_HIGHLORD_ALEXANDROS_MOGRAINE, LightofDawnLoc[22].x, LightofDawnLoc[22].y, LightofDawnLoc[22].z, LightofDawnLoc[22].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000)) + if (Creature* temp = me->SummonCreature(NPC_HIGHLORD_ALEXANDROS_MOGRAINE, LightofDawnLoc[22].x, LightofDawnLoc[22].y, LightofDawnLoc[22].z, LightofDawnLoc[22].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000)) { temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); temp->CastSpell(temp, SPELL_ALEXANDROS_MOGRAINE_SPAWN, true); - DoScriptText(EMOTE_LIGHT_OF_DAWN06, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN06); uiAlexandrosGUID = temp->GetGUID(); } JumpToNextStep(4000); @@ -810,7 +796,7 @@ public: { temp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[23].x, LightofDawnLoc[23].y, LightofDawnLoc[23].z); - DoScriptText(SAY_LIGHT_OF_DAWN32, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN32); } SetHoldState(false); // makes darion turns back JumpToNextStep(5000); @@ -818,14 +804,14 @@ public: case 17: me->SetStandState(UNIT_STAND_STATE_KNEEL); - DoScriptText(SAY_LIGHT_OF_DAWN34, me); + Talk(SAY_LIGHT_OF_DAWN34); JumpToNextStep(5000); break; case 18: // Darion's spirit out - if (Unit* temp = me->SummonCreature(NPC_DARION_MOGRAINE, LightofDawnLoc[24].x, LightofDawnLoc[24].y, LightofDawnLoc[24].z, LightofDawnLoc[24].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000)) + if (Creature* temp = me->SummonCreature(NPC_DARION_MOGRAINE, LightofDawnLoc[24].x, LightofDawnLoc[24].y, LightofDawnLoc[24].z, LightofDawnLoc[24].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000)) { - DoScriptText(SAY_LIGHT_OF_DAWN35, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN35); temp->SetWalk(false); uiDarionGUID = temp->GetGUID(); } @@ -835,7 +821,7 @@ public: case 19: // runs to father if (Creature* temp = Unit::GetCreature(*me, uiDarionGUID)) { - DoScriptText(EMOTE_LIGHT_OF_DAWN07, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN07); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[25].x, LightofDawnLoc[25].y, LightofDawnLoc[25].z); } JumpToNextStep(4000); @@ -843,31 +829,31 @@ public: case 20: if (Creature* temp = Unit::GetCreature(*me, uiDarionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN36, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN36); JumpToNextStep(4000); break; case 21: if (Creature* temp = Unit::GetCreature(*me, uiDarionGUID)) - DoScriptText(EMOTE_LIGHT_OF_DAWN08, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN08); JumpToNextStep(4000); break; case 22: if (Creature* temp = Unit::GetCreature(*me, uiAlexandrosGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN37, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN37); JumpToNextStep(8000); break; case 23: if (Creature* temp = Unit::GetCreature(*me, uiDarionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN38, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN38); JumpToNextStep(8000); break; case 24: if (Creature* temp = Unit::GetCreature(*me, uiAlexandrosGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN39, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN39); if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) // Tirion moves forward here temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[1].x, LightofDawnLoc[1].y, LightofDawnLoc[1].z); @@ -877,13 +863,13 @@ public: case 25: if (Creature* temp = Unit::GetCreature(*me, uiDarionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN40, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN40); JumpToNextStep(11000); break; case 26: if (Creature* temp = Unit::GetCreature(*me, uiAlexandrosGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN41, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN41); JumpToNextStep(5000); break; @@ -895,14 +881,14 @@ public: case 28: if (Creature* temp = Unit::GetCreature(*me, uiAlexandrosGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN42, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN42); JumpToNextStep(6000); break; case 29: // lich king spawns - if (Unit* temp = me->SummonCreature(NPC_THE_LICH_KING, LightofDawnLoc[26].x, LightofDawnLoc[26].y, LightofDawnLoc[26].z, LightofDawnLoc[26].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000)) + if (Creature* temp = me->SummonCreature(NPC_THE_LICH_KING, LightofDawnLoc[26].x, LightofDawnLoc[26].y, LightofDawnLoc[26].z, LightofDawnLoc[26].o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000)) { - DoScriptText(SAY_LIGHT_OF_DAWN43, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN43); uiLichKingGUID = temp->GetGUID(); if (Unit* pAlex = Unit::GetCreature(*me, uiAlexandrosGUID)) temp->CastSpell(pAlex, SPELL_SOUL_FEAST_ALEX, false); @@ -913,21 +899,21 @@ public: case 30: if (Creature* temp = Unit::GetCreature(*me, uiAlexandrosGUID)) // just hide him { - DoScriptText(EMOTE_LIGHT_OF_DAWN09, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN09); temp->SetVisible(false); } if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) { temp->InterruptNonMeleeSpells(false); - DoScriptText(SAY_LIGHT_OF_DAWN45, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN45); } JumpToNextStep(3000); break; case 31: me->SetStandState(UNIT_STAND_STATE_STAND); - DoScriptText(EMOTE_LIGHT_OF_DAWN10, me); - DoScriptText(SAY_LIGHT_OF_DAWN44, me); + Talk(EMOTE_LIGHT_OF_DAWN10); + Talk(SAY_LIGHT_OF_DAWN44); JumpToNextStep(3000); break; @@ -951,7 +937,7 @@ public: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) { temp->HandleEmoteCommand(EMOTE_ONESHOT_KICK); - DoScriptText(SAY_LIGHT_OF_DAWN46, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN46); } me->SetSpeed(MOVE_RUN, 6.0f); me->SetStandState(UNIT_STAND_STATE_DEAD); @@ -966,33 +952,33 @@ public: case 38: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN47, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN47); JumpToNextStep(8000); break; case 39: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN48, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN48); JumpToNextStep(15000); break; case 40: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN49, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN49); JumpToNextStep(17000); break; case 41: // Lich king - Apocalypse if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) { - DoScriptText(EMOTE_LIGHT_OF_DAWN11, temp); - DoScriptText(SAY_LIGHT_OF_DAWN51, temp); - if (Unit* pTirion = Unit::GetCreature(*me, uiTirionGUID)) + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN11); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN51); + if (Creature* pTirion = Unit::GetCreature(*me, uiTirionGUID)) { pTirion->SetStandState(UNIT_STAND_STATE_KNEEL); //temp->CastSpell(pTirion, SPELL_APOCALYPSE, false); // not working temp->CastSpell(pTirion, SPELL_SOUL_FEAST_TIRION, false); - DoScriptText(EMOTE_LIGHT_OF_DAWN12, pTirion); + pTirion->AI()->Talk(EMOTE_LIGHT_OF_DAWN12); } } JumpToNextStep(2000); @@ -1034,7 +1020,7 @@ public: temp->SetWalk(false); temp->SetSpeed(MOVE_RUN, 2.0f); temp->GetMotionMaster()->MovePoint(0, fLichPositionX, fLichPositionY, fLichPositionZ); - DoScriptText(SAY_LIGHT_OF_DAWN50, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN50); } if (Creature* temp = Unit::GetCreature(*me, uiKorfaxGUID)) { @@ -1057,7 +1043,7 @@ public: case 43: // They all got kicked if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) - DoScriptText(EMOTE_LIGHT_OF_DAWN13, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN13); if (Creature* temp = Unit::GetCreature(*me, uiMaxwellGUID)) { @@ -1106,7 +1092,7 @@ public: break; case 45: - DoScriptText(SAY_LIGHT_OF_DAWN52, me); + Talk(SAY_LIGHT_OF_DAWN52); JumpToNextStep(5000); break; @@ -1114,14 +1100,14 @@ public: me->SetSpeed(MOVE_RUN, 1.0f); me->SetWalk(true); me->SetStandState(UNIT_STAND_STATE_STAND); - DoScriptText(SAY_LIGHT_OF_DAWN53, me); + Talk(SAY_LIGHT_OF_DAWN53); SetHoldState(false); // Darion throws sword JumpToNextStep(7000); break; case 47: // Ashbringer rebirth me->SetStandState(UNIT_STAND_STATE_KNEEL); - DoScriptText(EMOTE_LIGHT_OF_DAWN15, me); + Talk(EMOTE_LIGHT_OF_DAWN15); if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) { temp->SetStandState(UNIT_STAND_STATE_STAND); @@ -1149,26 +1135,26 @@ public: case 49: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN54, temp); + Talk(SAY_LIGHT_OF_DAWN54); JumpToNextStep(4000); break; case 50: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN55, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN55); JumpToNextStep(5000); break; case 51: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN56, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN56); JumpToNextStep(1000); break; case 52: // Tiron charges if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) { - DoScriptText(EMOTE_LIGHT_OF_DAWN16, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN16); temp->CastSpell(temp, SPELL_TIRION_CHARGE, false); // jumping charge temp->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2H); temp->SetSpeed(MOVE_RUN, 3.0f); // workarounds, make Tirion still running @@ -1182,7 +1168,7 @@ public: case 53: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN57, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN57); JumpToNextStep(1000); break; @@ -1210,13 +1196,13 @@ public: case 57: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN58, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN58); JumpToNextStep(10000); break; case 58: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN59, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN59); JumpToNextStep(10000); break; @@ -1235,7 +1221,7 @@ public: case 60: if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) // Lich king disappears here { - DoScriptText(EMOTE_LIGHT_OF_DAWN17, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN17); temp->Kill(temp); } JumpToNextStep(10000); @@ -1243,7 +1229,7 @@ public: case 61: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN60, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN60); JumpToNextStep(3000); break; @@ -1260,50 +1246,50 @@ public: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) { temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[8].x, LightofDawnLoc[8].y, LightofDawnLoc[8].z); - DoScriptText(SAY_LIGHT_OF_DAWN61, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN61); } JumpToNextStep(15000); break; case 64: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN62, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN62); JumpToNextStep(7000); break; case 65: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN63, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN63); JumpToNextStep(10000); break; case 66: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN64, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN64); JumpToNextStep(11000); break; case 67: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN65, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN65); JumpToNextStep(10000); break; case 68: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN66, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN66); JumpToNextStep(8000); break; case 69: if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN67, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN67); JumpToNextStep(10000); break; case 70: me->SetStandState(UNIT_STAND_STATE_STAND); - DoScriptText(SAY_LIGHT_OF_DAWN68, me); + Talk(SAY_LIGHT_OF_DAWN68); JumpToNextStep(10000); break; @@ -1381,12 +1367,7 @@ public: if (uiFight_speech <= diff) { - DoScriptText(RAND(SAY_LIGHT_OF_DAWN09, SAY_LIGHT_OF_DAWN10, SAY_LIGHT_OF_DAWN11, - SAY_LIGHT_OF_DAWN12, SAY_LIGHT_OF_DAWN13, SAY_LIGHT_OF_DAWN14, - SAY_LIGHT_OF_DAWN15, SAY_LIGHT_OF_DAWN16, SAY_LIGHT_OF_DAWN17, - SAY_LIGHT_OF_DAWN18, SAY_LIGHT_OF_DAWN19, SAY_LIGHT_OF_DAWN20, - SAY_LIGHT_OF_DAWN21, SAY_LIGHT_OF_DAWN22, SAY_LIGHT_OF_DAWN23, - SAY_LIGHT_OF_DAWN24), me); + Talk(SAY_LIGHT_OF_DAWN09); uiFight_speech = urand(15000, 20000); } else uiFight_speech -= diff; @@ -1419,11 +1400,11 @@ public: if (uiFight_duration <= diff + 5000) { if (!uiTirionGUID) - if (Unit* temp = me->SummonCreature(NPC_HIGHLORD_TIRION_FORDRING, LightofDawnLoc[0].x, LightofDawnLoc[0].y, LightofDawnLoc[0].z, 1.528f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000)) + if (Creature* temp = me->SummonCreature(NPC_HIGHLORD_TIRION_FORDRING, LightofDawnLoc[0].x, LightofDawnLoc[0].y, LightofDawnLoc[0].z, 1.528f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000)) { temp->setFaction(me->getFaction()); temp->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(EQUIP_UNEQUIP)); - DoScriptText(SAY_LIGHT_OF_DAWN25, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN25); uiTirionGUID = temp->GetGUID(); } } @@ -1500,7 +1481,7 @@ public: } if (Creature* temp = Unit::GetCreature(*me, uiOrbazGUID)) - DoScriptText(EMOTE_LIGHT_OF_DAWN04, temp); + temp->AI()->Talk(EMOTE_LIGHT_OF_DAWN04); if (Creature* temp = Unit::GetCreature(*me, uiThassarianGUID)) { @@ -1515,7 +1496,7 @@ public: } if (Creature* temp = Unit::GetCreature(*me, uiTirionGUID)) - DoScriptText(SAY_LIGHT_OF_DAWN26, temp); + temp->AI()->Talk(SAY_LIGHT_OF_DAWN26); SetHoldState(false); diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp index 81211f36df3..6e7f7e103c5 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "PassiveAI.h" +#include "Player.h" /*#### ## npc_valkyr_battle_maiden diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp index c39a647d5e1..33335c32d05 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp @@ -28,8 +28,8 @@ EndScriptData */ enum eEnums { - SAY_AGGRO = -1189019, - SAY_SPECIALAE = -1189020, + SAY_AGGRO = 0, + SAY_SPECIALAE = 1, SPELL_POLYMORPH = 13323, SPELL_AOESILENCE = 8988, @@ -69,7 +69,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void UpdateAI(const uint32 diff) @@ -93,7 +93,7 @@ public: if (me->IsNonMeleeSpellCasted(false)) return; - DoScriptText(SAY_SPECIALAE, me); + Talk(SAY_SPECIALAE); DoCast(me, SPELL_ARCANEBUBBLE); bCanDetonate = true; diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp index ff1a0867de0..b97e1d15dc0 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp @@ -28,9 +28,9 @@ EndScriptData */ enum eEnums { - SAY_AGGRO = -1189016, - SAY_HEALTH = -1189017, - SAY_KILL = -1189018, + SAY_AGGRO = 0, + SAY_HEALTH = 1, + SAY_KILL = 2, SPELL_FLAMESHOCK = 8053, SPELL_SHADOWBOLT = 1106, @@ -69,12 +69,12 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void KilledUnit(Unit* /*Victim*/) { - DoScriptText(SAY_KILL, me); + Talk(SAY_KILL); } void UpdateAI(const uint32 diff) @@ -85,7 +85,7 @@ public: //If we are <35% hp if (!HpYell && !HealthAbovePct(35)) { - DoScriptText(SAY_HEALTH, me); + Talk(SAY_HEALTH); HpYell = true; } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 5e7fa111a7b..78a5f3797d8 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -28,17 +28,20 @@ EndScriptData */ #include "SpellMgr.h" #include "scarlet_monastery.h" #include "LFGMgr.h" +#include "Player.h" +#include "SpellInfo.h" //this texts are already used by 3975 and 3976 enum Says { - SAY_ENTRANCE = -1189001, - SAY_REJOINED = -1189002, - SAY_LOST_HEAD = -1189003, - SAY_CONFLAGRATION = -1189004, - SAY_SPROUTING_PUMPKINS = -1189005, - SAY_PLAYER_DEATH = -1189006, - SAY_DEATH = -1189007 + SAY_LOST_HEAD = 0, + SAY_PLAYER_DEATH = 1, + + SAY_ENTRANCE = 0, + SAY_REJOINED = 1, + SAY_CONFLAGRATION = 2, + SAY_SPROUTING_PUMPKINS = 3, + SAY_DEATH = 4, }; uint32 RandomLaugh[] = {11965, 11975, 11976}; @@ -249,13 +252,17 @@ public: laugh = urand(15000, 30000); } - void EnterCombat(Unit* /*who*/) {} - void SaySound(int32 textEntry, Unit* target = 0) + void EnterCombat(Unit* /*who*/) { } + + void SaySound(uint8 textEntry, Unit* target = 0) { - DoScriptText(textEntry, me, target); + if (target) + Talk(textEntry, target->GetGUID()); + else + Talk(textEntry); + //DoCast(me, SPELL_HEAD_SPEAKS, true); - Creature* speaker = DoSpawnCreature(HELPER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 1000); - if (speaker) + if (Creature* speaker = DoSpawnCreature(HELPER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 1000)) speaker->CastSpell(speaker, SPELL_HEAD_SPEAKS, false); laugh += 3000; } @@ -515,9 +522,12 @@ public: } } - void SaySound(int32 textEntry, Unit* target = 0) + void SaySound(uint8 textEntry, Unit* target = 0) { - DoScriptText(textEntry, me, target); + if (target) + Talk(textEntry, target->GetGUID()); + else + Talk(textEntry); laugh += 4000; } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp index dbbbb7fb0dd..8c1b22e9871 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp @@ -29,15 +29,11 @@ EndScriptData */ enum Says { - SAY_AGGRO = -1189000, - SAY_WHIRLWIND = -1189001, - SAY_ENRAGE = -1189002, - SAY_KILL = -1189003 -}; - -enum Emotes -{ - EMOTE_ENRAGE = -1189004 + SAY_AGGRO = 0, + SAY_WHIRLWIND = 1, + SAY_ENRAGE = 2, + SAY_KILL = 3, + EMOTE_ENRAGE = 4 }; enum Spells @@ -82,13 +78,13 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); DoCast(me, SPELL_RUSHINGCHARGE); } void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_KILL, me); + Talk(SAY_KILL); } void JustDied(Unit* /*killer*/) @@ -105,8 +101,8 @@ public: //If we are <30% hp goes Enraged if (!Enrage && !HealthAbovePct(30) && !me->IsNonMeleeSpellCasted(false)) { - DoScriptText(EMOTE_ENRAGE, me); - DoScriptText(SAY_ENRAGE, me); + Talk(EMOTE_ENRAGE); + Talk(SAY_ENRAGE); DoCast(me, SPELL_FRENZY); Enrage = true; } @@ -122,7 +118,7 @@ public: // Whirlwind_Timer if (Whirlwind_Timer <= diff) { - DoScriptText(SAY_WHIRLWIND, me); + Talk(SAY_WHIRLWIND); DoCast(me->getVictim(), SPELL_WHIRLWIND); Whirlwind_Timer = 30000; } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_houndmaster_loksey.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_houndmaster_loksey.cpp index 9a66c9ba728..0d08431d39c 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_houndmaster_loksey.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_houndmaster_loksey.cpp @@ -28,7 +28,7 @@ EndScriptData */ enum eEnums { - SAY_AGGRO = -1189021, + SAY_AGGRO = 0, SPELL_SUMMONSCARLETHOUND = 17164, SPELL_BLOODLUST = 6742 }; @@ -56,7 +56,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp index 07b5ec5d584..f0e7ac94703 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp @@ -29,11 +29,11 @@ EndScriptData */ enum Says { - SAY_AGGRO = -1189011, - SAY_HEALTH1 = -1189012, - SAY_HEALTH2 = -1189013, - SAY_KILL = -1189014, - SAY_TRIGGER_VORREL = -1189015 + SAY_AGGRO = 0, + SAY_HEALTH1 = 1, + SAY_HEALTH2 = 2, + SAY_KILL = 3, + SAY_TRIGGER_VORREL = 0 }; enum Spells @@ -71,12 +71,12 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void KilledUnit(Unit* /*Victim*/) { - DoScriptText(SAY_KILL, me); + Talk(SAY_KILL); } void JustDied(Unit* /*killer*/) @@ -85,8 +85,8 @@ public: return; //Any other Actions to do with vorrel? setStandState? - if (Unit* vorrel = Unit::GetUnit(*me, instance->GetData64(DATA_VORREL))) - DoScriptText(SAY_TRIGGER_VORREL, vorrel); + if (Creature* vorrel = Creature::GetCreature(*me, instance->GetData64(DATA_VORREL))) + vorrel->AI()->Talk(SAY_TRIGGER_VORREL); } void UpdateAI(const uint32 diff) @@ -97,13 +97,13 @@ public: //If we are low on hp Do sayings if (!Yell60 && !HealthAbovePct(60)) { - DoScriptText(SAY_HEALTH1, me); + Talk(SAY_HEALTH1); Yell60 = true; } if (!Yell30 && !HealthAbovePct(30)) { - DoScriptText(SAY_HEALTH2, me); + Talk(SAY_HEALTH2); Yell30 = true; } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp index 0aad2857a45..651ca453916 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp @@ -26,18 +26,19 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "scarlet_monastery.h" +#include "SpellInfo.h" enum Says { //Mograine says - SAY_MO_AGGRO = -1189005, - SAY_MO_KILL = -1189006, - SAY_MO_RESSURECTED = -1189007, + SAY_MO_AGGRO = 0, + SAY_MO_KILL = 1, + SAY_MO_RESSURECTED = 2, //Whitemane says - SAY_WH_INTRO = -1189008, - SAY_WH_KILL = -1189009, - SAY_WH_RESSURECT = -1189010, + SAY_WH_INTRO = 0, + SAY_WH_KILL = 1, + SAY_WH_RESSURECT = 2, }; enum Spells @@ -113,7 +114,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_MO_AGGRO, me); + Talk(SAY_MO_AGGRO); DoCast(me, SPELL_RETRIBUTIONAURA); me->CallForHelp(VISIBLE_RANGE); @@ -121,7 +122,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_MO_KILL, me); + Talk(SAY_MO_KILL); } void DamageTaken(Unit* /*doneBy*/, uint32 &damage) @@ -166,7 +167,7 @@ public: //When hit with ressurection say text if (spell->Id == SPELL_SCARLETRESURRECTION) { - DoScriptText(SAY_MO_RESSURECTED, me); + Talk(SAY_MO_RESSURECTED); _bFakeDeath = false; if (instance) @@ -275,12 +276,12 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_WH_INTRO, me); + Talk(SAY_WH_INTRO); } void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_WH_KILL, me); + Talk(SAY_WH_KILL); } void DamageTaken(Unit* /*attacker*/, uint32& damage) @@ -302,7 +303,7 @@ public: if (Unit* Mograine = Unit::GetUnit(*me, instance->GetData64(DATA_MOGRAINE))) { DoCast(Mograine, SPELL_SCARLETRESURRECTION); - DoScriptText(SAY_WH_RESSURECT, me); + Talk(SAY_WH_RESSURECT); _bCanResurrect = false; } } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp index 3d3d9ae52ae..e65ab21b8cf 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/instance_scarlet_monastery.cpp @@ -132,7 +132,7 @@ public: } } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { @@ -147,7 +147,7 @@ public: return 0; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == TYPE_MOGRAINE_AND_WHITE_EVENT) return encounter[0]; diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp index 197ee9a5bfe..08aa86d6a06 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp @@ -29,6 +29,7 @@ EndScriptData */ enum eEnums { + EMOTE_FRENZY_KILL = 0, SPELL_REND = 16509, SPELL_BACKHAND = 18103, SPELL_FRENZY = 8269 @@ -67,7 +68,10 @@ public: instance->SetData(DATA_DOCTORTHEOLENKRASTINOV_DEATH, 0); if (instance->GetData(TYPE_GANDLING) == IN_PROGRESS) + { + instance->SetData(TYPE_GANDLING, IN_PROGRESS); me->SummonCreature(1853, 180.73f, -9.43856f, 75.507f, 1.61399f, TEMPSUMMON_DEAD_DESPAWN, 0); + } } } @@ -100,7 +104,7 @@ public: if (m_uiFrenzy_Timer <= uiDiff) { DoCast(me, SPELL_FRENZY); - DoScriptText(EMOTE_GENERIC_FRENZY_KILL, me); + Talk(EMOTE_FRENZY_KILL); m_uiFrenzy_Timer = 120000; } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp index b6b5cc0acbd..e1cffbaf90d 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_illucia_barov.cpp @@ -67,7 +67,10 @@ public: instance->SetData(DATA_LADYILLUCIABAROV_DEATH, 0); if (instance->GetData(TYPE_GANDLING) == IN_PROGRESS) + { + instance->SetData(TYPE_GANDLING, IN_PROGRESS); me->SummonCreature(1853, 180.73f, -9.43856f, 75.507f, 1.61399f, TEMPSUMMON_DEAD_DESPAWN, 0); + } } } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp index 406b1a6b10d..1768584cb25 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_instructor_malicia.cpp @@ -74,7 +74,10 @@ public: instance->SetData(DATA_INSTRUCTORMALICIA_DEATH, 0); if (instance->GetData(TYPE_GANDLING) == IN_PROGRESS) + { + instance->SetData(TYPE_GANDLING, IN_PROGRESS); me->SummonCreature(1853, 180.73f, -9.43856f, 75.507f, 1.61399f, TEMPSUMMON_DEAD_DESPAWN, 0); + } } } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp index 438c3c88bb4..3035688343c 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_lord_alexei_barov.cpp @@ -63,7 +63,10 @@ public: instance->SetData(DATA_LORDALEXEIBAROV_DEATH, 0); if (instance->GetData(TYPE_GANDLING) == IN_PROGRESS) + { + instance->SetData(TYPE_GANDLING, IN_PROGRESS); me->SummonCreature(1853, 180.73f, -9.43856f, 75.507f, 1.61399f, TEMPSUMMON_DEAD_DESPAWN, 0); + } } } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp index 64bbbbe9514..dfab9dd37df 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_lorekeeper_polkelt.cpp @@ -67,7 +67,10 @@ public: instance->SetData(DATA_LOREKEEPERPOLKELT_DEATH, 0); if (instance->GetData(TYPE_GANDLING) == IN_PROGRESS) + { + instance->SetData(TYPE_GANDLING, IN_PROGRESS); me->SummonCreature(1853, 180.73f, -9.43856f, 75.507f, 1.61399f, TEMPSUMMON_DEAD_DESPAWN, 0); + } } } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp index 381a039d609..b3d42d4676a 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_the_ravenian.cpp @@ -69,7 +69,10 @@ public: instance->SetData(DATA_THERAVENIAN_DEATH, 0); if (instance->GetData(TYPE_GANDLING) == IN_PROGRESS) + { + instance->SetData(TYPE_GANDLING, IN_PROGRESS); me->SummonCreature(1853, 180.73f, -9.43856f, 75.507f, 1.61399f, TEMPSUMMON_DEAD_DESPAWN, 0); + } } } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp index 3c7771612e2..dd3e591bf61 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp @@ -28,6 +28,7 @@ EndScriptData */ enum eEnums { + EMOTE_FRENZY_KILL = 0, SPELL_FLAMESTRIKE = 18399, SPELL_BLAST_WAVE = 16046, SPELL_FIRESHIELD = 19626, @@ -88,7 +89,7 @@ public: if (m_uiFrenzy_Timer <= uiDiff) { DoCast(me, SPELL_FRENZY); - DoScriptText(EMOTE_GENERIC_FRENZY_KILL, me); + Talk(EMOTE_FRENZY_KILL); m_uiFrenzy_Timer = 24000; } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp index c3b3724ec3d..f8a0c0010d2 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp @@ -128,21 +128,14 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { - if (type == TYPE_GANDLING) - { - if (IsBossDied[0] && IsBossDied[1] && IsBossDied[2] && IsBossDied[3] && IsBossDied[4] && IsBossDied[5]) - { - m_auiEncounter[0] = IN_PROGRESS; - return IN_PROGRESS; - } - } - - return 0; + return (type == TYPE_GANDLING && + IsBossDied[0] && IsBossDied[1] && IsBossDied[2] && + IsBossDied[3] && IsBossDied[4] && IsBossDied[5]) + ? IN_PROGRESS : 0; } }; - }; void AddSC_instance_scholomance() diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp index b405f9eba85..5d9df239870 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp @@ -23,17 +23,19 @@ SDComment: SDCategory: Shadowfang Keep EndScriptData */ +#include "ScriptedCreature.h" #include "ScriptMgr.h" #include "InstanceScript.h" #include "shadowfang_keep.h" +#include "TemporarySummon.h" #define MAX_ENCOUNTER 4 enum eEnums { - SAY_BOSS_DIE_AD = -1033007, - SAY_BOSS_DIE_AS = -1033008, - SAY_ARCHMAGE = -1033009, + SAY_BOSS_DIE_AD = 0, + SAY_BOSS_DIE_AS = 0, + SAY_ARCHMAGE = 0, NPC_ASH = 3850, NPC_ADA = 3849, @@ -138,8 +140,8 @@ public: if (pAda && pAda->isAlive() && pAsh && pAsh->isAlive()) { - DoScriptText(SAY_BOSS_DIE_AD, pAda); - DoScriptText(SAY_BOSS_DIE_AS, pAsh); + pAda->AI()->Talk(SAY_BOSS_DIE_AD); + pAsh->AI()->Talk(SAY_BOSS_DIE_AS); } } @@ -191,7 +193,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -256,7 +258,7 @@ public: summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); summon->SetReactState(REACT_DEFENSIVE); summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true); - DoScriptText(SAY_ARCHMAGE, summon); + summon->AI()->Talk(SAY_ARCHMAGE); uiTimer = 2000; uiPhase = 2; break; diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp index 9ee3428c7dd..c98148e645b 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "SpellAuraEffects.h" #include "ScriptedEscortAI.h" #include "shadowfang_keep.h" +#include "Player.h" /*###### ## npc_shadowfang_prisoner @@ -41,13 +42,13 @@ EndContentData */ enum eEnums { - SAY_FREE_AS = -1033000, - SAY_OPEN_DOOR_AS = -1033001, - SAY_POST_DOOR_AS = -1033002, - SAY_FREE_AD = -1033003, - SAY_OPEN_DOOR_AD = -1033004, - SAY_POST1_DOOR_AD = -1033005, - SAY_POST2_DOOR_AD = -1033006, + SAY_FREE_AS = 0, + SAY_OPEN_DOOR_AS = 1, + SAY_POST_DOOR_AS = 2, + SAY_FREE_AD = 0, + SAY_OPEN_DOOR_AD = 1, + SAY_POST1_DOOR_AD = 2, + SAY_POST2_DOOR_AD = 3, SPELL_UNLOCK = 6421, NPC_ASH = 3850, @@ -109,15 +110,15 @@ public: { case 0: if (uiNpcEntry == NPC_ASH) - DoScriptText(SAY_FREE_AS, me); + Talk(SAY_FREE_AS); else - DoScriptText(SAY_FREE_AD, me); + Talk(SAY_FREE_AD); break; case 10: if (uiNpcEntry == NPC_ASH) - DoScriptText(SAY_OPEN_DOOR_AS, me); + Talk(SAY_OPEN_DOOR_AS); else - DoScriptText(SAY_OPEN_DOOR_AD, me); + Talk(SAY_OPEN_DOOR_AD); break; case 11: if (uiNpcEntry == NPC_ASH) @@ -125,16 +126,16 @@ public: break; case 12: if (uiNpcEntry == NPC_ASH) - DoScriptText(SAY_POST_DOOR_AS, me); + Talk(SAY_POST_DOOR_AS); else - DoScriptText(SAY_POST1_DOOR_AD, me); + Talk(SAY_POST1_DOOR_AD); if (instance) instance->SetData(TYPE_FREE_NPC, DONE); break; case 13: if (uiNpcEntry != NPC_ASH) - DoScriptText(SAY_POST2_DOOR_AD, me); + Talk(SAY_POST2_DOOR_AD); break; } } diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp index 47c6b66f4bb..96e59a657a3 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "stratholme.h" +#include "Player.h" /*##### # Additional: diff --git a/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp index 98df9638bae..2e4ec7278fc 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/instance_stratholme.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "stratholme.h" +#include "Player.h" #define GO_SERVICE_ENTRANCE 175368 #define GO_GAUNTLET_GATE1 175357 @@ -401,7 +402,7 @@ class instance_stratholme : public InstanceMapScript OUT_LOAD_INST_DATA_COMPLETE; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -425,7 +426,7 @@ class instance_stratholme : public InstanceMapScript return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp index 9b4591bc633..467b532163b 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp @@ -34,6 +34,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "stratholme.h" #include "Group.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## go_gauntlet_gate (this is the _first_ of the gauntlet gates, two exist) diff --git a/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp b/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp index e0987961f7e..624e5460213 100644 --- a/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp +++ b/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp @@ -193,7 +193,7 @@ public: State = data; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == EVENT_STATE) return State; diff --git a/src/server/scripts/EasternKingdoms/SunkenTemple/sunken_temple.cpp b/src/server/scripts/EasternKingdoms/SunkenTemple/sunken_temple.cpp index 83ff86f5b88..040e2153c2d 100644 --- a/src/server/scripts/EasternKingdoms/SunkenTemple/sunken_temple.cpp +++ b/src/server/scripts/EasternKingdoms/SunkenTemple/sunken_temple.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "sunken_temple.h" +#include "Player.h" /*##### # at_malfurion_Stormrage_trigger diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index c763cb69dec..3e9d2e991fc 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -28,41 +28,37 @@ EndScriptData */ enum Quotes { - YELL_INTRO = -1580017, - YELL_INTRO_BREAK_ICE = -1580018, - YELL_INTRO_CHARGE = -1580019, - YELL_INTRO_KILL_MADRIGOSA = -1580020, - YELL_INTRO_TAUNT = -1580021, - - YELL_MADR_ICE_BARRIER = -1580031, - YELL_MADR_INTRO = -1580032, - YELL_MADR_ICE_BLOCK = -1580033, - YELL_MADR_TRAP = -1580034, - YELL_MADR_DEATH = -1580035, - - YELL_AGGRO = -1580022, - YELL_KILL1 = -1580023, - YELL_KILL2 = -1580024, - YELL_KILL3 = -1580025, - YELL_LOVE1 = -1580026, - YELL_LOVE2 = -1580027, - YELL_LOVE3 = -1580028, - YELL_BERSERK = -1580029, - YELL_DEATH = -1580030 + YELL_INTRO = 0, + YELL_INTRO_BREAK_ICE = 1, + YELL_INTRO_CHARGE = 2, + YELL_INTRO_KILL_MADRIGOSA = 3, + YELL_INTRO_TAUNT = 4, + + YELL_AGGRO = 5, + YELL_KILL = 6, + YELL_LOVE = 7, + YELL_BERSERK = 8, + YELL_DEATH = 9, + + YELL_MADR_ICE_BARRIER = 0, + YELL_MADR_INTRO = 1, + YELL_MADR_ICE_BLOCK = 2, + YELL_MADR_TRAP = 3, + YELL_MADR_DEATH = 4, }; enum Spells { - SPELL_METEOR_SLASH = 45150, - SPELL_BURN = 46394, - SPELL_STOMP = 45185, - SPELL_BERSERK = 26662, - SPELL_DUAL_WIELD = 42459, - - SPELL_INTRO_FROST_BLAST = 45203, - SPELL_INTRO_FROSTBOLT = 44843, - SPELL_INTRO_ENCAPSULATE = 45665, - SPELL_INTRO_ENCAPSULATE_CHANELLING = 45661 + SPELL_METEOR_SLASH = 45150, + SPELL_BURN = 46394, + SPELL_STOMP = 45185, + SPELL_BERSERK = 26662, + SPELL_DUAL_WIELD = 42459, + + SPELL_INTRO_FROST_BLAST = 45203, + SPELL_INTRO_FROSTBOLT = 44843, + SPELL_INTRO_ENCAPSULATE = 45665, + SPELL_INTRO_ENCAPSULATE_CHANELLING = 45661 }; #define FELMYST 25038 @@ -122,7 +118,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(YELL_AGGRO, me); + Talk(YELL_AGGRO); if (instance) instance->SetData(DATA_BRUTALLUS_EVENT, IN_PROGRESS); @@ -130,12 +126,12 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(YELL_KILL1, YELL_KILL2, YELL_KILL3), me); + Talk(YELL_KILL); } void JustDied(Unit* /*killer*/) { - DoScriptText(YELL_DEATH, me); + Talk(YELL_DEATH); if (instance) { @@ -199,19 +195,19 @@ public: switch (IntroPhase) { case 0: - DoScriptText(YELL_MADR_ICE_BARRIER, Madrigosa); + Madrigosa->AI()->Talk(YELL_MADR_ICE_BARRIER); IntroPhaseTimer = 7000; ++IntroPhase; break; case 1: me->SetInFront(Madrigosa); Madrigosa->SetInFront(me); - DoScriptText(YELL_MADR_INTRO, Madrigosa, me); + Madrigosa->AI()->Talk(YELL_MADR_INTRO, me->GetGUID()); IntroPhaseTimer = 9000; ++IntroPhase; break; case 2: - DoScriptText(YELL_INTRO, me, Madrigosa); + Talk(YELL_INTRO, Madrigosa->GetGUID()); IntroPhaseTimer = 13000; ++IntroPhase; break; @@ -225,32 +221,32 @@ public: ++IntroPhase; break; case 4: - DoScriptText(YELL_INTRO_BREAK_ICE, me); + Talk(YELL_INTRO_BREAK_ICE); IntroPhaseTimer = 6000; ++IntroPhase; break; case 5: Madrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE_CHANELLING, false); - DoScriptText(YELL_MADR_TRAP, Madrigosa); + Madrigosa->AI()->Talk(YELL_MADR_TRAP); DoCast(me, SPELL_INTRO_ENCAPSULATE); IntroPhaseTimer = 11000; ++IntroPhase; break; case 6: - DoScriptText(YELL_INTRO_CHARGE, me); + Talk(YELL_INTRO_CHARGE); IntroPhaseTimer = 5000; ++IntroPhase; break; case 7: me->Kill(Madrigosa); - DoScriptText(YELL_MADR_DEATH, Madrigosa); + Madrigosa->AI()->Talk(YELL_MADR_DEATH); me->SetFullHealth(); me->AttackStop(); IntroPhaseTimer = 4000; ++IntroPhase; break; case 8: - DoScriptText(YELL_INTRO_KILL_MADRIGOSA, me); + Talk(YELL_INTRO_KILL_MADRIGOSA); me->SetOrientation(0.14f); me->StopMoving(); Madrigosa->setDeathState(CORPSE); @@ -258,7 +254,7 @@ public: ++IntroPhase; break; case 9: - DoScriptText(YELL_INTRO_TAUNT, me); + Talk(YELL_INTRO_TAUNT); IntroPhaseTimer = 5000; ++IntroPhase; break; @@ -316,7 +312,7 @@ public: if (StompTimer <= diff) { - DoScriptText(RAND(YELL_LOVE1, YELL_LOVE2, YELL_LOVE3), me); + Talk(YELL_LOVE); DoCast(me->getVictim(), SPELL_STOMP); StompTimer = 30000; } else StompTimer -= diff; @@ -336,7 +332,7 @@ public: if (BerserkTimer < diff && !Enraged) { - DoScriptText(YELL_BERSERK, me); + Talk(YELL_BERSERK); DoCast(me, SPELL_BERSERK); Enraged = true; } else BerserkTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp index 34548ec9116..23a83a7ee8f 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp @@ -24,38 +24,31 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "sunwell_plateau.h" +#include "SpellInfo.h" enum Quotes { - //Alytesh - YELL_CANFLAGRATION = -1580044, - YELL_SISTER_SACROLASH_DEAD = -1580045, - YELL_ALY_KILL_1 = -1580046, - YELL_ALY_KILL_2 = -1580047, - YELL_ALY_DEAD = -1580048, - YELL_BERSERK = -1580049, - - //Sacrolash - YELL_SHADOW_NOVA = -1580050, - YELL_SISTER_ALYTHESS_DEAD = -1580051, - YELL_SAC_KILL_1 = -1580052, - YELL_SAC_KILL_2 = -1580053, - SAY_SAC_DEAD = -1580054, - YELL_ENRAGE = -1580055, - - //Intro - YELL_INTRO_SAC_1 = -1580056, - YELL_INTRO_ALY_2 = -1580057, - YELL_INTRO_SAC_3 = -1580058, - YELL_INTRO_ALY_4 = -1580059, - YELL_INTRO_SAC_5 = -1580060, - YELL_INTRO_ALY_6 = -1580061, - YELL_INTRO_SAC_7 = -1580062, - YELL_INTRO_ALY_8 = -1580063, - - //Emote - EMOTE_SHADOW_NOVA = -1580064, - EMOTE_CONFLAGRATION = -1580065 + YELL_INTRO_SAC_1 = 0, + YELL_INTRO_SAC_3 = 1, + YELL_INTRO_SAC_5 = 2, + YELL_INTRO_SAC_7 = 3, + YELL_SAC_DEAD = 4, + EMOTE_SHADOW_NOVA = 5, + YELL_ENRAGE = 6, + YELL_SISTER_ALYTHESS_DEAD = 7, + YELL_SAC_KILL = 8, + YELL_SHADOW_NOVA = 9, + + YELL_INTRO_ALY_2 = 0, + YELL_INTRO_ALY_4 = 1, + YELL_INTRO_ALY_6 = 2, + YELL_INTRO_ALY_8 = 3, + EMOTE_CONFLAGRATION = 4, + YELL_ALY_KILL = 5, + YELL_ALY_DEAD = 6, + YELL_SISTER_SACROLASH_DEAD = 7, + YELL_CANFLAGRATION = 8, + YELL_BERSERK = 9, }; enum Spells @@ -164,7 +157,7 @@ public: void KilledUnit(Unit* /*victim*/) { if (rand()%4 == 0) - DoScriptText(RAND(YELL_SAC_KILL_1, YELL_SAC_KILL_2), me); + Talk(YELL_SAC_KILL); } void JustDied(Unit* /*killer*/) @@ -172,7 +165,7 @@ public: // only if ALY death if (SisterDeath) { - DoScriptText(SAY_SAC_DEAD, me); + Talk(YELL_SAC_DEAD); if (instance) instance->SetData(DATA_EREDAR_TWINS_EVENT, DONE); @@ -234,7 +227,7 @@ public: Temp = Unit::GetUnit(*me, instance->GetData64(DATA_ALYTHESS)); if (Temp && Temp->isDead()) { - DoScriptText(YELL_SISTER_ALYTHESS_DEAD, me); + Talk(YELL_SISTER_ALYTHESS_DEAD); DoCast(me, SPELL_EMPOWER); me->InterruptSpell(CURRENT_GENERIC_SPELL); SisterDeath = true; @@ -274,8 +267,8 @@ public: if (!SisterDeath) { if (target) - DoScriptText(EMOTE_SHADOW_NOVA, me, target); - DoScriptText(YELL_SHADOW_NOVA, me); + Talk(EMOTE_SHADOW_NOVA, target->GetGUID()); + Talk(YELL_SHADOW_NOVA); } ShadownovaTimer = 30000+(rand()%5000); } @@ -323,7 +316,7 @@ public: if (EnrageTimer < diff && !Enraged) { me->InterruptSpell(CURRENT_GENERIC_SPELL); - DoScriptText(YELL_ENRAGE, me); + Talk(YELL_ENRAGE); DoCast(me, SPELL_ENRAGE); Enraged = true; } else EnrageTimer -= diff; @@ -456,7 +449,7 @@ public: { if (rand()%4 == 0) { - DoScriptText(RAND(YELL_ALY_KILL_1, YELL_ALY_KILL_2), me); + Talk(YELL_ALY_KILL); } } @@ -464,7 +457,7 @@ public: { if (SisterDeath) { - DoScriptText(YELL_ALY_DEAD, me); + Talk(YELL_ALY_DEAD); if (instance) instance->SetData(DATA_EREDAR_TWINS_EVENT, DONE); @@ -527,24 +520,24 @@ public: case 0: return 0; case 1: if (Sacrolash) - DoScriptText(YELL_INTRO_SAC_1, Sacrolash); + Sacrolash->AI()->Talk(YELL_INTRO_SAC_1); return 1000; - case 2: DoScriptText(YELL_INTRO_ALY_2, me); return 1000; + case 2: Talk(YELL_INTRO_ALY_2); return 1000; case 3: if (Sacrolash) - DoScriptText(YELL_INTRO_SAC_3, Sacrolash); + Sacrolash->AI()->Talk(YELL_INTRO_SAC_3); return 2000; - case 4: DoScriptText(YELL_INTRO_ALY_4, me); return 1000; + case 4: Talk(YELL_INTRO_ALY_4); return 1000; case 5: if (Sacrolash) - DoScriptText(YELL_INTRO_SAC_5, Sacrolash); + Sacrolash->AI()->Talk(YELL_INTRO_SAC_5); return 2000; - case 6: DoScriptText(YELL_INTRO_ALY_6, me); return 1000; + case 6: Talk(YELL_INTRO_ALY_6); return 1000; case 7: if (Sacrolash) - DoScriptText(YELL_INTRO_SAC_7, Sacrolash); + Sacrolash->AI()->Talk(YELL_INTRO_SAC_7); return 3000; - case 8: DoScriptText(YELL_INTRO_ALY_8, me); return 900000; + case 8: Talk(YELL_INTRO_ALY_8); return 900000; } return 10000; } @@ -567,7 +560,7 @@ public: Temp = Unit::GetUnit(*me, instance->GetData64(DATA_SACROLASH)); if (Temp && Temp->isDead()) { - DoScriptText(YELL_SISTER_SACROLASH_DEAD, me); + Talk(YELL_SISTER_SACROLASH_DEAD); DoCast(me, SPELL_EMPOWER); me->InterruptSpell(CURRENT_GENERIC_SPELL); SisterDeath = true; @@ -621,8 +614,8 @@ public: if (!SisterDeath) { if (target) - DoScriptText(EMOTE_CONFLAGRATION, me, target); - DoScriptText(YELL_CANFLAGRATION, me); + Talk(EMOTE_CONFLAGRATION, target->GetGUID()); + Talk(YELL_CANFLAGRATION); } BlazeTimer = 4000; @@ -660,7 +653,7 @@ public: if (EnrageTimer < diff && !Enraged) { me->InterruptSpell(CURRENT_GENERIC_SPELL); - DoScriptText(YELL_BERSERK, me); + Talk(YELL_BERSERK); DoCast(me, SPELL_ENRAGE); Enraged = true; } else EnrageTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index bc841d76714..35fabb7a195 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -31,14 +31,13 @@ EndScriptData */ enum Yells { - YELL_BIRTH = -1580036, - YELL_KILL1 = -1580037, - YELL_KILL2 = -1580038, - YELL_BREATH = -1580039, - YELL_TAKEOFF = -1580040, - YELL_BERSERK = -1580041, - YELL_DEATH = -1580042, - YELL_KALECGOS = -1580043, // after felmyst's death spawned and say this + YELL_BIRTH = 0, + YELL_KILL = 1, + YELL_BREATH = 2, + YELL_TAKEOFF = 3, + YELL_BERSERK = 4, + YELL_DEATH = 5, + //YELL_KALECGOS = 6, Not used. After felmyst's death spawned and say this }; enum Spells @@ -181,17 +180,17 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(YELL_KILL1, YELL_KILL2), me); + Talk(YELL_KILL); } void JustRespawned() { - DoScriptText(YELL_BIRTH, me); + Talk(YELL_BIRTH); } void JustDied(Unit* /*killer*/) { - DoScriptText(YELL_DEATH, me); + Talk(YELL_DEATH); if (instance) instance->SetData(DATA_FELMYST_EVENT, DONE); @@ -279,7 +278,7 @@ public: me->GetMotionMaster()->Clear(false); me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); me->StopMoving(); - DoScriptText(YELL_TAKEOFF, me); + Talk(YELL_TAKEOFF); events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 2000); break; case 1: @@ -424,7 +423,7 @@ public: switch (events.ExecuteEvent()) { case EVENT_BERSERK: - DoScriptText(YELL_BERSERK, me); + Talk(YELL_BERSERK); DoCast(me, SPELL_BERSERK, true); events.ScheduleEvent(EVENT_BERSERK, 10000); break; @@ -459,7 +458,7 @@ public: switch (events.ExecuteEvent()) { case EVENT_BERSERK: - DoScriptText(YELL_BERSERK, me); + Talk(YELL_BERSERK); DoCast(me, SPELL_BERSERK, true); break; case EVENT_FLIGHT_SEQUENCE: diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 3e503a547d8..c7db80c7f22 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -26,63 +26,57 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "sunwell_plateau.h" +#include "Player.h" +#include "WorldSession.h" enum Yells { - //Kalecgos dragon form - SAY_EVIL_AGGRO = -1580000, - SAY_EVIL_SPELL1 = -1580001, - SAY_EVIL_SPELL2 = -1580002, - SAY_EVIL_SLAY1 = -1580003, - SAY_EVIL_SLAY2 = -1580004, - SAY_EVIL_ENRAGE = -1580005, - - //Kalecgos humanoid form - SAY_GOOD_AGGRO = -1580006, - SAY_GOOD_NEAR_DEATH = -1580007, - SAY_GOOD_NEAR_DEATH2 = -1580008, - SAY_GOOD_PLRWIN = -1580009, - - //Sathrovarr - SAY_SATH_AGGRO = -1580010, - SAY_SATH_DEATH = -1580011, - SAY_SATH_SPELL1 = -1580012, - SAY_SATH_SPELL2 = -1580013, - SAY_SATH_SLAY1 = -1580014, - SAY_SATH_SLAY2 = -1580015, - SAY_SATH_ENRAGE = -1580016, + SAY_SATH_AGGRO = 0, + SAY_SATH_SLAY = 1, + SAY_SATH_DEATH = 2, + SAY_SATH_SPELL1 = 3, + SAY_SATH_SPELL2 = 4, + + SAY_EVIL_AGGRO = 0, + SAY_EVIL_SLAY = 1, + SAY_GOOD_PLRWIN = 2, + SAY_EVIL_ENRAGE = 3, + + SAY_GOOD_AGGRO = 0, + SAY_GOOD_NEAR_DEATH = 1, + SAY_GOOD_NEAR_DEATH2 = 2, }; enum Spells { - AURA_SUNWELL_RADIANCE = 45769, - AURA_SPECTRAL_EXHAUSTION = 44867, - AURA_SPECTRAL_REALM = 46021, - AURA_SPECTRAL_INVISIBILITY = 44801, - AURA_DEMONIC_VISUAL = 44800, - - SPELL_SPECTRAL_BLAST = 44869, - SPELL_TELEPORT_SPECTRAL = 46019, - SPELL_ARCANE_BUFFET = 45018, - SPELL_FROST_BREATH = 44799, - SPELL_TAIL_LASH = 45122, - - SPELL_BANISH = 44836, - SPELL_TRANSFORM_KALEC = 44670, - SPELL_ENRAGE = 44807, - - SPELL_CORRUPTION_STRIKE = 45029, - SPELL_AGONY_CURSE = 45032, - SPELL_SHADOW_BOLT = 45031, - - SPELL_HEROIC_STRIKE = 45026, - SPELL_REVITALIZE = 45027 + AURA_SUNWELL_RADIANCE = 45769, + AURA_SPECTRAL_EXHAUSTION = 44867, + AURA_SPECTRAL_REALM = 46021, + AURA_SPECTRAL_INVISIBILITY = 44801, + AURA_DEMONIC_VISUAL = 44800, + + SPELL_SPECTRAL_BLAST = 44869, + SPELL_TELEPORT_SPECTRAL = 46019, + SPELL_ARCANE_BUFFET = 45018, + SPELL_FROST_BREATH = 44799, + SPELL_TAIL_LASH = 45122, + + SPELL_BANISH = 44836, + SPELL_TRANSFORM_KALEC = 44670, + SPELL_ENRAGE = 44807, + + SPELL_CORRUPTION_STRIKE = 45029, + SPELL_AGONY_CURSE = 45032, + SPELL_SHADOW_BOLT = 45031, + + SPELL_HEROIC_STRIKE = 45026, + SPELL_REVITALIZE = 45027 }; enum SWPActions { - DO_ENRAGE = 1, - DO_BANISH = 2, + DO_ENRAGE = 1, + DO_BANISH = 2, }; #define GO_FAILED "You are unable to use this currently." @@ -358,7 +352,7 @@ public: void EnterCombat(Unit* /*who*/) { me->SetStandState(UNIT_STAND_STATE_STAND); - DoScriptText(SAY_EVIL_AGGRO, me); + Talk(SAY_EVIL_AGGRO); DoZoneInCombat(); if (instance) @@ -367,7 +361,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_EVIL_SLAY1, SAY_EVIL_SLAY2), me); + Talk(SAY_EVIL_SLAY); } void MovementInform(uint32 type, uint32 /*id*/) @@ -406,7 +400,7 @@ public: TalkTimer = 1000; break; case 2: - DoScriptText(SAY_GOOD_PLRWIN, me); + Talk(SAY_GOOD_PLRWIN); TalkTimer = 10000; break; case 3: @@ -424,7 +418,7 @@ public: switch (TalkSequence) { case 1: - DoScriptText(SAY_EVIL_ENRAGE, me); + Talk(SAY_EVIL_ENRAGE); TalkTimer = 3000; break; case 2: @@ -503,20 +497,20 @@ public: switch (YellSequence) { case 0: - DoScriptText(SAY_GOOD_AGGRO, me); + Talk(SAY_GOOD_AGGRO); ++YellSequence; break; case 1: if (HealthBelowPct(50)) { - DoScriptText(SAY_GOOD_NEAR_DEATH, me); + Talk(SAY_GOOD_NEAR_DEATH); ++YellSequence; } break; case 2: if (HealthBelowPct(10)) { - DoScriptText(SAY_GOOD_NEAR_DEATH2, me); + Talk(SAY_GOOD_NEAR_DEATH2); ++YellSequence; } break; @@ -640,7 +634,7 @@ public: me->AddThreat(Kalec, 100.0f); Kalec->setActive(true); } - DoScriptText(SAY_SATH_AGGRO, me); + Talk(SAY_SATH_AGGRO); } void DamageTaken(Unit* done_by, uint32 &damage) @@ -662,12 +656,12 @@ public: EnterEvadeMode(); return; } - DoScriptText(RAND(SAY_SATH_SLAY1, SAY_SATH_SLAY2), me); + Talk(SAY_SATH_SLAY); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_SATH_DEATH, me); + Talk(SAY_SATH_DEATH); me->SetPosition(me->GetPositionX(), me->GetPositionY(), DRAGON_REALM_Z, me->GetOrientation()); TeleportAllPlayersBack(); if (Creature* Kalecgos = Unit::GetCreature(*me, KalecgosGUID)) @@ -779,7 +773,7 @@ public: if (ShadowBoltTimer <= diff) { - if (!(rand()%5))DoScriptText(SAY_SATH_SPELL1, me); + if (!(rand()%5))Talk(SAY_SATH_SPELL1); DoCast(me, SPELL_SHADOW_BOLT); ShadowBoltTimer = 7000+(rand()%3000); } else ShadowBoltTimer -= diff; @@ -794,7 +788,7 @@ public: if (CorruptionStrikeTimer <= diff) { - if (!(rand()%5))DoScriptText(SAY_SATH_SPELL2, me); + if (!(rand()%5))Talk(SAY_SATH_SPELL2); DoCast(me->getVictim(), SPELL_CORRUPTION_STRIKE); CorruptionStrikeTimer = 13000; } else CorruptionStrikeTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index 096f6daaec2..c2552963b0e 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -28,50 +28,39 @@ EndScriptData */ #include "ScriptedCreature.h" #include "sunwell_plateau.h" #include <math.h> +#include "Player.h" /*** Speech and sounds***/ enum Yells { - // These are used throughout Sunwell and Magisters(?). Players can hear this while running through the instances. - SAY_KJ_OFFCOMBAT1 = -1580066, - SAY_KJ_OFFCOMBAT2 = -1580067, - SAY_KJ_OFFCOMBAT3 = -1580068, - SAY_KJ_OFFCOMBAT4 = -1580069, - SAY_KJ_OFFCOMBAT5 = -1580070, - - // Encounter speech and sounds - SAY_KJ_EMERGE = -1580071, - SAY_KJ_SLAY1 = -1580072, - SAY_KJ_SLAY2 = -1580073, - SAY_KJ_REFLECTION1 = -1580074, - SAY_KJ_REFLECTION2 = -1580075, - SAY_KJ_DARKNESS1 = -1580076, - SAY_KJ_DARKNESS2 = -1580077, - SAY_KJ_DARKNESS3 = -1580078, - SAY_KJ_PHASE3 = -1580079, - SAY_KJ_PHASE4 = -1580080, - SAY_KJ_PHASE5 = -1580081, - SAY_KJ_DEATH = -1580093, - EMOTE_KJ_DARKNESS = -1580094, - - /*** Kalecgos - Anveena speech at the beginning of Phase 5; Anveena's sacrifice ***/ - SAY_KALECGOS_AWAKEN = -1580082, - SAY_ANVEENA_IMPRISONED = -1580083, - SAY_KALECGOS_LETGO = -1580084, - SAY_ANVEENA_LOST = -1580085, - SAY_KALECGOS_FOCUS = -1580086, - SAY_ANVEENA_KALEC = -1580087, - SAY_KALECGOS_FATE = -1580088, - SAY_ANVEENA_GOODBYE = -1580089, - SAY_KALECGOS_GOODBYE = -1580090, - SAY_KALECGOS_ENCOURAGE = -1580091, - - /*** Kalecgos says throughout the fight ***/ - SAY_KALECGOS_JOIN = -1580092, - SAY_KALEC_ORB_READY1 = -1580095, - SAY_KALEC_ORB_READY2 = -1580096, - SAY_KALEC_ORB_READY3 = -1580097, - SAY_KALEC_ORB_READY4 = -1580098 + SAY_KJ_OFFCOMBAT = 0, + + SAY_KALECGOS_ENCOURAGE = 0, + SAY_KALECGOS_READY1 = 1, + SAY_KALECGOS_READY2 = 2, + SAY_KALECGOS_READY3 = 3, + SAY_KALECGOS_READY4 = 4, + SAY_KALECGOS_AWAKEN = 5, + SAY_KALECGOS_LETGO = 6, + SAY_KALECGOS_FOCUS = 7, + SAY_KALECGOS_FATE = 8, + SAY_KALECGOS_GOODBYE = 9, + SAY_KALECGOS_JOIN = 10, + + SAY_KJ_DEATH = 0, + SAY_KJ_SLAY = 1, + SAY_KJ_REFLECTION = 2, + SAY_KJ_EMERGE = 3, + SAY_KJ_DARKNESS = 4, + SAY_KJ_PHASE3 = 5, + SAY_KJ_PHASE4 = 6, + SAY_KJ_PHASE5 = 7, + EMOTE_KJ_DARKNESS = 8, + + SAY_ANVEENA_IMPRISONED = 0, + SAY_ANVEENA_LOST = 1, + SAY_ANVEENA_KALEC = 2, + SAY_ANVEENA_GOODBYE = 3, }; /*** Spells used during the encounter ***/ @@ -321,7 +310,7 @@ public: pOrb->Refresh(); } } - DoScriptText(SAY_KALECGOS_ENCOURAGE, me); + Talk(SAY_KALECGOS_ENCOURAGE); } else { @@ -337,10 +326,10 @@ public: ++EmpowerCount; switch (EmpowerCount) { - case 1: DoScriptText(SAY_KALEC_ORB_READY1, me); break; - case 2: DoScriptText(SAY_KALEC_ORB_READY2, me); break; - case 3: DoScriptText(SAY_KALEC_ORB_READY3, me); break; - case 4: DoScriptText(SAY_KALEC_ORB_READY4, me); break; + case 1: Talk(SAY_KALECGOS_READY1); break; + case 2: Talk(SAY_KALECGOS_READY2); break; + case 3: Talk(SAY_KALECGOS_READY3); break; + case 4: Talk(SAY_KALECGOS_READY4); break; } } } @@ -468,7 +457,7 @@ public: if (uiRandomSayTimer < diff) { if (instance && instance->GetData(DATA_MURU_EVENT) != DONE && instance->GetData(DATA_KILJAEDEN_EVENT) == NOT_STARTED) - DoScriptText(RAND(SAY_KJ_OFFCOMBAT1, SAY_KJ_OFFCOMBAT2, SAY_KJ_OFFCOMBAT3, SAY_KJ_OFFCOMBAT4, SAY_KJ_OFFCOMBAT5), me); + Talk(SAY_KJ_OFFCOMBAT); uiRandomSayTimer = 30000; } else uiRandomSayTimer -= diff; @@ -612,7 +601,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_KJ_DEATH, me); + Talk(SAY_KJ_DEATH); summons.DespawnAll(); if (instance) @@ -621,7 +610,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_KJ_SLAY1, SAY_KJ_SLAY2), me); + Talk(SAY_KJ_SLAY); } void EnterEvadeMode() @@ -656,7 +645,7 @@ public: void CastSinisterReflection() { - DoScriptText(RAND(SAY_KJ_REFLECTION1, SAY_KJ_REFLECTION2), me); + Talk(SAY_KJ_REFLECTION); for (uint8 i = 0; i < 4; ++i) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true, -SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT)) @@ -716,8 +705,8 @@ public: { SpeechTimer = 0; if (instance) - if (Creature* pSpeechCreature = Unit::GetCreature(*me, instance->GetData64(Speeches[speechCount].creature))) - DoScriptText(Speeches[speechCount].textid, pSpeechCreature); + if (Creature* speechCreature = Unit::GetCreature(*me, instance->GetData64(Speeches[speechCount].creature))) + speechCreature->AI()->Talk(Speeches[speechCount].textid); if (speechCount == 12) if (Creature* pAnveena = Unit::GetCreature(*me, instance->GetData64(DATA_ANVEENA))) pAnveena->CastSpell(me, SPELL_SACRIFICE_OF_ANVEENA, false); @@ -798,7 +787,7 @@ public: // Begins to channel for 8 seconds, then deals 50'000 damage to all raid members. if (!IsInDarkness) { - DoScriptText(EMOTE_KJ_DARKNESS, me); + Talk(EMOTE_KJ_DARKNESS); DoCastAOE(SPELL_DARKNESS_OF_A_THOUSAND_SOULS, false); ChangeTimers(true, 9000); Timer[TIMER_DARKNESS] = 8750; @@ -812,7 +801,7 @@ public: Timer[TIMER_DARKNESS] = (Phase == PHASE_SACRIFICE) ? 15000 : urand(40000, 70000); IsInDarkness = false; DoCastAOE(SPELL_DARKNESS_OF_A_THOUSAND_SOULS_DAMAGE); - DoScriptText(RAND(SAY_KJ_DARKNESS1, SAY_KJ_DARKNESS2, SAY_KJ_DARKNESS3), me); + Talk(SAY_KJ_DARKNESS); } Timer[TIMER_SOUL_FLAY] = 9000; } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index 9fd0a5eb5d8..d23ca834f86 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -24,6 +24,8 @@ SDComment: all sounds, black hole effect triggers to often (46228) #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "sunwell_plateau.h" +#include "Player.h" +#include "SpellInfo.h" // Muru & Entropius's spells enum Spells diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index bea73837304..c4bb41036bc 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "sunwell_plateau.h" +#include "Player.h" #define MAX_ENCOUNTER 6 @@ -121,7 +122,7 @@ public: return false; } - Player* GetPlayerInMap() + Player const * GetPlayerInMap() const { Map::PlayerList const& players = instance->GetPlayers(); @@ -181,7 +182,7 @@ public: } } - uint32 GetData(uint32 id) + uint32 GetData(uint32 id) const { switch (id) { @@ -195,7 +196,7 @@ public: return 0; } - uint64 GetData64(uint32 id) + uint64 GetData64(uint32 id) const { switch (id) { @@ -214,8 +215,8 @@ public: case DATA_ANVEENA: return Anveena; case DATA_KALECGOS_KJ: return KalecgosKJ; case DATA_PLAYER_GUID: - Player* Target = GetPlayerInMap(); - return Target->GetGUID(); + Player const* target = GetPlayerInMap(); + return target ? target->GetGUID() : 0; } return 0; } diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp index 74fad4f94d8..0b7a62f6563 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp @@ -29,6 +29,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "uldaman.h" +#include "Player.h" #define SAY_AGGRO "Who dares awaken Archaedas? Who dares the wrath of the makers!" #define SOUND_AGGRO 5855 diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp index c05a36f93a7..1537f0eeb88 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp @@ -26,11 +26,13 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" -#define SAY_AGGRO -1070000 - -#define SPELL_ARCINGSMASH 8374 -#define SPELL_KNOCKAWAY 10101 -#define SPELL_WSTOMP 11876 +enum Ironaya +{ + SAY_AGGRO = 0, + SPELL_ARCINGSMASH = 8374, + SPELL_KNOCKAWAY = 10101, + SPELL_WSTOMP = 11876, +}; class boss_ironaya : public CreatureScript { @@ -58,7 +60,7 @@ class boss_ironaya : public CreatureScript void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); } void UpdateAI(const uint32 uiDiff) diff --git a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp index ee82da668f8..efbc4f75ae1 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp @@ -466,20 +466,27 @@ class instance_uldaman : public InstanceMapScript } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { - if (identifier == 0) return uiWhoWokeuiArchaedasGUID; - if (identifier == 1) return vVaultWalker[0]; // VaultWalker1 - if (identifier == 2) return vVaultWalker[1]; // VaultWalker2 - if (identifier == 3) return vVaultWalker[2]; // VaultWalker3 - if (identifier == 4) return vVaultWalker[3]; // VaultWalker4 - - if (identifier == 5) return vEarthenGuardian[0]; - if (identifier == 6) return vEarthenGuardian[1]; - if (identifier == 7) return vEarthenGuardian[2]; - if (identifier == 8) return vEarthenGuardian[3]; - if (identifier == 9) return vEarthenGuardian[4]; - if (identifier == 10) return vEarthenGuardian[5]; + switch (identifier) + { + case 0: + return uiWhoWokeuiArchaedasGUID; + case 1: + case 2: + case 3: + case 4: + return vVaultWalker.at(identifier - 1); + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + return vEarthenGuardian.at(identifier - 5); + default: + break; + } return 0; } // end GetData64 diff --git a/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp b/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp index 2b8d4e37b65..d86da3efce5 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/uldaman.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "uldaman.h" +#include "Player.h" /*###### ## mob_jadespine_basilisk diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp index a8afd19cd96..f7f279cf716 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp @@ -26,7 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "zulaman.h" -//#include "spell.h" +#include "SpellInfo.h" #define YELL_AGGRO "Get on your knees and bow to da fang and claw!" #define SOUND_AGGRO 12020 diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp index 8a102757036..ed10dec97dd 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp @@ -31,16 +31,15 @@ EndScriptData */ enum eEnums { - SAY_AGGRO = -1568000, - SAY_FIRE_BOMBS = -1568001, - SAY_SUMMON_HATCHER = -1568002, - SAY_ALL_EGGS = -1568003, - SAY_BERSERK = -1568004, - SAY_SLAY_1 = -1568005, - SAY_SLAY_2 = -1568006, - SAY_DEATH = -1568007, - SAY_EVENT_STRANGERS = -1568008, - SAY_EVENT_FRIENDS = -1568009, + SAY_AGGRO = 0, + SAY_FIRE_BOMBS = 1, + SAY_SUMMON_HATCHER = 2, + SAY_ALL_EGGS = 3, + SAY_BERSERK = 4, + SAY_SLAY = 5, + SAY_DEATH = 6, + SAY_EVENT_STRANGERS = 7, + SAY_EVENT_FRIENDS = 8, // Jan'alai SPELL_FLAME_BREATH = 43140, @@ -163,7 +162,7 @@ class boss_janalai : public CreatureScript void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (instance) instance->SetData(DATA_JANALAIEVENT, DONE); @@ -171,7 +170,7 @@ class boss_janalai : public CreatureScript void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me); + Talk(SAY_SLAY); } void EnterCombat(Unit* /*who*/) @@ -179,7 +178,7 @@ class boss_janalai : public CreatureScript if (instance) instance->SetData(DATA_JANALAIEVENT, IN_PROGRESS); - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); // DoZoneInCombat(); } @@ -352,7 +351,7 @@ class boss_janalai : public CreatureScript } else { - DoScriptText(SAY_BERSERK, me); + Talk(SAY_BERSERK); DoCast(me, SPELL_BERSERK, true); EnrageTimer = 300000; } @@ -360,7 +359,7 @@ class boss_janalai : public CreatureScript if (BombTimer <= diff) { - DoScriptText(SAY_FIRE_BOMBS, me); + Talk(SAY_FIRE_BOMBS); me->AttackStop(); me->GetMotionMaster()->Clear(); @@ -393,7 +392,7 @@ class boss_janalai : public CreatureScript { if (HealthBelowPct(35)) { - DoScriptText(SAY_ALL_EGGS, me); + Talk(SAY_ALL_EGGS); me->AttackStop(); me->GetMotionMaster()->Clear(); @@ -407,7 +406,7 @@ class boss_janalai : public CreatureScript { if (HatchAllEggs(0)) { - DoScriptText(SAY_SUMMON_HATCHER, me); + Talk(SAY_SUMMON_HATCHER); me->SummonCreature(MOB_AMANI_HATCHER, hatcherway[0][0][0], hatcherway[0][0][1], hatcherway[0][0][2], 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); me->SummonCreature(MOB_AMANI_HATCHER, hatcherway[1][0][0], hatcherway[1][0][1], hatcherway[1][0][2], 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); HatcherTimer = 90000; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp index 8fb3dd55077..5aa74fbbe89 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "zulaman.h" +#include "SpellInfo.h" //Speech const char* YELL_TRANSFORM_TO_LYNX = "Let me introduce to you my new bruddahs: fang and claw!"; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp index 235bec7cc8a..7273ca99c7c 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp @@ -26,6 +26,8 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "zulaman.h" +#include "Player.h" +#include "TemporarySummon.h" #define MAX_ENCOUNTER 6 #define RAND_VENDOR 2 @@ -282,7 +284,7 @@ class instance_zulaman : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp index f0bea065eb6..61c7bda00ac 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp @@ -31,6 +31,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "zulaman.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## npc_forest_frog diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp index 104d479383b..8d17a18bb1b 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp @@ -113,7 +113,7 @@ class instance_zulgurub : public InstanceMapScript } } - uint32 GetData(uint32 uiType) + uint32 GetData(uint32 uiType) const { switch (uiType) { @@ -137,7 +137,7 @@ class instance_zulgurub : public InstanceMapScript return 0; } - uint64 GetData64(uint32 uiData) + uint64 GetData64(uint32 uiData) const { switch (uiData) { @@ -163,4 +163,4 @@ class instance_zulgurub : public InstanceMapScript void AddSC_instance_zulgurub() { new instance_zulgurub(); -}
\ No newline at end of file +} diff --git a/src/server/scripts/EasternKingdoms/arathi_highlands.cpp b/src/server/scripts/EasternKingdoms/arathi_highlands.cpp index b0d59fe8b5a..7f96706f48e 100644 --- a/src/server/scripts/EasternKingdoms/arathi_highlands.cpp +++ b/src/server/scripts/EasternKingdoms/arathi_highlands.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_professor_phizzlethorpe diff --git a/src/server/scripts/EasternKingdoms/blasted_lands.cpp b/src/server/scripts/EasternKingdoms/blasted_lands.cpp index 75109f3a2f6..47fb8298ca7 100644 --- a/src/server/scripts/EasternKingdoms/blasted_lands.cpp +++ b/src/server/scripts/EasternKingdoms/blasted_lands.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npc_deathly_usher diff --git a/src/server/scripts/EasternKingdoms/burning_steppes.cpp b/src/server/scripts/EasternKingdoms/burning_steppes.cpp index eec747d6d73..ba1d339730a 100644 --- a/src/server/scripts/EasternKingdoms/burning_steppes.cpp +++ b/src/server/scripts/EasternKingdoms/burning_steppes.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npc_ragged_john diff --git a/src/server/scripts/EasternKingdoms/duskwood.cpp b/src/server/scripts/EasternKingdoms/duskwood.cpp index e5af5344dc1..fbb98979e77 100644 --- a/src/server/scripts/EasternKingdoms/duskwood.cpp +++ b/src/server/scripts/EasternKingdoms/duskwood.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" enum Yells { diff --git a/src/server/scripts/EasternKingdoms/eastern_plaguelands.cpp b/src/server/scripts/EasternKingdoms/eastern_plaguelands.cpp index 7ca76e38fce..c9b60f847e8 100644 --- a/src/server/scripts/EasternKingdoms/eastern_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/eastern_plaguelands.cpp @@ -33,6 +33,8 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "WorldSession.h" class mobs_ghoul_flayer : public CreatureScript { diff --git a/src/server/scripts/EasternKingdoms/eversong_woods.cpp b/src/server/scripts/EasternKingdoms/eversong_woods.cpp index d69ae3454b4..f62273e583d 100644 --- a/src/server/scripts/EasternKingdoms/eversong_woods.cpp +++ b/src/server/scripts/EasternKingdoms/eversong_woods.cpp @@ -35,6 +35,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## Quest 9686 Second Trial diff --git a/src/server/scripts/EasternKingdoms/ghostlands.cpp b/src/server/scripts/EasternKingdoms/ghostlands.cpp index 9793c6fd31c..ddd3b0f423a 100644 --- a/src/server/scripts/EasternKingdoms/ghostlands.cpp +++ b/src/server/scripts/EasternKingdoms/ghostlands.cpp @@ -34,6 +34,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npc_budd_nedreck @@ -109,18 +111,18 @@ public: enum eEnums { - SAY_START = -1000140, - SAY_PROGRESS1 = -1000141, - SAY_PROGRESS2 = -1000142, - SAY_PROGRESS3 = -1000143, - SAY_END1 = -1000144, - SAY_END2 = -1000145, - SAY_CAPTAIN_ANSWER = -1000146, + SAY_START = 0, + SAY_PROGRESS1 = 1, + SAY_PROGRESS2 = 2, + SAY_PROGRESS3 = 3, + SAY_END1 = 4, + SAY_END2 = 5, + SAY_CAPTAIN_ANSWER = 0, QUEST_ESCAPE_FROM_THE_CATACOMBS = 9212, - GO_CAGE = 181152, - NPC_CAPTAIN_HELIOS = 16220, - FACTION_SMOON_E = 1603, + GO_CAGE = 181152, + NPC_CAPTAIN_HELIOS = 16220, + FACTION_SMOON_E = 1603 }; class npc_ranger_lilatha : public CreatureScript @@ -144,18 +146,18 @@ public: me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); if (GameObject* Cage = me->FindNearestGameObject(GO_CAGE, 20)) Cage->SetGoState(GO_STATE_ACTIVE); - DoScriptText(SAY_START, me, player); + Talk(SAY_START, player->GetGUID()); break; case 5: - DoScriptText(SAY_PROGRESS1, me, player); + Talk(SAY_PROGRESS1, player->GetGUID()); break; case 11: - DoScriptText(SAY_PROGRESS2, me, player); + Talk(SAY_PROGRESS2, player->GetGUID()); me->SetOrientation(4.762841f); break; case 18: { - DoScriptText(SAY_PROGRESS3, me, player); + Talk(SAY_PROGRESS3, player->GetGUID()); Creature* Summ1 = me->SummonCreature(16342, 7627.083984f, -7532.538086f, 152.128616f, 1.082733f, TEMPSUMMON_DEAD_DESPAWN, 0); Creature* Summ2 = me->SummonCreature(16343, 7620.432129f, -7532.550293f, 152.454865f, 0.827478f, TEMPSUMMON_DEAD_DESPAWN, 0); if (Summ1 && Summ2) @@ -178,14 +180,14 @@ public: break; case 32: me->SetOrientation(2.978281f); - DoScriptText(SAY_END1, me, player); + Talk(SAY_END1, player->GetGUID()); break; case 33: me->SetOrientation(5.858011f); - DoScriptText(SAY_END2, me, player); - Unit* CaptainHelios = me->FindNearestCreature(NPC_CAPTAIN_HELIOS, 50); + Talk(SAY_END2, player->GetGUID()); + Creature* CaptainHelios = me->FindNearestCreature(NPC_CAPTAIN_HELIOS, 50); if (CaptainHelios) - DoScriptText(SAY_CAPTAIN_ANSWER, CaptainHelios, player); + CaptainHelios->AI()->Talk(SAY_CAPTAIN_ANSWER, player->GetGUID()); break; } } diff --git a/src/server/scripts/EasternKingdoms/hinterlands.cpp b/src/server/scripts/EasternKingdoms/hinterlands.cpp index a6d01f0ca93..544ea0fd175 100644 --- a/src/server/scripts/EasternKingdoms/hinterlands.cpp +++ b/src/server/scripts/EasternKingdoms/hinterlands.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_00x09hl @@ -38,11 +39,11 @@ EndContentData */ enum eOOX { - SAY_OOX_START = -1000287, - SAY_OOX_AGGRO1 = -1000288, - SAY_OOX_AGGRO2 = -1000289, - SAY_OOX_AMBUSH = -1000290, - SAY_OOX_END = -1000292, + SAY_OOX_START = 0, + SAY_OOX_AGGRO = 1, + SAY_OOX_AMBUSH = 3, + SAY_OOX_AMBUSH_REPLY = 4, + SAY_OOX_END = 5, QUEST_RESQUE_OOX_09 = 836, @@ -69,7 +70,7 @@ public: else if (player->GetTeam() == HORDE) creature->setFaction(FACTION_ESCORTEE_H); - DoScriptText(SAY_OOX_START, creature, player); + creature->AI()->Talk(SAY_OOX_START, player->GetGUID()); if (npc_00x09hlAI* pEscortAI = CAST_AI(npc_00x09hl::npc_00x09hlAI, creature->AI())) pEscortAI->Start(false, false, player->GetGUID(), quest); @@ -93,13 +94,13 @@ public: switch (waypointId) { case 26: - DoScriptText(SAY_OOX_AMBUSH, me); + Talk(SAY_OOX_AMBUSH); break; case 43: - DoScriptText(SAY_OOX_AMBUSH, me); + Talk(SAY_OOX_AMBUSH); break; case 64: - DoScriptText(SAY_OOX_END, me); + Talk(SAY_OOX_END); if (Player* player = GetPlayerForEscort()) player->GroupEventHappens(QUEST_RESQUE_OOX_09, me); break; @@ -136,10 +137,7 @@ public: if (who->GetEntry() == NPC_MARAUDING_OWL || who->GetEntry() == NPC_VILE_AMBUSHER) return; - if (rand()%1) - DoScriptText(SAY_OOX_AGGRO1, me); - else - DoScriptText(SAY_OOX_AGGRO2, me); + Talk(SAY_OOX_AGGRO); } void JustSummoned(Creature* summoned) @@ -155,13 +153,13 @@ public: enum eRinji { - SAY_RIN_FREE = -1000403, //from here - SAY_RIN_BY_OUTRUNNER = -1000404, - SAY_RIN_HELP_1 = -1000405, - SAY_RIN_HELP_2 = -1000406, //to here, are used also by 6182 but this is wrong... - SAY_RIN_COMPLETE = -1000407, - SAY_RIN_PROGRESS_1 = -1000408, - SAY_RIN_PROGRESS_2 = -1000409, + SAY_RIN_BY_OUTRUNNER = 0, + + SAY_RIN_FREE = 0, //from here + SAY_RIN_HELP = 1, + SAY_RIN_COMPLETE = 2, + SAY_RIN_PROGRESS_1 = 3, + SAY_RIN_PROGRESS_2 = 4, QUEST_RINJI_TRAPPED = 2742, NPC_RANGER = 2694, @@ -242,7 +240,8 @@ public: { if (who->GetEntry() == NPC_OUTRUNNER && !m_bIsByOutrunner) { - DoScriptText(SAY_RIN_BY_OUTRUNNER, who); + if (Creature* talker = who->ToCreature()) + talker->AI()->Talk(SAY_RIN_BY_OUTRUNNER); m_bIsByOutrunner = true; } @@ -250,7 +249,7 @@ public: return; //only if attacked and escorter is not in combat? - DoScriptText(RAND(SAY_RIN_HELP_1, SAY_RIN_HELP_2), me); + Talk(SAY_RIN_HELP); } } @@ -286,7 +285,7 @@ public: switch (waypointId) { case 1: - DoScriptText(SAY_RIN_FREE, me, player); + Talk(SAY_RIN_FREE, player->GetGUID()); break; case 7: DoSpawnAmbush(true); @@ -295,7 +294,7 @@ public: DoSpawnAmbush(false); break; case 17: - DoScriptText(SAY_RIN_COMPLETE, me, player); + Talk(SAY_RIN_COMPLETE, player->GetGUID()); player->GroupEventHappens(QUEST_RINJI_TRAPPED, me); SetRun(); m_uiPostEventCount = 1; @@ -319,11 +318,11 @@ public: switch (m_uiPostEventCount) { case 1: - DoScriptText(SAY_RIN_PROGRESS_1, me, player); + Talk(SAY_RIN_PROGRESS_1, player->GetGUID()); ++m_uiPostEventCount; break; case 2: - DoScriptText(SAY_RIN_PROGRESS_2, me, player); + Talk(SAY_RIN_PROGRESS_2, player->GetGUID()); m_uiPostEventCount = 0; break; } diff --git a/src/server/scripts/EasternKingdoms/ironforge.cpp b/src/server/scripts/EasternKingdoms/ironforge.cpp index 2915ee1f3cb..fdd9f5f9a86 100644 --- a/src/server/scripts/EasternKingdoms/ironforge.cpp +++ b/src/server/scripts/EasternKingdoms/ironforge.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npc_royal_historian_archesonus diff --git a/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp b/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp index e448ccda14c..c3a725f2f45 100644 --- a/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp +++ b/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp @@ -30,6 +30,9 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" +#include "Pet.h" +#include "SpellInfo.h" /*###### ## npc_converted_sentry diff --git a/src/server/scripts/EasternKingdoms/loch_modan.cpp b/src/server/scripts/EasternKingdoms/loch_modan.cpp index 4e3aaae71a1..0937e3cbb30 100644 --- a/src/server/scripts/EasternKingdoms/loch_modan.cpp +++ b/src/server/scripts/EasternKingdoms/loch_modan.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npc_mountaineer_pebblebitty diff --git a/src/server/scripts/EasternKingdoms/redridge_mountains.cpp b/src/server/scripts/EasternKingdoms/redridge_mountains.cpp index 2473fec899a..f04b0111da7 100644 --- a/src/server/scripts/EasternKingdoms/redridge_mountains.cpp +++ b/src/server/scripts/EasternKingdoms/redridge_mountains.cpp @@ -24,6 +24,7 @@ Script Data End */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" enum eCorporalKeeshan { diff --git a/src/server/scripts/EasternKingdoms/silvermoon_city.cpp b/src/server/scripts/EasternKingdoms/silvermoon_city.cpp index 954f21f73f5..d8e9a9ae49a 100644 --- a/src/server/scripts/EasternKingdoms/silvermoon_city.cpp +++ b/src/server/scripts/EasternKingdoms/silvermoon_city.cpp @@ -29,13 +29,15 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" +#include "SpellInfo.h" /*####### # npc_blood_knight_stillblade #######*/ enum eStillbladeData { - SAY_HEAL = -1000193, + SAY_HEAL = 0, QUEST_REDEEMING_THE_DEAD = 9685, SPELL_SHIMMERING_VESSEL = 31225, @@ -96,7 +98,7 @@ public: me->SetStandState(UNIT_STAND_STATE_STAND); me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); //me->RemoveAllAuras(); - DoScriptText(SAY_HEAL, me); + Talk(SAY_HEAL); spellHit = true; } } diff --git a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp index b2cd3b16e7b..905d34221ed 100644 --- a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp +++ b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_deathstalker_erland diff --git a/src/server/scripts/EasternKingdoms/stormwind_city.cpp b/src/server/scripts/EasternKingdoms/stormwind_city.cpp index 560214d4085..188b3dcd2b1 100644 --- a/src/server/scripts/EasternKingdoms/stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/stormwind_city.cpp @@ -37,6 +37,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_archmage_malin @@ -205,13 +206,13 @@ public: enum eLordGregorLescovar { - SAY_LESCOVAR_2 = -1000457, - SAY_GUARD_2 = -1000458, - SAY_LESCOVAR_3 = -1000459, - SAY_MARZON_1 = -1000460, - SAY_LESCOVAR_4 = -1000461, - SAY_TYRION_2 = -1000462, - SAY_MARZON_2 = -1000463, + SAY_GUARD_2 = 0, + SAY_LESCOVAR_2 = 0, + SAY_LESCOVAR_3 = 1, + SAY_LESCOVAR_4 = 2, + SAY_MARZON_1 = 0, + SAY_MARZON_2 = 1, + SAY_TYRION_2 = 0, NPC_STORMWIND_ROYAL = 1756, NPC_MARZON_BLADE = 1755, @@ -276,7 +277,7 @@ public: { case 14: SetEscortPaused(true); - DoScriptText(SAY_LESCOVAR_2, me); + Talk(SAY_LESCOVAR_2); uiTimer = 3000; uiPhase = 1; break; @@ -317,7 +318,7 @@ public: { case 1: if (Creature* pGuard = me->FindNearestCreature(NPC_STORMWIND_ROYAL, 8.0f, true)) - DoScriptText(SAY_GUARD_2, pGuard); + pGuard->AI()->Talk(SAY_GUARD_2); uiTimer = 3000; uiPhase = 2; break; @@ -332,18 +333,18 @@ public: uiPhase = 0; break; case 4: - DoScriptText(SAY_LESCOVAR_3, me); + Talk(SAY_LESCOVAR_3); uiTimer = 0; uiPhase = 0; break; case 5: if (Creature* pMarzon = Unit::GetCreature(*me, MarzonGUID)) - DoScriptText(SAY_MARZON_1, pMarzon); + pMarzon->AI()->Talk(SAY_MARZON_1); uiTimer = 3000; uiPhase = 6; break; case 6: - DoScriptText(SAY_LESCOVAR_4, me); + Talk(SAY_LESCOVAR_4); if (Player* player = GetPlayerForEscort()) player->AreaExploredOrEventHappens(QUEST_THE_ATTACK); uiTimer = 2000; @@ -351,7 +352,7 @@ public: break; case 7: if (Creature* pTyrion = me->FindNearestCreature(NPC_TYRION, 20.0f, true)) - DoScriptText(SAY_TYRION_2, pTyrion); + pTyrion->AI()->Talk(SAY_TYRION_2); if (Creature* pMarzon = Unit::GetCreature(*me, MarzonGUID)) pMarzon->setFaction(14); me->setFaction(14); @@ -399,7 +400,7 @@ public: void EnterCombat(Unit* who) { - DoScriptText(SAY_MARZON_2, me); + Talk(SAY_MARZON_2); if (me->isSummon()) { @@ -463,14 +464,14 @@ public: enum eTyrionSpybot { - SAY_QUEST_ACCEPT_ATTACK = -1000499, - SAY_TYRION_1 = -1000450, - SAY_SPYBOT_1 = -1000451, - SAY_GUARD_1 = -1000452, - SAY_SPYBOT_2 = -1000453, - SAY_SPYBOT_3 = -1000454, - SAY_LESCOVAR_1 = -1000455, - SAY_SPYBOT_4 = -1000456, + SAY_QUEST_ACCEPT_ATTACK = 0, + SAY_SPYBOT_1 = 1, + SAY_SPYBOT_2 = 2, + SAY_SPYBOT_3 = 3, + SAY_SPYBOT_4 = 4, + SAY_TYRION_1 = 0, + SAY_GUARD_1 = 0, + SAY_LESCOVAR_1 = 0, NPC_PRIESTESS_TYRIONA = 7779, NPC_LORD_GREGOR_LESCOVAR = 1754, @@ -510,13 +511,13 @@ public: break; case 5: SetEscortPaused(true); - DoScriptText(SAY_SPYBOT_1, me); + Talk(SAY_SPYBOT_1); uiTimer = 2000; uiPhase = 5; break; case 17: SetEscortPaused(true); - DoScriptText(SAY_SPYBOT_3, me); + Talk(SAY_SPYBOT_3); uiTimer = 3000; uiPhase = 8; break; @@ -532,13 +533,13 @@ public: switch (uiPhase) { case 1: - DoScriptText(SAY_QUEST_ACCEPT_ATTACK, me); + Talk(SAY_QUEST_ACCEPT_ATTACK); uiTimer = 3000; uiPhase = 2; break; case 2: if (Creature* pTyrion = me->FindNearestCreature(NPC_TYRION, 10.0f)) - DoScriptText(SAY_TYRION_1, pTyrion); + pTyrion->AI()->Talk(SAY_TYRION_1); uiTimer = 3000; uiPhase = 3; break; @@ -554,12 +555,12 @@ public: break; case 5: if (Creature* pGuard = me->FindNearestCreature(NPC_STORMWIND_ROYAL, 10.0f, true)) - DoScriptText(SAY_GUARD_1, pGuard); + pGuard->AI()->Talk(SAY_GUARD_1); uiTimer = 3000; uiPhase = 6; break; case 6: - DoScriptText(SAY_SPYBOT_2, me); + Talk(SAY_SPYBOT_2); uiTimer = 3000; uiPhase = 7; break; @@ -570,12 +571,12 @@ public: break; case 8: if (Creature* pLescovar = me->FindNearestCreature(NPC_LORD_GREGOR_LESCOVAR, 10.0f)) - DoScriptText(SAY_LESCOVAR_1, pLescovar); + pLescovar->AI()->Talk(SAY_LESCOVAR_1); uiTimer = 3000; uiPhase = 9; break; case 9: - DoScriptText(SAY_SPYBOT_4, me); + Talk(SAY_SPYBOT_4); uiTimer = 3000; uiPhase = 10; break; diff --git a/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp b/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp index 40f046a5075..2217eba7d1b 100644 --- a/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp +++ b/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp @@ -29,6 +29,8 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## mob_yenniku diff --git a/src/server/scripts/EasternKingdoms/swamp_of_sorrows.cpp b/src/server/scripts/EasternKingdoms/swamp_of_sorrows.cpp index 4c81380fb60..099bc0770b7 100644 --- a/src/server/scripts/EasternKingdoms/swamp_of_sorrows.cpp +++ b/src/server/scripts/EasternKingdoms/swamp_of_sorrows.cpp @@ -19,6 +19,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_galen_goodward @@ -30,13 +31,12 @@ enum Galen GO_GALENS_CAGE = 37118, - SAY_PERIODIC = -1000500, - SAY_QUEST_ACCEPTED = -1000501, - SAY_ATTACKED_1 = -1000502, - SAY_ATTACKED_2 = -1000503, - SAY_QUEST_COMPLETE = -1000504, - EMOTE_WHISPER = -1000505, - EMOTE_DISAPPEAR = -1000506 + SAY_PERIODIC = 0, + SAY_QUEST_ACCEPTED = 1, + SAY_ATTACKED = 2, + SAY_QUEST_COMPLETE = 3, + EMOTE_WHISPER = 4, + EMOTE_DISAPPEAR = 5, }; class npc_galen_goodward : public CreatureScript @@ -51,7 +51,7 @@ public: { CAST_AI(npc_galen_goodward::npc_galen_goodwardAI, creature->AI())->Start(false, false, player->GetGUID()); creature->setFaction(FACTION_ESCORT_N_NEUTRAL_ACTIVE); - DoScriptText(SAY_QUEST_ACCEPTED, creature); + creature->AI()->Talk(SAY_QUEST_ACCEPTED); } return true; } @@ -80,7 +80,7 @@ public: void EnterCombat(Unit* who) { if (HasEscortState(STATE_ESCORT_ESCORTING)) - DoScriptText(RAND(SAY_ATTACKED_1, SAY_ATTACKED_2), me, who); + Talk(SAY_ATTACKED, who->GetGUID()); } void WaypointStart(uint32 uiPointId) @@ -102,7 +102,7 @@ public: break; } case 21: - DoScriptText(EMOTE_DISAPPEAR, me); + Talk(EMOTE_DISAPPEAR); break; } } @@ -119,8 +119,8 @@ public: if (Player* player = GetPlayerForEscort()) { me->SetFacingToObject(player); - DoScriptText(SAY_QUEST_COMPLETE, me, player); - DoScriptText(EMOTE_WHISPER, me, player); + Talk(SAY_QUEST_COMPLETE, player->GetGUID()); + Talk(EMOTE_WHISPER, player->GetGUID()); player->GroupEventHappens(QUEST_GALENS_ESCAPE, me); } SetRun(true); @@ -138,7 +138,7 @@ public: if (m_uiPeriodicSay < uiDiff) { if (!HasEscortState(STATE_ESCORT_ESCORTING)) - DoScriptText(SAY_PERIODIC, me); + Talk(SAY_PERIODIC); m_uiPeriodicSay = 15000; } else diff --git a/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp b/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp index 70f9f93c7a7..041f5976a6e 100644 --- a/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp +++ b/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" /*###### ## npc_calvin_montague diff --git a/src/server/scripts/EasternKingdoms/undercity.cpp b/src/server/scripts/EasternKingdoms/undercity.cpp index 0d44db01592..05938452520 100644 --- a/src/server/scripts/EasternKingdoms/undercity.cpp +++ b/src/server/scripts/EasternKingdoms/undercity.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npc_lady_sylvanas_windrunner @@ -40,8 +41,8 @@ EndContentData */ enum Sylvanas { QUEST_JOURNEY_TO_UNDERCITY = 9180, - SAY_LAMENT_END = -1000196, - EMOTE_LAMENT_END = -1000197, + EMOTE_LAMENT_END = 0, + SAY_LAMENT_END = 1, SOUND_CREDIT = 10896, ENTRY_HIGHBORNE_LAMENTER = 21628, @@ -152,8 +153,8 @@ public: LamentEventTimer = 2000; if (!me->HasAura(SPELL_SYLVANAS_CAST)) { - DoScriptText(SAY_LAMENT_END, me); - DoScriptText(EMOTE_LAMENT_END, me); + Talk(SAY_LAMENT_END); + Talk(EMOTE_LAMENT_END); LamentEvent = false; } } else LamentEventTimer -= diff; diff --git a/src/server/scripts/EasternKingdoms/western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/western_plaguelands.cpp index 31dea10453a..1c2f2624b34 100644 --- a/src/server/scripts/EasternKingdoms/western_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/western_plaguelands.cpp @@ -34,6 +34,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npcs_dithers_and_arbington diff --git a/src/server/scripts/EasternKingdoms/westfall.cpp b/src/server/scripts/EasternKingdoms/westfall.cpp index 478c5f6c0d6..16ba171928c 100644 --- a/src/server/scripts/EasternKingdoms/westfall.cpp +++ b/src/server/scripts/EasternKingdoms/westfall.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_daphne_stilwell @@ -38,11 +39,11 @@ EndContentData */ enum eEnums { - SAY_DS_START = -1000293, - SAY_DS_DOWN_1 = -1000294, - SAY_DS_DOWN_2 = -1000295, - SAY_DS_DOWN_3 = -1000296, - SAY_DS_PROLOGUE = -1000297, + SAY_DS_START = 0, + SAY_DS_DOWN_1 = 1, + SAY_DS_DOWN_2 = 2, + SAY_DS_DOWN_3 = 3, + SAY_DS_PROLOGUE = 4, SPELL_SHOOT = 6660, QUEST_TOME_VALOR = 1651, @@ -59,7 +60,7 @@ public: { if (quest->GetQuestId() == QUEST_TOME_VALOR) { - DoScriptText(SAY_DS_START, creature); + creature->AI()->Talk(SAY_DS_START); if (npc_escortAI* pEscortAI = CAST_AI(npc_daphne_stilwell::npc_daphne_stilwellAI, creature->AI())) pEscortAI->Start(true, true, player->GetGUID()); @@ -87,13 +88,13 @@ public: switch (uiWPHolder) { case 7: - DoScriptText(SAY_DS_DOWN_1, me); + Talk(SAY_DS_DOWN_1); break; case 8: - DoScriptText(SAY_DS_DOWN_2, me); + Talk(SAY_DS_DOWN_2); break; case 9: - DoScriptText(SAY_DS_DOWN_3, me); + Talk(SAY_DS_DOWN_3); break; } } @@ -142,7 +143,7 @@ public: SetRun(false); break; case 11: - DoScriptText(SAY_DS_PROLOGUE, me); + Talk(SAY_DS_PROLOGUE); break; case 13: SetEquipmentSlots(true); @@ -196,12 +197,14 @@ public: /*###### ## npc_defias_traitor ######*/ +enum DefiasSays +{ + SAY_START = 0, + SAY_PROGRESS = 1, + SAY_END = 2, + SAY_AGGRO = 3 +}; -#define SAY_START -1000101 -#define SAY_PROGRESS -1000102 -#define SAY_END -1000103 -#define SAY_AGGRO_1 -1000104 -#define SAY_AGGRO_2 -1000105 #define QUEST_DEFIAS_BROTHERHOOD 155 @@ -217,7 +220,7 @@ public: if (npc_escortAI* pEscortAI = CAST_AI(npc_defias_traitor::npc_defias_traitorAI, creature->AI())) pEscortAI->Start(true, true, player->GetGUID()); - DoScriptText(SAY_START, creature, player); + creature->AI()->Talk(SAY_START, player->GetGUID()); } return true; @@ -244,10 +247,10 @@ public: SetRun(false); break; case 36: - DoScriptText(SAY_PROGRESS, me, player); + Talk(SAY_PROGRESS, player->GetGUID()); break; case 44: - DoScriptText(SAY_END, me, player); + Talk(SAY_END, player->GetGUID()); player->GroupEventHappens(QUEST_DEFIAS_BROTHERHOOD, me); break; } @@ -255,7 +258,7 @@ public: void EnterCombat(Unit* who) { - DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2), me, who); + Talk(SAY_AGGRO, who->GetGUID()); } void Reset() {} diff --git a/src/server/scripts/EasternKingdoms/wetlands.cpp b/src/server/scripts/EasternKingdoms/wetlands.cpp index 34e6e7c9ddf..98f7b0ac967 100644 --- a/src/server/scripts/EasternKingdoms/wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/wetlands.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_tapoke_slim_jahn diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp index 763961271d8..28d033f9d48 100644 --- a/src/server/scripts/Events/childrens_week.cpp +++ b/src/server/scripts/Events/childrens_week.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellAuras.h" +#include "Player.h" enum Orphans { diff --git a/src/server/scripts/Events/event.cpp b/src/server/scripts/Events/event.cpp index 22334f8d365..d77ef2b78c1 100644 --- a/src/server/scripts/Events/event.cpp +++ b/src/server/scripts/Events/event.cpp @@ -15,8 +15,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "ScriptPCH.h" - void AddSC_event_childrens_week(); void AddSC_event_scripts() diff --git a/src/server/scripts/Examples/example_creature.cpp b/src/server/scripts/Examples/example_creature.cpp index 17b9aae732b..1ef15c0ca61 100644 --- a/src/server/scripts/Examples/example_creature.cpp +++ b/src/server/scripts/Examples/example_creature.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" // **** This script is designed as an example for others to build on **** // **** Please modify whatever you'd like to as this script is only for developement **** diff --git a/src/server/scripts/Examples/example_escort.cpp b/src/server/scripts/Examples/example_escort.cpp index 20e4c5614e9..8cf0dad25d2 100644 --- a/src/server/scripts/Examples/example_escort.cpp +++ b/src/server/scripts/Examples/example_escort.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" enum eEnums { diff --git a/src/server/scripts/Examples/example_gossip_codebox.cpp b/src/server/scripts/Examples/example_gossip_codebox.cpp index d6936c8fb9e..352c43fc1de 100644 --- a/src/server/scripts/Examples/example_gossip_codebox.cpp +++ b/src/server/scripts/Examples/example_gossip_codebox.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" #include <cstring> enum eEnums diff --git a/src/server/scripts/Examples/example_misc.cpp b/src/server/scripts/Examples/example_misc.cpp index 3aa4bac3f1e..5ff66c4a7ed 100644 --- a/src/server/scripts/Examples/example_misc.cpp +++ b/src/server/scripts/Examples/example_misc.cpp @@ -24,6 +24,7 @@ SDCategory: Script Examples EndScriptData */ #include "ScriptMgr.h" +#include "Player.h" enum eSay { diff --git a/src/server/scripts/Examples/example_spell.cpp b/src/server/scripts/Examples/example_spell.cpp index cc27392919f..35e61a5300d 100644 --- a/src/server/scripts/Examples/example_spell.cpp +++ b/src/server/scripts/Examples/example_spell.cpp @@ -26,6 +26,7 @@ #include "SpellAuras.h" #include "SpellAuraEffects.h" #include "SpellScript.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp index a70d05fa0ef..9cc515c1b0d 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp @@ -20,6 +20,7 @@ #include "ScriptedGossip.h" #include "blackfathom_deeps.h" #include "ScriptedEscortAI.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp index 236c7b1ba69..8df5c5cdfd4 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp @@ -212,7 +212,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -233,7 +233,7 @@ public: return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index 1c91d78cd29..afd7603a506 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "hyjal.h" #include "SpellAuras.h" #include "hyjal_trash.h" +#include "Player.h" enum Texts { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp index 48dd847b190..3ab06642fb5 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "hyjalAI.h" +#include "Player.h" #define GOSSIP_ITEM_BEGIN_ALLY "My companions and I are with you, Lady Proudmoore." #define GOSSIP_ITEM_ANETHERON "We are ready for whatever Archimonde might send our way, Lady Proudmoore." diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp index caff71c7320..df180bf5568 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp @@ -27,6 +27,9 @@ EndScriptData */ #include "InstanceScript.h" #include "ScriptedCreature.h" #include "hyjal_trash.h" +#include "Player.h" +#include "WorldPacket.h" +#include "Opcodes.h" enum Misc { @@ -156,7 +159,7 @@ public: } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -293,7 +296,7 @@ public: } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp index e74ba833908..365c5dd7300 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp @@ -21,6 +21,8 @@ #include "culling_of_stratholme.h" #include "ScriptedEscortAI.h" #include "PassiveAI.h" +#include "Player.h" +#include "SpellInfo.h" enum Says { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp index ea02e8f50b5..0467109effc 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp @@ -19,6 +19,9 @@ #include "InstanceScript.h" #include "CreatureTextMgr.h" #include "culling_of_stratholme.h" +#include "Player.h" +#include "TemporarySummon.h" +#include "SpellInfo.h" #define MAX_ENCOUNTER 5 @@ -195,7 +198,7 @@ class instance_culling_of_stratholme : public InstanceMapScript SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -215,7 +218,7 @@ class instance_culling_of_stratholme : public InstanceMapScript return 0; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp index bed3cde6fa4..8ca14d72b94 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp @@ -33,6 +33,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "dark_portal.h" +#include "Player.h" +#include "SpellInfo.h" #define SAY_ENTER -1269020 //where does this belong? #define SAY_INTRO -1269021 diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp index da34eff7b77..b7820bae920 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/instance_dark_portal.cpp @@ -26,6 +26,9 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "dark_portal.h" +#include "Player.h" +#include "TemporarySummon.h" +#include "SpellInfo.h" #define MAX_ENCOUNTER 2 @@ -236,7 +239,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -252,7 +255,7 @@ public: return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { if (data == DATA_MEDIVH) return MedivhGUID; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp index 7f7cbeaf566..5f7af55358e 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/instance_old_hillsbrad.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "old_hillsbrad.h" +#include "Player.h" #define MAX_ENCOUNTER 6 @@ -202,7 +203,7 @@ public: } } - uint32 GetData(uint32 data) + uint32 GetData(uint32 data) const { switch (data) { @@ -222,7 +223,7 @@ public: return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp index 0158d470ef9..2000d8a52f8 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "old_hillsbrad.h" +#include "Player.h" #define QUEST_ENTRY_HILLSBRAD 10282 #define QUEST_ENTRY_DIVERSION 10283 diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp index 0689a8872bb..adcec659fa3 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp @@ -29,6 +29,7 @@ EndScriptData */ #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "onyxias_lair.h" +#include "TemporarySummon.h" class instance_onyxias_lair : public InstanceMapScript { @@ -189,7 +190,7 @@ public: } } - uint32 GetData(uint32 Type) + uint32 GetData(uint32 Type) const { switch (Type) { @@ -200,7 +201,7 @@ public: return 0; } - uint64 GetData64(uint32 Data) + uint64 GetData64(uint32 Data) const { switch (Data) { diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp index a0a8bb02d90..f7161638909 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp @@ -18,6 +18,8 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "razorfen_downs.h" +#include "Player.h" +#include "TemporarySummon.h" #define MAX_ENCOUNTER 1 @@ -185,7 +187,7 @@ public: } } - uint32 GetData(uint32 uiType) + uint32 GetData(uint32 uiType) const { switch (uiType) { @@ -196,7 +198,7 @@ public: return 0; } - uint64 GetData64(uint32 uiType) + uint64 GetData64(uint32 uiType) const { switch (uiType) { diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp index 3a147007fce..443c9f73cfb 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "razorfen_downs.h" +#include "Player.h" /*### # npc_henry_stern diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp index cce0f8b180e..152c38a6b58 100644 --- a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp +++ b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "razorfen_kraul.h" +#include "Player.h" #define WARD_KEEPERS_NR 2 diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp index 374059c46ac..7b3cd9f9900 100644 --- a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp +++ b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "razorfen_kraul.h" +#include "Player.h" #define SAY_READY -1047000 #define SAY_POINT -1047001 diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp index 36a1ff1bade..e6c5243819a 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp @@ -19,6 +19,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ruins_of_ahnqiraj.h" +#include "CreatureTextMgr.h" enum Spells { @@ -38,6 +39,11 @@ enum Events EVENT_WIDE_SLASH = 4 }; +enum Texts +{ + SAY_KURINAXX_DEATH = 5, // Yelled by Ossirian the Unscarred +}; + class boss_kurinnaxx : public CreatureScript { public: @@ -45,7 +51,7 @@ class boss_kurinnaxx : public CreatureScript struct boss_kurinnaxxAI : public BossAI { - boss_kurinnaxxAI(Creature* creature) : BossAI(creature, BOSS_KURINNAXX) + boss_kurinnaxxAI(Creature* creature) : BossAI(creature, DATA_KURINNAXX) { } @@ -68,6 +74,13 @@ class boss_kurinnaxx : public CreatureScript } } + void JustDied(Unit* /*killer*/) + { + _JustDied(); + if (Creature* Ossirian = me->GetMap()->GetCreature(instance->GetData64(DATA_OSSIRIAN))) + sCreatureTextMgr->SendChat(Ossirian, SAY_KURINAXX_DEATH, 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp index c05613d387f..4abbf99d4ef 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp @@ -58,7 +58,7 @@ class boss_moam : public CreatureScript struct boss_moamAI : public BossAI { - boss_moamAI(Creature* creature) : BossAI(creature, BOSS_MOAM) + boss_moamAI(Creature* creature) : BossAI(creature, DATA_MOAM) { } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp index e9bb8be67b7..2bbdaa389ad 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> - * 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 @@ -16,39 +15,262 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Boss_Ossirian -SD%Complete: 0 -SDComment: Place holder -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ruins_of_ahnqiraj.h" +#include "Player.h" +#include "SpellInfo.h" +#include "WorldPacket.h" +#include "Opcodes.h" + +enum Texts +{ + SAY_SUPREME = 0, + SAY_INTRO = 1, + SAY_AGGRO = 2, + SAY_SLAY = 3, + SAY_DEATH = 4, +}; + +enum Spells +{ + SPELL_SILENCE = 25195, + SPELL_CYCLONE = 25189, + SPELL_STOMP = 25188, + SPELL_SUPREME = 25176, + SPELL_SUMMON = 20477, + SPELL_SAND_STORM = 25160, + SPELL_SUMMON_CRYSTAL = 25192, +}; + +enum Actions +{ + ACTION_TRIGGER_WEAKNESS = 1, +}; + +enum Events +{ + EVENT_SILENCE = 1, + EVENT_CYCLONE = 2, + EVENT_STOMP = 3 +}; + +uint8 const NUM_CRYSTALS = 9; -enum Yells +// You spin me right round, baby +// right round like a record, baby +// right round round round +Position CrystalCoordinates[NUM_CRYSTALS] = { - SAY_SURPREME2 = -1509019, - SAY_SURPREME3 = -1509020, - SAY_RAND_INTRO1 = -1509021, - SAY_RAND_INTRO2 = -1509022, - SAY_RAND_INTRO3 = -1509023, - SAY_RAND_INTRO4 = -1509024, //possibly old? - SAY_AGGRO = -1509025, - SAY_SLAY = -1509026, - SAY_DEATH = -1509027 + { -9394.230469f, 1951.808594f, 85.97733f, 0.0f }, + { -9357.931641f, 1930.596802f, 85.556198f, 0.0f }, + { -9383.113281f, 2011.042725f, 85.556389f, 0.0f }, + { -9243.36f, 1979.04f, 85.556f, 0.0f }, + { -9281.68f, 1886.66f, 85.5558f, 0.0f }, + { -9241.8f, 1806.39f, 85.5557f, 0.0f }, + { -9366.78f, 1781.76f, 85.5561f, 0.0f }, + { -9430.37f, 1786.86f, 85.557f, 0.0f }, + { -9406.73f, 1863.13f, 85.5558f, 0.0f } }; +float RoomRadius = 165.0f; +uint8 const NUM_TORNADOS = 5; // TODO: This number is completly random! +uint8 const NUM_WEAKNESS = 5; +uint32 const SpellWeakness[NUM_WEAKNESS] = { 25177, 25178, 25180, 25181, 25183 }; +Position const RoomCenter = { -9343.041992f, 1923.278198f, 85.555984f, 0.0 }; + class boss_ossirian : public CreatureScript { public: boss_ossirian() : CreatureScript("boss_ossirian") { } - struct boss_ossirianAI : public ScriptedAI + struct boss_ossirianAI : public BossAI { - boss_ossirianAI(Creature* creature) : ScriptedAI(creature) + boss_ossirianAI(Creature* creature) : BossAI(creature, DATA_OSSIRIAN) + { + SaidIntro = false; + Reset(); + } + + uint64 TriggerGUID; + uint64 CrystalGUID; + uint8 CrystalIterator; + bool SaidIntro; + + void Reset() + { + _Reset(); + CrystalIterator = 0; + TriggerGUID = 0; + CrystalGUID = 0; + } + + void SpellHit(Unit* caster, SpellInfo const* spell) + { + for (uint8 i = 0; i < NUM_WEAKNESS; ++i) + { + if (spell->Id == SpellWeakness[i]) + { + me->RemoveAurasDueToSpell(SPELL_SUPREME); + ((TempSummon*)caster)->UnSummon(); + SpawnNextCrystal(); + } + } + } + + void DoAction(const int32 action) + { + if (action == ACTION_TRIGGER_WEAKNESS) + { + if (Creature* Trigger = me->GetMap()->GetCreature(TriggerGUID)) + { + if (!Trigger->HasUnitState(UNIT_STATE_CASTING)) + Trigger->CastSpell(Trigger, SpellWeakness[urand(0, 4)], false); + } + } + } + + void EnterCombat(Unit* /*who*/) + { + _EnterCombat(); + events.Reset(); + events.ScheduleEvent(EVENT_SILENCE, 30000); + events.ScheduleEvent(EVENT_CYCLONE, 20000); + events.ScheduleEvent(EVENT_STOMP, 30000); + + DoCast(me, SPELL_SUPREME); + Talk(SAY_AGGRO); + + if (instance) + { + Map* map = me->GetMap(); + if (!map->IsDungeon()) + return; + + WorldPacket data(SMSG_WEATHER, (4+4+4)); + data << uint32(WEATHER_STATE_HEAVY_SANDSTORM) << float(1) << uint8(0); + map->SendToPlayers(&data); + + for (uint8 i = 0; i < NUM_TORNADOS; ++i) + { + Position Point; + me->GetRandomPoint(RoomCenter, RoomRadius, Point); + if (Creature* Tornado = me->GetMap()->SummonCreature(NPC_SAND_VORTEX, Point)) + Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true); + } + + SpawnNextCrystal(); + } + } + + void KilledUnit(Unit* /*victim*/) { + Talk(SAY_SLAY); + } + + void EnterEvadeMode() + { + Cleanup(); + summons.DespawnAll(); + ScriptedAI::EnterEvadeMode(); + } + + void JustDied(Unit* /*killer*/) + { + Cleanup(); + _JustDied(); + } + + void Cleanup() + { + if (GameObject* Crystal = me->GetMap()->GetGameObject(CrystalGUID)) + Crystal->Use(me); + } + + void SpawnNextCrystal() + { + if (CrystalIterator == NUM_CRYSTALS) + CrystalIterator = 0; + + if (Creature* Trigger = me->GetMap()->SummonCreature(NPC_OSSIRIAN_TRIGGER, CrystalCoordinates[CrystalIterator])) + { + TriggerGUID = Trigger->GetGUID(); + if (GameObject* Crystal = Trigger->SummonGameObject(GO_OSSIRIAN_CRYSTAL, + CrystalCoordinates[CrystalIterator].GetPositionX(), + CrystalCoordinates[CrystalIterator].GetPositionY(), + CrystalCoordinates[CrystalIterator].GetPositionZ(), + 0, 0, 0, 0, 0, -1)) + { + CrystalGUID = Crystal->GetGUID(); + ++CrystalIterator; + } + } + } + + void MoveInLineOfSight(Unit* /*who*/) + { + if (!SaidIntro) + { + Talk(SAY_INTRO); + SaidIntro = true; + } + } + + void UpdateAI(uint32 const diff) + { + if (!UpdateVictim()) + return; + + events.Update(diff); + + // No kiting! + if (me->GetDistance(me->getVictim()) > 60.00f && me->GetDistance(me->getVictim()) < 120.00f) + DoCast(me->getVictim(), SPELL_SUMMON); + + bool ApplySupreme = true; + + if (me->HasAura(SPELL_SUPREME)) + ApplySupreme = false; + else + { + for (uint8 i = 0; i < NUM_WEAKNESS; ++i) + { + if (me->HasAura(SpellWeakness[i])) + { + ApplySupreme = false; + break; + } + } + } + + if (ApplySupreme) + { + DoCast(me, SPELL_SUPREME); + Talk(SAY_SUPREME); + } + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_SILENCE: + DoCast(me, SPELL_SILENCE); + events.ScheduleEvent(EVENT_SILENCE, urand(20000, 30000)); + break; + case EVENT_CYCLONE: + DoCast(me->getVictim(), SPELL_CYCLONE); + events.ScheduleEvent(EVENT_CYCLONE, 20000); + break; + case EVENT_STOMP: + DoCast(me, SPELL_STOMP); + events.ScheduleEvent(EVENT_STOMP, 30000); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); } }; @@ -58,7 +280,28 @@ class boss_ossirian : public CreatureScript } }; +class go_ossirian_crystal : public GameObjectScript +{ + public: + go_ossirian_crystal() : GameObjectScript("go_ossirian_crystal") { } + + bool OnGossipHello(Player* player, GameObject* /*go*/) + { + InstanceScript* Instance = player->GetInstanceScript(); + if (!Instance) + return false; + + Creature* Ossirian = player->FindNearestCreature(NPC_OSSIRIAN, 30.0f); + if (!Ossirian || Instance->GetBossState(DATA_OSSIRIAN) != IN_PROGRESS) + return false; + + Ossirian->AI()->DoAction(ACTION_TRIGGER_WEAKNESS); + return true; + } +}; + void AddSC_boss_ossirian() { new boss_ossirian(); + new go_ossirian_crystal(); } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp index afa8eff5823..da67f93f968 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_rajaxx.cpp @@ -63,7 +63,7 @@ class boss_rajaxx : public CreatureScript struct boss_rajaxxAI : public BossAI { - boss_rajaxxAI(Creature* creature) : BossAI(creature, BOSS_RAJAXX) + boss_rajaxxAI(Creature* creature) : BossAI(creature, DATA_RAJAXX) { } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp index 2dbd52f7e42..d61d9416ac6 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp @@ -28,7 +28,7 @@ class instance_ruins_of_ahnqiraj : public InstanceMapScript { instance_ruins_of_ahnqiraj_InstanceMapScript(Map* map) : InstanceScript(map) { - SetBossNumber(MAX_ENCOUNTER); + SetBossNumber(NUM_ENCOUNTER); _kurinaxxGUID = 0; _rajaxxGUID = 0; @@ -71,21 +71,21 @@ class instance_ruins_of_ahnqiraj : public InstanceMapScript return true; } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { - case BOSS_KURINNAXX: + case DATA_KURINNAXX: return _kurinaxxGUID; - case BOSS_RAJAXX: + case DATA_RAJAXX: return _rajaxxGUID; - case BOSS_MOAM: + case DATA_MOAM: return _moamGUID; - case BOSS_BURU: + case DATA_BURU: return _buruGUID; - case BOSS_AYAMISS: + case DATA_AYAMISS: return _ayamissGUID; - case BOSS_OSSIRIAN: + case DATA_OSSIRIAN: return _ossirianGUID; } @@ -120,7 +120,7 @@ class instance_ruins_of_ahnqiraj : public InstanceMapScript if (dataHead1 == 'R' && dataHead2 == 'A') { - for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) + for (uint8 i = 0; i < NUM_ENCOUNTER; ++i) { uint32 tmpState; loadStream >> tmpState; diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.h b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.h index 14d129a7468..7f7efc83eb5 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.h +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/ruins_of_ahnqiraj.h @@ -18,15 +18,15 @@ #ifndef DEF_RUINS_OF_AHNQIRAJ_H #define DEF_RUINS_OF_AHNQIRAJ_H -enum Encounters +enum DataTypes { - BOSS_KURINNAXX = 0, - BOSS_RAJAXX = 1, - BOSS_MOAM = 2, - BOSS_BURU = 3, - BOSS_AYAMISS = 4, - BOSS_OSSIRIAN = 5, - MAX_ENCOUNTER, + DATA_KURINNAXX = 0, + DATA_RAJAXX = 1, + DATA_MOAM = 2, + DATA_BURU = 3, + DATA_AYAMISS = 4, + DATA_OSSIRIAN = 5, + NUM_ENCOUNTER = 6 }; enum Creatures @@ -40,6 +40,13 @@ enum Creatures NPC_HIVEZARA_HORNET = 15934, NPC_HIVEZARA_SWARMER = 15546, NPC_HIVEZARA_LARVA = 15555, + NPC_SAND_VORTEX = 15428, + NPC_OSSIRIAN_TRIGGER = 15590, +}; + +enum GameObjects +{ + GO_OSSIRIAN_CRYSTAL = 180619, }; #endif diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 95c6d033aab..6b569bbd3e5 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "temple_of_ahnqiraj.h" +#include "Player.h" /* * This is a 2 phases events. Here follows an explanation of the main events and transition between phases and sub-phases. diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp index 36388cfbe9c..917c790f42b 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "temple_of_ahnqiraj.h" #include "Group.h" +#include "Player.h" #define SAY_AGGRO1 -1531000 #define SAY_AGGRO2 -1531001 diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp index 887ca4f3ad5..c8a1ff63925 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp @@ -90,7 +90,7 @@ public: return false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -118,7 +118,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp b/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp index 1bb5c1180bd..afd4d834f07 100644 --- a/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp +++ b/src/server/scripts/Kalimdor/WailingCaverns/instance_wailing_caverns.cpp @@ -80,7 +80,7 @@ public: if (data == DONE)SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -98,7 +98,7 @@ public: return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { if (data == DATA_NARALEX)return NaralexGUID; return 0; diff --git a/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp b/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp index 0d4efac4321..e1a3c3aeb45 100644 --- a/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp +++ b/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "wailing_caverns.h" +#include "Player.h" /*###### ## npc_disciple_of_naralex diff --git a/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp b/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp index 3a6a3f6241c..4cdddb2d9da 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp @@ -18,6 +18,8 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "zulfarrak.h" +#include "Player.h" +#include "TemporarySummon.h" #define NPC_GAHZRILLA 7273 #define PATH_ADDS 81553 @@ -179,7 +181,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -189,7 +191,7 @@ public: return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp index 03e3756f964..f288db920f4 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/zulfarrak.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "zulfarrak.h" +#include "Player.h" /*###### ## npc_sergeant_bly diff --git a/src/server/scripts/Kalimdor/ashenvale.cpp b/src/server/scripts/Kalimdor/ashenvale.cpp index 6a9dd77433a..0e44da371d6 100644 --- a/src/server/scripts/Kalimdor/ashenvale.cpp +++ b/src/server/scripts/Kalimdor/ashenvale.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*#### # npc_torek diff --git a/src/server/scripts/Kalimdor/azshara.cpp b/src/server/scripts/Kalimdor/azshara.cpp index 8d08c26f0a7..213918db338 100644 --- a/src/server/scripts/Kalimdor/azshara.cpp +++ b/src/server/scripts/Kalimdor/azshara.cpp @@ -33,6 +33,9 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "SpellInfo.h" +#include "WorldSession.h" /*###### ## mobs_spitelashes @@ -355,14 +358,14 @@ public: if (TeleportTimer <= diff) { - //temp solution - unit can't be teleported by core using spelleffect 5, only players - if (me->GetMap()) - { - me->SetPosition(3706.39f, -3969.15f, 35.9118f, 0); - me->AI_SendMoveToPacket(3706.39f, -3969.15f, 35.9118f, 0, 0, 0); - } + // temp solution - unit can't be teleported by core using spelleffect 5, only players + DoTeleportTo(3706.39f, -3969.15f, 35.9118f); + //begin swimming and summon depth charges Player* player = Unit::GetPlayer(*me, PlayerGUID); + if (!player) + return; + SendText(MSG_ESCAPE_NOTICE, player); DoCast(me, SPELL_PERIODIC_DEPTH_CHARGE); me->SetUnitMovementFlags(MOVEMENTFLAG_HOVER | MOVEMENTFLAG_SWIMMING); diff --git a/src/server/scripts/Kalimdor/bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/bloodmyst_isle.cpp index 3883b740d02..339cd02c2e3 100644 --- a/src/server/scripts/Kalimdor/bloodmyst_isle.cpp +++ b/src/server/scripts/Kalimdor/bloodmyst_isle.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## mob_webbed_creature diff --git a/src/server/scripts/Kalimdor/darkshore.cpp b/src/server/scripts/Kalimdor/darkshore.cpp index 0e02a77169e..5d10076c114 100644 --- a/src/server/scripts/Kalimdor/darkshore.cpp +++ b/src/server/scripts/Kalimdor/darkshore.cpp @@ -34,6 +34,8 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.h" +#include "SpellInfo.h" /*#### # npc_kerlonian diff --git a/src/server/scripts/Kalimdor/desolace.cpp b/src/server/scripts/Kalimdor/desolace.cpp index e196c71f681..30a87ef0197 100644 --- a/src/server/scripts/Kalimdor/desolace.cpp +++ b/src/server/scripts/Kalimdor/desolace.cpp @@ -34,6 +34,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "SpellInfo.h" enum DyingKodo { diff --git a/src/server/scripts/Kalimdor/durotar.cpp b/src/server/scripts/Kalimdor/durotar.cpp index ec06a542b6f..83111829c9e 100644 --- a/src/server/scripts/Kalimdor/durotar.cpp +++ b/src/server/scripts/Kalimdor/durotar.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "Vehicle.h" #include "SpellScript.h" +#include "Player.h" /*###### ##Quest 5441: Lazy Peons diff --git a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp index 5800a6a58a0..6ab9b653c5d 100644 --- a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp +++ b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp @@ -36,6 +36,8 @@ EndContentData */ #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "SpellScript.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## mobs_risen_husk_spirit diff --git a/src/server/scripts/Kalimdor/felwood.cpp b/src/server/scripts/Kalimdor/felwood.cpp index 1a0aa7b21c0..f1d9a9028e1 100644 --- a/src/server/scripts/Kalimdor/felwood.cpp +++ b/src/server/scripts/Kalimdor/felwood.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npcs_riverbreeze_and_silversky diff --git a/src/server/scripts/Kalimdor/feralas.cpp b/src/server/scripts/Kalimdor/feralas.cpp index c1e247044f7..df4345b3aae 100644 --- a/src/server/scripts/Kalimdor/feralas.cpp +++ b/src/server/scripts/Kalimdor/feralas.cpp @@ -28,6 +28,8 @@ EndScriptData */ #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "SpellScript.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npc_gregan_brewspewer diff --git a/src/server/scripts/Kalimdor/moonglade.cpp b/src/server/scripts/Kalimdor/moonglade.cpp index 3c8d2267903..6d93e074e79 100644 --- a/src/server/scripts/Kalimdor/moonglade.cpp +++ b/src/server/scripts/Kalimdor/moonglade.cpp @@ -35,6 +35,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## npc_bunthen_plainswind diff --git a/src/server/scripts/Kalimdor/mulgore.cpp b/src/server/scripts/Kalimdor/mulgore.cpp index 5b35688c2b8..8ed26b8cf38 100644 --- a/src/server/scripts/Kalimdor/mulgore.cpp +++ b/src/server/scripts/Kalimdor/mulgore.cpp @@ -32,6 +32,8 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "SpellInfo.h" /*###### # npc_skorn_whitecloud diff --git a/src/server/scripts/Kalimdor/orgrimmar.cpp b/src/server/scripts/Kalimdor/orgrimmar.cpp index fca8d0f5fc5..5080daefbf9 100644 --- a/src/server/scripts/Kalimdor/orgrimmar.cpp +++ b/src/server/scripts/Kalimdor/orgrimmar.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npc_shenthul diff --git a/src/server/scripts/Kalimdor/silithus.cpp b/src/server/scripts/Kalimdor/silithus.cpp index 45a2fad9999..df7d3b1ee89 100644 --- a/src/server/scripts/Kalimdor/silithus.cpp +++ b/src/server/scripts/Kalimdor/silithus.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "Group.h" +#include "Player.h" /*### ## npc_highlord_demitrian diff --git a/src/server/scripts/Kalimdor/stonetalon_mountains.cpp b/src/server/scripts/Kalimdor/stonetalon_mountains.cpp index d38395c7b37..5cf6d141805 100644 --- a/src/server/scripts/Kalimdor/stonetalon_mountains.cpp +++ b/src/server/scripts/Kalimdor/stonetalon_mountains.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_braug_dimspirit diff --git a/src/server/scripts/Kalimdor/tanaris.cpp b/src/server/scripts/Kalimdor/tanaris.cpp index 417c8b338c7..7341ccb1e2c 100644 --- a/src/server/scripts/Kalimdor/tanaris.cpp +++ b/src/server/scripts/Kalimdor/tanaris.cpp @@ -38,6 +38,8 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## mob_aquementas diff --git a/src/server/scripts/Kalimdor/teldrassil.cpp b/src/server/scripts/Kalimdor/teldrassil.cpp index 7f2b2fc7f05..6c1993d6447 100644 --- a/src/server/scripts/Kalimdor/teldrassil.cpp +++ b/src/server/scripts/Kalimdor/teldrassil.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedFollowerAI.h" +#include "Player.h" /*#### # npc_mist diff --git a/src/server/scripts/Kalimdor/the_barrens.cpp b/src/server/scripts/Kalimdor/the_barrens.cpp index f4983558b67..8a24f696a23 100644 --- a/src/server/scripts/Kalimdor/the_barrens.cpp +++ b/src/server/scripts/Kalimdor/the_barrens.cpp @@ -36,6 +36,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## npc_beaten_corpse diff --git a/src/server/scripts/Kalimdor/thousand_needles.cpp b/src/server/scripts/Kalimdor/thousand_needles.cpp index b9ae356ddf1..7667a8b312c 100644 --- a/src/server/scripts/Kalimdor/thousand_needles.cpp +++ b/src/server/scripts/Kalimdor/thousand_needles.cpp @@ -36,6 +36,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*##### # npc_kanati diff --git a/src/server/scripts/Kalimdor/thunder_bluff.cpp b/src/server/scripts/Kalimdor/thunder_bluff.cpp index b8b05b9692f..1b10a3a204b 100644 --- a/src/server/scripts/Kalimdor/thunder_bluff.cpp +++ b/src/server/scripts/Kalimdor/thunder_bluff.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*##### # npc_cairne_bloodhoof diff --git a/src/server/scripts/Kalimdor/ungoro_crater.cpp b/src/server/scripts/Kalimdor/ungoro_crater.cpp index 786d2fc0cd3..e00ea566c8f 100644 --- a/src/server/scripts/Kalimdor/ungoro_crater.cpp +++ b/src/server/scripts/Kalimdor/ungoro_crater.cpp @@ -32,6 +32,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.h" +#include "SpellInfo.h" enum AmeData { diff --git a/src/server/scripts/Kalimdor/winterspring.cpp b/src/server/scripts/Kalimdor/winterspring.cpp index 2c4da0fdf7c..73b8bfe9af1 100644 --- a/src/server/scripts/Kalimdor/winterspring.cpp +++ b/src/server/scripts/Kalimdor/winterspring.cpp @@ -30,6 +30,8 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npc_rivern_frostwind diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp index fe86f54ae15..9b48d7a9e1c 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp @@ -116,7 +116,7 @@ class boss_elder_nadox : public CreatureScript GuardianDied = true; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_RESPECT_YOUR_ELDERS) return !GuardianDied ? 1 : 0; diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp index 3a937942118..b4756a33b38 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp @@ -22,6 +22,8 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ahnkahet.h" +#include "Player.h" +#include "SpellInfo.h" enum Spells { diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp index 02dcc04abd6..e6bb23b61d7 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp @@ -156,7 +156,7 @@ public: volunteerWork = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_VOLUNTEER_WORK) return volunteerWork ? 1 : 0; diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp index f870c61dd5f..7eaf8368c21 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp @@ -160,7 +160,7 @@ public: } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -252,7 +252,7 @@ public: SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp index 4e06ac0ba3a..10575ae288c 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/instance_azjol_nerub.cpp @@ -105,7 +105,7 @@ public: } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -149,7 +149,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp index a9d6d9d91ba..e20b08c515e 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp @@ -404,7 +404,7 @@ public: me->AddLootMode(LOOT_MODE_HARD_MODE_1); // Add 1st Drake loot mode } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == TWILIGHT_ACHIEVEMENTS) return drakeCount; diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp index 7d4438ed7c7..c39d7fbeb09 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/instance_obsidian_sanctum.cpp @@ -108,7 +108,7 @@ public: m_bVesperonKilled = true; } - uint32 GetData(uint32 uiType) + uint32 GetData(uint32 uiType) const { if (uiType == TYPE_SARTHARION_EVENT) return m_auiEncounter[0]; @@ -122,7 +122,7 @@ public: return 0; } - uint64 GetData64(uint32 uiData) + uint64 GetData64(uint32 uiData) const { switch (uiData) { diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 82739c0026a..2bb2b1c3cd7 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -24,12 +24,13 @@ #include "GameObjectAI.h" #include "ScriptedCreature.h" #include "ruby_sanctum.h" +#include "Player.h" /* ScriptData SDName: ruby_sanctum SDAuthors: Kaelima, Warpten SD%Complete: 90% -SDComment: Based on Kaelima's initial work (nearly half of it). Corporeality handling is a pure guess, we lack info. +SDComment: Based on Kaelima's initial work (half of it). Corporeality handling is a pure guess, we lack info. SDCategory: Chamber of Aspects EndScriptData */ @@ -123,13 +124,12 @@ enum Events // Halion EVENT_ACTIVATE_FIREWALL = 1, EVENT_CLEAVE = 2, - EVENT_FLAME_BREATH = 3, + EVENT_BREATH = 3, EVENT_METEOR_STRIKE = 4, EVENT_FIERY_COMBUSTION = 5, EVENT_TAIL_LASH = 6, // Twilight Halion - EVENT_DARK_BREATH = 7, EVENT_SOUL_CONSUMPTION = 8, // Meteor Strike @@ -153,12 +153,10 @@ enum Actions ACTION_METEOR_STRIKE_AOE = 2, // Halion Controller - ACTION_PHASE_TWO = 3, - ACTION_PHASE_THREE = 4, - ACTION_CLEANUP = 5, + ACTION_MONITOR_CORPOREALITY = 3, // Orb Carrier - ACTION_SHOOT = 6 + ACTION_SHOOT = 4 }; enum Phases @@ -231,9 +229,11 @@ struct generic_halionAI : public BossAI void EnterCombat(Unit* who) { BossAI::EnterCombat(who); + me->AddAura(SPELL_TWILIGHT_PRECISION, me); _canEvade = false; events.ScheduleEvent(EVENT_CLEAVE, urand(8000, 10000)); events.ScheduleEvent(EVENT_TAIL_LASH, 10000); + events.ScheduleEvent(EVENT_BREATH, urand(10000, 15000)); } void Reset() @@ -260,19 +260,20 @@ struct generic_halionAI : public BossAI DoCastAOE(SPELL_TAIL_LASH); events.ScheduleEvent(EVENT_TAIL_LASH, 10000); break; + case EVENT_BREATH: + DoCast(me, me->GetEntry() == NPC_HALION ? SPELL_FLAME_BREATH : SPELL_DARK_BREATH); + events.ScheduleEvent(EVENT_BREATH, urand(10000, 12000)); + break; } } void UpdateAI(uint32 const diff) { - if (!UpdateVictim()) + if (!UpdateVictim() || me->HasUnitState(UNIT_STATE_CASTING)) return; events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; - while (uint32 eventId = events.ExecuteEvent()) ExecuteEvent(eventId); @@ -319,7 +320,6 @@ class boss_halion : public CreatureScript me->SetReactState(REACT_DEFENSIVE); me->RemoveAurasDueToSpell(SPELL_TWILIGHT_PHASING); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->AddAura(SPELL_TWILIGHT_PRECISION, me); } void EnterEvadeMode() @@ -342,7 +342,6 @@ class boss_halion : public CreatureScript instance->SetBossState(DATA_HALION, IN_PROGRESS); events.ScheduleEvent(EVENT_ACTIVATE_FIREWALL, 5000); - events.ScheduleEvent(EVENT_FLAME_BREATH, urand(10000, 12000)); events.ScheduleEvent(EVENT_METEOR_STRIKE, urand(20000, 25000)); events.ScheduleEvent(EVENT_FIERY_COMBUSTION, urand(15000, 18000)); @@ -408,10 +407,6 @@ class boss_halion : public CreatureScript if (GameObject* flameRing = ObjectAccessor::GetGameObject(*me, instance->GetData64(i))) instance->HandleGameObject(instance->GetData64(DATA_FLAME_RING), false, flameRing); break; - case EVENT_FLAME_BREATH: - DoCast(me, SPELL_FLAME_BREATH); - events.ScheduleEvent(EVENT_FLAME_BREATH, 25000); - break; case EVENT_METEOR_STRIKE: { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_TWILIGHT_REALM)) @@ -490,7 +485,6 @@ class boss_twilight_halion : public CreatureScript generic_halionAI::EnterCombat(who); - events.ScheduleEvent(EVENT_DARK_BREATH, urand(10000, 15000)); events.ScheduleEvent(EVENT_SOUL_CONSUMPTION, 20000); instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 2); @@ -554,7 +548,7 @@ class boss_twilight_halion : public CreatureScript { case SPELL_TWILIGHT_DIVISION: if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HALION_CONTROLLER))) - controller->AI()->SetData(DATA_FIGHT_PHASE, PHASE_THREE); + controller->AI()->DoAction(ACTION_MONITOR_CORPOREALITY); break; default: generic_halionAI::SpellHit(who, spell); @@ -566,10 +560,6 @@ class boss_twilight_halion : public CreatureScript { switch (eventId) { - case EVENT_DARK_BREATH: - DoCast(me, SPELL_DARK_BREATH); - events.ScheduleEvent(EVENT_DARK_BREATH, urand(10000, 15000)); - break; case EVENT_SOUL_CONSUMPTION: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true, SPELL_TWILIGHT_REALM)) DoCast(target, SPELL_SOUL_CONSUMPTION); @@ -610,6 +600,8 @@ class npc_halion_controller : public CreatureScript _summons.DespawnAll(); _events.Reset(); _materialCorporealityValue = 5; + _materialDamageTaken = 0; + _twilightDamageTaken = 0; DoCast(me, SPELL_CLEAR_DEBUFFS); } @@ -658,6 +650,34 @@ class npc_halion_controller : public CreatureScript _events.SetPhase(PHASE_INTRO); _events.ScheduleEvent(EVENT_START_INTRO, 2000); break; + case ACTION_MONITOR_CORPOREALITY: + { + for (uint8 itr = DATA_HALION; itr <= DATA_TWILIGHT_HALION; itr++) + { + Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetData64(itr)); + if (!halion) + continue; + + halion->CastSpell(halion, GetSpell(_materialCorporealityValue, itr == DATA_TWILIGHT_HALION), false); + halion->AI()->SetData(DATA_FIGHT_PHASE, PHASE_THREE); + + if (itr == DATA_TWILIGHT_HALION) + continue; + + halion->RemoveAurasDueToSpell(SPELL_TWILIGHT_PHASING); + halion->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + // Summon Twilight portals + DoCast(me, SPELL_SUMMON_EXIT_PORTALS); + + _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_TOGGLE, 1); + // Hardcoding doesn't really matter here. + _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_MATERIAL, 50); + _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_TWILIGHT, 50); + + _events.ScheduleEvent(EVENT_CHECK_CORPOREALITY, 7500); + } default: break; } @@ -748,36 +768,8 @@ class npc_halion_controller : public CreatureScript DoZoneInCombat(); break; case PHASE_TWO: - // Timer taken from a 4.3.4 solo video and confirmed by TankSpot's 3.3.5 guide. http://www.tankspot.com/showthread.php?67195-Halion-Encounter-Guide-Live _events.ScheduleEvent(EVENT_SHADOW_PULSARS_SHOOT, 29000); break; - case PHASE_THREE: - _events.ScheduleEvent(EVENT_CHECK_CORPOREALITY, 5000); - // Load up corporeality data. - for (uint8 itr = DATA_HALION; itr <= DATA_TWILIGHT_HALION; itr++) - { - Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetData64(itr)); - if (!halion) - continue; - - halion->CastSpell(halion, GetSpell(_materialCorporealityValue, itr == DATA_TWILIGHT_HALION), false); - halion->AI()->SetData(DATA_FIGHT_PHASE, PHASE_THREE); - - if (itr == DATA_TWILIGHT_HALION) - continue; - - halion->RemoveAurasDueToSpell(SPELL_TWILIGHT_PHASING); - halion->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - // Summon Twilight portals - DoCast(me, SPELL_SUMMON_EXIT_PORTALS); - - _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_TOGGLE, 1); - // Hardcoding doesn't really matter here. - _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_MATERIAL, 50); - _instance->DoUpdateWorldState(WORLDSTATE_CORPOREALITY_TWILIGHT, 50); - break; default: break; } @@ -808,17 +800,21 @@ class npc_halion_controller : public CreatureScript float damageRatio = float(_materialDamageTaken) / float(_twilightDamageTaken); CorporealityEvent action = CORPOREALITY_NONE; - if (damageRatio < 0.98f) // [0 , 0.98[: Corporeality goes down + if (damageRatio < 0.98f) // [0 , 0.98[: Corporeality goes down action = CORPOREALITY_DECREASE; - else if (0.99f < damageRatio && damageRatio < 1.0f) // ]0.99, 1.01[: Twilight Mending + else if (0.99f < damageRatio && damageRatio < 1.01f) // ]0.99, 1.01[: Twilight Mending action = CORPOREALITY_TWILIGHT_MENDING; - else if (1.02f < damageRatio) // ]1.02, +oo [: Corporeality goes up + else if (1.02f < damageRatio) // ]1.02, +oo [: Corporeality goes up action = CORPOREALITY_INCREASE; switch (action) { case CORPOREALITY_NONE: + { + _materialDamageTaken = 0; + _twilightDamageTaken = 0; return; + } case CORPOREALITY_INCREASE: { if (_materialCorporealityValue >= (MAX_CORPOREALITY_STATE - 1)) @@ -1375,7 +1371,7 @@ class spell_halion_combustion_consumption : public SpellScriptLoader public: spell_halion_combustion_consumption_AuraScript(uint32 spellID) : AuraScript(), _markSpell(spellID) { } - bool Validate(SpellEntry const* /*spell*/) + bool Validate(SpellInfo const* /*spell*/) { if (!sSpellMgr->GetSpellInfo(_markSpell)) return false; @@ -1434,7 +1430,7 @@ class spell_halion_marks : public SpellScriptLoader spell_halion_marks_AuraScript(uint32 summonSpell, uint32 removeSpell) : AuraScript(), _summonSpellId(summonSpell), _removeSpellId(removeSpell) { } - bool Validate(SpellEntry const* /*spell*/) + bool Validate(SpellInfo const* /*spell*/) { if (!sSpellMgr->GetSpellInfo(_summonSpellId)) return false; diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp index bf48132b2b2..939c22325d7 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp @@ -18,7 +18,9 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "ruby_sanctum.h" - +#include "Player.h" +#include "TemporarySummon.h" +#include "WorldPacket.h" DoorData const doorData[] = { @@ -162,7 +164,7 @@ class instance_ruby_sanctum : public InstanceMapScript } } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { @@ -272,7 +274,7 @@ class instance_ruby_sanctum : public InstanceMapScript BaltharusSharedHealth = data; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type != DATA_BALTHARUS_SHARED_HEALTH) return 0; diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.cpp index 273c860a2ad..ce543b95fd5 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ruby_sanctum.h" +#include "Player.h" enum Texts { diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp index f3b6078d536..35a22c6bf37 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "ScriptedEscortAI.h" #include "Vehicle.h" #include "trial_of_the_champion.h" +#include "Player.h" enum eSpells { diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp index 310dd1003c3..d2a01003324 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "trial_of_the_champion.h" +#include "Player.h" #define MAX_ENCOUNTER 4 @@ -234,7 +235,7 @@ public: SaveToDB(); } - uint32 GetData(uint32 uiData) + uint32 GetData(uint32 uiData) const { switch (uiData) { @@ -250,7 +251,7 @@ public: return 0; } - uint64 GetData64(uint32 uiData) + uint64 GetData64(uint32 uiData) const { switch (uiData) { diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp index a2488513d63..ffda3d12e2f 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "trial_of_the_champion.h" #include "Vehicle.h" +#include "Player.h" #define GOSSIP_START_EVENT1 "I'm ready to start challenge." #define GOSSIP_START_EVENT2 "I'm ready for the next challenge." diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 564df34462b..f618d0e04e7 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -16,24 +16,16 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: boss_anubarak_trial -SD%Complete: ??% -SDComment: based on /dev/rsa -SDCategory: -EndScriptData */ - // Known bugs: // Anubarak - underground phase partially not worked // - tele after impale hit a permafrost doesn't work (the entire tele spell should be better) -// Burrow - visual is vanishing -// Burrower - Spider Frenzy not working as it should (frenzy not stacking) // Scarab - Kill credit isn't crediting? -// FrostSph - often they are casting Permafrost a little above the ground #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "trial_of_the_crusader.h" +#include "SpellScript.h" +#include <limits> enum Yells { @@ -47,7 +39,7 @@ enum Yells SAY_KILL_PLAYER = 7, SAY_DEATH = 8, - EMOTE_SPIKE = 0, + EMOTE_SPIKE = 0 }; enum Summons @@ -56,7 +48,7 @@ enum Summons NPC_BURROW = 34862, NPC_BURROWER = 34607, NPC_SCARAB = 34605, - NPC_SPIKE = 34660, + NPC_SPIKE = 34660 }; enum BossSpells @@ -86,8 +78,9 @@ enum BossSpells SPELL_EXPOSE_WEAKNESS = 67720, //Passive - Triggered SPELL_SHADOW_STRIKE = 66134, SPELL_SUBMERGE_EFFECT = 68394, - SPELL_EMERGE_EFFECT = 65982, SPELL_AWAKENED = 66311, + SPELL_EMERGE_EFFECT = 65982, + SPELL_PERSISTENT_DIRT = 68048, SUMMON_SCARAB = NPC_SCARAB, @@ -107,15 +100,15 @@ enum BossSpells SPELL_SPIKE_SPEED2 = 65922, SPELL_SPIKE_SPEED3 = 65923, SPELL_SPIKE_FAIL = 66181, - SPELL_SPIKE_TELE = 66170, + SPELL_SPIKE_TELE = 66170 }; #define SPELL_PERMAFROST_HELPER RAID_MODE<uint32>(66193, 67855, 67856, 67857) enum SummonActions { - ACTION_SHADOW_STRIKE, - ACTION_SCARAB_SUBMERGE, + ACTION_SHADOW_STRIKE = 0, + ACTION_SCARAB_SUBMERGE = 1 }; const Position SphereSpawn[6] = @@ -133,446 +126,468 @@ enum MovementPoints POINT_FALL_GROUND = 1 }; -class boss_anubarak_trial : public CreatureScript +enum PursuingSpikesPhases { -public: - boss_anubarak_trial() : CreatureScript("boss_anubarak_trial") { } + PHASE_NO_MOVEMENT = 0, + PHASE_IMPALE_NORMAL = 1, + PHASE_IMPALE_MIDDLE = 2, + PHASE_IMPALE_FAST = 3 +}; - CreatureAI* GetAI(Creature* creature) const - { - return new boss_anubarak_trialAI(creature); - }; +enum Events +{ + // Anub'arak + EVENT_FREEZE_SLASH = 1, + EVENT_PENETRATING_COLD = 2, + EVENT_SUMMON_NERUBIAN = 3, + EVENT_NERUBIAN_SHADOW_STRIKE = 4, + EVENT_SUBMERGE = 5, + EVENT_EMERGE = 6, + EVENT_PURSUING_SPIKE = 7, + EVENT_SUMMON_SCARAB = 8, + EVENT_SUMMON_FROST_SPHERE = 9, + EVENT_BERSERK = 10 +}; - struct boss_anubarak_trialAI : public ScriptedAI - { - boss_anubarak_trialAI(Creature* creature) : ScriptedAI(creature), Summons(me) - { - instance = creature->GetInstanceScript(); - } +enum Phases +{ + // Anub'arak + PHASE_MELEE = 1, + PHASE_SUBMERGED = 2, - InstanceScript* instance; - - SummonList Summons; - std::list<uint64> m_vBurrowGUID; - uint64 m_aSphereGUID[6]; - - uint32 m_uiFreezeSlashTimer; - uint32 m_uiPenetratingColdTimer; - uint32 m_uiSummonNerubianTimer; - uint32 m_uiNerubianShadowStrikeTimer; - uint32 m_uiSubmergeTimer; - uint32 m_uiPursuingSpikeTimer; - uint32 m_uiSummonScarabTimer; - uint32 m_uiSummonFrostSphereTimer; - uint32 m_uiBerserkTimer; - - uint8 m_uiStage; - bool m_bIntro; - bool m_bReachedPhase3; - uint64 m_uiTargetGUID; - uint8 m_uiScarabSummoned; - - void Reset() - { - m_uiFreezeSlashTimer = 15*IN_MILLISECONDS; - m_uiPenetratingColdTimer = 20*IN_MILLISECONDS; - m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS; - m_uiSummonNerubianTimer = 10*IN_MILLISECONDS; - m_uiSubmergeTimer = 80*IN_MILLISECONDS; - - m_uiPursuingSpikeTimer = 2*IN_MILLISECONDS; - m_uiSummonScarabTimer = 2*IN_MILLISECONDS; - - m_uiSummonFrostSphereTimer = 20*IN_MILLISECONDS; - - m_uiBerserkTimer = 10*MINUTE*IN_MILLISECONDS; - m_uiStage = 0; - m_uiScarabSummoned = 0; - m_bIntro = true; - m_bReachedPhase3 = false; - m_uiTargetGUID = 0; - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - Summons.DespawnAll(); - m_vBurrowGUID.clear(); - } + PHASE_MASK_MELEE = 1 << PHASE_MELEE +}; - void KilledUnit(Unit* who) +class boss_anubarak_trial : public CreatureScript +{ + public: + boss_anubarak_trial() : CreatureScript("boss_anubarak_trial") { } + + struct boss_anubarak_trialAI : public BossAI { - if (who->GetTypeId() == TYPEID_PLAYER) + boss_anubarak_trialAI(Creature* creature) : BossAI(creature, BOSS_ANUBARAK) { - Talk(SAY_KILL_PLAYER); - if (instance) - instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); } - } - void MoveInLineOfSight(Unit* /*who*/) - { - if (!m_bIntro) + void Reset() { - Talk(SAY_INTRO); - m_bIntro = false; + _Reset(); + events.SetPhase(PHASE_MELEE); + events.ScheduleEvent(EVENT_FREEZE_SLASH, 15*IN_MILLISECONDS, 0, PHASE_MELEE); + events.ScheduleEvent(EVENT_PENETRATING_COLD, 20*IN_MILLISECONDS, PHASE_MELEE); + events.ScheduleEvent(EVENT_SUMMON_NERUBIAN, 10*IN_MILLISECONDS, 0, PHASE_MELEE); + events.ScheduleEvent(EVENT_SUBMERGE, 80*IN_MILLISECONDS, 0, PHASE_MELEE); + events.ScheduleEvent(EVENT_BERSERK, 10*MINUTE*IN_MILLISECONDS); + if (IsHeroic()) + events.ScheduleEvent(EVENT_NERUBIAN_SHADOW_STRIKE, 30*IN_MILLISECONDS, 0, PHASE_MELEE); + + if (!IsHeroic()) + events.ScheduleEvent(EVENT_SUMMON_FROST_SPHERE, 20*IN_MILLISECONDS); + + _intro = true; + _reachedPhase3 = false; + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + // clean up spawned Frost Spheres + std::list<Creature*> FrostSphereList; + me->GetCreatureListWithEntryInGrid(FrostSphereList, NPC_FROST_SPHERE, 150.0f); + if (!FrostSphereList.empty()) + for (std::list<Creature*>::iterator itr = FrostSphereList.begin(); itr != FrostSphereList.end(); itr++) + (*itr)->DespawnOrUnsummon(); + + _burrowGUID.clear(); } - } - void JustReachedHome() - { - if (instance) - instance->SetData(TYPE_ANUBARAK, FAIL); - //Summon Scarab Swarms neutral at random places - for (int i=0; i < 10; i++) - if (Creature* temp = me->SummonCreature(NPC_SCARAB, AnubarakLoc[1].GetPositionX()+urand(0, 50)-25, AnubarakLoc[1].GetPositionY()+urand(0, 50)-25, AnubarakLoc[1].GetPositionZ())) + void KilledUnit(Unit* who) + { + if (who->GetTypeId() == TYPEID_PLAYER) { - temp->setFaction(31); - temp->GetMotionMaster()->MoveRandom(10); + Talk(SAY_KILL_PLAYER); + if (instance) + instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0); } - } - - void JustDied(Unit* /*killer*/) - { - Summons.DespawnAll(); - Talk(SAY_DEATH); - if (instance) - instance->SetData(TYPE_ANUBARAK, DONE); - } - - void JustSummoned(Creature* summoned) - { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true); - switch (summoned->GetEntry()) - { - case NPC_BURROW: - m_vBurrowGUID.push_back(summoned->GetGUID()); - summoned->SetReactState(REACT_PASSIVE); - summoned->CastSpell(summoned, SPELL_CHURNING_GROUND, false); - break; - case NPC_SPIKE: - summoned->CombatStart(target); - Talk(EMOTE_SPIKE, target->GetGUID()); - break; - } - Summons.Summon(summoned); - } + } - void SummonedCreatureDespawn(Creature* summoned) - { - switch (summoned->GetEntry()) + void MoveInLineOfSight(Unit* /*who*/) { - case NPC_SPIKE: - m_uiPursuingSpikeTimer = 2*IN_MILLISECONDS; - break; + if (!_intro) + { + Talk(SAY_INTRO); + _intro = false; + } } - } - - void EnterCombat(Unit* /*who*/) - { - Talk(SAY_AGGRO); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetInCombatWithZone(); - if (instance) - instance->SetData(TYPE_ANUBARAK, IN_PROGRESS); - //Despawn Scarab Swarms neutral - EntryCheckPredicate pred(NPC_SCARAB); - Summons.DoAction(ACTION_SCARAB_SUBMERGE, pred); - //Spawn Burrow - for (int i=0; i < 4; i++) - me->SummonCreature(NPC_BURROW, AnubarakLoc[i+2]); - //Spawn Frost Spheres - for (int i=0; i < 6; i++) - if (Unit* summoned = me->SummonCreature(NPC_FROST_SPHERE, SphereSpawn[i])) - m_aSphereGUID[i] = summoned->GetGUID(); - } - void UpdateAI(const uint32 uiDiff) - { - if (!UpdateVictim()) - return; + void JustReachedHome() + { + if (instance) + instance->SetBossState(BOSS_ANUBARAK, FAIL); + //Summon Scarab Swarms neutral at random places + for (int i = 0; i < 10; i++) + if (Creature* temp = me->SummonCreature(NPC_SCARAB, AnubarakLoc[1].GetPositionX()+urand(0, 50)-25, AnubarakLoc[1].GetPositionY()+urand(0, 50)-25, AnubarakLoc[1].GetPositionZ())) + { + temp->setFaction(31); + temp->GetMotionMaster()->MoveRandom(10); + } + } - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + void JustDied(Unit* /*killer*/) + { + _JustDied(); + Talk(SAY_DEATH); + + // despawn frostspheres and Burrowers on death + std::list<Creature*> AddList; + me->GetCreatureListWithEntryInGrid(AddList, NPC_FROST_SPHERE, 150.0f); + me->GetCreatureListWithEntryInGrid(AddList, NPC_BURROWER, 150.0f); + if (!AddList.empty()) + for (std::list<Creature*>::iterator itr = AddList.begin(); itr != AddList.end(); itr++) + (*itr)->DespawnOrUnsummon(); + } - switch (m_uiStage) + void JustSummoned(Creature* summoned) { - case 0: - if (m_uiFreezeSlashTimer <= uiDiff) - { - DoCastVictim(SPELL_FREEZE_SLASH); - m_uiFreezeSlashTimer = 15*IN_MILLISECONDS; - } else m_uiFreezeSlashTimer -= uiDiff; + Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true); + switch (summoned->GetEntry()) + { + case NPC_BURROW: + _burrowGUID.push_back(summoned->GetGUID()); + summoned->SetReactState(REACT_PASSIVE); + summoned->CastSpell(summoned, SPELL_CHURNING_GROUND, false); + summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid2); + break; + case NPC_SPIKE: + summoned->CombatStart(target); + summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid1); + Talk(EMOTE_SPIKE, target->GetGUID()); + break; + default: + break; + } + summons.Summon(summoned); + } - if (m_uiPenetratingColdTimer <= uiDiff) - { - me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5, 2, 5)); - m_uiPenetratingColdTimer = 20*IN_MILLISECONDS; - } else m_uiPenetratingColdTimer -= uiDiff; + void EnterCombat(Unit* /*who*/) + { + _EnterCombat(); + Talk(SAY_AGGRO); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + + // Despawn Scarab Swarms neutral + EntryCheckPredicate pred(NPC_SCARAB); + summons.DoAction(ACTION_SCARAB_SUBMERGE, pred); + + // Spawn Burrow + for (int i = 0; i < 4; i++) + me->SummonCreature(NPC_BURROW, AnubarakLoc[i + 2]); + + // Spawn 6 Frost Spheres at start + for (int i = 0; i < 6; i++) + if (Unit* summoned = me->SummonCreature(NPC_FROST_SPHERE, SphereSpawn[i])) + _sphereGUID[i] = summoned->GetGUID(); + } - if (m_uiSummonNerubianTimer <= uiDiff && (IsHeroic() || !m_bReachedPhase3)) - { - me->CastCustomSpell(SPELL_SUMMON_BURROWER, SPELLVALUE_MAX_TARGETS, RAID_MODE(1, 2, 2, 4)); - m_uiSummonNerubianTimer = 45*IN_MILLISECONDS; - } else m_uiSummonNerubianTimer -= uiDiff; + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; - if (IsHeroic() && m_uiNerubianShadowStrikeTimer <= uiDiff) - { - EntryCheckPredicate pred(NPC_BURROWER); - Summons.DoAction(ACTION_SHADOW_STRIKE, pred); - m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS; - } else m_uiNerubianShadowStrikeTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiSubmergeTimer <= uiDiff && !m_bReachedPhase3 && !me->HasAura(SPELL_BERSERK)) - { - m_uiStage = 1; - m_uiSubmergeTimer = 60*IN_MILLISECONDS; - } else m_uiSubmergeTimer -= uiDiff; - break; - case 1: - DoCast(me, SPELL_SUBMERGE_ANUBARAK); - DoCast(me, SPELL_CLEAR_ALL_DEBUFFS); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - Talk(EMOTE_BURROWER); - m_uiScarabSummoned = 0; - m_uiSummonScarabTimer = 4*IN_MILLISECONDS; - m_uiStage = 2; - break; - case 2: - if (m_uiPursuingSpikeTimer <= uiDiff) - { - DoCast(SPELL_SPIKE_CALL); - // Just to make sure it won't happen again in this phase - m_uiPursuingSpikeTimer = 90*IN_MILLISECONDS; - } else m_uiPursuingSpikeTimer -= uiDiff; + events.Update(diff); - if (m_uiSummonScarabTimer <= uiDiff) - { - /* WORKAROUND - * - The correct implementation is more likely the comment below but it needs spell knowledge - */ - std::list<uint64>::iterator i = m_vBurrowGUID.begin(); - uint32 at = urand(0, m_vBurrowGUID.size()-1); - for (uint32 k = 0; k < at; k++) - ++i; - if (Creature* pBurrow = Unit::GetCreature(*me, *i)) - pBurrow->CastSpell(pBurrow, 66340, false); - m_uiScarabSummoned++; - m_uiSummonScarabTimer = 4*IN_MILLISECONDS; - if (m_uiScarabSummoned == 4) m_uiSummonScarabTimer = RAID_MODE(4, 20)*IN_MILLISECONDS; - - /*It seems that this spell have something more that needs to be taken into account - //Need more sniff info - DoCast(SPELL_SUMMON_BEATLES); - // Just to make sure it won't happen again in this phase - m_uiSummonScarabTimer = 90*IN_MILLISECONDS;*/ - } else m_uiSummonScarabTimer -= uiDiff; - - if (m_uiSubmergeTimer <= uiDiff) - { - m_uiStage = 3; - m_uiSubmergeTimer = 80*IN_MILLISECONDS; - } else m_uiSubmergeTimer -= uiDiff; - break; - case 3: - m_uiStage = 0; - DoCast(SPELL_SPIKE_TELE); - Summons.DespawnEntry(NPC_SPIKE); - me->RemoveAurasDueToSpell(SPELL_SUBMERGE_ANUBARAK); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - DoCast(me, SPELL_EMERGE_ANUBARAK); - me->GetMotionMaster()->MoveChase(me->getVictim()); - m_uiSummonNerubianTimer = 10*IN_MILLISECONDS; - m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS; - m_uiSummonScarabTimer = 2*IN_MILLISECONDS; - break; - } - - if (!IsHeroic()) - { - if (m_uiSummonFrostSphereTimer <= uiDiff) + while (uint32 eventId = events.ExecuteEvent()) { - uint8 startAt = urand(0, 5); - uint8 i = startAt; - do + switch (eventId) { - if (Unit* pSphere = Unit::GetCreature(*me, m_aSphereGUID[i])) + case EVENT_FREEZE_SLASH: + DoCastVictim(SPELL_FREEZE_SLASH); + events.ScheduleEvent(EVENT_FREEZE_SLASH, 15*IN_MILLISECONDS, 0, PHASE_MELEE); + return; + case EVENT_PENETRATING_COLD: + me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5, 2, 5)); + events.ScheduleEvent(EVENT_PENETRATING_COLD, 20*IN_MILLISECONDS, 0, PHASE_MELEE); + return; + case EVENT_SUMMON_NERUBIAN: + if (IsHeroic() || !_reachedPhase3) + me->CastCustomSpell(SPELL_SUMMON_BURROWER, SPELLVALUE_MAX_TARGETS, RAID_MODE(1, 2, 2, 4)); + events.ScheduleEvent(EVENT_SUMMON_NERUBIAN, 45*IN_MILLISECONDS, 0, PHASE_MELEE); + return; + case EVENT_NERUBIAN_SHADOW_STRIKE: { - if (!pSphere->HasAura(SPELL_FROST_SPHERE)) + EntryCheckPredicate pred(NPC_BURROWER); + summons.DoAction(ACTION_SHADOW_STRIKE, pred); + events.ScheduleEvent(EVENT_NERUBIAN_SHADOW_STRIKE, 30*IN_MILLISECONDS, 0, PHASE_MELEE); + break; + } + case EVENT_SUBMERGE: + if (!_reachedPhase3 && !me->HasAura(SPELL_BERSERK)) { - if (Creature* summon = me->SummonCreature(NPC_FROST_SPHERE, SphereSpawn[i])) - m_aSphereGUID[i] = summon->GetGUID(); - break; + DoCast(me, SPELL_SUBMERGE_ANUBARAK); + DoCast(me, SPELL_CLEAR_ALL_DEBUFFS); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + Talk(EMOTE_BURROWER); + events.SetPhase(PHASE_SUBMERGED); + events.ScheduleEvent(EVENT_PURSUING_SPIKE, 2*IN_MILLISECONDS, 0, PHASE_SUBMERGED); + events.ScheduleEvent(EVENT_SUMMON_SCARAB, 4*IN_MILLISECONDS, 0, PHASE_SUBMERGED); + events.ScheduleEvent(EVENT_EMERGE, 1*MINUTE*IN_MILLISECONDS, 0, PHASE_SUBMERGED); } + break; + case EVENT_PURSUING_SPIKE: + DoCast(SPELL_SPIKE_CALL); + break; + case EVENT_SUMMON_SCARAB: + { + /* WORKAROUND + * - The correct implementation is more likely the comment below but it needs spell knowledge + */ + std::list<uint64>::iterator i = _burrowGUID.begin(); + uint32 at = urand(0, _burrowGUID.size()-1); + for (uint32 k = 0; k < at; k++) + ++i; + if (Creature* pBurrow = Unit::GetCreature(*me, *i)) + pBurrow->CastSpell(pBurrow, 66340, false); + + events.ScheduleEvent(EVENT_SUMMON_SCARAB, 4*IN_MILLISECONDS, 0, PHASE_SUBMERGED); + + /*It seems that this spell have something more that needs to be taken into account + //Need more sniff info + DoCast(SPELL_SUMMON_BEATLES); + // Just to make sure it won't happen again in this phase + m_uiSummonScarabTimer = 90*IN_MILLISECONDS;*/ + break; } - i = (i+1)%6; - } while (i != startAt); - m_uiSummonFrostSphereTimer = urand(20, 30)*IN_MILLISECONDS; - } else m_uiSummonFrostSphereTimer -= uiDiff; - } + case EVENT_EMERGE: + events.ScheduleEvent(EVENT_SUBMERGE, 80*IN_MILLISECONDS, 0, PHASE_MELEE); + DoCast(SPELL_SPIKE_TELE); + summons.DespawnEntry(NPC_SPIKE); + me->RemoveAurasDueToSpell(SPELL_SUBMERGE_ANUBARAK); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_EMERGE_ANUBARAK); + events.SetPhase(PHASE_MELEE); + events.ScheduleEvent(EVENT_FREEZE_SLASH, 15*IN_MILLISECONDS, 0, PHASE_MELEE); + events.ScheduleEvent(EVENT_PENETRATING_COLD, 20*IN_MILLISECONDS, PHASE_MELEE); + events.ScheduleEvent(EVENT_SUMMON_NERUBIAN, 10*IN_MILLISECONDS, 0, PHASE_MELEE); + events.ScheduleEvent(EVENT_SUBMERGE, 80*IN_MILLISECONDS, 0, PHASE_MELEE); + if (IsHeroic()) + events.ScheduleEvent(EVENT_NERUBIAN_SHADOW_STRIKE, 30*IN_MILLISECONDS, 0, PHASE_MELEE); + return; + case EVENT_SUMMON_FROST_SPHERE: + { + uint8 startAt = urand(0, 5); + uint8 i = startAt; + do + { + if (Unit* pSphere = Unit::GetCreature(*me, _sphereGUID[i])) + { + if (!pSphere->HasAura(SPELL_FROST_SPHERE)) + { + if (Creature* summon = me->SummonCreature(NPC_FROST_SPHERE, SphereSpawn[i])) + _sphereGUID[i] = summon->GetGUID(); + break; + } + } + i = (i + 1) % 6; + } + while + (i != startAt); + events.ScheduleEvent(EVENT_SUMMON_FROST_SPHERE, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + break; + } + case EVENT_BERSERK: + DoCast(me, SPELL_BERSERK); + break; + default: + break; + } - if (HealthBelowPct(30) && m_uiStage == 0 && !m_bReachedPhase3) - { - m_bReachedPhase3 = true; - DoCastAOE(SPELL_LEECHING_SWARM); - Talk(EMOTE_LEECHING_SWARM); - Talk(SAY_LEECHING_SWARM); - } + } - if (m_uiBerserkTimer <= uiDiff && !me->HasAura(SPELL_BERSERK)) - { - DoCast(me, SPELL_BERSERK); - } else m_uiBerserkTimer -= uiDiff; + if (HealthBelowPct(30) && events.GetPhaseMask() & PHASE_MASK_MELEE && !_reachedPhase3) + { + _reachedPhase3 = true; + DoCastAOE(SPELL_LEECHING_SWARM); + Talk(EMOTE_LEECHING_SWARM); + Talk(SAY_LEECHING_SWARM); + } - DoMeleeAttackIfReady(); - } - }; + if (events.GetPhaseMask() & PHASE_MASK_MELEE) + DoMeleeAttackIfReady(); + } + private: + std::list<uint64> _burrowGUID; + uint64 _sphereGUID[6]; + bool _intro; + bool _reachedPhase3; + uint32 _frostSphereTimer; + uint32 _berserkTimer; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new boss_anubarak_trialAI(creature); + }; }; class mob_swarm_scarab : public CreatureScript { -public: - mob_swarm_scarab() : CreatureScript("mob_swarm_scarab") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_swarm_scarabAI(creature); - }; - - struct mob_swarm_scarabAI : public ScriptedAI - { - mob_swarm_scarabAI(Creature* creature) : ScriptedAI(creature) - { - instance = creature->GetInstanceScript(); - } - - InstanceScript* instance; - - uint32 m_uiDeterminationTimer; + public: + mob_swarm_scarab() : CreatureScript("mob_swarm_scarab") { } - void Reset() + struct mob_swarm_scarabAI : public ScriptedAI { - me->SetCorpseDelay(0); - m_uiDeterminationTimer = urand(5*IN_MILLISECONDS, 60*IN_MILLISECONDS); - DoCast(me, SPELL_ACID_MANDIBLE); - me->SetInCombatWithZone(); - if (me->isInCombat()) - if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANUBARAK))) - Anubarak->AI()->JustSummoned(me); - } + mob_swarm_scarabAI(Creature* creature) : ScriptedAI(creature) + { + _instance = creature->GetInstanceScript(); + } - void DoAction(const int32 actionId) - { - switch (actionId) + void Reset() { - case ACTION_SCARAB_SUBMERGE: - DoCast(SPELL_SUBMERGE_EFFECT); - me->DespawnOrUnsummon(1000); - break; + me->SetCorpseDelay(0); + _determinationTimer = urand(5*IN_MILLISECONDS, 60*IN_MILLISECONDS); + DoCast(me, SPELL_ACID_MANDIBLE); + me->SetInCombatWithZone(); + if (me->isInCombat()) + if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_ANUBARAK))) + Anubarak->AI()->JustSummoned(me); } - } - void JustDied(Unit* killer) - { - DoCast(killer, RAID_MODE(SPELL_TRAITOR_KING_10, SPELL_TRAITOR_KING_25)); - } + void DoAction(const int32 actionId) + { + switch (actionId) + { + case ACTION_SCARAB_SUBMERGE: + DoCast(SPELL_SUBMERGE_EFFECT); + me->DespawnOrUnsummon(1*IN_MILLISECONDS); + break; + default: + break; + } + } - void UpdateAI(const uint32 uiDiff) - { - if (!UpdateVictim()) - return; + void JustDied(Unit* killer) + { + DoCast(killer, RAID_MODE(SPELL_TRAITOR_KING_10, SPELL_TRAITOR_KING_25)); + } - /* Bosskillers don't recognize */ - if (m_uiDeterminationTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - DoCast(me, SPELL_DETERMINATION); - m_uiDeterminationTimer = urand(10*IN_MILLISECONDS, 60*IN_MILLISECONDS); - } else m_uiDeterminationTimer -= uiDiff; + if (_instance && _instance->GetBossState(BOSS_ANUBARAK) != IN_PROGRESS) + me->DisappearAndDie(); - DoMeleeAttackIfReady(); - } - }; + if (!UpdateVictim()) + return; -}; + /* Bosskillers don't recognize */ + if (_determinationTimer <= diff) + { + DoCast(me, SPELL_DETERMINATION); + _determinationTimer = urand(10*IN_MILLISECONDS, 60*IN_MILLISECONDS); + } + else + _determinationTimer -= diff; -class mob_nerubian_burrower : public CreatureScript -{ -public: - mob_nerubian_burrower() : CreatureScript("mob_nerubian_burrower") { } + DoMeleeAttackIfReady(); + } - CreatureAI* GetAI(Creature* creature) const - { - return new mob_nerubian_burrowerAI(creature); - }; + private: + InstanceScript* _instance; + uint32 _determinationTimer; + }; - struct mob_nerubian_burrowerAI : public ScriptedAI - { - mob_nerubian_burrowerAI(Creature* creature) : ScriptedAI(creature) + CreatureAI* GetAI(Creature* creature) const { - instance = creature->GetInstanceScript(); - } - - InstanceScript* instance; - - uint32 m_uiSpiderFrenzyTimer; - uint32 m_uiSubmergeTimer; + return new mob_swarm_scarabAI(creature); + }; +}; - void Reset() - { - me->SetCorpseDelay(10); - m_uiSpiderFrenzyTimer = urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS); - m_uiSubmergeTimer = 30*IN_MILLISECONDS; - DoCast(me, SPELL_EXPOSE_WEAKNESS); - DoCast(me, SPELL_SPIDER_FRENZY); - DoCast(me, SPELL_AWAKENED); - me->SetInCombatWithZone(); - if (me->isInCombat()) - if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_ANUBARAK))) - Anubarak->AI()->JustSummoned(me); - } +class mob_nerubian_burrower : public CreatureScript +{ + public: + mob_nerubian_burrower() : CreatureScript("mob_nerubian_burrower") { } - void DoAction(const int32 actionId) + struct mob_nerubian_burrowerAI : public ScriptedAI { - switch (actionId) + mob_nerubian_burrowerAI(Creature* creature) : ScriptedAI(creature) { - case ACTION_SHADOW_STRIKE: - if (!me->HasAura(SPELL_AWAKENED)) - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_SHADOW_STRIKE); - break; + _instance = creature->GetInstanceScript(); } - } - - void UpdateAI(const uint32 uiDiff) - { - if (!UpdateVictim()) - return; - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + void Reset() + { + me->SetCorpseDelay(10); + _submergeTimer = 30*IN_MILLISECONDS; + DoCast(me, SPELL_EXPOSE_WEAKNESS); + DoCast(me, SPELL_SPIDER_FRENZY); + DoCast(me, SPELL_AWAKENED); + me->SetInCombatWithZone(); + if (me->isInCombat()) + if (Creature* Anubarak = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_ANUBARAK))) + Anubarak->AI()->JustSummoned(me); + } - if ((m_uiSubmergeTimer <= uiDiff) && HealthBelowPct(80)) + void DoAction(const int32 actionId) { - if (me->HasAura(SPELL_SUBMERGE_EFFECT)) + switch (actionId) { - me->RemoveAurasDueToSpell(SPELL_SUBMERGE_EFFECT); - DoCast(me, SPELL_EMERGE_EFFECT); - DoCast(me, SPELL_AWAKENED); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + case ACTION_SHADOW_STRIKE: + if (!me->HasAura(SPELL_AWAKENED)) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_SHADOW_STRIKE); + break; + default: + break; } - else + } + + void UpdateAI(const uint32 diff) + { + if (_instance && _instance->GetBossState(BOSS_ANUBARAK) != IN_PROGRESS) + me->DisappearAndDie(); + + if (!UpdateVictim() && !me->HasAura(SPELL_SUBMERGE_EFFECT)) + return; + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + if ((_submergeTimer <= diff) && HealthBelowPct(80)) { - if (!me->HasAura(SPELL_PERMAFROST_HELPER)) + if (me->HasAura(SPELL_SUBMERGE_EFFECT)) { - DoCast(me, SPELL_SUBMERGE_EFFECT); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoCast(me, SPELL_PERSISTENT_DIRT, true); + me->RemoveAurasDueToSpell(SPELL_SUBMERGE_EFFECT); + DoCast(me, SPELL_EMERGE_EFFECT); + DoCast(me, SPELL_AWAKENED); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + else + { + if (!me->HasAura(SPELL_PERMAFROST_HELPER)) + { + DoCast(me, SPELL_SUBMERGE_EFFECT); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoCast(me, SPELL_PERSISTENT_DIRT, true); + } } + _submergeTimer = 20*IN_MILLISECONDS; } - m_uiSubmergeTimer = 20*IN_MILLISECONDS; - } else m_uiSubmergeTimer -= uiDiff; + else + _submergeTimer -= diff; - DoMeleeAttackIfReady(); - } - }; + DoMeleeAttackIfReady(); + } + + private: + uint32 _submergeTimer; + Phases _phase; + EventMap _events; + InstanceScript* _instance; + }; + CreatureAI* GetAI(Creature* creature) const + { + return new mob_nerubian_burrowerAI(creature); + }; }; class mob_frost_sphere : public CreatureScript @@ -636,6 +651,8 @@ class mob_frost_sphere : public CreatureScript DoCast(SPELL_PERMAFROST); me->SetObjectScale(2.0f); break; + default: + break; } } }; @@ -648,92 +665,180 @@ class mob_frost_sphere : public CreatureScript class mob_anubarak_spike : public CreatureScript { -public: - mob_anubarak_spike() : CreatureScript("mob_anubarak_spike") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_anubarak_spikeAI(creature); - }; + public: + mob_anubarak_spike() : CreatureScript("mob_anubarak_spike") { } - struct mob_anubarak_spikeAI : public ScriptedAI - { - mob_anubarak_spikeAI(Creature* creature) : ScriptedAI(creature) + struct mob_anubarak_spikeAI : public ScriptedAI { - instance = creature->GetInstanceScript(); - } - - InstanceScript* instance; - uint32 m_uiIncreaseSpeedTimer; - uint8 m_uiSpeed; - uint64 m_uiTargetGUID; + mob_anubarak_spikeAI(Creature* creature) : ScriptedAI(creature) + { + } - void Reset() - { - // For an unknown reason this npc isn't recognize the Aura of Permafrost with this flags =/ - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); - m_uiTargetGUID = 0; - } + void Reset() + { + _phase = PHASE_NO_MOVEMENT; + _phaseSwitchTimer = 1; + // make sure the spike has everyone on threat list + me->SetInCombatWithZone(); + } - bool CanAIAttack(Unit const* victim) const - { - return victim->GetTypeId() == TYPEID_PLAYER; - } + bool CanAIAttack(Unit const* victim) const + { + return victim->GetTypeId() == TYPEID_PLAYER; + } - void EnterCombat(Unit* who) - { - m_uiTargetGUID = who->GetGUID(); - DoCast(who, SPELL_MARK); - Talk(EMOTE_SPIKE, who->GetGUID()); - me->SetSpeed(MOVE_RUN, 0.5f); - m_uiSpeed = 0; - m_uiIncreaseSpeedTimer = 1*IN_MILLISECONDS; - me->TauntApply(who); - } + void EnterCombat(Unit* who) + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + { + StartChase(target); + Talk(EMOTE_SPIKE, who->GetGUID()); + } + } - void DamageTaken(Unit* /*who*/, uint32& uiDamage) - { - uiDamage = 0; - } + void DamageTaken(Unit* /*who*/, uint32& uiDamage) + { + uiDamage = 0; + } - void UpdateAI(const uint32 uiDiff) - { - Unit* target = Unit::GetPlayer(*me, m_uiTargetGUID); - if (!target || !target->isAlive() || !target->HasAura(SPELL_MARK)) + void UpdateAI(const uint32 diff) { - if (Creature* pAnubarak = Unit::GetCreature((*me), instance->GetData64(NPC_ANUBARAK))) - pAnubarak->CastSpell(pAnubarak, SPELL_SPIKE_TELE, false); - me->DisappearAndDie(); - return; + if (!UpdateVictim()) + { + me->DisappearAndDie(); + return; + } + + if (_phaseSwitchTimer) + { + if (_phaseSwitchTimer <= diff) + { + switch (_phase) + { + case PHASE_NO_MOVEMENT: + DoCast(me, SPELL_SPIKE_SPEED1); + DoCast(me, SPELL_SPIKE_TRAIL); + _phase = PHASE_IMPALE_NORMAL; + if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + { + StartChase(target2); + Talk(EMOTE_SPIKE, target2->GetGUID()); + } + _phaseSwitchTimer = 7*IN_MILLISECONDS; + return; + case PHASE_IMPALE_NORMAL: + DoCast(me, SPELL_SPIKE_SPEED2); + _phase = PHASE_IMPALE_MIDDLE; + _phaseSwitchTimer = 7*IN_MILLISECONDS; + return; + case PHASE_IMPALE_MIDDLE: + DoCast(me, SPELL_SPIKE_SPEED3); + _phase = PHASE_IMPALE_FAST; + _phaseSwitchTimer = 0; + return; + default: + return; + } + } + else + _phaseSwitchTimer -= diff; + } } - if (m_uiIncreaseSpeedTimer) + void MoveInLineOfSight(Unit* pWho) { - if (m_uiIncreaseSpeedTimer <= uiDiff) + if (!pWho) + return; + + if (pWho->GetEntry() != NPC_FROST_SPHERE) + return; + + if (_phase == PHASE_NO_MOVEMENT) + return; + + if (me->IsWithinDist(pWho, 7.0f)) { - switch (m_uiSpeed) + switch (_phase) { - case 0: - DoCast(me, SPELL_SPIKE_SPEED1); - DoCast(me, SPELL_SPIKE_TRAIL); - m_uiSpeed = 1; - m_uiIncreaseSpeedTimer = 7*IN_MILLISECONDS; + case PHASE_IMPALE_NORMAL: + me->RemoveAurasDueToSpell(SPELL_SPIKE_SPEED1); + break; + case PHASE_IMPALE_MIDDLE: + me->RemoveAurasDueToSpell(SPELL_SPIKE_SPEED2); break; - case 1: - DoCast(me, SPELL_SPIKE_SPEED2); - m_uiSpeed = 2; - m_uiIncreaseSpeedTimer = 7*IN_MILLISECONDS; + case PHASE_IMPALE_FAST: + me->RemoveAurasDueToSpell(SPELL_SPIKE_SPEED3); break; - case 2: - DoCast(me, SPELL_SPIKE_SPEED3); - m_uiIncreaseSpeedTimer = 0; + default: break; } - } else m_uiIncreaseSpeedTimer -= uiDiff; + + me->CastSpell(me, SPELL_SPIKE_FAIL, true); + + pWho->ToCreature()->DespawnOrUnsummon(3*IN_MILLISECONDS); + + // After the spikes hit the icy surface they can't move for about ~5 seconds + _phase = PHASE_NO_MOVEMENT; + _phaseSwitchTimer = 5*IN_MILLISECONDS; + SetCombatMovement(false); + me->GetMotionMaster()->MoveIdle(); + me->GetMotionMaster()->Clear(); + } + } + + void StartChase(Unit* who) + { + DoCast(who, SPELL_MARK); + me->SetSpeed(MOVE_RUN, 0.5f); + // make sure the Spine will really follow the one he should + me->getThreatManager().clearReferences(); + me->SetInCombatWithZone(); + me->getThreatManager().addThreat(who, std::numeric_limits<float>::max()); + me->GetMotionMaster()->Clear(true); + me->GetMotionMaster()->MoveChase(who); + me->TauntApply(who); + } + + private: + uint32 _phaseSwitchTimer; + PursuingSpikesPhases _phase; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new mob_anubarak_spikeAI(creature); + }; +}; + +class spell_impale : public SpellScriptLoader +{ + public: + spell_impale() : SpellScriptLoader("spell_impale") { } + + class spell_impale_SpellScript : public SpellScript + { + PrepareSpellScript(spell_impale_SpellScript); + + void HandleDamageCalc(SpellEffIndex /*effIndex*/) + { + Unit* target = GetHitUnit(); + uint32 permafrost = sSpellMgr->GetSpellIdForDifficulty(SPELL_PERMAFROST, target); + + // make sure Impale doesnt do damage if we are standing on permafrost + if (target && target->HasAura(permafrost)) + SetHitDamage(0); } - } - }; + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_impale_SpellScript::HandleDamageCalc, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_impale_SpellScript(); + } }; void AddSC_boss_anubarak_trial() @@ -743,4 +848,6 @@ void AddSC_boss_anubarak_trial() new mob_nerubian_burrower(); new mob_anubarak_spike(); new mob_frost_sphere(); + + new spell_impale(); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index c662daf3671..a99aa373602 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -16,26 +16,17 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: faction_champions -SD%Complete: ??% -SDComment: Scripts by Selector, modified by /dev/rsa -SDCategory: Crusader Coliseum -EndScriptData */ - -// Known bugs: -// All - untested -// Pets aren't being summoned by their masters - #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" #include "trial_of_the_crusader.h" +#include "Player.h" +#include "GridNotifiers.h" enum Yells { - SAY_KILL_PLAYER = 6, + SAY_KILL_PLAYER = 6 }; enum eAIs @@ -43,234 +34,527 @@ enum eAIs AI_MELEE = 0, AI_RANGED = 1, AI_HEALER = 2, - AI_PET = 3, + AI_PET = 3 }; enum eSpells { - SPELL_ANTI_AOE = 68595, - SPELL_PVP_TRINKET = 65547, + // generic + SPELL_ANTI_AOE = 68595, + SPELL_PVP_TRINKET = 65547, + + // druid healer + SPELL_LIFEBLOOM = 66093, + SPELL_NOURISH = 66066, + SPELL_REGROWTH = 66067, + SPELL_REJUVENATION = 66065, + SPELL_TRANQUILITY = 66086, + SPELL_BARKSKIN = 65860, + SPELL_THORNS = 66068, + SPELL_NATURE_GRASP = 66071, + + // shaman healer + SPELL_HEALING_WAVE = 66055, + SPELL_RIPTIDE = 66053, + SPELL_SPIRIT_CLEANSE = 66056, //friendly only + SPELL_HEROISM = 65983, + SPELL_BLOODLUST = 65980, + SPELL_HEX = 66054, + SPELL_EARTH_SHIELD = 66063, + SPELL_EARTH_SHOCK = 65973, + AURA_EXHAUSTION = 57723, + AURA_SATED = 57724, + + // paladin healer + SPELL_HAND_OF_FREEDOM = 68757, + SPELL_DIVINE_SHIELD = 66010, + SPELL_CLEANSE = 66116, + SPELL_FLASH_OF_LIGHT = 66113, + SPELL_HOLY_LIGHT = 66112, + SPELL_HOLY_SHOCK = 66114, + SPELL_HAND_OF_PROTECTION = 66009, + SPELL_HAMMER_OF_JUSTICE = 66613, + SPELL_FORBEARANCE = 25771, + + // priest healer + SPELL_RENEW = 66177, + SPELL_SHIELD = 66099, + SPELL_FLASH_HEAL = 66104, + SPELL_DISPEL = 65546, + SPELL_PSYCHIC_SCREAM = 65543, + SPELL_MANA_BURN = 66100, + SPELL_PENANCE = 66097, + + // priest dps + SPELL_SILENCE = 65542, + SPELL_VAMPIRIC_TOUCH = 65490, + SPELL_SW_PAIN = 65541, + SPELL_MIND_FLAY = 65488, + SPELL_MIND_BLAST = 65492, + SPELL_HORROR = 65545, + SPELL_DISPERSION = 65544, + SPELL_SHADOWFORM = 16592, + + // warlock + SPELL_HELLFIRE = 65816, + SPELL_CORRUPTION = 65810, + SPELL_CURSE_OF_AGONY = 65814, + SPELL_CURSE_OF_EXHAUSTION = 65815, + SPELL_FEAR = 65809, + SPELL_SEARING_PAIN = 65819, + SPELL_SHADOW_BOLT = 65821, + SPELL_UNSTABLE_AFFLICTION = 65812, + SPELL_UNSTABLE_AFFLICTION_DISPEL = 65813, + SPELL_SUMMON_FELHUNTER = 67514, + + // mage + SPELL_ARCANE_BARRAGE = 65799, + SPELL_ARCANE_BLAST = 65791, + SPELL_ARCANE_EXPLOSION = 65800, + SPELL_BLINK = 65793, + SPELL_COUNTERSPELL = 65790, + SPELL_FROST_NOVA = 65792, + SPELL_FROSTBOLT = 65807, + SPELL_ICE_BLOCK = 65802, + SPELL_POLYMORPH = 65801, + + // hunter + SPELL_AIMED_SHOT = 65883, + SPELL_DETERRENCE = 65871, + SPELL_DISENGAGE = 65869, + SPELL_EXPLOSIVE_SHOT = 65866, + SPELL_FROST_TRAP = 65880, + SPELL_SHOOT = 65868, + SPELL_STEADY_SHOT = 65867, + SPELL_WING_CLIP = 66207, + SPELL_WYVERN_STING = 65877, + SPELL_CALL_PET = 67777, + + // druid dps + SPELL_CYCLONE = 65859, + SPELL_ENTANGLING_ROOTS = 65857, + SPELL_FAERIE_FIRE = 65863, + SPELL_FORCE_OF_NATURE = 65861, + SPELL_INSECT_SWARM = 65855, + SPELL_MOONFIRE = 65856, + SPELL_STARFIRE = 65854, + SPELL_WRATH = 65862, + + // warrior + SPELL_BLADESTORM = 65947, + SPELL_INTIMIDATING_SHOUT = 65930, + SPELL_MORTAL_STRIKE = 65926, + SPELL_CHARGE = 68764, + SPELL_DISARM = 65935, + SPELL_OVERPOWER = 65924, + SPELL_SUNDER_ARMOR = 65936, + SPELL_SHATTERING_THROW = 65940, + SPELL_RETALIATION = 65932, + + // death knight + SPELL_CHAINS_OF_ICE = 66020, + SPELL_DEATH_COIL = 66019, + SPELL_DEATH_GRIP = 66017, + SPELL_FROST_STRIKE = 66047, + SPELL_ICEBOUND_FORTITUDE = 66023, + SPELL_ICY_TOUCH = 66021, + SPELL_STRANGULATE = 66018, + SPELL_DEATH_GRIP_PULL = 64431, // used at spellscript + + // rogue + SPELL_FAN_OF_KNIVES = 65955, + SPELL_BLIND = 65960, + SPELL_CLOAK = 65961, + SPELL_BLADE_FLURRY = 65956, + SPELL_SHADOWSTEP = 66178, + SPELL_HEMORRHAGE = 65954, + SPELL_EVISCERATE = 65957, + SPELL_WOUND_POISON = 65962, + + // shaman dps (some spells taken from shaman healer) + SPELL_LAVA_LASH = 65974, + SPELL_STORMSTRIKE = 65970, + SPELL_WINDFURY = 65976, + + // paladin dps + SPELL_AVENGING_WRATH = 66011, + SPELL_CRUSADER_STRIKE = 66003, + SPELL_DIVINE_STORM = 66006, + SPELL_HAMMER_OF_JUSTICE_RET = 66007, + SPELL_JUDGEMENT_OF_COMMAND = 66005, + SPELL_REPENTANCE = 66008, + SPELL_SEAL_OF_COMMAND = 66004, + + // warlock pet + SPELL_DEVOUR_MAGIC = 67518, + SPELL_SPELL_LOCK = 67519, + + // hunter pet + SPELL_CLAW = 67793 }; -class boss_toc_champion_controller : public CreatureScript +enum Events { -public: - boss_toc_champion_controller() : CreatureScript("boss_toc_champion_controller") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new boss_toc_champion_controllerAI (creature); - } - - struct boss_toc_champion_controllerAI : public ScriptedAI - { - boss_toc_champion_controllerAI(Creature* creature) : ScriptedAI(creature), Summons(me) - { - instance = creature->GetInstanceScript(); - } + // generic + EVENT_THREAT = 1, + EVENT_REMOVE_CC = 2, + + // druid healer + EVENT_LIFEBLOOM = 1, + EVENT_NOURISH = 2, + EVENT_REGROWTH = 3, + EVENT_REJUVENATION = 4, + EVENT_TRANQUILITY = 5, + EVENT_HEAL_BARKSKIN = 6, + EVENT_THORNS = 7, + EVENT_NATURE_GRASP = 8, + + // shaman healer + EVENT_HEALING_WAVE = 1, + EVENT_RIPTIDE = 2, + EVENT_SPIRIT_CLEANSE = 3, + EVENT_HEAL_BLOODLUST_HEROISM = 4, + EVENT_HEX = 5, + EVENT_EARTH_SHIELD = 6, + EVENT_HEAL_EARTH_SHOCK = 7, + + // paladin healer + EVENT_HAND_OF_FREEDOM = 1, + EVENT_HEAL_DIVINE_SHIELD = 2, + EVENT_CLEANSE = 3, + EVENT_FLASH_OF_LIGHT = 4, + EVENT_HOLY_LIGHT = 5, + EVENT_HOLY_SHOCK = 6, + EVENT_HEAL_HAND_OF_PROTECTION = 7, + EVENT_HAMMER_OF_JUSTICE = 8, + + // priest healer + EVENT_RENEW = 1, + EVENT_SHIELD = 2, + EVENT_FLASH_HEAL = 3, + EVENT_HEAL_DISPEL = 4, + EVENT_HEAL_PSYCHIC_SCREAM = 5, + EVENT_MANA_BURN = 6, + EVENT_PENANCE = 7, + + // priest dps + EVENT_SILENCE = 1, + EVENT_VAMPIRIC_TOUCH = 2, + EVENT_SW_PAIN = 3, + EVENT_MIND_BLAST = 4, + EVENT_HORROR = 5, + EVENT_DISPERSION = 6, + EVENT_DPS_DISPEL = 7, + EVENT_DPS_PSYCHIC_SCREAM = 8, + + // warlock + EVENT_HELLFIRE = 1, + EVENT_CORRUPTION = 2, + EVENT_CURSE_OF_AGONY = 3, + EVENT_CURSE_OF_EXHAUSTION = 4, + EVENT_FEAR = 5, + EVENT_SEARING_PAIN = 6, + EVENT_UNSTABLE_AFFLICTION = 7, + + // mage + EVENT_ARCANE_BARRAGE = 1, + EVENT_ARCANE_BLAST = 2, + EVENT_ARCANE_EXPLOSION = 3, + EVENT_BLINK = 4, + EVENT_COUNTERSPELL = 5, + EVENT_FROST_NOVA = 6, + EVENT_ICE_BLOCK = 7, + EVENT_POLYMORPH = 8, + + // hunter + EVENT_AIMED_SHOT = 1, + EVENT_DETERRENCE = 2, + EVENT_DISENGAGE = 3, + EVENT_EXPLOSIVE_SHOT = 4, + EVENT_FROST_TRAP = 5, + EVENT_STEADY_SHOT = 6, + EVENT_WING_CLIP = 7, + EVENT_WYVERN_STING = 8, + + // druid dps + EVENT_CYCLONE = 1, + EVENT_ENTANGLING_ROOTS = 2, + EVENT_FAERIE_FIRE = 3, + EVENT_FORCE_OF_NATURE = 4, + EVENT_INSECT_SWARM = 5, + EVENT_MOONFIRE = 6, + EVENT_STARFIRE = 7, + EVENT_DPS_BARKSKIN = 8, + + // warrior + EVENT_BLADESTORM = 1, + EVENT_INTIMIDATING_SHOUT = 2, + EVENT_MORTAL_STRIKE = 3, + EVENT_WARR_CHARGE = 4, + EVENT_DISARM = 5, + EVENT_OVERPOWER = 6, + EVENT_SUNDER_ARMOR = 7, + EVENT_SHATTERING_THROW = 8, + EVENT_RETALIATION = 9, + + // death knight + EVENT_CHAINS_OF_ICE = 1, + EVENT_DEATH_COIL = 2, + EVENT_DEATH_GRIP = 3, + EVENT_FROST_STRIKE = 4, + EVENT_ICEBOUND_FORTITUDE = 5, + EVENT_ICY_TOUCH = 6, + EVENT_STRANGULATE = 7, + + // rogue + EVENT_FAN_OF_KNIVES = 1, + EVENT_BLIND = 2, + EVENT_CLOAK = 3, + EVENT_BLADE_FLURRY = 4, + EVENT_SHADOWSTEP = 5, + EVENT_HEMORRHAGE = 6, + EVENT_EVISCERATE = 7, + EVENT_WOUND_POISON = 8, + + // shaman dps + EVENT_DPS_EARTH_SHOCK = 1, + EVENT_LAVA_LASH = 2, + EVENT_STORMSTRIKE = 3, + EVENT_DPS_BLOODLUST_HEROISM = 4, + EVENT_DEPLOY_TOTEM = 5, + EVENT_WINDFURY = 6, + + // paladin dps + EVENT_AVENGING_WRATH = 1, + EVENT_CRUSADER_STRIKE = 2, + EVENT_DIVINE_STORM = 3, + EVENT_HAMMER_OF_JUSTICE_RET = 4, + EVENT_JUDGEMENT_OF_COMMAND = 5, + EVENT_REPENTANCE = 6, + EVENT_DPS_HAND_OF_PROTECTION = 7, + EVENT_DPS_DIVINE_SHIELD = 8, + + // warlock pet + EVENT_DEVOUR_MAGIC = 1, + EVENT_SPELL_LOCK = 2 +}; - InstanceScript* instance; - SummonList Summons; - uint32 m_uiChampionsNotStarted; - uint32 m_uiChampionsFailed; - uint32 m_uiChampionsKilled; - bool m_bInProgress; +class boss_toc_champion_controller : public CreatureScript +{ + public: + boss_toc_champion_controller() : CreatureScript("boss_toc_champion_controller") { } - void Reset() + struct boss_toc_champion_controllerAI : public ScriptedAI { - m_uiChampionsNotStarted = 0; - m_uiChampionsFailed = 0; - m_uiChampionsKilled = 0; - m_bInProgress = false; - } + boss_toc_champion_controllerAI(Creature* creature) : ScriptedAI(creature), _summons(me) + { + _instance = creature->GetInstanceScript(); + } - std::vector<uint32> SelectChampions(Team playerTeam) - { - std::vector<uint32> vHealersEntries; - vHealersEntries.clear(); - vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_DRUID_RESTORATION : NPC_ALLIANCE_DRUID_RESTORATION); - vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_PALADIN_HOLY : NPC_ALLIANCE_PALADIN_HOLY); - vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_PRIEST_DISCIPLINE : NPC_ALLIANCE_PRIEST_DISCIPLINE); - vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_SHAMAN_RESTORATION : NPC_ALLIANCE_SHAMAN_RESTORATION); - - std::vector<uint32> vOtherEntries; - vOtherEntries.clear(); - vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_DEATH_KNIGHT : NPC_ALLIANCE_DEATH_KNIGHT); - vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_HUNTER : NPC_ALLIANCE_HUNTER); - vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_MAGE : NPC_ALLIANCE_MAGE); - vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_ROGUE : NPC_ALLIANCE_ROGUE); - vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_WARLOCK : NPC_ALLIANCE_WARLOCK); - vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_WARRIOR : NPC_ALLIANCE_WARRIOR); - - uint8 healersSubtracted = 2; - if (instance->instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_NORMAL || instance->instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_HEROIC) - healersSubtracted = 1; - for (uint8 i = 0; i < healersSubtracted; ++i) + void Reset() { - uint8 pos = urand(0, vHealersEntries.size()-1); - switch (vHealersEntries[pos]) + _championsNotStarted = 0; + _championsFailed = 0; + _championsKilled = 0; + _inProgress = false; + } + + std::vector<uint32> SelectChampions(Team playerTeam) + { + std::vector<uint32> vHealersEntries; + vHealersEntries.clear(); + vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_DRUID_RESTORATION : NPC_ALLIANCE_DRUID_RESTORATION); + vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_PALADIN_HOLY : NPC_ALLIANCE_PALADIN_HOLY); + vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_PRIEST_DISCIPLINE : NPC_ALLIANCE_PRIEST_DISCIPLINE); + vHealersEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_SHAMAN_RESTORATION : NPC_ALLIANCE_SHAMAN_RESTORATION); + + std::vector<uint32> vOtherEntries; + vOtherEntries.clear(); + vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_DEATH_KNIGHT : NPC_ALLIANCE_DEATH_KNIGHT); + vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_HUNTER : NPC_ALLIANCE_HUNTER); + vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_MAGE : NPC_ALLIANCE_MAGE); + vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_ROGUE : NPC_ALLIANCE_ROGUE); + vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_WARLOCK : NPC_ALLIANCE_WARLOCK); + vOtherEntries.push_back(playerTeam == ALLIANCE ? NPC_HORDE_WARRIOR : NPC_ALLIANCE_WARRIOR); + + uint8 healersSubtracted = 2; + if (_instance->instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_NORMAL || _instance->instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_HEROIC) + healersSubtracted = 1; + for (uint8 i = 0; i < healersSubtracted; ++i) { - case NPC_ALLIANCE_DRUID_RESTORATION: - vOtherEntries.push_back(NPC_ALLIANCE_DRUID_BALANCE); - break; - case NPC_HORDE_DRUID_RESTORATION: - vOtherEntries.push_back(NPC_HORDE_DRUID_BALANCE); - break; - case NPC_ALLIANCE_PALADIN_HOLY: - vOtherEntries.push_back(NPC_ALLIANCE_PALADIN_RETRIBUTION); - break; - case NPC_HORDE_PALADIN_HOLY: - vOtherEntries.push_back(NPC_HORDE_PALADIN_RETRIBUTION); - break; - case NPC_ALLIANCE_PRIEST_DISCIPLINE: - vOtherEntries.push_back(NPC_ALLIANCE_PRIEST_SHADOW); - break; - case NPC_HORDE_PRIEST_DISCIPLINE: - vOtherEntries.push_back(NPC_HORDE_PRIEST_SHADOW); - break; - case NPC_ALLIANCE_SHAMAN_RESTORATION: - vOtherEntries.push_back(NPC_ALLIANCE_SHAMAN_ENHANCEMENT); - break; - case NPC_HORDE_SHAMAN_RESTORATION: - vOtherEntries.push_back(NPC_HORDE_SHAMAN_ENHANCEMENT); - break; + uint8 pos = urand(0, vHealersEntries.size() - 1); + switch (vHealersEntries[pos]) + { + case NPC_ALLIANCE_DRUID_RESTORATION: + vOtherEntries.push_back(NPC_ALLIANCE_DRUID_BALANCE); + break; + case NPC_HORDE_DRUID_RESTORATION: + vOtherEntries.push_back(NPC_HORDE_DRUID_BALANCE); + break; + case NPC_ALLIANCE_PALADIN_HOLY: + vOtherEntries.push_back(NPC_ALLIANCE_PALADIN_RETRIBUTION); + break; + case NPC_HORDE_PALADIN_HOLY: + vOtherEntries.push_back(NPC_HORDE_PALADIN_RETRIBUTION); + break; + case NPC_ALLIANCE_PRIEST_DISCIPLINE: + vOtherEntries.push_back(NPC_ALLIANCE_PRIEST_SHADOW); + break; + case NPC_HORDE_PRIEST_DISCIPLINE: + vOtherEntries.push_back(NPC_HORDE_PRIEST_SHADOW); + break; + case NPC_ALLIANCE_SHAMAN_RESTORATION: + vOtherEntries.push_back(NPC_ALLIANCE_SHAMAN_ENHANCEMENT); + break; + case NPC_HORDE_SHAMAN_RESTORATION: + vOtherEntries.push_back(NPC_HORDE_SHAMAN_ENHANCEMENT); + break; + default: + break; + } + vHealersEntries.erase(vHealersEntries.begin() + pos); } - vHealersEntries.erase(vHealersEntries.begin()+pos); - } - if (instance->instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_NORMAL || instance->instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_HEROIC) - for (uint8 i = 0; i < 4; ++i) - vOtherEntries.erase(vOtherEntries.begin()+urand(0, vOtherEntries.size()-1)); + if (_instance->instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_NORMAL || _instance->instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_HEROIC) + for (uint8 i = 0; i < 4; ++i) + vOtherEntries.erase(vOtherEntries.begin() + urand(0, vOtherEntries.size() - 1)); - std::vector<uint32> vChampionEntries; - vChampionEntries.clear(); - for (uint8 i = 0; i < vHealersEntries.size(); ++i) - vChampionEntries.push_back(vHealersEntries[i]); - for (uint8 i = 0; i < vOtherEntries.size(); ++i) - vChampionEntries.push_back(vOtherEntries[i]); + std::vector<uint32> vChampionEntries; + vChampionEntries.clear(); + for (uint8 i = 0; i < vHealersEntries.size(); ++i) + vChampionEntries.push_back(vHealersEntries[i]); + for (uint8 i = 0; i < vOtherEntries.size(); ++i) + vChampionEntries.push_back(vOtherEntries[i]); - return vChampionEntries; - } + return vChampionEntries; + } - void SummonChampions(Team playerTeam) - { - std::vector<Position> vChampionJumpOrigin; - if (playerTeam == ALLIANCE) - for (uint8 i = 0; i < 5; i++) - vChampionJumpOrigin.push_back(FactionChampionLoc[i]); - else - for (uint8 i = 5; i < 10; i++) - vChampionJumpOrigin.push_back(FactionChampionLoc[i]); + void SummonChampions(Team playerTeam) + { + std::vector<Position> vChampionJumpOrigin; + if (playerTeam == ALLIANCE) + for (uint8 i = 0; i < 5; i++) + vChampionJumpOrigin.push_back(FactionChampionLoc[i]); + else + for (uint8 i = 5; i < 10; i++) + vChampionJumpOrigin.push_back(FactionChampionLoc[i]); - std::vector<Position> vChampionJumpTarget; - for (uint8 i = 10; i < 20; i++) - vChampionJumpTarget.push_back(FactionChampionLoc[i]); - std::vector<uint32> vChampionEntries = SelectChampions(playerTeam); + std::vector<Position> vChampionJumpTarget; + for (uint8 i = 10; i < 20; i++) + vChampionJumpTarget.push_back(FactionChampionLoc[i]); + std::vector<uint32> vChampionEntries = SelectChampions(playerTeam); - for (uint8 i = 0; i < vChampionEntries.size(); ++i) - { - uint8 pos = urand(0, vChampionJumpTarget.size()-1); - if (Creature* temp = me->SummonCreature(vChampionEntries[i], vChampionJumpOrigin[urand(0, vChampionJumpOrigin.size()-1)], TEMPSUMMON_MANUAL_DESPAWN)) + for (uint8 i = 0; i < vChampionEntries.size(); ++i) { - Summons.Summon(temp); - temp->SetReactState(REACT_PASSIVE); - temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); - if (playerTeam == ALLIANCE) + uint8 pos = urand(0, vChampionJumpTarget.size()-1); + if (Creature* temp = me->SummonCreature(vChampionEntries[i], vChampionJumpOrigin[urand(0, vChampionJumpOrigin.size()-1)], TEMPSUMMON_MANUAL_DESPAWN)) { - temp->SetHomePosition(vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 0); - temp->GetMotionMaster()->MoveJump(vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 20.0f, 20.0f); - temp->SetOrientation(0); - } - else - { - temp->SetHomePosition((ToCCommonLoc[1].GetPositionX()*2)-vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 3); - temp->GetMotionMaster()->MoveJump((ToCCommonLoc[1].GetPositionX()*2)-vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 20.0f, 20.0f); - temp->SetOrientation(3); + _summons.Summon(temp); + temp->SetReactState(REACT_PASSIVE); + temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); + if (playerTeam == ALLIANCE) + { + temp->SetHomePosition(vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 0); + temp->GetMotionMaster()->MoveJump(vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 20.0f, 20.0f); + temp->SetOrientation(0); + } + else + { + temp->SetHomePosition((ToCCommonLoc[1].GetPositionX()*2)-vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 3); + temp->GetMotionMaster()->MoveJump((ToCCommonLoc[1].GetPositionX()*2)-vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 20.0f, 20.0f); + temp->SetOrientation(3); + } } + vChampionJumpTarget.erase(vChampionJumpTarget.begin()+pos); } - vChampionJumpTarget.erase(vChampionJumpTarget.begin()+pos); } - } - void SetData(uint32 uiType, uint32 uiData) - { - switch (uiType) + void SetData(uint32 uiType, uint32 uiData) { - case 0: - SummonChampions((Team)uiData); - break; - case 1: - for (std::list<uint64>::iterator i = Summons.begin(); i != Summons.end(); ++i) - { - if (Creature* temp = Unit::GetCreature(*me, *i)) + switch (uiType) + { + case 0: + SummonChampions((Team)uiData); + break; + case 1: + for (std::list<uint64>::iterator i = _summons.begin(); i != _summons.end(); ++i) { - temp->SetReactState(REACT_AGGRESSIVE); - temp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); - } - } - break; - case 2: - switch (uiData) - { - case FAIL: - m_uiChampionsFailed++; - if (m_uiChampionsFailed + m_uiChampionsKilled >= Summons.size()) - { - instance->SetData(TYPE_CRUSADERS, FAIL); - Summons.DespawnAll(); - me->DespawnOrUnsummon(); - } - break; - case IN_PROGRESS: - if (!m_bInProgress) - { - m_uiChampionsNotStarted = 0; - m_uiChampionsFailed = 0; - m_uiChampionsKilled = 0; - m_bInProgress = true; - Summons.DoZoneInCombat(); - instance->SetData(TYPE_CRUSADERS, IN_PROGRESS); - } - break; - case DONE: - m_uiChampionsKilled++; - if (m_uiChampionsKilled == 1) - instance->SetData(TYPE_CRUSADERS, SPECIAL); - else if (m_uiChampionsKilled >= Summons.size()) + if (Creature* temp = Unit::GetCreature(*me, *i)) { - instance->SetData(TYPE_CRUSADERS, DONE); - Summons.DespawnAll(); - me->DespawnOrUnsummon(); + temp->SetReactState(REACT_AGGRESSIVE); + temp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC); } - break; - } - break; + } + break; + case 2: + switch (uiData) + { + case FAIL: + _championsFailed++; + if (_championsFailed + _championsKilled >= _summons.size()) + { + _instance->SetBossState(BOSS_CRUSADERS, FAIL); + _summons.DespawnAll(); + me->DespawnOrUnsummon(); + } + break; + case IN_PROGRESS: + if (!_inProgress) + { + _championsNotStarted = 0; + _championsFailed = 0; + _championsKilled = 0; + _inProgress = true; + _summons.DoZoneInCombat(); + _instance->SetBossState(BOSS_CRUSADERS, IN_PROGRESS); + } + break; + case DONE: + _championsKilled++; + if (_championsKilled == 1) + _instance->SetBossState(BOSS_CRUSADERS, SPECIAL); + else if (_championsKilled >= _summons.size()) + { + _instance->SetBossState(BOSS_CRUSADERS, DONE); + _summons.DespawnAll(); + me->DespawnOrUnsummon(); + } + break; + default: + break; + } + break; + default: + break; + } } - } - }; + private: + InstanceScript* _instance; + SummonList _summons; + uint32 _championsNotStarted; + uint32 _championsFailed; + uint32 _championsKilled; + bool _inProgress; + }; + CreatureAI* GetAI(Creature* creature) const + { + return new boss_toc_champion_controllerAI (creature); + } }; -struct boss_faction_championsAI : public ScriptedAI +struct boss_faction_championsAI : public BossAI { - boss_faction_championsAI(Creature* creature, uint32 aitype) : ScriptedAI(creature) + boss_faction_championsAI(Creature* creature, uint32 aitype) : BossAI(creature, BOSS_CRUSADERS) { - instance = creature->GetInstanceScript(); - mAIType = aitype; + _aiType = aitype; } - InstanceScript* instance; - - uint64 championControllerGUID; - uint32 mAIType; - uint32 ThreatTimer; - uint32 CCTimer; - void Reset() { - championControllerGUID = 0; - CCTimer = rand()%10000; - ThreatTimer = 5000; + _events.ScheduleEvent(EVENT_THREAT, 5*IN_MILLISECONDS); + if (IsHeroic() && (_aiType != AI_PET)) + _events.ScheduleEvent(EVENT_REMOVE_CC, 5*IN_MILLISECONDS); } void JustReachedHome() @@ -283,9 +567,9 @@ struct boss_faction_championsAI : public ScriptedAI float CalculateThreat(float distance, float armor, uint32 health) { - float dist_mod = (mAIType == AI_MELEE || mAIType == AI_PET) ? 15.0f/(15.0f + distance) : 1.0f; - float armor_mod = (mAIType == AI_MELEE || mAIType == AI_PET) ? armor / 16635.0f : 0.0f; - float eh = (health+1) * (1.0f + armor_mod); + float dist_mod = (_aiType == AI_MELEE || _aiType == AI_PET) ? 15.0f / (15.0f + distance) : 1.0f; + float armor_mod = (_aiType == AI_MELEE || _aiType == AI_PET) ? armor / 16635.0f : 0.0f; + float eh = (health + 1) * (1.0f + armor_mod); return dist_mod * 30000.0f / eh; } @@ -297,7 +581,7 @@ struct boss_faction_championsAI : public ScriptedAI Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && me->getThreatManager().getThreat(unit)) { - if (unit->GetTypeId()==TYPEID_PLAYER) + if (unit->GetTypeId() == TYPEID_PLAYER) { float threat = CalculateThreat(me->GetDistance2d(unit), (float)unit->GetArmor(), unit->GetHealth()); me->getThreatManager().modifyThreatPercent(unit, -100); @@ -311,8 +595,6 @@ struct boss_faction_championsAI : public ScriptedAI { if (me->getPowerType() == POWER_MANA) me->ModifyPower(POWER_MANA, me->GetMaxPower(POWER_MANA) / 3); - //else if (me->getPowerType() == POWER_ENERGY) - // me->ModifyPower(POWER_ENERGY, 100); } void RemoveCC() @@ -327,7 +609,7 @@ struct boss_faction_championsAI : public ScriptedAI void JustDied(Unit* /*killer*/) { - if (mAIType != AI_PET) + if (_aiType != AI_PET) if (instance) if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER))) pChampionController->AI()->SetData(2, DONE); @@ -336,7 +618,7 @@ struct boss_faction_championsAI : public ScriptedAI void EnterCombat(Unit* /*who*/) { DoCast(me, SPELL_ANTI_AOE, true); - me->SetInCombatWithZone(); + _EnterCombat(); if (instance) if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER))) pChampionController->AI()->SetData(2, IN_PROGRESS); @@ -365,7 +647,7 @@ struct boss_faction_championsAI : public ScriptedAI temp->AI()->Talk(SAY_KILL_PLAYER); - instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); + instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0); } } } @@ -376,7 +658,7 @@ struct boss_faction_championsAI : public ScriptedAI std::list<Creature*>::const_iterator itr = lst.begin(); if (lst.empty()) return NULL; - advance(itr, rand()%lst.size()); + advance(itr, rand() % lst.size()); return (*itr); } @@ -400,7 +682,7 @@ struct boss_faction_championsAI : public ScriptedAI std::list<HostileReference*>::const_iterator iter; uint32 count = 0; Unit* target; - for (iter = tList.begin(); iter!=tList.end(); ++iter) + for (iter = tList.begin(); iter != tList.end(); ++iter) { target = Unit::GetUnit(*me, (*iter)->getUnitGuid()); if (target && me->GetDistance2d(target) < distance) @@ -420,7 +702,7 @@ struct boss_faction_championsAI : public ScriptedAI me->SetInCombatWith(who); who->SetInCombatWith(me); - if (mAIType == AI_MELEE || mAIType == AI_PET) + if (_aiType == AI_MELEE || _aiType == AI_PET) DoStartMovement(who); else DoStartMovement(who, 20.0f); @@ -428,1642 +710,1666 @@ struct boss_faction_championsAI : public ScriptedAI } } - void UpdateAI(const uint32 uiDiff) + void UpdateAI(const uint32 diff) { - if (ThreatTimer < uiDiff) - { - UpdatePower(); - UpdateThreat(); - ThreatTimer = 4000; - } - else ThreatTimer -= uiDiff; + _events.Update(diff); - if (mAIType != AI_PET) + while (uint32 eventId = _events.ExecuteEvent()) { - if (CCTimer < uiDiff) - { - RemoveCC(); - CCTimer = 8000+rand()%2000; + switch (eventId) + { + case EVENT_THREAT: + UpdatePower(); + UpdateThreat(); + _events.ScheduleEvent(EVENT_THREAT, 4*IN_MILLISECONDS); + return; + case EVENT_REMOVE_CC: + if (me->HasBreakableByDamageCrowdControlAura()) + { + RemoveCC(); + _events.RescheduleEvent(EVENT_REMOVE_CC, 2*MINUTE*IN_MILLISECONDS); + } + else + _events.RescheduleEvent(EVENT_REMOVE_CC, 3*IN_MILLISECONDS); + return; + default: + return; } - else CCTimer -= uiDiff; } - if (mAIType == AI_MELEE || mAIType == AI_PET) DoMeleeAttackIfReady(); + if (_aiType == AI_MELEE || _aiType == AI_PET) + DoMeleeAttackIfReady(); } + + private: + uint32 _aiType; + // make sure that every bosses separate events dont mix with these _events + EventMap _events; }; /******************************************************************** HEALERS ********************************************************************/ -enum eDruidSpells -{ - SPELL_LIFEBLOOM = 66093, - SPELL_NOURISH = 66066, - SPELL_REGROWTH = 66067, - SPELL_REJUVENATION = 66065, - SPELL_TRANQUILITY = 66086, - SPELL_BARKSKIN = 65860, //1 min cd - SPELL_THORNS = 66068, - SPELL_NATURE_GRASP = 66071, //1 min cd, self buff -}; - class mob_toc_druid : public CreatureScript { -public: - mob_toc_druid() : CreatureScript("mob_toc_druid") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_druidAI (creature); - } - - struct mob_toc_druidAI : public boss_faction_championsAI - { - mob_toc_druidAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} - - uint32 m_uiNatureGraspTimer; - uint32 m_uiTranquilityTimer; - uint32 m_uiBarkskinTimer; - uint32 m_uiCommonTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiNatureGraspTimer = IN_MILLISECONDS; - m_uiTranquilityTimer = IN_MILLISECONDS; - m_uiBarkskinTimer = IN_MILLISECONDS; - m_uiCommonTimer = IN_MILLISECONDS; - SetEquipmentSlots(false, 51799, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - } + public: + mob_toc_druid() : CreatureScript("mob_toc_druid") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_druidAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_druidAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_LIFEBLOOM, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_NOURISH, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_REGROWTH, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_REJUVENATION, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_TRANQUILITY, urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HEAL_BARKSKIN, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_THORNS, 2*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_NATURE_GRASP, urand(3*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + SetEquipmentSlots(false, 51799, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + } - if (m_uiNatureGraspTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - DoCast(me, SPELL_NATURE_GRASP); - m_uiNatureGraspTimer = urand(40*IN_MILLISECONDS, 80*IN_MILLISECONDS); - } else m_uiNatureGraspTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiTranquilityTimer <= uiDiff) - { - DoCastAOE(SPELL_TRANQUILITY); - m_uiTranquilityTimer = urand(40*IN_MILLISECONDS, 90*IN_MILLISECONDS); - } else m_uiTranquilityTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiBarkskinTimer <= uiDiff) - { - if (HealthBelowPct(50)) - DoCast(me, SPELL_BARKSKIN); - m_uiBarkskinTimer = urand(45*IN_MILLISECONDS, 90*IN_MILLISECONDS); - } else m_uiBarkskinTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 4)) + while (uint32 eventId = events.ExecuteEvent()) { - case 0: - DoCast(me, SPELL_LIFEBLOOM); - break; - case 1: - DoCast(me, SPELL_NOURISH); - break; - case 2: - DoCast(me, SPELL_REGROWTH); - break; - case 3: - DoCast(me, SPELL_REJUVENATION); - break; - case 4: - if (Creature* target = SelectRandomFriendlyMissingBuff(SPELL_THORNS)) - DoCast(target, SPELL_THORNS); - break; + switch (eventId) + { + case EVENT_LIFEBLOOM: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_LIFEBLOOM); + events.ScheduleEvent(EVENT_LIFEBLOOM, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_NOURISH: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_NOURISH); + events.ScheduleEvent(EVENT_NOURISH, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_REGROWTH: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_REGROWTH); + events.ScheduleEvent(EVENT_REGROWTH, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_REJUVENATION: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_REJUVENATION); + events.ScheduleEvent(EVENT_REJUVENATION, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_TRANQUILITY: + DoCastAOE(SPELL_TRANQUILITY); + events.ScheduleEvent(EVENT_TRANQUILITY, urand(15*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + return; + case EVENT_HEAL_BARKSKIN: + if (HealthBelowPct(30)) + { + DoCast(me, SPELL_BARKSKIN); + events.RescheduleEvent(EVENT_HEAL_BARKSKIN, 60*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_HEAL_BARKSKIN, 3*IN_MILLISECONDS); + return; + case EVENT_THORNS: + if (Creature* target = SelectRandomFriendlyMissingBuff(SPELL_THORNS)) + DoCast(target, SPELL_THORNS); + events.ScheduleEvent(EVENT_THORNS, urand(25*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + return; + case EVENT_NATURE_GRASP: + DoCast(me, SPELL_NATURE_GRASP); + events.ScheduleEvent(EVENT_NATURE_GRASP, 60*IN_MILLISECONDS); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_druidAI (creature); } - }; - -}; - -enum eShamanSpells -{ - SPELL_HEALING_WAVE = 66055, - SPELL_RIPTIDE = 66053, - SPELL_SPIRIT_CLEANSE = 66056, //friendly only - SPELL_HEROISM = 65983, - SPELL_BLOODLUST = 65980, - SPELL_HEX = 66054, - SPELL_EARTH_SHIELD = 66063, - SPELL_EARTH_SHOCK = 65973, - AURA_EXHAUSTION = 57723, - AURA_SATED = 57724, }; class mob_toc_shaman : public CreatureScript { -public: - mob_toc_shaman() : CreatureScript("mob_toc_shaman") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_shamanAI (creature); - } - - struct mob_toc_shamanAI : public boss_faction_championsAI - { - mob_toc_shamanAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} - - uint32 m_uiHeroismOrBloodlustTimer; - uint32 m_uiHexTimer; - uint32 m_uiCommonTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiHeroismOrBloodlustTimer = IN_MILLISECONDS; - m_uiHexTimer = IN_MILLISECONDS; - m_uiCommonTimer = IN_MILLISECONDS; - SetEquipmentSlots(false, 49992, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - } + public: + mob_toc_shaman() : CreatureScript("mob_toc_shaman") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_shamanAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_shamanAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_HEALING_WAVE, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_RIPTIDE, urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SPIRIT_CLEANSE, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HEAL_BLOODLUST_HEROISM, 20*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_HEX, urand(5*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_EARTH_SHIELD, 1*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_HEAL_EARTH_SHOCK, urand(5*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + SetEquipmentSlots(false, 49992, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + } - if (m_uiHeroismOrBloodlustTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (me->getFaction()) //Am i alliance? - { - if (!me->HasAura(AURA_EXHAUSTION)) - DoCastAOE(SPELL_HEROISM); - } - else - if (!me->HasAura(AURA_SATED)) - DoCastAOE(SPELL_BLOODLUST); - m_uiHeroismOrBloodlustTimer = 300*IN_MILLISECONDS; - } else m_uiHeroismOrBloodlustTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiHexTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_HEX); - m_uiHexTimer = urand(10*IN_MILLISECONDS, 40*IN_MILLISECONDS); - } else m_uiHexTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 5)) + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) { - case 0: case 1: - DoCast(me, SPELL_HEALING_WAVE); - break; - case 2: - DoCast(me, SPELL_RIPTIDE); - break; - case 3: - DoCast(me, SPELL_EARTH_SHOCK); - break; - case 4: - DoCast(me, SPELL_SPIRIT_CLEANSE); - break; - case 5: - if (Unit* target = SelectRandomFriendlyMissingBuff(SPELL_EARTH_SHIELD)) - DoCast(target, SPELL_EARTH_SHIELD); - break; + switch (eventId) + { + case EVENT_HEALING_WAVE: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_HEALING_WAVE); + events.ScheduleEvent(EVENT_HEALING_WAVE, urand(3*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + return; + case EVENT_RIPTIDE: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_RIPTIDE); + events.ScheduleEvent(EVENT_RIPTIDE, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_SPIRIT_CLEANSE: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_SPIRIT_CLEANSE); + events.ScheduleEvent(EVENT_SPIRIT_CLEANSE, urand(15*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_HEAL_BLOODLUST_HEROISM: + if (me->getFaction()) // alliance = 1 + { + if (!me->HasAura(AURA_EXHAUSTION)) + DoCastAOE(SPELL_HEROISM); + } + else + { + if (!me->HasAura(AURA_SATED)) + DoCastAOE(SPELL_BLOODLUST); + } + events.ScheduleEvent(EVENT_HEAL_BLOODLUST_HEROISM, 5*MINUTE*IN_MILLISECONDS); + return; + case EVENT_HEX: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) + DoCast(target, SPELL_HEX); + events.ScheduleEvent(EVENT_HEX, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_EARTH_SHIELD: + if (Creature* target = SelectRandomFriendlyMissingBuff(SPELL_EARTH_SHIELD)) + DoCast(target, SPELL_EARTH_SHIELD); + events.ScheduleEvent(EVENT_EARTH_SHIELD, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_HEAL_EARTH_SHOCK: + if (Unit* target = SelectEnemyCaster(true)) + DoCast(target, SPELL_EARTH_SHOCK); + events.ScheduleEvent(EVENT_HEAL_EARTH_SHOCK, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + default: + return; + } } - m_uiCommonTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_shamanAI (creature); } - }; - -}; - -enum ePaladinSpells -{ - SPELL_HAND_OF_FREEDOM = 68757, //25 sec cd - SPELL_BUBBLE = 66010, //5 min cd - SPELL_CLEANSE = 66116, - SPELL_FLASH_OF_LIGHT = 66113, - SPELL_HOLY_LIGHT = 66112, - SPELL_HOLY_SHOCK = 66114, - SPELL_HAND_OF_PROTECTION = 66009, - SPELL_HAMMER_OF_JUSTICE = 66613, }; class mob_toc_paladin : public CreatureScript { -public: - mob_toc_paladin() : CreatureScript("mob_toc_paladin") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_paladinAI (creature); - } - - struct mob_toc_paladinAI : public boss_faction_championsAI - { - mob_toc_paladinAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} - - uint32 m_uiBubbleTimer; - uint32 m_uiHandOfProtectionTimer; - uint32 m_uiHolyShockTimer; - uint32 m_uiHandOfFreedomTimer; - uint32 m_uiHammerOfJusticeTimer; - uint32 m_uiCommonTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiBubbleTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - m_uiHandOfProtectionTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - m_uiHolyShockTimer = urand(6*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiHandOfFreedomTimer = urand(25*IN_MILLISECONDS, 40*IN_MILLISECONDS); - m_uiHammerOfJusticeTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - SetEquipmentSlots(false, 50771, 47079, EQUIP_NO_CHANGE); - } + public: + mob_toc_paladin() : CreatureScript("mob_toc_paladin") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_paladinAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; - - if (m_uiBubbleTimer <= uiDiff) - { - //cast bubble at 20% hp - if (HealthBelowPct(20)) - DoCast(me, SPELL_BUBBLE); - m_uiBubbleTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - } else m_uiBubbleTimer -= uiDiff; + mob_toc_paladinAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_HAND_OF_FREEDOM, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HEAL_DIVINE_SHIELD, 20*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_CLEANSE, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FLASH_OF_LIGHT, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HOLY_LIGHT, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HOLY_SHOCK, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HEAL_HAND_OF_PROTECTION, urand(30*IN_MILLISECONDS, 60*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HAMMER_OF_JUSTICE, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + SetEquipmentSlots(false, 50771, 47079, EQUIP_NO_CHANGE); + } - if (m_uiHandOfProtectionTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (Unit* target = DoSelectLowestHpFriendly(40.0f)) - if (target->HealthBelowPct(15)) - DoCast(target, SPELL_HAND_OF_PROTECTION); - m_uiHandOfProtectionTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - } else m_uiHandOfProtectionTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiHolyShockTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_HOLY_SHOCK); - m_uiHolyShockTimer = urand(6*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiHolyShockTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiHandOfFreedomTimer <= uiDiff) - { - if (Unit* target = SelectRandomFriendlyMissingBuff(SPELL_HAND_OF_FREEDOM)) - DoCast(target, SPELL_HAND_OF_FREEDOM); - m_uiHandOfFreedomTimer = urand(25*IN_MILLISECONDS, 40*IN_MILLISECONDS); - } else m_uiHandOfFreedomTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiHammerOfJusticeTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_HAMMER_OF_JUSTICE); - m_uiHammerOfJusticeTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiHammerOfJusticeTimer -= uiDiff; - - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 4)) + while (uint32 eventId = events.ExecuteEvent()) { - case 0: case 1: - DoCast(me, SPELL_FLASH_OF_LIGHT); - break; - case 2: case 3: - DoCast(me, SPELL_HOLY_LIGHT); - break; - case 4: - DoCast(me, SPELL_CLEANSE); - break; + switch (eventId) + { + case EVENT_HAND_OF_FREEDOM: + if (Unit* target = SelectRandomFriendlyMissingBuff(SPELL_HAND_OF_FREEDOM)) + DoCast(target, SPELL_HAND_OF_FREEDOM); + events.ScheduleEvent(EVENT_HAND_OF_FREEDOM, urand(15*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_HEAL_DIVINE_SHIELD: + if (HealthBelowPct(30) && !me->HasAura(SPELL_FORBEARANCE)) + { + DoCast(me, SPELL_DIVINE_SHIELD); + events.RescheduleEvent(EVENT_HEAL_DIVINE_SHIELD, 5*MINUTE*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_HEAL_DIVINE_SHIELD, 5*IN_MILLISECONDS); + return; + case EVENT_CLEANSE: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_CLEANSE); + events.ScheduleEvent(EVENT_CLEANSE, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_FLASH_OF_LIGHT: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_FLASH_OF_LIGHT); + events.ScheduleEvent(EVENT_FLASH_OF_LIGHT, urand(3*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + return; + case EVENT_HOLY_LIGHT: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_HOLY_LIGHT); + events.ScheduleEvent(EVENT_HOLY_LIGHT, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + return; + case EVENT_HOLY_SHOCK: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_HOLY_SHOCK); + events.ScheduleEvent(EVENT_HOLY_SHOCK, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_HEAL_HAND_OF_PROTECTION: + if (Unit* target = DoSelectLowestHpFriendly(30.0f)) + { + if (!target->HasAura(SPELL_FORBEARANCE)) + { + DoCast(target, SPELL_HAND_OF_PROTECTION); + events.RescheduleEvent(EVENT_HEAL_HAND_OF_PROTECTION, 5*MINUTE*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_HEAL_HAND_OF_PROTECTION, 3*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_HEAL_HAND_OF_PROTECTION, 10*IN_MILLISECONDS); + return; + case EVENT_HAMMER_OF_JUSTICE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 15.0f, true)) + DoCast(target, SPELL_HAMMER_OF_JUSTICE); + events.ScheduleEvent(EVENT_HAMMER_OF_JUSTICE, 40*IN_MILLISECONDS); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_paladinAI (creature); } - }; - -}; - -enum ePriestSpells -{ - SPELL_RENEW = 66177, - SPELL_SHIELD = 66099, - SPELL_FLASH_HEAL = 66104, - SPELL_DISPEL = 65546, - SPELL_PSYCHIC_SCREAM = 65543, - SPELL_MANA_BURN = 66100, }; class mob_toc_priest : public CreatureScript { -public: - mob_toc_priest() : CreatureScript("mob_toc_priest") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_priestAI (creature); - } - - struct mob_toc_priestAI : public boss_faction_championsAI - { - mob_toc_priestAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} - - uint32 m_uiPsychicScreamTimer; - uint32 m_uiCommonTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiPsychicScreamTimer = IN_MILLISECONDS; - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - SetEquipmentSlots(false, 49992, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - } + public: + mob_toc_priest() : CreatureScript("mob_toc_priest") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_priestAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_priestAI(Creature* creature) : boss_faction_championsAI(creature, AI_HEALER) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_RENEW, urand(3*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SHIELD, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FLASH_HEAL, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HEAL_DISPEL, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HEAL_PSYCHIC_SCREAM, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_MANA_BURN, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_PENANCE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + SetEquipmentSlots(false, 49992, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + } - if (m_uiPsychicScreamTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (EnemiesInRange(10.0f) > 2) - DoCastAOE(SPELL_PSYCHIC_SCREAM); - m_uiPsychicScreamTimer = urand(5*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiPsychicScreamTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 5)) + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) { - case 0: - DoCast(me, SPELL_RENEW); - break; - case 1: - DoCast(me, SPELL_SHIELD); - break; - case 2: case 3: - DoCast(me, SPELL_FLASH_HEAL); - break; - case 4: - if (Unit* target = urand(0, 1) ? SelectTarget(SELECT_TARGET_RANDOM, 0) : DoSelectLowestHpFriendly(40.0f)) - DoCast(target, SPELL_DISPEL); - break; - case 5: - DoCast(me, SPELL_MANA_BURN); - break; + switch (eventId) + { + case EVENT_RENEW: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_RENEW); + events.ScheduleEvent(EVENT_RENEW, urand(3*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + return; + case EVENT_SHIELD: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_SHIELD); + events.ScheduleEvent(EVENT_SHIELD, urand(15*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_FLASH_HEAL: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_FLASH_HEAL); + events.ScheduleEvent(EVENT_FLASH_HEAL, urand(3*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + return; + case EVENT_HEAL_DISPEL: + if (Unit* target = urand(0, 1) ? SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f, true) : DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_DISPEL); + events.ScheduleEvent(EVENT_HEAL_DISPEL, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_HEAL_PSYCHIC_SCREAM: + if (EnemiesInRange(10.0f) >= 2) + DoCastAOE(SPELL_PSYCHIC_SCREAM); + events.ScheduleEvent(EVENT_HEAL_PSYCHIC_SCREAM, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_MANA_BURN: + if (Unit* target = SelectEnemyCaster(false)) + DoCast(target, SPELL_MANA_BURN); + events.ScheduleEvent(EVENT_MANA_BURN, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_PENANCE: + if (Unit* target = DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_PENANCE); + events.ScheduleEvent(EVENT_PENANCE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_priestAI (creature); } - }; - }; /******************************************************************** RANGED ********************************************************************/ -enum eShadowPriestSpells -{ - SPELL_SILENCE = 65542, - SPELL_VAMPIRIC_TOUCH = 65490, - SPELL_SW_PAIN = 65541, - SPELL_MIND_FLAY = 65488, - SPELL_MIND_BLAST = 65492, - SPELL_HORROR = 65545, - SPELL_DISPERSION = 65544, - SPELL_SHADOWFORM = 16592, -}; - class mob_toc_shadow_priest : public CreatureScript { -public: - mob_toc_shadow_priest() : CreatureScript("mob_toc_shadow_priest") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_shadow_priestAI (creature); - } - - struct mob_toc_shadow_priestAI : public boss_faction_championsAI - { - mob_toc_shadow_priestAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} - - uint32 m_uiPsychicScreamTimer; - uint32 m_uiDispersionTimer; - uint32 m_uiSilenceTimer; - uint32 m_uiMindBlastTimer; - uint32 m_uiCommonTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiPsychicScreamTimer = urand(5*IN_MILLISECONDS, 25*IN_MILLISECONDS); - m_uiDispersionTimer = urand(1*IN_MILLISECONDS, 180*IN_MILLISECONDS); - m_uiSilenceTimer = urand(8*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiMindBlastTimer = urand(3*IN_MILLISECONDS, 8*IN_MILLISECONDS); - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - SetEquipmentSlots(false, 50040, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - DoCast(me, SPELL_SHADOWFORM); - } - - void EnterCombat(Unit* who) - { - boss_faction_championsAI::EnterCombat(who); - } + public: + mob_toc_shadow_priest() : CreatureScript("mob_toc_shadow_priest") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_shadow_priestAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; - - if (m_uiPsychicScreamTimer <= uiDiff) - { - if (EnemiesInRange(10.0f) > 2) - DoCastAOE(SPELL_PSYCHIC_SCREAM); - m_uiPsychicScreamTimer = urand(5*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiPsychicScreamTimer -= uiDiff; + mob_toc_shadow_priestAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_SILENCE, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_VAMPIRIC_TOUCH, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SW_PAIN, urand(3*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_MIND_BLAST, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HORROR, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DISPERSION, urand(20*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DPS_DISPEL, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DPS_PSYCHIC_SCREAM, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + SetEquipmentSlots(false, 50040, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + DoCast(me, SPELL_SHADOWFORM); + } - if (m_uiDispersionTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (HealthBelowPct(20)) - DoCast(me, SPELL_DISPERSION); - m_uiDispersionTimer = urand(1*IN_MILLISECONDS, 180*IN_MILLISECONDS); - } else m_uiDispersionTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiSilenceTimer <= uiDiff) - { - if (Unit* target = SelectEnemyCaster(false)) - DoCast(target, SPELL_SILENCE); - m_uiSilenceTimer = urand(8*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiSilenceTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiMindBlastTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_MIND_BLAST); - m_uiMindBlastTimer = urand(3*IN_MILLISECONDS, 8*IN_MILLISECONDS); - } else m_uiMindBlastTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 4)) + while (uint32 eventId = events.ExecuteEvent()) { - case 0: case 1: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_MIND_FLAY); - break; - case 2: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_VAMPIRIC_TOUCH); - break; - case 3: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_SW_PAIN); - break; - case 4: - if (Unit* target = urand(0, 1) ? SelectTarget(SELECT_TARGET_RANDOM, 0) : DoSelectLowestHpFriendly(40.0f)) - DoCast(target, SPELL_DISPEL); - break; + switch (eventId) + { + case EVENT_SILENCE: + if (Unit* target = SelectEnemyCaster(true)) + DoCast(target, SPELL_SILENCE); + events.ScheduleEvent(EVENT_SILENCE, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_VAMPIRIC_TOUCH: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f, true)) + DoCast(target, SPELL_VAMPIRIC_TOUCH); + events.ScheduleEvent(EVENT_VAMPIRIC_TOUCH, urand(10*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_SW_PAIN: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 40.0f, true)) + DoCast(target, SPELL_SW_PAIN); + events.ScheduleEvent(EVENT_SW_PAIN, urand(10*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_MIND_BLAST: + DoCastVictim(SPELL_MIND_BLAST); + events.ScheduleEvent(EVENT_MIND_BLAST, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_HORROR: + DoCastVictim(SPELL_HORROR); + events.ScheduleEvent(EVENT_HORROR, urand(15*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_DISPERSION: + if (HealthBelowPct(40)) + { + DoCast(me, SPELL_DISPERSION); + events.RescheduleEvent(EVENT_DISPERSION, 180*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_DISPERSION, 5*IN_MILLISECONDS); + return; + case EVENT_DPS_DISPEL: + if (Unit* target = urand(0, 1) ? SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f, true) : DoSelectLowestHpFriendly(40.0f)) + DoCast(target, SPELL_DISPEL); + events.ScheduleEvent(EVENT_DPS_DISPEL, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_DPS_PSYCHIC_SCREAM: + if (EnemiesInRange(10.0f) >= 2) + DoCastAOE(SPELL_PSYCHIC_SCREAM); + events.ScheduleEvent(EVENT_DPS_PSYCHIC_SCREAM, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + DoSpellAttackIfReady(SPELL_MIND_FLAY); + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_shadow_priestAI (creature); } - }; - -}; - -enum WarlockSpells -{ - SPELL_HELLFIRE = 65816, - SPELL_CORRUPTION = 65810, - SPELL_CURSE_OF_AGONY = 65814, - SPELL_CURSE_OF_EXHAUSTION = 65815, - SPELL_FEAR = 65809, // 8s - SPELL_SEARING_PAIN = 65819, - SPELL_SHADOW_BOLT = 65821, - SPELL_UNSTABLE_AFFLICTION = 65812, // 15s - SPELL_UNSTABLE_AFFLICTION_DISPEL = 65813, - SPELL_SUMMON_FELHUNTER = 67514, }; class mob_toc_warlock : public CreatureScript { -public: - mob_toc_warlock() : CreatureScript("mob_toc_warlock") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_warlockAI (creature); - } - - struct mob_toc_warlockAI : public boss_faction_championsAI - { - mob_toc_warlockAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED), Summons(me) {} - - SummonList Summons; - - uint32 m_uiFearTimer; - uint32 m_uiHellfireTimer; - uint32 m_uiUnstableAfflictionTimer; - uint32 m_uiCommonTimer; - uint32 m_uiSummonPetTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiFearTimer = urand(4*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiHellfireTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - m_uiUnstableAfflictionTimer = urand(2*IN_MILLISECONDS, 10*IN_MILLISECONDS); - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - SetEquipmentSlots(false, 49992, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - - m_uiSummonPetTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - DoCast(SPELL_SUMMON_FELHUNTER); - } + public: + mob_toc_warlock() : CreatureScript("mob_toc_warlock") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_warlockAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_warlockAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_HELLFIRE, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_CORRUPTION, urand(2*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_CURSE_OF_AGONY, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_CURSE_OF_EXHAUSTION, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FEAR, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SEARING_PAIN, urand(5*IN_MILLISECONDS, 12*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_UNSTABLE_AFFLICTION, urand(7*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + SetEquipmentSlots(false, 49992, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + } - if (m_uiFearTimer <= uiDiff) + void EnterCombat(Unit* who) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_FEAR); - m_uiFearTimer = urand(4*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiFearTimer -= uiDiff; + boss_faction_championsAI::EnterCombat(who); + DoCast(SPELL_SUMMON_FELHUNTER); + } - if (m_uiHellfireTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (EnemiesInRange(10.0f) > 2) - DoCastAOE(SPELL_HELLFIRE); - m_uiHellfireTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiHellfireTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiUnstableAfflictionTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_UNSTABLE_AFFLICTION); - m_uiUnstableAfflictionTimer = urand(2*IN_MILLISECONDS, 10*IN_MILLISECONDS); - } else m_uiUnstableAfflictionTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiSummonPetTimer <= uiDiff) - { - m_uiSummonPetTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiSummonPetTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 5)) + while (uint32 eventId = events.ExecuteEvent()) { - case 0: case 1: - DoCastVictim(SPELL_SHADOW_BOLT); - break; - case 2: - DoCastVictim(SPELL_SEARING_PAIN); - break; - case 3: - DoCastVictim(SPELL_CORRUPTION); - break; - case 4: - DoCastVictim(SPELL_CURSE_OF_AGONY); - break; - case 5: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_CURSE_OF_EXHAUSTION); - break; + switch (eventId) + { + case EVENT_HELLFIRE: + if (EnemiesInRange(10.0f) >= 2) + DoCastAOE(SPELL_HELLFIRE); + events.ScheduleEvent(EVENT_HELLFIRE, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_CORRUPTION: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f)) + DoCast(target, SPELL_CORRUPTION); + events.ScheduleEvent(EVENT_CORRUPTION, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_CURSE_OF_AGONY: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f)) + DoCast(target, SPELL_CURSE_OF_AGONY); + events.ScheduleEvent(EVENT_CURSE_OF_AGONY, urand(20*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_CURSE_OF_EXHAUSTION: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f)) + DoCast(target, SPELL_CURSE_OF_EXHAUSTION); + events.ScheduleEvent(EVENT_CURSE_OF_EXHAUSTION, urand(20*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_FEAR: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 20.0f, true)) + DoCast(target, SPELL_FEAR); + events.ScheduleEvent(EVENT_FEAR, urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_SEARING_PAIN: + DoCastVictim(SPELL_SEARING_PAIN); + events.ScheduleEvent(EVENT_SEARING_PAIN, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_UNSTABLE_AFFLICTION: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f, true)) + DoCast(target, SPELL_UNSTABLE_AFFLICTION); + events.ScheduleEvent(EVENT_UNSTABLE_AFFLICTION, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; - boss_faction_championsAI::UpdateAI(uiDiff); - } - }; - -}; + DoSpellAttackIfReady(SPELL_SHADOW_BOLT); + } + }; -enum eMageSpells -{ - SPELL_ARCANE_BARRAGE = 65799, //3s - SPELL_ARCANE_BLAST = 65791, - SPELL_ARCANE_EXPLOSION = 65800, - SPELL_BLINK = 65793, //15s - SPELL_COUNTERSPELL = 65790, //24s - SPELL_FROST_NOVA = 65792, //25s - SPELL_FROSTBOLT = 65807, - SPELL_ICE_BLOCK = 65802, //5min - SPELL_POLYMORPH = 65801, //15s + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_warlockAI (creature); + } }; class mob_toc_mage : public CreatureScript { -public: - mob_toc_mage() : CreatureScript("mob_toc_mage") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_mageAI (creature); - } - - struct mob_toc_mageAI : public boss_faction_championsAI - { - mob_toc_mageAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} - - uint32 m_uiCounterspellTimer; - uint32 m_uiBlinkTimer; - uint32 m_uiIceBlockTimer; - uint32 m_uiPolymorphTimer; - uint32 m_uiCommonTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiCounterspellTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiBlinkTimer = urand(7*IN_MILLISECONDS, 25*IN_MILLISECONDS); - m_uiIceBlockTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - m_uiPolymorphTimer = urand(15*IN_MILLISECONDS, 40*IN_MILLISECONDS); - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - SetEquipmentSlots(false, 47524, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - } + public: + mob_toc_mage() : CreatureScript("mob_toc_mage") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_mageAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_mageAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_ARCANE_BARRAGE, urand(1*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ARCANE_BLAST, urand(3*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ARCANE_EXPLOSION, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_BLINK, urand(15*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_COUNTERSPELL, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FROST_NOVA, urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ICE_BLOCK, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_POLYMORPH, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + SetEquipmentSlots(false, 47524, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + } - if (m_uiCounterspellTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (Unit* target = SelectEnemyCaster(false)) - DoCast(target, SPELL_COUNTERSPELL); - m_uiCounterspellTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiCounterspellTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiBlinkTimer <= uiDiff) - { - if (HealthBelowPct(50) && EnemiesInRange(10.0f) > 3) - { - DoCastAOE(SPELL_FROST_NOVA); - DoCast(SPELL_BLINK); - } - m_uiBlinkTimer = urand(7*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiBlinkTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiIceBlockTimer <= uiDiff) - { - if (HealthBelowPct(20)) - DoCast(me, SPELL_ICE_BLOCK); - m_uiIceBlockTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - } else m_uiIceBlockTimer -= uiDiff; - - if (m_uiPolymorphTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_POLYMORPH); - m_uiPolymorphTimer = urand(15*IN_MILLISECONDS, 40*IN_MILLISECONDS); - } else m_uiPolymorphTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 2)) + while (uint32 eventId = events.ExecuteEvent()) { - case 0: - DoCast(me, SPELL_ARCANE_BARRAGE); - break; - case 1: - DoCastVictim(SPELL_ARCANE_BLAST); - break; - case 2: - DoCastVictim(SPELL_FROSTBOLT); - break; + switch (eventId) + { + case EVENT_ARCANE_BARRAGE: + DoCastVictim(SPELL_ARCANE_BARRAGE); + events.ScheduleEvent(EVENT_ARCANE_BARRAGE, urand(5*IN_MILLISECONDS, 7*IN_MILLISECONDS)); + return; + case EVENT_ARCANE_BLAST: + DoCastVictim(SPELL_ARCANE_BLAST); + events.ScheduleEvent(EVENT_ARCANE_BLAST, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_ARCANE_EXPLOSION: + if (EnemiesInRange(10.0f) >= 2) + DoCastAOE(SPELL_ARCANE_EXPLOSION); + events.ScheduleEvent(EVENT_ARCANE_EXPLOSION, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_BLINK: + if (EnemiesInRange(10.0f) >= 2) + DoCast(SPELL_BLINK); + events.ScheduleEvent(EVENT_BLINK, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_COUNTERSPELL: + if (Unit* target = SelectEnemyCaster(true)) + DoCast(target, SPELL_COUNTERSPELL); + events.ScheduleEvent(EVENT_COUNTERSPELL, 24*IN_MILLISECONDS); + return; + case EVENT_FROST_NOVA: + if (EnemiesInRange(10.0f) >= 2) + DoCastAOE(SPELL_FROST_NOVA); + events.ScheduleEvent(EVENT_FROST_NOVA, 25*IN_MILLISECONDS); + return; + case EVENT_ICE_BLOCK: + if (HealthBelowPct(30)) + { + DoCast(SPELL_ICE_BLOCK); + events.RescheduleEvent(EVENT_ICE_BLOCK, 5*MINUTE*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_ICE_BLOCK, 5*IN_MILLISECONDS); + return; + case EVENT_POLYMORPH: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) + DoCast(target, SPELL_POLYMORPH); + events.ScheduleEvent(EVENT_POLYMORPH, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + DoSpellAttackIfReady(SPELL_FROSTBOLT); + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_mageAI (creature); } - }; - -}; - -enum eHunterSpells -{ - SPELL_AIMED_SHOT = 65883, - SPELL_DETERRENCE = 65871, //90s - SPELL_DISENGAGE = 65869, //30s - SPELL_EXPLOSIVE_SHOT = 65866, - SPELL_FROST_TRAP = 65880, //30s - SPELL_SHOOT = 65868, //1.7s - SPELL_STEADY_SHOT = 65867, //3s - SPELL_WING_CLIP = 66207, //6s - SPELL_WYVERN_STING = 65877, //60s - SPELL_CALL_PET = 67777, }; class mob_toc_hunter : public CreatureScript { -public: - mob_toc_hunter() : CreatureScript("mob_toc_hunter") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_hunterAI (creature); - } - - struct mob_toc_hunterAI : public boss_faction_championsAI - { - mob_toc_hunterAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED), Summons(me) {} - - SummonList Summons; - - uint32 m_uiDisengageTimer; - uint32 m_uiDeterrenceTimer; - uint32 m_uiWyvernStingTimer; - uint32 m_uiFrostTrapTimer; - uint32 m_uiWingClipTimer; - uint32 m_uiCommonTimer; - uint32 m_uiSummonPetTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiDisengageTimer = urand(12*IN_MILLISECONDS, 20*IN_MILLISECONDS); - m_uiDeterrenceTimer = urand(20*IN_MILLISECONDS, 120*IN_MILLISECONDS); - m_uiWyvernStingTimer = urand(7*IN_MILLISECONDS, 60*IN_MILLISECONDS); - m_uiFrostTrapTimer = urand(12*IN_MILLISECONDS, 30*IN_MILLISECONDS); - m_uiWingClipTimer = urand(4*IN_MILLISECONDS, 8*IN_MILLISECONDS); - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - SetEquipmentSlots(false, 47156, EQUIP_NO_CHANGE, 48711); - - m_uiSummonPetTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - DoCast(SPELL_CALL_PET); - } + public: + mob_toc_hunter() : CreatureScript("mob_toc_hunter") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_hunterAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; - - if (m_uiDisengageTimer <= uiDiff) - { - if (EnemiesInRange(10.0f) > 3) - DoCast(SPELL_DISENGAGE); - m_uiDisengageTimer = urand(12*IN_MILLISECONDS, 20*IN_MILLISECONDS); - } else m_uiDisengageTimer -= uiDiff; + mob_toc_hunterAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_AIMED_SHOT, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DETERRENCE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DISENGAGE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_EXPLOSIVE_SHOT, urand(3*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FROST_TRAP, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_STEADY_SHOT, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_WING_CLIP, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_WYVERN_STING, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + SetEquipmentSlots(false, 47156, EQUIP_NO_CHANGE, 48711); + } - if (m_uiDeterrenceTimer <= uiDiff) + void EnterCombat(Unit* who) { - if (HealthBelowPct(20)) - DoCast(SPELL_DETERRENCE); - m_uiDeterrenceTimer = urand(20*IN_MILLISECONDS, 120*IN_MILLISECONDS); - } else m_uiDeterrenceTimer -= uiDiff; + boss_faction_championsAI::EnterCombat(who); + DoCast(SPELL_CALL_PET); + } - if (m_uiWyvernStingTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - DoCastVictim(SPELL_WYVERN_STING); - m_uiWyvernStingTimer = urand(7*IN_MILLISECONDS, 60*IN_MILLISECONDS); - } else m_uiWyvernStingTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiFrostTrapTimer <= uiDiff) - { - DoCast(SPELL_FROST_TRAP); - m_uiFrostTrapTimer = urand(12*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiFrostTrapTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiWingClipTimer <= uiDiff) - { - if (me->GetDistance2d(me->getVictim()) < 5.0f) - DoCastVictim(SPELL_WING_CLIP); - m_uiWingClipTimer = urand(4*IN_MILLISECONDS, 8*IN_MILLISECONDS); - } else m_uiWingClipTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiSummonPetTimer <= uiDiff) - { - m_uiSummonPetTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiSummonPetTimer -= uiDiff; - - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 3)) + while (uint32 eventId = events.ExecuteEvent()) { - case 0: case 1: - DoCastVictim(SPELL_SHOOT); - break; - case 2: - DoCastVictim(SPELL_EXPLOSIVE_SHOT); - break; - case 3: - DoCastVictim(SPELL_AIMED_SHOT); - break; + switch (eventId) + { + case EVENT_AIMED_SHOT: + DoCastVictim(SPELL_AIMED_SHOT); + events.ScheduleEvent(EVENT_AIMED_SHOT, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_DETERRENCE: + if (HealthBelowPct(30)) + { + DoCast(SPELL_DETERRENCE); + events.RescheduleEvent(EVENT_DETERRENCE, 150*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_DETERRENCE, 10*IN_MILLISECONDS); + return; + case EVENT_DISENGAGE: + if (EnemiesInRange(10.0f) >= 2) + DoCast(SPELL_DISENGAGE); + events.ScheduleEvent(EVENT_DISENGAGE, 30*IN_MILLISECONDS); + return; + case EVENT_EXPLOSIVE_SHOT: + DoCastVictim(SPELL_EXPLOSIVE_SHOT); + events.ScheduleEvent(EVENT_EXPLOSIVE_SHOT, urand(6*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + return; + case EVENT_FROST_TRAP: + if (EnemiesInRange(10.0f) >= 2) + DoCastAOE(SPELL_FROST_TRAP); + events.ScheduleEvent(EVENT_FROST_TRAP, 30*IN_MILLISECONDS); + return; + case EVENT_STEADY_SHOT: + DoCastVictim(SPELL_STEADY_SHOT); + events.ScheduleEvent(EVENT_STEADY_SHOT, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_WING_CLIP: + if (me->GetDistance2d(me->getVictim()) < 6.0f) + DoCastVictim(SPELL_WING_CLIP); + events.ScheduleEvent(EVENT_WING_CLIP, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_WYVERN_STING: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) + DoCast(target, SPELL_WYVERN_STING); + events.ScheduleEvent(EVENT_WYVERN_STING, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + DoSpellAttackIfReady(SPELL_SHOOT); + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_hunterAI (creature); } - }; - -}; - -enum eBoomkinSpells -{ - SPELL_CYCLONE = 65859, //6s - SPELL_ENTANGLING_ROOTS = 65857, //10s - SPELL_FAERIE_FIRE = 65863, - SPELL_FORCE_OF_NATURE = 65861, //180s - SPELL_INSECT_SWARM = 65855, - SPELL_MOONFIRE = 65856, //5s - SPELL_STARFIRE = 65854, - SPELL_WRATH = 65862, }; class mob_toc_boomkin : public CreatureScript { -public: - mob_toc_boomkin() : CreatureScript("mob_toc_boomkin") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_boomkinAI (creature); - } - - struct mob_toc_boomkinAI : public boss_faction_championsAI - { - mob_toc_boomkinAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} - - uint32 m_uiBarkskinTimer; - uint32 m_uiCycloneTimer; - uint32 m_uiEntanglingRootsTimer; - uint32 m_uiFaerieFireTimer; - uint32 m_uiCommonTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiBarkskinTimer = urand(5*IN_MILLISECONDS, 120*IN_MILLISECONDS); - m_uiCycloneTimer = urand(5*IN_MILLISECONDS, 40*IN_MILLISECONDS); - m_uiEntanglingRootsTimer = urand(5*IN_MILLISECONDS, 40*IN_MILLISECONDS); - m_uiFaerieFireTimer = urand(10*IN_MILLISECONDS, 40*IN_MILLISECONDS); - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - SetEquipmentSlots(false, 50966, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - } + public: + mob_toc_boomkin() : CreatureScript("mob_toc_boomkin") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_boomkinAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_boomkinAI(Creature* creature) : boss_faction_championsAI(creature, AI_RANGED) {} - if (m_uiBarkskinTimer <= uiDiff) + void Reset() { - if (HealthBelowPct(50)) - DoCast(me, SPELL_BARKSKIN); - m_uiBarkskinTimer = urand(5*IN_MILLISECONDS, 120*IN_MILLISECONDS); - } else m_uiBarkskinTimer -= uiDiff; + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_CYCLONE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ENTANGLING_ROOTS, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FAERIE_FIRE, urand(2*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FORCE_OF_NATURE, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_INSECT_SWARM, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_MOONFIRE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_STARFIRE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DPS_BARKSKIN, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); - if (m_uiCycloneTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_CYCLONE); - m_uiCycloneTimer = urand(5*IN_MILLISECONDS, 40*IN_MILLISECONDS); - } else m_uiCycloneTimer -= uiDiff; + SetEquipmentSlots(false, 50966, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + } - if (m_uiEntanglingRootsTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_ENTANGLING_ROOTS); - m_uiEntanglingRootsTimer = urand(5*IN_MILLISECONDS, 40*IN_MILLISECONDS); - } else m_uiEntanglingRootsTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiFaerieFireTimer <= uiDiff) - { - DoCastVictim(SPELL_FAERIE_FIRE); - m_uiFaerieFireTimer = urand(10*IN_MILLISECONDS, 40*IN_MILLISECONDS); - } else m_uiFaerieFireTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiCommonTimer <= uiDiff) - { - switch (urand(0, 6)) + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) { - case 0: case 1: - DoCastVictim(SPELL_MOONFIRE); - break; - case 2: - DoCastVictim(SPELL_INSECT_SWARM); - break; - case 3: - DoCastVictim(SPELL_STARFIRE); - break; - case 4: case 5: case 6: - DoCastVictim(SPELL_WRATH); - break; + switch (eventId) + { + case EVENT_CYCLONE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) + DoCast(target, SPELL_CYCLONE); + events.ScheduleEvent(EVENT_CYCLONE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_ENTANGLING_ROOTS: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30.0f, true)) + DoCast(target, SPELL_ENTANGLING_ROOTS); + events.ScheduleEvent(EVENT_ENTANGLING_ROOTS, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_FAERIE_FIRE: + DoCastVictim(SPELL_FAERIE_FIRE); + events.ScheduleEvent(EVENT_FAERIE_FIRE, urand(30*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + return; + case EVENT_FORCE_OF_NATURE: + DoCastVictim(SPELL_FORCE_OF_NATURE); + events.ScheduleEvent(EVENT_FORCE_OF_NATURE, 180*IN_MILLISECONDS); + return; + case EVENT_INSECT_SWARM: + DoCastVictim(SPELL_INSECT_SWARM); + events.ScheduleEvent(EVENT_INSECT_SWARM, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_MOONFIRE: + DoCastVictim(SPELL_MOONFIRE); + events.ScheduleEvent(EVENT_MOONFIRE, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_STARFIRE: + DoCastVictim(SPELL_STARFIRE); + events.ScheduleEvent(EVENT_STARFIRE, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_DPS_BARKSKIN: + if (HealthBelowPct(30)) + { + DoCast(me, SPELL_BARKSKIN); + events.RescheduleEvent(EVENT_DPS_BARKSKIN, 60*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_DPS_BARKSKIN, 5*IN_MILLISECONDS); + return; + default: + return; + } } - m_uiCommonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiCommonTimer -= uiDiff; + DoSpellAttackIfReady(SPELL_WRATH); + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_boomkinAI (creature); } - }; - }; /******************************************************************** MELEE ********************************************************************/ -enum eWarriorSpells -{ - SPELL_BLADESTORM = 65947, - SPELL_INTIMIDATING_SHOUT = 65930, - SPELL_MORTAL_STRIKE = 65926, - SPELL_CHARGE = 68764, - SPELL_DISARM = 65935, - SPELL_OVERPOWER = 65924, - SPELL_SUNDER_ARMOR = 65936, - SPELL_SHATTERING_THROW = 65940, - SPELL_RETALIATION = 65932, -}; - class mob_toc_warrior : public CreatureScript { -public: - mob_toc_warrior() : CreatureScript("mob_toc_warrior") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_warriorAI (creature); - } - - struct mob_toc_warriorAI : public boss_faction_championsAI - { - mob_toc_warriorAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} - - uint32 m_uiBladestormTimer; - uint32 m_uiIntimidatingShoutTimer; - uint32 m_uiMortalStrikeTimer; - uint32 m_uiSunderArmorTimer; - uint32 m_uiChargeTimer; - uint32 m_uiRetaliationTimer; - uint32 m_uiOverpowerTimer; - uint32 m_uiShatteringThrowTimer; - uint32 m_uiDisarmTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiBladestormTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); - m_uiIntimidatingShoutTimer = urand(10*IN_MILLISECONDS, 60*IN_MILLISECONDS); - m_uiMortalStrikeTimer = urand(6*IN_MILLISECONDS, 25*IN_MILLISECONDS); - m_uiSunderArmorTimer = urand(5*IN_MILLISECONDS, 25*IN_MILLISECONDS); - m_uiChargeTimer = urand(3*IN_MILLISECONDS, 25*IN_MILLISECONDS); - m_uiRetaliationTimer = urand(30*IN_MILLISECONDS, 60*IN_MILLISECONDS); - m_uiOverpowerTimer = urand(30*IN_MILLISECONDS, 90*IN_MILLISECONDS); - m_uiShatteringThrowTimer = urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS); - m_uiDisarmTimer = urand(20*IN_MILLISECONDS, 80*IN_MILLISECONDS); - SetEquipmentSlots(false, 47427, 46964, EQUIP_NO_CHANGE); - } + public: + mob_toc_warrior() : CreatureScript("mob_toc_warrior") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_warriorAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; - - if (m_uiBladestormTimer <= uiDiff) - { - DoCastVictim(SPELL_BLADESTORM); - m_uiBladestormTimer = urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiBladestormTimer -= uiDiff; - - if (m_uiIntimidatingShoutTimer <= uiDiff) - { - DoCast(me, SPELL_INTIMIDATING_SHOUT); - m_uiIntimidatingShoutTimer = urand(10*IN_MILLISECONDS, 60*IN_MILLISECONDS); - } else m_uiIntimidatingShoutTimer -= uiDiff; - - if (m_uiMortalStrikeTimer <= uiDiff) - { - DoCastVictim(SPELL_MORTAL_STRIKE); - m_uiMortalStrikeTimer = urand(6*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiMortalStrikeTimer -= uiDiff; - - if (m_uiSunderArmorTimer <= uiDiff) - { - DoCastVictim(SPELL_SUNDER_ARMOR); - m_uiSunderArmorTimer = urand(5*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiSunderArmorTimer -= uiDiff; - - if (m_uiChargeTimer <= uiDiff) - { - DoCastVictim(SPELL_CHARGE); - m_uiChargeTimer = urand(3*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiChargeTimer -= uiDiff; + mob_toc_warriorAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_BLADESTORM, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_INTIMIDATING_SHOUT, urand(20*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_MORTAL_STRIKE, urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_WARR_CHARGE, 1*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_DISARM, urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_OVERPOWER, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SUNDER_ARMOR, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SHATTERING_THROW, urand(20*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_RETALIATION, urand(5*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + SetEquipmentSlots(false, 47427, 46964, EQUIP_NO_CHANGE); + } - if (m_uiRetaliationTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - DoCastVictim(SPELL_RETALIATION); - m_uiRetaliationTimer = urand(30*IN_MILLISECONDS, 60*IN_MILLISECONDS); - } else m_uiRetaliationTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiOverpowerTimer <= uiDiff) - { - DoCastVictim(SPELL_OVERPOWER); - m_uiOverpowerTimer = urand(30*IN_MILLISECONDS, 90*IN_MILLISECONDS); - } else m_uiOverpowerTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiShatteringThrowTimer <= uiDiff) - { - DoCastVictim(SPELL_SHATTERING_THROW); - m_uiShatteringThrowTimer = urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiShatteringThrowTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiDisarmTimer <= uiDiff) - { - DoCastVictim(SPELL_DISARM); - m_uiDisarmTimer = urand(20*IN_MILLISECONDS, 80*IN_MILLISECONDS); - } else m_uiDisarmTimer -= uiDiff; + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_BLADESTORM: + DoCastVictim(SPELL_BLADESTORM); + events.ScheduleEvent(EVENT_BLADESTORM, 150*IN_MILLISECONDS); + return; + case EVENT_INTIMIDATING_SHOUT: + DoCastAOE(SPELL_INTIMIDATING_SHOUT); + events.ScheduleEvent(EVENT_INTIMIDATING_SHOUT, 120*IN_MILLISECONDS); + return; + case EVENT_MORTAL_STRIKE: + DoCastVictim(SPELL_MORTAL_STRIKE); + events.ScheduleEvent(EVENT_MORTAL_STRIKE, urand(10*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_WARR_CHARGE: + DoCastVictim(SPELL_CHARGE); + events.ScheduleEvent(EVENT_WARR_CHARGE, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_DISARM: + DoCastVictim(SPELL_DISARM); + events.ScheduleEvent(EVENT_DISARM, urand(15*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + return; + case EVENT_OVERPOWER: + DoCastVictim(SPELL_OVERPOWER); + events.ScheduleEvent(EVENT_OVERPOWER, urand(20*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + return; + case EVENT_SUNDER_ARMOR: + DoCastVictim(SPELL_SUNDER_ARMOR); + events.ScheduleEvent(EVENT_SUNDER_ARMOR, urand(2*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + return; + case EVENT_SHATTERING_THROW: + if (me->getVictim()->HasAuraWithMechanic(1<<MECHANIC_IMMUNE_SHIELD)) + { + DoCastVictim(SPELL_SHATTERING_THROW); + events.RescheduleEvent(EVENT_SHATTERING_THROW, 5*MINUTE*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_SHATTERING_THROW, 3*IN_MILLISECONDS); + return; + case EVENT_RETALIATION: + if (HealthBelowPct(50)) + { + DoCast(SPELL_RETALIATION); + events.RescheduleEvent(EVENT_RETALIATION, 5*MINUTE*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_RETALIATION, 5*IN_MILLISECONDS); + return; + default: + return; + } + } + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_warriorAI (creature); } - }; - -}; - -enum eDeathKnightSpells -{ - SPELL_CHAINS_OF_ICE = 66020, //8sec - SPELL_DEATH_COIL = 66019, //5sec - SPELL_DEATH_GRIP = 66017, //35sec - SPELL_FROST_STRIKE = 66047, //6sec - SPELL_ICEBOUND_FORTITUDE = 66023, //1min - SPELL_ICY_TOUCH = 66021, //8sec - SPELL_STRANGULATE = 66018, //2min }; class mob_toc_dk : public CreatureScript { -public: - mob_toc_dk() : CreatureScript("mob_toc_dk") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_dkAI (creature); - } - - struct mob_toc_dkAI : public boss_faction_championsAI - { - mob_toc_dkAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} - - uint32 m_uiIceboundFortitudeTimer; - uint32 m_uiChainsOfIceTimer; - uint32 m_uiDeathCoilTimer; - uint32 m_uiStrangulateTimer; - uint32 m_uiFrostStrikeTimer; - uint32 m_uiIcyTouchTimer; - uint32 m_uiDeathGripTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiIceboundFortitudeTimer = urand(5*IN_MILLISECONDS, 90*IN_MILLISECONDS); - m_uiChainsOfIceTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiDeathCoilTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiStrangulateTimer = urand(10*IN_MILLISECONDS, 90*IN_MILLISECONDS); - m_uiFrostStrikeTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiIcyTouchTimer = urand(8*IN_MILLISECONDS, 12*IN_MILLISECONDS); - m_uiDeathGripTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - SetEquipmentSlots(false, 47518, 51021, EQUIP_NO_CHANGE); - } + public: + mob_toc_dk() : CreatureScript("mob_toc_dk") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_dkAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; - - if (m_uiIceboundFortitudeTimer <= uiDiff) - { - if (HealthBelowPct(50)) - DoCast(me, SPELL_ICEBOUND_FORTITUDE); - m_uiIceboundFortitudeTimer = urand(5*IN_MILLISECONDS, 90*IN_MILLISECONDS); - } else m_uiIceboundFortitudeTimer -= uiDiff; - - if (m_uiChainsOfIceTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_CHAINS_OF_ICE); - m_uiChainsOfIceTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiChainsOfIceTimer -= uiDiff; - - if (m_uiDeathCoilTimer <= uiDiff) - { - DoCastVictim(SPELL_DEATH_COIL); - m_uiDeathCoilTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiDeathCoilTimer -= uiDiff; + mob_toc_dkAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_CHAINS_OF_ICE, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DEATH_COIL, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DEATH_GRIP, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_FROST_STRIKE, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ICEBOUND_FORTITUDE, urand(25*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ICY_TOUCH, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_STRANGULATE, urand(5*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + SetEquipmentSlots(false, 47518, 51021, EQUIP_NO_CHANGE); + } - if (m_uiStrangulateTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (Unit* target = SelectEnemyCaster(false)) - DoCast(target, SPELL_STRANGULATE); - m_uiStrangulateTimer = urand(10*IN_MILLISECONDS, 90*IN_MILLISECONDS); - } else m_uiStrangulateTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiFrostStrikeTimer <= uiDiff) - { - DoCastVictim(SPELL_FROST_STRIKE); - m_uiFrostStrikeTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiFrostStrikeTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiIcyTouchTimer <= uiDiff) - { - DoCastVictim(SPELL_ICY_TOUCH); - m_uiIcyTouchTimer = urand(8*IN_MILLISECONDS, 12*IN_MILLISECONDS); - } else m_uiIcyTouchTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiDeathGripTimer <= uiDiff) - { - if (me->IsInRange(me->getVictim(), 10.0f, 30.0f, false)) - DoCastVictim(SPELL_DEATH_GRIP); - m_uiDeathGripTimer = urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiDeathGripTimer -= uiDiff; + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_CHAINS_OF_ICE: + DoCastVictim(SPELL_CHAINS_OF_ICE); + events.ScheduleEvent(EVENT_CHAINS_OF_ICE, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_DEATH_COIL: + DoCastVictim(SPELL_DEATH_COIL); + events.ScheduleEvent(EVENT_DEATH_COIL, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_DEATH_GRIP: + if (me->IsInRange(me->getVictim(), 5.0f, 30.0f, false)) + { + DoCast(me->getVictim(), SPELL_DEATH_GRIP); + events.RescheduleEvent(EVENT_DEATH_GRIP, 35*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_DEATH_GRIP, 3*IN_MILLISECONDS); + return; + case EVENT_FROST_STRIKE: + DoCastVictim(SPELL_FROST_STRIKE); + events.ScheduleEvent(EVENT_FROST_STRIKE, urand(6*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + return; + case EVENT_ICEBOUND_FORTITUDE: + if (HealthBelowPct(50)) + { + DoCast(SPELL_ICEBOUND_FORTITUDE); + events.RescheduleEvent(EVENT_ICEBOUND_FORTITUDE, 60*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_ICEBOUND_FORTITUDE, 5*IN_MILLISECONDS); + return; + case EVENT_ICY_TOUCH: + DoCastVictim(SPELL_ICY_TOUCH); + events.ScheduleEvent(EVENT_ICY_TOUCH, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_STRANGULATE: + if (Unit* target = SelectEnemyCaster(false)) + { + DoCast(target, SPELL_STRANGULATE); + events.RescheduleEvent(EVENT_STRANGULATE, 120*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_STRANGULATE, 5*IN_MILLISECONDS); + return; + default: + return; + } + } + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_dkAI (creature); } - }; - -}; - -enum eRogueSpells -{ - SPELL_FAN_OF_KNIVES = 65955, //2sec - SPELL_BLIND = 65960, //2min - SPELL_CLOAK = 65961, //90sec - SPELL_BLADE_FLURRY = 65956, //2min - SPELL_SHADOWSTEP = 66178, //30sec - SPELL_HEMORRHAGE = 65954, - SPELL_EVISCERATE = 65957, }; class mob_toc_rogue : public CreatureScript { -public: - mob_toc_rogue() : CreatureScript("mob_toc_rogue") { } + public: + mob_toc_rogue() : CreatureScript("mob_toc_rogue") { } - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_rogueAI (creature); - } + struct mob_toc_rogueAI : public boss_faction_championsAI + { + mob_toc_rogueAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_FAN_OF_KNIVES, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_BLIND, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_CLOAK, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_BLADE_FLURRY, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SHADOWSTEP, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HEMORRHAGE, urand(3*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_EVISCERATE, urand(20*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_WOUND_POISON, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + SetEquipmentSlots(false, 47422, 49982, EQUIP_NO_CHANGE); + me->setPowerType(POWER_ENERGY); + me->SetMaxPower(POWER_ENERGY, 100); + } - struct mob_toc_rogueAI : public boss_faction_championsAI - { - mob_toc_rogueAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; + + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - uint32 m_uiFanOfKnivesTimer; - uint32 m_uiHemorrhageTimer; - uint32 m_uiEviscerateTimer; - uint32 m_uiShadowstepTimer; - uint32 m_uiBlindTimer; - uint32 m_uiCloakTimer; - uint32 m_uiBladeFlurryTimer; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_FAN_OF_KNIVES: + if (EnemiesInRange(10.0f) >= 2) + DoCastAOE(SPELL_FAN_OF_KNIVES); + events.ScheduleEvent(EVENT_FAN_OF_KNIVES, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_BLIND: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) + DoCast(target, SPELL_BLIND); + events.ScheduleEvent(EVENT_BLIND, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_CLOAK: + if (HealthBelowPct(50)) + { + DoCast(SPELL_CLOAK); + events.RescheduleEvent(EVENT_CLOAK, 90*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_CLOAK, 5*IN_MILLISECONDS); + return; + case EVENT_BLADE_FLURRY: + if (EnemiesInRange(10.0f) >= 2) + { + DoCast(SPELL_BLADE_FLURRY); + events.RescheduleEvent(EVENT_BLADE_FLURRY, 120*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_BLADE_FLURRY, 5*IN_MILLISECONDS); + return; + case EVENT_SHADOWSTEP: + if (me->IsInRange(me->getVictim(), 10.0f, 40.0f, false)) + { + DoCast(me->getVictim(), SPELL_SHADOWSTEP); + events.RescheduleEvent(EVENT_SHADOWSTEP, 30*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_SHADOWSTEP, 5*IN_MILLISECONDS); + return; + case EVENT_HEMORRHAGE: + DoCastVictim(SPELL_HEMORRHAGE); + events.ScheduleEvent(EVENT_HEMORRHAGE, urand(3*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + return; + case EVENT_EVISCERATE: + DoCastVictim(SPELL_EVISCERATE); + events.ScheduleEvent(EVENT_EVISCERATE, urand(30*IN_MILLISECONDS, 40*IN_MILLISECONDS)); + return; + case EVENT_WOUND_POISON: + DoCastVictim(SPELL_WOUND_POISON); + events.ScheduleEvent(EVENT_WOUND_POISON, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + default: + return; + } + } + } + }; - void Reset() + CreatureAI* GetAI(Creature* creature) const { - boss_faction_championsAI::Reset(); - m_uiFanOfKnivesTimer = urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS); - m_uiHemorrhageTimer = urand(5*IN_MILLISECONDS, 8*IN_MILLISECONDS); - m_uiEviscerateTimer = urand(15*IN_MILLISECONDS, 20*IN_MILLISECONDS); - m_uiShadowstepTimer = urand(10*IN_MILLISECONDS, 80*IN_MILLISECONDS); - m_uiBlindTimer = urand(7*IN_MILLISECONDS, 8*IN_MILLISECONDS); - m_uiCloakTimer = urand(20*IN_MILLISECONDS, 120*IN_MILLISECONDS); - m_uiBladeFlurryTimer = urand(12*IN_MILLISECONDS, 120*IN_MILLISECONDS); - SetEquipmentSlots(false, 47422, 49982, EQUIP_NO_CHANGE); + return new mob_toc_rogueAI (creature); } +}; + +class mob_toc_enh_shaman : public CreatureScript +{ + public: + mob_toc_enh_shaman() : CreatureScript("mob_toc_enh_shaman") { } - void UpdateAI(const uint32 uiDiff) + struct mob_toc_enh_shamanAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_enh_shamanAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_DPS_EARTH_SHOCK, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_LAVA_LASH, urand(3*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_STORMSTRIKE, urand(2*IN_MILLISECONDS, 5*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DPS_BLOODLUST_HEROISM, 20*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_DEPLOY_TOTEM, 1*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_WINDFURY, urand(20*IN_MILLISECONDS, 50*IN_MILLISECONDS)); + + _totemCount = 0; + _totemOldCenterX = me->GetPositionX(); + _totemOldCenterY = me->GetPositionY(); + SetEquipmentSlots(false, 51803, 48013, EQUIP_NO_CHANGE); + summons.DespawnAll(); + } - if (m_uiFanOfKnivesTimer <= uiDiff) + void JustSummoned(Creature* summoned) { - if (EnemiesInRange(15.0f) > 2) - DoCastAOE(SPELL_FAN_OF_KNIVES); - m_uiFanOfKnivesTimer = urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS); - } else m_uiFanOfKnivesTimer -= uiDiff; + summons.Summon(summoned); + } - if (m_uiHemorrhageTimer <= uiDiff) + void SummonedCreatureDespawn(Creature* /*pSummoned*/) { - DoCastVictim(SPELL_HEMORRHAGE); - m_uiHemorrhageTimer = urand(5*IN_MILLISECONDS, 8*IN_MILLISECONDS); - } else m_uiHemorrhageTimer -= uiDiff; + --_totemCount; + } - if (m_uiEviscerateTimer <= uiDiff) + void DeployTotem() { - DoCastVictim(SPELL_EVISCERATE); - m_uiEviscerateTimer = urand(15*IN_MILLISECONDS, 20*IN_MILLISECONDS); - } else m_uiEviscerateTimer -= uiDiff; + _totemCount = 4; + _totemOldCenterX = me->GetPositionX(); + _totemOldCenterY = me->GetPositionY(); + /* + -Windfury (16% melee haste) + -Grounding (redirects one harmful magic spell to the totem) - if (m_uiShadowstepTimer <= uiDiff) - { - if (me->IsInRange(me->getVictim(), 10.0f, 40.0f)) - DoCastVictim(SPELL_SHADOWSTEP); - m_uiShadowstepTimer = urand(10*IN_MILLISECONDS, 80*IN_MILLISECONDS); - } else m_uiShadowstepTimer -= uiDiff; + -Healing Stream (unable to find amount of healing in our logs) - if (m_uiBlindTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1)) - if (me->IsInRange(target, 0.0f, 15.0f, false)) - DoCast(target, SPELL_BLIND); - m_uiBlindTimer = urand(7*IN_MILLISECONDS, 8*IN_MILLISECONDS); - } else m_uiBlindTimer -= uiDiff; + -Tremor (prevents fear effects) + -Strength of Earth (155 strength and agil for the opposing team) - if (m_uiCloakTimer <= uiDiff) - { - if (HealthBelowPct(50)) - DoCast(me, SPELL_CLOAK); - m_uiCloakTimer = urand(20*IN_MILLISECONDS, 120*IN_MILLISECONDS); - } else m_uiCloakTimer -= uiDiff; + -Searing (average ~3500 damage on a random target every ~3.5 seconds) + */ + } - if (m_uiBladeFlurryTimer <= uiDiff) + void JustDied(Unit* killer) { - DoCastVictim(SPELL_BLADE_FLURRY); - m_uiBladeFlurryTimer = urand(12*IN_MILLISECONDS, 120*IN_MILLISECONDS); - } else m_uiBladeFlurryTimer -= uiDiff; - - boss_faction_championsAI::UpdateAI(uiDiff); - } - }; - -}; - -enum eEnhShamanSpells -{ - SPELL_EARTH_SHOCK_ENH = 65973, - SPELL_LAVA_LASH = 65974, - SPELL_STORMSTRIKE = 65970, -}; - -class mob_toc_enh_shaman : public CreatureScript -{ -public: - mob_toc_enh_shaman() : CreatureScript("mob_toc_enh_shaman") { } + boss_faction_championsAI::JustDied(killer); + summons.DespawnAll(); + } - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_enh_shamanAI (creature); - } + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; - struct mob_toc_enh_shamanAI : public boss_faction_championsAI - { - mob_toc_enh_shamanAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE), Summons(me) {} + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - SummonList Summons; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - uint32 m_uiHeroismOrBloodlustTimer; - uint32 m_uiEarthShockTimer; - uint32 m_uiStormstrikeTimer; - uint32 m_uiLavaLashTimer; - uint32 m_uiDeployTotemTimer; - uint8 m_uiTotemCount; - float m_fTotemOldCenterX, m_fTotemOldCenterY; + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_DPS_EARTH_SHOCK: + if (Unit* target = SelectEnemyCaster(true)) + DoCast(target, SPELL_EARTH_SHOCK); + events.ScheduleEvent(EVENT_DPS_EARTH_SHOCK, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_LAVA_LASH: + DoCastVictim(SPELL_LAVA_LASH); + events.ScheduleEvent(EVENT_LAVA_LASH, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_STORMSTRIKE: + DoCastVictim(SPELL_STORMSTRIKE); + events.ScheduleEvent(EVENT_STORMSTRIKE, urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + return; + case EVENT_DPS_BLOODLUST_HEROISM: + if (me->getFaction()) //Am i alliance? + { + if (!me->HasAura(AURA_EXHAUSTION)) + DoCastAOE(SPELL_HEROISM); + } + else + { + if (!me->HasAura(AURA_SATED)) + DoCastAOE(SPELL_BLOODLUST); + } + events.ScheduleEvent(EVENT_DPS_BLOODLUST_HEROISM, 5*MINUTE*IN_MILLISECONDS); + return; + case EVENT_DEPLOY_TOTEM: + if (_totemCount < 4 || me->GetDistance2d(_totemOldCenterX, _totemOldCenterY) > 20.0f) + DeployTotem(); + events.ScheduleEvent(EVENT_DEPLOY_TOTEM, 1*IN_MILLISECONDS); + return; + case EVENT_WINDFURY: + DoCastVictim(SPELL_WINDFURY); + events.ScheduleEvent(EVENT_WINDFURY, urand(20*IN_MILLISECONDS, 60*IN_MILLISECONDS)); + return; + default: + return; + } + } + } + private: + uint8 _totemCount; + float _totemOldCenterX, _totemOldCenterY; + }; - void Reset() + CreatureAI* GetAI(Creature* creature) const { - boss_faction_championsAI::Reset(); - m_uiHeroismOrBloodlustTimer = urand(25*IN_MILLISECONDS, 60*IN_MILLISECONDS); - m_uiEarthShockTimer = urand(5*IN_MILLISECONDS, 8*IN_MILLISECONDS); - m_uiStormstrikeTimer = urand(5*IN_MILLISECONDS, 90*IN_MILLISECONDS); - m_uiLavaLashTimer = urand(5*IN_MILLISECONDS, 8*IN_MILLISECONDS); - m_uiDeployTotemTimer = urand(1*IN_MILLISECONDS, 3*IN_MILLISECONDS); - m_uiTotemCount = 0; - m_fTotemOldCenterX = me->GetPositionX(); - m_fTotemOldCenterY = me->GetPositionY(); - SetEquipmentSlots(false, 51803, 48013, EQUIP_NO_CHANGE); - Summons.DespawnAll(); + return new mob_toc_enh_shamanAI (creature); } +}; - void JustSummoned(Creature* summoned) - { - Summons.Summon(summoned); - } +class mob_toc_retro_paladin : public CreatureScript +{ + public: + mob_toc_retro_paladin() : CreatureScript("mob_toc_retro_paladin") { } - void SummonedCreatureDespawn(Creature* /*pSummoned*/) + struct mob_toc_retro_paladinAI : public boss_faction_championsAI { - --m_uiTotemCount; - } + mob_toc_retro_paladinAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} + + void Reset() + { + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_AVENGING_WRATH, urand(25*IN_MILLISECONDS, 35*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_CRUSADER_STRIKE, urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DIVINE_STORM, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_HAMMER_OF_JUSTICE_RET, urand(10*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_JUDGEMENT_OF_COMMAND, urand(5*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_REPENTANCE, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DPS_HAND_OF_PROTECTION, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_DPS_DIVINE_SHIELD, urand(20*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + SetEquipmentSlots(false, 47519, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); + } - void DeployTotem() - { - m_uiTotemCount = 4; - m_fTotemOldCenterX = me->GetPositionX(); - m_fTotemOldCenterY = me->GetPositionY(); - /* - -Windfury (16% melee haste) - -Grounding (redirects one harmful magic spell to the totem) + void EnterCombat(Unit* who) + { + boss_faction_championsAI::EnterCombat(who); + DoCast(SPELL_SEAL_OF_COMMAND); + } - -Healing Stream (unable to find amount of healing in our logs) + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; - -Tremor (prevents fear effects) - -Strength of Earth (155 strength and agil for the opposing team) + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - -Searing (average ~3500 damage on a random target every ~3.5 seconds) - */ - } + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_AVENGING_WRATH: + DoCast(SPELL_AVENGING_WRATH); + events.ScheduleEvent(EVENT_AVENGING_WRATH, 180*IN_MILLISECONDS); + return; + case EVENT_CRUSADER_STRIKE: + DoCastVictim(SPELL_CRUSADER_STRIKE); + events.ScheduleEvent(EVENT_CRUSADER_STRIKE, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_DIVINE_STORM: + if (EnemiesInRange(10.0f) >= 2) + DoCast(SPELL_DIVINE_STORM); + events.ScheduleEvent(EVENT_DIVINE_STORM, urand(10*IN_MILLISECONDS, 20*IN_MILLISECONDS)); + return; + case EVENT_HAMMER_OF_JUSTICE_RET: + DoCastVictim(SPELL_HAMMER_OF_JUSTICE_RET); + events.ScheduleEvent(EVENT_HAMMER_OF_JUSTICE_RET, 40*IN_MILLISECONDS); + return; + case EVENT_JUDGEMENT_OF_COMMAND: + DoCastVictim(SPELL_JUDGEMENT_OF_COMMAND); + events.ScheduleEvent(EVENT_JUDGEMENT_OF_COMMAND, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_REPENTANCE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me))) + DoCast(target, SPELL_REPENTANCE); + events.ScheduleEvent(EVENT_REPENTANCE, 60*IN_MILLISECONDS); + return; + case EVENT_DPS_HAND_OF_PROTECTION: + if (Unit* target = DoSelectLowestHpFriendly(30.0f)) + { + if (!target->HasAura(SPELL_FORBEARANCE)) + { + DoCast(target, SPELL_HAND_OF_PROTECTION); + events.RescheduleEvent(EVENT_DPS_HAND_OF_PROTECTION, 5*MINUTE*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_DPS_HAND_OF_PROTECTION, 5*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_DPS_HAND_OF_PROTECTION, 5*IN_MILLISECONDS); + return; + case EVENT_DPS_DIVINE_SHIELD: + if (HealthBelowPct(30) && !me->HasAura(SPELL_FORBEARANCE)) + { + DoCast(me, SPELL_DIVINE_SHIELD); + events.RescheduleEvent(EVENT_DPS_DIVINE_SHIELD, 5*MINUTE*IN_MILLISECONDS); + } + else + events.RescheduleEvent(EVENT_DPS_DIVINE_SHIELD, 5*IN_MILLISECONDS); + return; + default: + return; + } + } + } + }; - void JustDied(Unit* killer) + CreatureAI* GetAI(Creature* creature) const { - boss_faction_championsAI::JustDied(killer); - Summons.DespawnAll(); + return new mob_toc_retro_paladinAI (creature); } +}; - void UpdateAI(const uint32 uiDiff) +class mob_toc_pet_warlock : public CreatureScript +{ + public: + mob_toc_pet_warlock() : CreatureScript("mob_toc_pet_warlock") { } + + struct mob_toc_pet_warlockAI : public boss_faction_championsAI { - if (!UpdateVictim()) - return; + mob_toc_pet_warlockAI(Creature* creature) : boss_faction_championsAI(creature, AI_PET) {} - if (m_uiHeroismOrBloodlustTimer <= uiDiff) + void Reset() { - if (me->getFaction()) //Am i alliance? - { - if (!me->HasAura(AURA_EXHAUSTION)) - DoCastAOE(SPELL_HEROISM); - } - else - if (!me->HasAura(AURA_SATED)) - DoCastAOE(SPELL_BLOODLUST); - m_uiHeroismOrBloodlustTimer = urand(25*IN_MILLISECONDS, 60*IN_MILLISECONDS); - } else m_uiHeroismOrBloodlustTimer -= uiDiff; + boss_faction_championsAI::Reset(); + events.ScheduleEvent(EVENT_DEVOUR_MAGIC, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_SPELL_LOCK, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + } - if (m_uiEarthShockTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - DoCastVictim(SPELL_EARTH_SHOCK_ENH); - m_uiEarthShockTimer = urand(5*IN_MILLISECONDS, 8*IN_MILLISECONDS); - } else m_uiEarthShockTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiStormstrikeTimer <= uiDiff) - { - DoCastVictim(SPELL_STORMSTRIKE); - m_uiStormstrikeTimer = urand(5*IN_MILLISECONDS, 90*IN_MILLISECONDS); - } else m_uiStormstrikeTimer -= uiDiff; + events.Update(diff); + boss_faction_championsAI::UpdateAI(diff); - if (m_uiLavaLashTimer <= uiDiff) - { - DoCastVictim(SPELL_LAVA_LASH); - m_uiLavaLashTimer = urand(5*IN_MILLISECONDS, 8*IN_MILLISECONDS); - } else m_uiLavaLashTimer -= uiDiff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (m_uiDeployTotemTimer <= uiDiff) - { - if (m_uiTotemCount < 4 || me->GetDistance2d(m_fTotemOldCenterX, m_fTotemOldCenterY) > 20.0f) - DeployTotem(); - m_uiDeployTotemTimer = urand(1*IN_MILLISECONDS, 3*IN_MILLISECONDS); - } else m_uiDeployTotemTimer -= uiDiff; + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_DEVOUR_MAGIC: + DoCastVictim(SPELL_DEVOUR_MAGIC); + events.ScheduleEvent(EVENT_DEVOUR_MAGIC, urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + return; + case EVENT_SPELL_LOCK: + DoCast(SPELL_SPELL_LOCK); + events.ScheduleEvent(EVENT_SPELL_LOCK, urand(24*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + default: + return; + } + } + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_toc_pet_warlockAI (creature); } - }; - }; -enum eRetroPaladinSpells +class mob_toc_pet_hunter : public CreatureScript { - SPELL_AVENGING_WRATH = 66011, //3min cd - SPELL_CRUSADER_STRIKE = 66003, //6sec cd - SPELL_DIVINE_SHIELD = 66010, //5min cd - SPELL_DIVINE_STORM = 66006, //10sec cd - SPELL_HAMMER_OF_JUSTICE_RET = 66007, //40sec cd - SPELL_HAND_OF_PROTECTION_RET = 66009, //5min cd - SPELL_JUDGEMENT_OF_COMMAND = 66005, //8sec cd - SPELL_REPENTANCE = 66008, //60sec cd - SPELL_SEAL_OF_COMMAND = 66004, //no cd -}; + public: + mob_toc_pet_hunter() : CreatureScript("mob_toc_pet_hunter") { } -class mob_toc_retro_paladin : public CreatureScript -{ -public: - mob_toc_retro_paladin() : CreatureScript("mob_toc_retro_paladin") { } + struct mob_toc_pet_hunterAI : public boss_faction_championsAI + { + mob_toc_pet_hunterAI(Creature* creature) : boss_faction_championsAI(creature, AI_PET) {} - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_retro_paladinAI (creature); - } + void Reset() + { + boss_faction_championsAI::Reset(); + _clawTimer = urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS); + } - struct mob_toc_retro_paladinAI : public boss_faction_championsAI - { - mob_toc_retro_paladinAI(Creature* creature) : boss_faction_championsAI(creature, AI_MELEE) {} + void UpdateAI(const uint32 diff) + { + if (!UpdateVictim()) + return; - uint32 m_uiRepeteanceTimer; - uint32 m_uiCrusaderStrikeTimer; - uint32 m_uiAvengingWrathTimer; - uint32 m_uiDivineShieldTimer; - uint32 m_uiDivineStormTimer; - uint32 m_uiJudgementOfCommandTimer; + boss_faction_championsAI::UpdateAI(diff); - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiRepeteanceTimer = 60*IN_MILLISECONDS; - m_uiCrusaderStrikeTimer = urand(6*IN_MILLISECONDS, 18*IN_MILLISECONDS); - m_uiAvengingWrathTimer = 180*IN_MILLISECONDS; - m_uiDivineShieldTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - m_uiDivineStormTimer = 10*IN_MILLISECONDS; - m_uiJudgementOfCommandTimer = urand(8*IN_MILLISECONDS, 15*IN_MILLISECONDS); - SetEquipmentSlots(false, 47519, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE); - } + if (_clawTimer <= diff) + { + DoCastVictim(SPELL_CLAW); + _clawTimer = urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS); + } + else + _clawTimer -= diff; + } + private: + uint32 _clawTimer; + }; - void EnterCombat(Unit* who) + CreatureAI* GetAI(Creature* creature) const { - boss_faction_championsAI::EnterCombat(who); - DoCast(SPELL_SEAL_OF_COMMAND); + return new mob_toc_pet_hunterAI (creature); } +}; - void UpdateAI(const uint32 uiDiff) - { - if (!UpdateVictim()) - return; - - if (m_uiRepeteanceTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_REPENTANCE); - m_uiRepeteanceTimer = 60*IN_MILLISECONDS; - } else m_uiRepeteanceTimer -= uiDiff; - - if (m_uiCrusaderStrikeTimer <= uiDiff) - { - DoCastVictim(SPELL_CRUSADER_STRIKE); - m_uiCrusaderStrikeTimer = urand(6*IN_MILLISECONDS, 18*IN_MILLISECONDS); - } else m_uiCrusaderStrikeTimer -= uiDiff; +class spell_faction_champion_warl_unstable_affliction : public SpellScriptLoader +{ + public: + spell_faction_champion_warl_unstable_affliction() : SpellScriptLoader("spell_faction_champion_warl_unstable_affliction") { } - if (m_uiAvengingWrathTimer <= uiDiff) - { - DoCastVictim(SPELL_AVENGING_WRATH); - m_uiAvengingWrathTimer = 180*IN_MILLISECONDS; - } else m_uiAvengingWrathTimer -= uiDiff; + class spell_faction_champion_warl_unstable_affliction_AuraScript : public AuraScript + { + PrepareAuraScript(spell_faction_champion_warl_unstable_affliction_AuraScript); - if (m_uiDivineShieldTimer <= uiDiff) + bool Validate(SpellInfo const* /*spell*/) { - if (HealthBelowPct(20)) - DoCast(me, SPELL_DIVINE_SHIELD); - m_uiDivineShieldTimer = urand(0*IN_MILLISECONDS, 360*IN_MILLISECONDS); - } else m_uiDivineShieldTimer -= uiDiff; + if (!sSpellMgr->GetSpellInfo(SPELL_UNSTABLE_AFFLICTION_DISPEL)) + return false; + return true; + } - if (m_uiDivineStormTimer <= uiDiff) + void HandleDispel(DispelInfo* dispelInfo) { - DoCastVictim(SPELL_DIVINE_STORM); - m_uiDivineStormTimer = 10*IN_MILLISECONDS; - } else m_uiDivineStormTimer -= uiDiff; + if (Unit* caster = GetCaster()) + caster->CastSpell(dispelInfo->GetDispeller(), SPELL_UNSTABLE_AFFLICTION_DISPEL, true, NULL, GetEffect(EFFECT_0)); + } - if (m_uiJudgementOfCommandTimer <= uiDiff) + void Register() { - DoCastVictim(SPELL_JUDGEMENT_OF_COMMAND); - m_uiJudgementOfCommandTimer = urand(8*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiJudgementOfCommandTimer -= uiDiff; + AfterDispel += AuraDispelFn(spell_faction_champion_warl_unstable_affliction_AuraScript::HandleDispel); + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + AuraScript* GetAuraScript() const + { + return new spell_faction_champion_warl_unstable_affliction_AuraScript(); } - }; - -}; - -enum eWarlockPetSpells -{ - SPELL_DEVOUR_MAGIC = 67518, - SPELL_SPELL_LOCK = 67519, }; -class mob_toc_pet_warlock : public CreatureScript +class spell_faction_champion_death_grip : public SpellScriptLoader { -public: - mob_toc_pet_warlock() : CreatureScript("mob_toc_pet_warlock") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_pet_warlockAI (creature); - } - - struct mob_toc_pet_warlockAI : public boss_faction_championsAI - { - mob_toc_pet_warlockAI(Creature* creature) : boss_faction_championsAI(creature, AI_PET) {} - - uint32 m_uiDevourMagicTimer; - uint32 m_uiSpellLockTimer; - - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiDevourMagicTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - m_uiSpellLockTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } + public: + spell_faction_champion_death_grip() : SpellScriptLoader("spell_faction_champion_death_grip") { } - void UpdateAI(const uint32 uiDiff) + class spell_faction_champion_death_grip_SpellScript : public SpellScript { - if (!UpdateVictim()) - return; + PrepareSpellScript(spell_faction_champion_death_grip_SpellScript); - if (m_uiDevourMagicTimer <= uiDiff) + bool Validate(SpellInfo const* /*spell*/) { - DoCastVictim(SPELL_DEVOUR_MAGIC); - m_uiDevourMagicTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiDevourMagicTimer -= uiDiff; + if (!sSpellMgr->GetSpellInfo(SPELL_DEATH_GRIP_PULL)) + return false; + return true; + } - if (m_uiSpellLockTimer <= uiDiff) + void HandleDummy(SpellEffIndex /*effIndex*/) { - DoCastVictim(SPELL_SPELL_LOCK); - m_uiSpellLockTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiSpellLockTimer -= uiDiff; + if (Unit* target = GetHitUnit()) + { + if (Unit* caster = GetCaster()) + target->CastSpell(caster, SPELL_DEATH_GRIP_PULL); + } + } - boss_faction_championsAI::UpdateAI(uiDiff); - } - }; + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_faction_champion_death_grip_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } -}; + }; -enum eHunterPetSpells -{ - SPELL_CLAW = 67793, + SpellScript* GetSpellScript() const + { + return new spell_faction_champion_death_grip_SpellScript(); + } }; -class mob_toc_pet_hunter : public CreatureScript +class spell_toc_bloodlust : public SpellScriptLoader { -public: - mob_toc_pet_hunter() : CreatureScript("mob_toc_pet_hunter") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_toc_pet_hunterAI (creature); - } + public: + spell_toc_bloodlust() : SpellScriptLoader("spell_toc_bloodlust") { } - struct mob_toc_pet_hunterAI : public boss_faction_championsAI - { - mob_toc_pet_hunterAI(Creature* creature) : boss_faction_championsAI(creature, AI_PET) {} + class spell_toc_bloodlust_SpellScript : public SpellScript + { + PrepareSpellScript(spell_toc_bloodlust_SpellScript); - uint32 m_uiClawTimer; + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(AURA_SATED)) + return false; + return true; + } - void Reset() - { - boss_faction_championsAI::Reset(); - m_uiClawTimer = urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS); - } + void RemoveInvalidTargets(std::list<WorldObject*>& targets) + { + targets.remove_if(Trinity::UnitAuraCheck(true, AURA_SATED)); + } - void UpdateAI(const uint32 uiDiff) - { - if (!UpdateVictim()) - return; + void ApplyDebuff() + { + if (Unit* target = GetHitUnit()) + target->CastSpell(target, AURA_SATED, true); + } - if (m_uiClawTimer <= uiDiff) + void Register() { - DoCastVictim(SPELL_CLAW); - m_uiClawTimer = urand(5*IN_MILLISECONDS, 10*IN_MILLISECONDS); - } else m_uiClawTimer -= uiDiff; + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_toc_bloodlust_SpellScript::RemoveInvalidTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_toc_bloodlust_SpellScript::RemoveInvalidTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ALLY); + AfterHit += SpellHitFn(spell_toc_bloodlust_SpellScript::ApplyDebuff); + } + }; - boss_faction_championsAI::UpdateAI(uiDiff); + SpellScript* GetSpellScript() const + { + return new spell_toc_bloodlust_SpellScript(); } - }; }; -class spell_faction_champion_warl_unstable_affliction : public SpellScriptLoader +class spell_toc_heroism : public SpellScriptLoader { public: - spell_faction_champion_warl_unstable_affliction() : SpellScriptLoader("spell_faction_champion_warl_unstable_affliction") { } + spell_toc_heroism() : SpellScriptLoader("spell_toc_heroism") { } - class spell_faction_champion_warl_unstable_affliction_AuraScript : public AuraScript + class spell_toc_heroism_SpellScript : public SpellScript { - PrepareAuraScript(spell_faction_champion_warl_unstable_affliction_AuraScript); + PrepareSpellScript(spell_toc_heroism_SpellScript); - bool Validate(SpellInfo const* /*spell*/) + bool Validate(SpellInfo const* /*spellEntry*/) { - if (!sSpellMgr->GetSpellInfo(SPELL_UNSTABLE_AFFLICTION_DISPEL)) + if (!sSpellMgr->GetSpellInfo(AURA_EXHAUSTION)) return false; return true; } - void HandleDispel(DispelInfo* dispelInfo) + void RemoveInvalidTargets(std::list<WorldObject*>& targets) { - if (Unit* caster = GetCaster()) - caster->CastSpell(dispelInfo->GetDispeller(), SPELL_UNSTABLE_AFFLICTION_DISPEL, true, NULL, GetEffect(EFFECT_0)); + targets.remove_if(Trinity::UnitAuraCheck(true, AURA_EXHAUSTION)); + } + + void ApplyDebuff() + { + if (Unit* target = GetHitUnit()) + target->CastSpell(target, AURA_EXHAUSTION, true); } void Register() { - AfterDispel += AuraDispelFn(spell_faction_champion_warl_unstable_affliction_AuraScript::HandleDispel); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_toc_heroism_SpellScript::RemoveInvalidTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_toc_heroism_SpellScript::RemoveInvalidTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ALLY); + AfterHit += SpellHitFn(spell_toc_heroism_SpellScript::ApplyDebuff); } }; - AuraScript* GetAuraScript() const + SpellScript* GetSpellScript() const { - return new spell_faction_champion_warl_unstable_affliction_AuraScript(); + return new spell_toc_heroism_SpellScript(); } }; @@ -2086,5 +2392,9 @@ void AddSC_boss_faction_champions() new mob_toc_retro_paladin(); new mob_toc_pet_warlock(); new mob_toc_pet_hunter(); + new spell_faction_champion_warl_unstable_affliction(); + new spell_faction_champion_death_grip(); + new spell_toc_bloodlust(); + new spell_toc_heroism(); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index 87e7801566e..e2068cabb95 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -16,23 +16,10 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: trial_of_the_crusader -SD%Complete: ??% -SDComment: based on /dev/rsa -SDCategory: Crusader Coliseum -EndScriptData */ - -// Known bugs: -// Some visuals aren't appearing right sometimes -// -// TODO: -// Redone summon's scripts in SAI -// Add immunities to the boss and summons - #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "trial_of_the_crusader.h" +#include "SpellScript.h" enum Yells { @@ -47,15 +34,7 @@ enum Yells SAY_INFERNAL_ERUPTION = 8, SAY_KILL_PLAYER = 9, SAY_DEATH = 10, - SAY_BERSERK = 11, -}; - -enum Equipment -{ - EQUIP_MAIN = 47266, - EQUIP_OFFHAND = 46996, - EQUIP_RANGED = 47267, - EQUIP_DONE = EQUIP_NO_CHANGE, + SAY_BERSERK = 11 }; enum Summons @@ -64,7 +43,7 @@ enum Summons NPC_INFERNAL_VOLCANO = 34813, NPC_FEL_INFERNAL = 34815, // immune to all CC on Heroic (stuns, banish, interrupt, etc) NPC_NETHER_PORTAL = 34825, - NPC_MISTRESS_OF_PAIN = 34826, + NPC_MISTRESS_OF_PAIN = 34826 }; enum BossSpells @@ -84,442 +63,530 @@ enum BossSpells SPELL_BERSERK = 64238, // unused // Mistress of Pain spells - SPELL_SHIVAN_SLASH = 67098, - SPELL_SPINNING_STRIKE = 66283, - SPELL_MISTRESS_KISS = 67077, - SPELL_FEL_INFERNO = 67047, - SPELL_FEL_STREAK = 66494, + SPELL_SHIVAN_SLASH = 67098, + SPELL_SPINNING_STRIKE = 66283, + SPELL_MISTRESS_KISS = 66336, + SPELL_FEL_INFERNO = 67047, + SPELL_FEL_STREAK = 66494, + SPELL_LORD_HITTIN = 66326, // special effect preventing more specific spells be cast on the same player within 10 seconds + SPELL_MISTRESS_KISS_DEBUFF = 66334, + SPELL_MISTRESS_KISS_DAMAGE_SILENCE = 66359 }; -/*###### -## boss_jaraxxus -######*/ +enum Events +{ + // Lord Jaraxxus + EVENT_FEL_FIREBALL = 1, + EVENT_FEL_LIGHTNING = 2, + EVENT_INCINERATE_FLESH = 3, + EVENT_NETHER_POWER = 4, + EVENT_LEGION_FLAME = 5, + EVENT_SUMMONO_NETHER_PORTAL = 6, + EVENT_SUMMON_INFERNAL_ERUPTION = 7, + + // Mistress of Pain + EVENT_SHIVAN_SLASH = 8, + EVENT_SPINNING_STRIKE = 9, + EVENT_MISTRESS_KISS = 10 +}; class boss_jaraxxus : public CreatureScript { -public: - boss_jaraxxus() : CreatureScript("boss_jaraxxus") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new boss_jaraxxusAI(creature); - } - - struct boss_jaraxxusAI : public ScriptedAI - { - boss_jaraxxusAI(Creature* creature) : ScriptedAI(creature), Summons(me) - { - instance = creature->GetInstanceScript(); - Reset(); - } - - InstanceScript* instance; + public: + boss_jaraxxus() : CreatureScript("boss_jaraxxus") { } - SummonList Summons; - - uint32 m_uiFelFireballTimer; - uint32 m_uiFelLightningTimer; - uint32 m_uiIncinerateFleshTimer; - uint32 m_uiNetherPowerTimer; - uint32 m_uiLegionFlameTimer; - uint32 m_uiSummonNetherPortalTimer; - uint32 m_uiSummonInfernalEruptionTimer; - - void Reset() + struct boss_jaraxxusAI : public BossAI { - if (instance) - instance->SetData(TYPE_JARAXXUS, NOT_STARTED); - SetEquipmentSlots(false, EQUIP_MAIN, EQUIP_OFFHAND, EQUIP_RANGED); - m_uiFelFireballTimer = 5*IN_MILLISECONDS; - m_uiFelLightningTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); - m_uiIncinerateFleshTimer = urand(20*IN_MILLISECONDS, 25*IN_MILLISECONDS); - m_uiNetherPowerTimer = 40*IN_MILLISECONDS; - m_uiLegionFlameTimer = 30*IN_MILLISECONDS; - m_uiSummonNetherPortalTimer = 1*MINUTE*IN_MILLISECONDS; - m_uiSummonInfernalEruptionTimer = 2*MINUTE*IN_MILLISECONDS; - Summons.DespawnAll(); - } + boss_jaraxxusAI(Creature* creature) : BossAI(creature, BOSS_JARAXXUS) + { + } - void JustReachedHome() - { - if (instance) - instance->SetData(TYPE_JARAXXUS, FAIL); - DoCast(me, SPELL_JARAXXUS_CHAINS); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - me->SetReactState(REACT_PASSIVE); - } + void Reset() + { + _Reset(); + events.ScheduleEvent(EVENT_FEL_FIREBALL, 5*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_FEL_LIGHTNING, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_INCINERATE_FLESH, urand(20*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_NETHER_POWER, 40*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_LEGION_FLAME, 30*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUMMONO_NETHER_PORTAL, 20*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUMMON_INFERNAL_ERUPTION, 80*IN_MILLISECONDS); + } - void KilledUnit(Unit* who) - { - if (who->GetTypeId() == TYPEID_PLAYER) + void JustReachedHome() { + _JustReachedHome(); if (instance) - instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); + instance->SetBossState(BOSS_JARAXXUS, FAIL); + DoCast(me, SPELL_JARAXXUS_CHAINS); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } - } - void JustDied(Unit* /*killer*/) - { - Summons.DespawnAll(); - Talk(SAY_DEATH); - if (instance) - instance->SetData(TYPE_JARAXXUS, DONE); - } - - void JustSummoned(Creature* summoned) - { - Summons.Summon(summoned); - } - - void EnterCombat(Unit* /*who*/) - { - me->SetInCombatWithZone(); - if (instance) - instance->SetData(TYPE_JARAXXUS, IN_PROGRESS); - Talk(SAY_AGGRO); - } - - void UpdateAI(const uint32 uiDiff) - { - if (!UpdateVictim()) - return; - - if (m_uiSummonInfernalEruptionTimer <= uiDiff) + void KilledUnit(Unit* who) { - Talk(EMOTE_INFERNAL_ERUPTION); - Talk(SAY_INFERNAL_ERUPTION); - DoCast(SPELL_INFERNAL_ERUPTION); - m_uiSummonInfernalEruptionTimer = 2*MINUTE*IN_MILLISECONDS; - } else m_uiSummonInfernalEruptionTimer -= uiDiff; + if (who->GetTypeId() == TYPEID_PLAYER) + { + Talk(SAY_KILL_PLAYER); + if (instance) + instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0); + } + } - if (m_uiSummonNetherPortalTimer <= uiDiff) + void JustDied(Unit* /*killer*/) { - Talk(EMOTE_NETHER_PORTAL); - Talk(SAY_MISTRESS_OF_PAIN); - DoCast(SPELL_NETHER_PORTAL); - m_uiSummonNetherPortalTimer = 2*MINUTE*IN_MILLISECONDS; - } else m_uiSummonNetherPortalTimer -= uiDiff; + _JustDied(); + Talk(SAY_DEATH); + } - if (m_uiFelFireballTimer <= uiDiff) + void JustSummoned(Creature* summoned) { - DoCastVictim(SPELL_FEL_FIREBALL); - m_uiFelFireballTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiFelFireballTimer -= uiDiff; + summons.Summon(summoned); + } - if (m_uiFelLightningTimer <= uiDiff) + void EnterCombat(Unit* /*who*/) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) - DoCast(target, SPELL_FEL_LIGHTING); - m_uiFelLightningTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); - } else m_uiFelLightningTimer -= uiDiff; + _EnterCombat(); + Talk(SAY_AGGRO); + } - if (m_uiIncinerateFleshTimer <= uiDiff) + void UpdateAI(const uint32 diff) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true)) - { - Talk(EMOTE_INCINERATE, target->GetGUID()); - Talk(SAY_INCINERATE); - DoCast(target, SPELL_INCINERATE_FLESH); - } - m_uiIncinerateFleshTimer = urand(20*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiIncinerateFleshTimer -= uiDiff; + if (!UpdateVictim()) + return; - if (m_uiNetherPowerTimer <= uiDiff) - { - me->CastCustomSpell(SPELL_NETHER_POWER, SPELLVALUE_AURA_STACK, RAID_MODE<uint32>(5, 10, 5,10), me, true); - m_uiNetherPowerTimer = 40*IN_MILLISECONDS; - } else m_uiNetherPowerTimer -= uiDiff; + events.Update(diff); - if (m_uiLegionFlameTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true)) + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) { - Talk(EMOTE_LEGION_FLAME, target->GetGUID()); - DoCast(target, SPELL_LEGION_FLAME); + switch (eventId) + { + case EVENT_FEL_FIREBALL: + DoCastVictim(SPELL_FEL_FIREBALL); + events.ScheduleEvent(EVENT_FEL_FIREBALL, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_FEL_LIGHTNING: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_LORD_HITTIN)) + DoCast(target, SPELL_FEL_LIGHTING); + events.ScheduleEvent(EVENT_FEL_LIGHTNING, urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS)); + return; + case EVENT_INCINERATE_FLESH: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true, -SPELL_LORD_HITTIN)) + { + Talk(EMOTE_INCINERATE, target->GetGUID()); + Talk(SAY_INCINERATE); + DoCast(target, SPELL_INCINERATE_FLESH); + } + events.ScheduleEvent(EVENT_INCINERATE_FLESH, urand(20*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + return; + case EVENT_NETHER_POWER: + me->CastCustomSpell(SPELL_NETHER_POWER, SPELLVALUE_AURA_STACK, RAID_MODE<uint32>(5, 10, 5,10), me, true); + events.ScheduleEvent(EVENT_NETHER_POWER, 40*IN_MILLISECONDS); + return; + case EVENT_LEGION_FLAME: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true, -SPELL_LORD_HITTIN)) + { + Talk(EMOTE_LEGION_FLAME, target->GetGUID()); + DoCast(target, SPELL_LEGION_FLAME); + } + events.ScheduleEvent(EVENT_LEGION_FLAME, 30*IN_MILLISECONDS); + return; + case EVENT_SUMMONO_NETHER_PORTAL: + Talk(EMOTE_NETHER_PORTAL); + Talk(SAY_MISTRESS_OF_PAIN); + DoCast(SPELL_NETHER_PORTAL); + events.ScheduleEvent(EVENT_SUMMONO_NETHER_PORTAL, 2*MINUTE*IN_MILLISECONDS); + return; + case EVENT_SUMMON_INFERNAL_ERUPTION: + Talk(EMOTE_INFERNAL_ERUPTION); + Talk(SAY_INFERNAL_ERUPTION); + DoCast(SPELL_INFERNAL_ERUPTION); + events.ScheduleEvent(EVENT_SUMMON_INFERNAL_ERUPTION, 2*MINUTE*IN_MILLISECONDS); + return; + } } - m_uiLegionFlameTimer = 30*IN_MILLISECONDS; - } else m_uiLegionFlameTimer -= uiDiff; - DoMeleeAttackIfReady(); - } - }; + DoMeleeAttackIfReady(); + } + }; + CreatureAI* GetAI(Creature* creature) const + { + return new boss_jaraxxusAI(creature); + } }; class mob_legion_flame : public CreatureScript { -public: - mob_legion_flame() : CreatureScript("mob_legion_flame") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_legion_flameAI(creature); - } + public: + mob_legion_flame() : CreatureScript("mob_legion_flame") { } - struct mob_legion_flameAI : public Scripted_NoMovementAI - { - mob_legion_flameAI(Creature* creature) : Scripted_NoMovementAI(creature) + struct mob_legion_flameAI : public Scripted_NoMovementAI { - Reset(); - } + mob_legion_flameAI(Creature* creature) : Scripted_NoMovementAI(creature) + { + _instance = creature->GetInstanceScript(); + } - void Reset() - { - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetInCombatWithZone(); - DoCast(SPELL_LEGION_FLAME_EFFECT); - } + void Reset() + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetInCombatWithZone(); + DoCast(SPELL_LEGION_FLAME_EFFECT); + } + + void UpdateAI(const uint32 /*diff*/) + { + UpdateVictim(); + if (_instance && _instance->GetBossState(BOSS_JARAXXUS) != IN_PROGRESS) + me->DespawnOrUnsummon(); + } + private: + InstanceScript* _instance; + }; - void UpdateAI(const uint32 /*uiDiff*/) + CreatureAI* GetAI(Creature* creature) const { - UpdateVictim(); + return new mob_legion_flameAI(creature); } - }; - }; class mob_infernal_volcano : public CreatureScript { -public: - mob_infernal_volcano() : CreatureScript("mob_infernal_volcano") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_infernal_volcanoAI(creature); - } + public: + mob_infernal_volcano() : CreatureScript("mob_infernal_volcano") { } - struct mob_infernal_volcanoAI : public Scripted_NoMovementAI - { - mob_infernal_volcanoAI(Creature* creature) : Scripted_NoMovementAI(creature), Summons(me) + struct mob_infernal_volcanoAI : public Scripted_NoMovementAI { - instance = creature->GetInstanceScript(); - Reset(); - } + mob_infernal_volcanoAI(Creature* creature) : Scripted_NoMovementAI(creature), _summons(me) + { + } - InstanceScript* instance; + void Reset() + { + me->SetReactState(REACT_PASSIVE); - SummonList Summons; + if (!IsHeroic()) + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); + else + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); - void Reset() - { - me->SetReactState(REACT_PASSIVE); + _summons.DespawnAll(); + } - if (!IsHeroic()) - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); - else - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); + void IsSummonedBy(Unit* /*summoner*/) + { + DoCast(SPELL_INFERNAL_ERUPTION_EFFECT); + } - Summons.DespawnAll(); - } + void JustSummoned(Creature* summoned) + { + _summons.Summon(summoned); + // makes immediate corpse despawn of summoned Felflame Infernals + summoned->SetCorpseDelay(0); + } - void IsSummonedBy(Unit* /*summoner*/) - { - DoCast(SPELL_INFERNAL_ERUPTION_EFFECT); - } + void JustDied(Unit* /*killer*/) + { + // used to despawn corpse immediately + me->DespawnOrUnsummon(); + } - void JustSummoned(Creature* summoned) - { - Summons.Summon(summoned); - // makes immediate corpse despawn of summoned Felflame Infernals - summoned->SetCorpseDelay(0); - } + void UpdateAI(uint32 const /*diff*/) {} + + private: + SummonList _summons; + }; - void JustDied(Unit* /*killer*/) + CreatureAI* GetAI(Creature* creature) const { - // used to despawn corpse immediately - me->DespawnOrUnsummon(); + return new mob_infernal_volcanoAI(creature); } - - void UpdateAI(uint32 const /*diff*/) {} - }; - }; class mob_fel_infernal : public CreatureScript { -public: - mob_fel_infernal() : CreatureScript("mob_fel_infernal") { } + public: + mob_fel_infernal() : CreatureScript("mob_fel_infernal") { } - CreatureAI* GetAI(Creature* creature) const - { - return new mob_fel_infernalAI(creature); - } - - struct mob_fel_infernalAI : public ScriptedAI - { - mob_fel_infernalAI(Creature* creature) : ScriptedAI(creature) + struct mob_fel_infernalAI : public ScriptedAI { - instance = creature->GetInstanceScript(); - Reset(); - } - - InstanceScript* instance; - uint32 m_uiFelStreakTimer; + mob_fel_infernalAI(Creature* creature) : ScriptedAI(creature) + { + _instance = creature->GetInstanceScript(); + } - void Reset() - { - m_uiFelStreakTimer = 30*IN_MILLISECONDS; - me->SetInCombatWithZone(); - } + void Reset() + { + _felStreakTimer = 30*IN_MILLISECONDS; + me->SetInCombatWithZone(); + } - /*void SpellHitTarget(Unit* target, const SpellInfo* pSpell) - { - if (pSpell->Id == SPELL_FEL_STREAK) - DoCastAOE(SPELL_FEL_INFERNO); //66517 - }*/ + void UpdateAI(const uint32 diff) + { + if (_instance && _instance->GetBossState(BOSS_JARAXXUS) != IN_PROGRESS) + { + me->DespawnOrUnsummon(); + return; + } - void UpdateAI(const uint32 uiDiff) - { - if (!UpdateVictim()) - return; + if (!UpdateVictim()) + return; - if (instance && instance->GetData(TYPE_JARAXXUS) != IN_PROGRESS) - me->DespawnOrUnsummon(); + if (_felStreakTimer <= diff) + { + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + DoCast(target, SPELL_FEL_STREAK); + _felStreakTimer = 30*IN_MILLISECONDS; + } + else + _felStreakTimer -= diff; - if (m_uiFelStreakTimer <= uiDiff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_FEL_STREAK); - m_uiFelStreakTimer = 30*IN_MILLISECONDS; - } else m_uiFelStreakTimer -= uiDiff; + DoMeleeAttackIfReady(); + } + private: + uint32 _felStreakTimer; + InstanceScript* _instance; + }; - DoMeleeAttackIfReady(); + CreatureAI* GetAI(Creature* creature) const + { + return new mob_fel_infernalAI(creature); } - }; - }; class mob_nether_portal : public CreatureScript { -public: - mob_nether_portal() : CreatureScript("mob_nether_portal") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_nether_portalAI(creature); - } + public: + mob_nether_portal() : CreatureScript("mob_nether_portal") { } - struct mob_nether_portalAI : public ScriptedAI - { - mob_nether_portalAI(Creature* creature) : ScriptedAI(creature), Summons(me) + struct mob_nether_portalAI : public ScriptedAI { - instance = creature->GetInstanceScript(); - Reset(); - } + mob_nether_portalAI(Creature* creature) : ScriptedAI(creature), _summons(me) + { + } - InstanceScript* instance; + void Reset() + { + me->SetReactState(REACT_PASSIVE); - SummonList Summons; + if (!IsHeroic()) + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); + else + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); - void Reset() - { - me->SetReactState(REACT_PASSIVE); + _summons.DespawnAll(); + } - if (!IsHeroic()) - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); - else - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); + void IsSummonedBy(Unit* /*summoner*/) + { + DoCast(SPELL_NETHER_PORTAL_EFFECT); + } - Summons.DespawnAll(); - } + void JustSummoned(Creature* summoned) + { + _summons.Summon(summoned); + // makes immediate corpse despawn of summoned Mistress of Pain + summoned->SetCorpseDelay(0); + } - void IsSummonedBy(Unit* /*summoner*/) - { - DoCast(SPELL_NETHER_PORTAL_EFFECT); - } + void JustDied(Unit* /*killer*/) + { + // used to despawn corpse immediately + me->DespawnOrUnsummon(); + } - void JustSummoned(Creature* summoned) - { - Summons.Summon(summoned); - // makes immediate corpse despawn of summoned Mistress of Pain - summoned->SetCorpseDelay(0); - } + void UpdateAI(uint32 const /*diff*/) {} + + private: + SummonList _summons; + }; - void JustDied(Unit* /*killer*/) + CreatureAI* GetAI(Creature* creature) const { - // used to despawn corpse immediately - me->DespawnOrUnsummon(); + return new mob_nether_portalAI(creature); } - - void UpdateAI(uint32 const /*diff*/) {} - }; - }; class mob_mistress_of_pain : public CreatureScript { -public: - mob_mistress_of_pain() : CreatureScript("mob_mistress_of_pain") { } + public: + mob_mistress_of_pain() : CreatureScript("mob_mistress_of_pain") { } - CreatureAI* GetAI(Creature* creature) const - { - return new mob_mistress_of_painAI(creature); - } + struct mob_mistress_of_painAI : public ScriptedAI + { + mob_mistress_of_painAI(Creature* creature) : ScriptedAI(creature) + { + _instance = creature->GetInstanceScript(); + if (_instance) + _instance->SetData(DATA_MISTRESS_OF_PAIN_COUNT, INCREASE); + } + + void Reset() + { + _events.ScheduleEvent(EVENT_SHIVAN_SLASH, 30*IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_SPINNING_STRIKE, 30*IN_MILLISECONDS); + if (IsHeroic()) + _events.ScheduleEvent(EVENT_MISTRESS_KISS, 15*IN_MILLISECONDS); + me->SetInCombatWithZone(); + } - struct mob_mistress_of_painAI : public ScriptedAI - { - mob_mistress_of_painAI(Creature* creature) : ScriptedAI(creature) + void JustDied(Unit* /*killer*/) + { + if (_instance) + _instance->SetData(DATA_MISTRESS_OF_PAIN_COUNT, DECREASE); + } + + void UpdateAI(const uint32 diff) + { + if (_instance && _instance->GetBossState(BOSS_JARAXXUS) != IN_PROGRESS) + { + me->DespawnOrUnsummon(); + return; + } + + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_SHIVAN_SLASH: + DoCastVictim(SPELL_SHIVAN_SLASH); + _events.ScheduleEvent(EVENT_SHIVAN_SLASH, 30*IN_MILLISECONDS); + return; + case EVENT_SPINNING_STRIKE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + DoCast(target, SPELL_SPINNING_STRIKE); + _events.ScheduleEvent(EVENT_SPINNING_STRIKE, 30*IN_MILLISECONDS); + return; + case EVENT_MISTRESS_KISS: + DoCast(me, SPELL_MISTRESS_KISS); + _events.ScheduleEvent(EVENT_MISTRESS_KISS, 30*IN_MILLISECONDS); + return; + default: + break; + } + } + + DoMeleeAttackIfReady(); + } + private: + InstanceScript* _instance; + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const { - instance = creature->GetInstanceScript(); - if (instance) - instance->SetData(DATA_MISTRESS_OF_PAIN_COUNT, INCREASE); - Reset(); + return new mob_mistress_of_painAI(creature); } +}; - InstanceScript* instance; - uint32 m_uiShivanSlashTimer; - uint32 m_uiSpinningStrikeTimer; - uint32 m_uiMistressKissTimer; +class spell_mistress_kiss : public SpellScriptLoader +{ + public: + spell_mistress_kiss() : SpellScriptLoader("spell_mistress_kiss") { } - void Reset() + class spell_mistress_kiss_AuraScript : public AuraScript { - m_uiShivanSlashTimer = 30*IN_MILLISECONDS; - m_uiSpinningStrikeTimer = 30*IN_MILLISECONDS; - m_uiMistressKissTimer = 15*IN_MILLISECONDS; - me->SetInCombatWithZone(); - } + PrepareAuraScript(spell_mistress_kiss_AuraScript); - void JustDied(Unit* /*killer*/) + bool Load() + { + if (GetCaster()) + if (sSpellMgr->GetSpellIdForDifficulty(SPELL_MISTRESS_KISS_DAMAGE_SILENCE, GetCaster())) + return true; + return false; + } + + void HandleDummyTick(AuraEffect const* /*aurEff*/) + { + Unit* caster = GetCaster(); + Unit* target = GetTarget(); + if (caster && target) + { + if (target->HasUnitState(UNIT_STATE_CASTING)) + { + caster->CastSpell(target, SPELL_MISTRESS_KISS_DAMAGE_SILENCE, true); + target->RemoveAurasDueToSpell(GetSpellInfo()->Id); + } + } + } + + void Register() + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_mistress_kiss_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } + }; + + AuraScript* GetAuraScript() const { - if (instance) - instance->SetData(DATA_MISTRESS_OF_PAIN_COUNT, DECREASE); + return new spell_mistress_kiss_AuraScript(); } +}; - void UpdateAI(const uint32 uiDiff) +class spell_mistress_kiss_area : public SpellScriptLoader +{ + public: + spell_mistress_kiss_area() : SpellScriptLoader("spell_mistress_kiss_area") {} + + class spell_mistress_kiss_area_SpellScript : public SpellScript { - if (instance && instance->GetData(TYPE_JARAXXUS) != IN_PROGRESS) + PrepareSpellScript(spell_mistress_kiss_area_SpellScript) + + bool Load() { - me->DespawnOrUnsummon(); - return; + if (GetCaster()) + if (sSpellMgr->GetSpellIdForDifficulty(SPELL_MISTRESS_KISS_DEBUFF, GetCaster())) + return true; + return false; } - if (!UpdateVictim()) - return; - - if (m_uiShivanSlashTimer <= uiDiff) + void HandleScript(SpellEffIndex /*effIndex*/) { - DoCastVictim(SPELL_SHIVAN_SLASH); - m_uiShivanSlashTimer = 30*IN_MILLISECONDS; - } else m_uiShivanSlashTimer -= uiDiff; + Unit* caster = GetCaster(); + Unit* target = GetHitUnit(); + if (caster && target) + caster->CastSpell(target, SPELL_MISTRESS_KISS_DEBUFF, true); + } - if (m_uiSpinningStrikeTimer <= uiDiff) + void FilterTargets(std::list<WorldObject*>& targets) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true)) - DoCast(target, SPELL_SPINNING_STRIKE); - m_uiSpinningStrikeTimer = 30*IN_MILLISECONDS; - } else m_uiSpinningStrikeTimer -= uiDiff; + // get a list of players with mana + std::list<WorldObject*> _targets; + for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr) + if ((*itr)->ToUnit()->getPowerType() == POWER_MANA) + _targets.push_back(*itr); + + // pick a random target and kiss him + if (WorldObject* _target = Trinity::Containers::SelectRandomContainerElement(_targets)) + { + // correctly fill "targets" for the visual effect + targets.clear(); + targets.push_back(_target); + if (Unit* caster = GetCaster()) + caster->CastSpell(_target->ToUnit(), SPELL_MISTRESS_KISS_DEBUFF, true); + } + } - if (IsHeroic() && m_uiMistressKissTimer <= uiDiff) + void Register() { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true)) - DoCast(target, SPELL_MISTRESS_KISS); - m_uiMistressKissTimer = 30*IN_MILLISECONDS; - } else m_uiMistressKissTimer -= uiDiff; + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mistress_kiss_area_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + } + }; - DoMeleeAttackIfReady(); + SpellScript* GetSpellScript() const + { + return new spell_mistress_kiss_area_SpellScript(); } - }; - }; void AddSC_boss_jaraxxus() @@ -530,4 +597,7 @@ void AddSC_boss_jaraxxus() new mob_fel_infernal(); new mob_nether_portal(); new mob_mistress_of_pain(); + + new spell_mistress_kiss(); + new spell_mistress_kiss_area(); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp index 506467be8a5..2d09feef089 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp @@ -15,23 +15,16 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: northrend_beasts -SD%Complete: 90% -SDComment: based on /dev/rsa -SDCategory: -EndScriptData */ // Known bugs: -// Gormok - Not implemented as a vehicle -// - Snobold Firebomb -// - Snobolled (creature at back) -// Snakes - miss the 1-hitkill from emerging -// - visual changes between mobile and stationary models seems not to work sometimes +// Gormok - Snobolled (creature at back) #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "trial_of_the_crusader.h" +#include "Vehicle.h" +#include "Player.h" +#include "SpellScript.h" enum Yells { @@ -44,7 +37,7 @@ enum Yells // Icehowl EMOTE_TRAMPLE_START = 0, EMOTE_TRAMPLE_CRASH = 1, - EMOTE_TRAMPLE_FAIL = 2, + EMOTE_TRAMPLE_FAIL = 2 }; enum Equipment @@ -52,7 +45,7 @@ enum Equipment EQUIP_MAIN = 50760, EQUIP_OFFHAND = 48040, EQUIP_RANGED = 47267, - EQUIP_DONE = EQUIP_NO_CHANGE, + EQUIP_DONE = EQUIP_NO_CHANGE }; enum Model @@ -60,13 +53,15 @@ enum Model MODEL_ACIDMAW_STATIONARY = 29815, MODEL_ACIDMAW_MOBILE = 29816, MODEL_DREADSCALE_STATIONARY = 26935, - MODEL_DREADSCALE_MOBILE = 24564, + MODEL_DREADSCALE_MOBILE = 24564 }; -enum Summons +enum BeastSummons { NPC_SNOBOLD_VASSAL = 34800, + NPC_FIRE_BOMB = 34854, NPC_SLIME_POOL = 35176, + MAX_SNOBOLDS = 4 }; enum BossSpells @@ -107,332 +102,446 @@ enum BossSpells SPELL_ARCTIC_BREATH = 66689, SPELL_TRAMPLE = 66734, SPELL_FROTHING_RAGE = 66759, - SPELL_STAGGERED_DAZE = 66758, + SPELL_STAGGERED_DAZE = 66758 }; -class boss_gormok : public CreatureScript +enum MyActions { -public: - boss_gormok() : CreatureScript("boss_gormok") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new boss_gormokAI(creature); - } + ACTION_ENABLE_FIRE_BOMB = 1, + ACTION_DISABLE_FIRE_BOMB = 2 +}; - struct boss_gormokAI : public ScriptedAI - { - boss_gormokAI(Creature* creature) : ScriptedAI(creature), Summons(me) - { - instance = creature->GetInstanceScript(); - } +enum Events +{ + // Gormok + EVENT_IMPALE = 1, + EVENT_STAGGERING_STOMP = 2, + EVENT_THROW = 3, - InstanceScript* instance; + // Snobold + EVENT_FIRE_BOMB = 4, + EVENT_BATTER = 5, + EVENT_HEAD_CRACK = 6, - uint32 m_uiImpaleTimer; - uint32 m_uiStaggeringStompTimer; - SummonList Summons; - uint32 m_uiSummonTimer; - uint32 m_uiSummonCount; + // Acidmaw & Dreadscale + EVENT_BITE = 7, + EVENT_SPEW = 8, + EVENT_SLIME_POOL = 9, + EVENT_SPIT = 10, + EVENT_SPRAY = 11, + EVENT_SWEEP = 12, + EVENT_SUBMERGE = 13, + EVENT_EMERGE = 14, + EVENT_SUMMON_ACIDMAW = 15, - void Reset() - { - m_uiImpaleTimer = urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS); - m_uiStaggeringStompTimer = 15*IN_MILLISECONDS; - m_uiSummonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);; + // Icehowl + EVENT_FEROCIOUS_BUTT = 16, + EVENT_MASSIVE_CRASH = 17, + EVENT_WHIRL = 18, + EVENT_ARCTIC_BREATH = 19, + EVENT_TRAMPLE = 20 +}; - if (GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL || - GetDifficulty() == RAID_DIFFICULTY_25MAN_HEROIC) - m_uiSummonCount = 5; - else - m_uiSummonCount = 4; +enum Phases +{ + PHASE_MOBILE = 1, + PHASE_STATIONARY = 2, + PHASE_SUBMERGED = 3, - Summons.DespawnAll(); - } + PHASE_MASK_MOBILE = 1 << PHASE_MOBILE, + PHASE_MASK_STATIONARY = 1 << PHASE_STATIONARY +}; - void EnterEvadeMode() - { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - ScriptedAI::EnterEvadeMode(); - } +class boss_gormok : public CreatureScript +{ + public: + boss_gormok() : CreatureScript("boss_gormok") { } - void MovementInform(uint32 type, uint32 pointId) + struct boss_gormokAI : public BossAI { - if (type != POINT_MOTION_TYPE) - return; - - switch (pointId) + boss_gormokAI(Creature* creature) : BossAI(creature, BOSS_BEASTS) { - case 0: - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_AGGRESSIVE); - me->SetInCombatWithZone(); - break; } - } - void JustDied(Unit* /*killer*/) - { - if (instance) - instance->SetData(TYPE_NORTHREND_BEASTS, GORMOK_DONE); - } + void Reset() + { + events.ScheduleEvent(EVENT_IMPALE, urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_STAGGERING_STOMP, 15*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_THROW, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); - void JustReachedHome() - { - if (instance) + summons.DespawnAll(); + } + + void EnterEvadeMode() { instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - instance->SetData(TYPE_NORTHREND_BEASTS, FAIL); + ScriptedAI::EnterEvadeMode(); } - me->DespawnOrUnsummon(); - } - void EnterCombat(Unit* /*who*/) - { - me->SetInCombatWithZone(); - instance->SetData(TYPE_NORTHREND_BEASTS, GORMOK_IN_PROGRESS); - } - - void JustSummoned(Creature* summon) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true)) + void MovementInform(uint32 type, uint32 pointId) { - if (summon->GetEntry() == NPC_SNOBOLD_VASSAL) + if (type != POINT_MOTION_TYPE) + return; + + switch (pointId) { - summon->GetMotionMaster()->MoveJump(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 10.0f, 20.0f); - DoCast(me, SPELL_RISING_ANGER); - --m_uiSummonCount; + case 0: + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + me->SetInCombatWithZone(); + break; + default: + break; } - summon->AI()->AttackStart(target); } - Summons.Summon(summon); - } - void SummonedCreatureDespawn(Creature* summon) - { - if (summon->GetEntry() == NPC_SNOBOLD_VASSAL) - if (summon->isAlive()) - ++m_uiSummonCount; - Summons.Despawn(summon); - } + void JustDied(Unit* /*killer*/) + { + if (instance) + instance->SetData(TYPE_NORTHREND_BEASTS, GORMOK_DONE); + } - void UpdateAI(uint32 const diff) - { - if (!UpdateVictim()) - return; + void JustReachedHome() + { + if (instance) + { + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + instance->SetData(TYPE_NORTHREND_BEASTS, FAIL); + } + me->DespawnOrUnsummon(); + } - if (m_uiImpaleTimer <= diff) + void EnterCombat(Unit* /*who*/) { - DoCastVictim(SPELL_IMPALE); - m_uiImpaleTimer = urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS); - } else m_uiImpaleTimer -= diff; + _EnterCombat(); + me->SetInCombatWithZone(); + instance->SetData(TYPE_NORTHREND_BEASTS, GORMOK_IN_PROGRESS); - if (m_uiStaggeringStompTimer <= diff) + for (uint8 i = 0; i < MAX_SNOBOLDS; i++) + { + if (Creature* pSnobold = DoSpawnCreature(NPC_SNOBOLD_VASSAL, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0)) + { + pSnobold->EnterVehicle(me, i); + pSnobold->SetInCombatWithZone(); + pSnobold->AI()->DoAction(ACTION_ENABLE_FIRE_BOMB); + } + } + } + + void DamageTaken(Unit* /*who*/, uint32& damage) { - DoCastVictim(SPELL_STAGGERING_STOMP); - m_uiStaggeringStompTimer = urand(20*IN_MILLISECONDS, 25*IN_MILLISECONDS); - } else m_uiStaggeringStompTimer -= diff; + // despawn the remaining passengers on death + if (damage >= me->GetHealth()) + for (uint8 i = 0; i < MAX_SNOBOLDS; ++i) + if (Unit* pSnobold = me->GetVehicleKit()->GetPassenger(i)) + pSnobold->ToCreature()->DespawnOrUnsummon(); + } - if (m_uiSummonTimer <= diff) + void UpdateAI(uint32 const diff) { - if (m_uiSummonCount > 0) + if (!UpdateVictim()) + return; + + events.Update(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = events.ExecuteEvent()) { - me->SummonCreature(NPC_SNOBOLD_VASSAL, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN); - Talk(EMOTE_SNOBOLLED); + switch (eventId) + { + case EVENT_IMPALE: + DoCastVictim(SPELL_IMPALE); + events.ScheduleEvent(EVENT_IMPALE, urand(8*IN_MILLISECONDS, 10*IN_MILLISECONDS)); + return; + case EVENT_STAGGERING_STOMP: + DoCastVictim(SPELL_STAGGERING_STOMP); + events.ScheduleEvent(EVENT_STAGGERING_STOMP, 15*IN_MILLISECONDS); + return; + case EVENT_THROW: + for (uint8 i = 0; i < MAX_SNOBOLDS; ++i) + { + if (Unit* pSnobold = me->GetVehicleKit()->GetPassenger(i)) + { + pSnobold->ExitVehicle(); + pSnobold->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + pSnobold->ToCreature()->SetReactState(REACT_AGGRESSIVE); + pSnobold->ToCreature()->AI()->DoAction(ACTION_DISABLE_FIRE_BOMB); + pSnobold->CastSpell(me, SPELL_RISING_ANGER, true); + Talk(EMOTE_SNOBOLLED); + break; + } + } + events.ScheduleEvent(EVENT_THROW, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + default: + return; + } } - m_uiSummonTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiSummonTimer -= diff; - DoMeleeAttackIfReady(); - } - }; + DoMeleeAttackIfReady(); + } + }; + CreatureAI* GetAI(Creature* creature) const + { + return new boss_gormokAI(creature); + } }; class mob_snobold_vassal : public CreatureScript { -public: - mob_snobold_vassal() : CreatureScript("mob_snobold_vassal") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_snobold_vassalAI(creature); - } + public: + mob_snobold_vassal() : CreatureScript("mob_snobold_vassal") { } - struct mob_snobold_vassalAI : public ScriptedAI - { - mob_snobold_vassalAI(Creature* creature) : ScriptedAI(creature) + struct mob_snobold_vassalAI : public ScriptedAI { - instance = creature->GetInstanceScript(); - if (instance) - instance->SetData(DATA_SNOBOLD_COUNT, INCREASE); - } + mob_snobold_vassalAI(Creature* creature) : ScriptedAI(creature) + { + _instance = creature->GetInstanceScript(); + if (_instance) + _instance->SetData(DATA_SNOBOLD_COUNT, INCREASE); + } - InstanceScript* instance; - uint32 m_uiFireBombTimer; - uint32 m_uiBatterTimer; - uint32 m_uiHeadCrackTimer; - uint64 m_uiBossGUID; - uint64 m_uiTargetGUID; - bool m_bTargetDied; + void Reset() + { + _events.ScheduleEvent(EVENT_BATTER, 5*IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_HEAD_CRACK, 25*IN_MILLISECONDS); - void Reset() - { - m_uiFireBombTimer = 15000; - m_uiBatterTimer = 5000; - m_uiHeadCrackTimer = 25000; + _targetGUID = 0; + _targetDied = false; - m_uiTargetGUID = 0; - m_bTargetDied = false; - if (instance) - m_uiBossGUID = instance->GetData64(NPC_GORMOK); - //Workaround for Snobold - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - } - - void EnterEvadeMode() - { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - ScriptedAI::EnterEvadeMode(); - } + if (_instance) + _bossGUID = _instance->GetData64(NPC_GORMOK); + //Workaround for Snobold + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + } - void EnterCombat(Unit* who) - { - m_uiTargetGUID = who->GetGUID(); - me->TauntApply(who); - DoCast(who, SPELL_SNOBOLLED); - } + void EnterEvadeMode() + { + ScriptedAI::EnterEvadeMode(); + } - void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) - { - if (pDoneBy->GetGUID()==m_uiTargetGUID) - uiDamage = 0; - } + void EnterCombat(Unit* who) + { + _targetGUID = who->GetGUID(); + me->TauntApply(who); + DoCast(who, SPELL_SNOBOLLED); + } - void MovementInform(uint32 type, uint32 pointId) - { - if (type != POINT_MOTION_TYPE) - return; + void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) + { + if (pDoneBy->GetGUID() == _targetGUID) + uiDamage = 0; + } - switch (pointId) + void MovementInform(uint32 type, uint32 pointId) { - case 0: - if (m_bTargetDied) - me->DespawnOrUnsummon(); - break; + if (type != POINT_MOTION_TYPE) + return; + + switch (pointId) + { + case 0: + if (_targetDied) + me->DespawnOrUnsummon(); + break; + default: + break; + } } - } - void JustDied(Unit* /*killer*/) - { - if (Unit* target = Unit::GetPlayer(*me, m_uiTargetGUID)) - if (target->isAlive()) - target->RemoveAurasDueToSpell(SPELL_SNOBOLLED); - if (instance) - instance->SetData(DATA_SNOBOLD_COUNT, DECREASE); - } + void JustDied(Unit* /*killer*/) + { + if (Unit* target = Unit::GetPlayer(*me, _targetGUID)) + if (target->isAlive()) + target->RemoveAurasDueToSpell(SPELL_SNOBOLLED); + if (_instance) + _instance->SetData(DATA_SNOBOLD_COUNT, DECREASE); + } - void UpdateAI(uint32 const diff) - { - if (m_bTargetDied || !UpdateVictim()) - return; + void DoAction(int32 const action) + { + switch (action) + { + case ACTION_ENABLE_FIRE_BOMB: + _events.ScheduleEvent(EVENT_FIRE_BOMB, urand(5*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + break; + case ACTION_DISABLE_FIRE_BOMB: + _events.CancelEvent(EVENT_FIRE_BOMB); + break; + default: + break; + } + } - if (Unit* target = Unit::GetPlayer(*me, m_uiTargetGUID)) + void UpdateAI(uint32 const diff) { - if (!target->isAlive()) + if (!UpdateVictim() || _targetDied) + return; + + if (Unit* target = Unit::GetPlayer(*me, _targetGUID)) { - if (instance) + if (!target->isAlive()) { - Unit* gormok = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_GORMOK)); - if (gormok && gormok->isAlive()) + if (_instance) { - SetCombatMovement(false); - m_bTargetDied = true; - me->GetMotionMaster()->MoveJump(gormok->GetPositionX(), gormok->GetPositionY(), gormok->GetPositionZ(), 15.0f, 15.0f); - } - else if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0)) - { - m_uiTargetGUID = target2->GetGUID(); - me->GetMotionMaster()->MoveJump(target2->GetPositionX(), target2->GetPositionY(), target2->GetPositionZ(), 15.0f, 15.0f); + Unit* gormok = ObjectAccessor::GetCreature(*me, _instance->GetData64(NPC_GORMOK)); + if (gormok && gormok->isAlive()) + { + SetCombatMovement(false); + _targetDied = true; + + // looping through Gormoks seats + for (uint8 i = 0; i < MAX_SNOBOLDS; i++) + { + if (!gormok->GetVehicleKit()->GetPassenger(i)) + { + me->EnterVehicle(gormok, i); + DoAction(ACTION_ENABLE_FIRE_BOMB); + break; + } + } + } + else if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + { + _targetGUID = target2->GetGUID(); + me->GetMotionMaster()->MoveJump(target2->GetPositionX(), target2->GetPositionY(), target2->GetPositionZ(), 15.0f, 15.0f); + } } } } + + _events.Update(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_FIRE_BOMB: + if (me->GetVehicleBase()) + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, -me->GetVehicleBase()->GetCombatReach(), true)) + me->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), SPELL_FIRE_BOMB, true); + _events.ScheduleEvent(EVENT_FIRE_BOMB, 20*IN_MILLISECONDS); + return; + case EVENT_HEAD_CRACK: + // commented out while SPELL_SNOBOLLED gets fixed + //if (Unit* target = Unit::GetPlayer(*me, m_uiTargetGUID)) + DoCastVictim(SPELL_HEAD_CRACK); + _events.ScheduleEvent(EVENT_HEAD_CRACK, 30*IN_MILLISECONDS); + return; + case EVENT_BATTER: + // commented out while SPELL_SNOBOLLED gets fixed + //if (Unit* target = Unit::GetPlayer(*me, m_uiTargetGUID)) + DoCastVictim(SPELL_BATTER); + _events.ScheduleEvent(EVENT_BATTER, 10*IN_MILLISECONDS); + return; + default: + return; + } + } + + // do melee attack only when not on Gormoks back + if (!me->GetVehicleBase()) + DoMeleeAttackIfReady(); } + private: + EventMap _events; + InstanceScript* _instance; + uint64 _bossGUID; + uint64 _targetGUID; + bool _targetDied; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new mob_snobold_vassalAI(creature); + } +}; + +class npc_firebomb : public CreatureScript +{ + public: + npc_firebomb() : CreatureScript("npc_firebomb") { } - if (m_uiFireBombTimer < diff) + struct npc_firebombAI : public ScriptedAI + { + npc_firebombAI(Creature* creature) : ScriptedAI(creature) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_FIRE_BOMB); - m_uiFireBombTimer = 20000; + _instance = creature->GetInstanceScript(); } - else m_uiFireBombTimer -= diff; - if (m_uiBatterTimer < diff) + void Reset() { - if (Unit* target = Unit::GetPlayer(*me, m_uiTargetGUID)) - DoCast(target, SPELL_BATTER); - m_uiBatterTimer = 10000; + DoCast(me, SPELL_FIRE_BOMB_DOT, true); + SetCombatMovement(false); + me->SetReactState(REACT_PASSIVE); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); } - else m_uiBatterTimer -= diff; - if (m_uiHeadCrackTimer < diff) + void UpdateAI(uint32 const /*diff*/) { - if (Unit* target = Unit::GetPlayer(*me, m_uiTargetGUID)) - DoCast(target, SPELL_HEAD_CRACK); - m_uiHeadCrackTimer = 35000; + if (_instance->GetData(TYPE_NORTHREND_BEASTS) != GORMOK_IN_PROGRESS) + me->DespawnOrUnsummon(); } - else m_uiHeadCrackTimer -= diff; - DoMeleeAttackIfReady(); - } - }; + private: + InstanceScript* _instance; + }; + CreatureAI* GetAI(Creature* creature) const + { + return new npc_firebombAI(creature); + } }; -struct boss_jormungarAI : public ScriptedAI +struct boss_jormungarAI : public BossAI { - boss_jormungarAI(Creature* creature) : ScriptedAI(creature) + boss_jormungarAI(Creature* creature) : BossAI(creature, BOSS_BEASTS) { - instanceScript = creature->GetInstanceScript(); } void Reset() { - enraged = false; - biteTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - spewTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - slimePoolTimer = 15*IN_MILLISECONDS; - spitTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - sprayTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - sweepTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); + Enraged = false; + + events.ScheduleEvent(EVENT_SPIT, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + events.ScheduleEvent(EVENT_SPRAY, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + events.ScheduleEvent(EVENT_SWEEP, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + events.ScheduleEvent(EVENT_BITE, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_MOBILE); + events.ScheduleEvent(EVENT_SPEW, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_MOBILE); + events.ScheduleEvent(EVENT_SLIME_POOL, 15*IN_MILLISECONDS, 0, PHASE_MOBILE); } void JustDied(Unit* /*killer*/) { - if (instanceScript) + if (instance) { - if (Creature* otherWorm = Unit::GetCreature(*me, instanceScript->GetData64(otherWormEntry))) + if (Creature* otherWorm = Unit::GetCreature(*me, instance->GetData64(OtherWormEntry))) { if (!otherWorm->isAlive()) { - instanceScript->SetData(TYPE_NORTHREND_BEASTS, SNAKES_DONE); + instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_DONE); me->DespawnOrUnsummon(); otherWorm->DespawnOrUnsummon(); } else - instanceScript->SetData(TYPE_NORTHREND_BEASTS, SNAKES_SPECIAL); + instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_SPECIAL); } } } void JustReachedHome() { - if (instanceScript && instanceScript->GetData(TYPE_NORTHREND_BEASTS) != FAIL) - { - instanceScript->SetData(TYPE_NORTHREND_BEASTS, FAIL); - } + // prevent losing 2 attempts at once on heroics + if (instance && instance->GetData(TYPE_NORTHREND_BEASTS) != FAIL) + instance->SetData(TYPE_NORTHREND_BEASTS, FAIL); me->DespawnOrUnsummon(); } @@ -440,17 +549,16 @@ struct boss_jormungarAI : public ScriptedAI void KilledUnit(Unit* who) { if (who->GetTypeId() == TYPEID_PLAYER) - { - if (instanceScript) - instanceScript->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); - } + if (instance) + instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0); } void EnterCombat(Unit* /*who*/) { + _EnterCombat(); me->SetInCombatWithZone(); - if (instanceScript) - instanceScript->SetData(TYPE_NORTHREND_BEASTS, SNAKES_IN_PROGRESS); + if (instance) + instance->SetData(TYPE_NORTHREND_BEASTS, SNAKES_IN_PROGRESS); } void UpdateAI(uint32 const diff) @@ -458,563 +566,597 @@ struct boss_jormungarAI : public ScriptedAI if (!UpdateVictim()) return; - if (instanceScript && instanceScript->GetData(TYPE_NORTHREND_BEASTS) == SNAKES_SPECIAL && !enraged) + if (!Enraged && instance && instance->GetData(TYPE_NORTHREND_BEASTS) == SNAKES_SPECIAL) { me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); DoCast(SPELL_ENRAGE); - enraged = true; + Enraged = true; Talk(EMOTE_ENRAGE); - switch (stage) - { - case 0: - break; - case 4: - stage = 5; - submergeTimer = 5*IN_MILLISECONDS; - break; - default: - stage = 7; - } } - switch (stage) - { - case 0: // Mobile - if (biteTimer <= diff) - { - DoCastVictim(biteSpell); - biteTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else biteTimer -= diff; + events.Update(diff); - if (spewTimer <= diff) - { - DoCastAOE(spewSpell); - spewTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else spewTimer -= diff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (slimePoolTimer <= diff) - { - /* Spell summon has only 30s duration */ + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_EMERGE: + Emerge(); + return; + case EVENT_SUBMERGE: + Submerge(); + return; + case EVENT_BITE: + DoCastVictim(BiteSpell); + events.ScheduleEvent(EVENT_BITE, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_MOBILE); + return; + case EVENT_SPEW: + DoCastAOE(SpewSpell); + events.ScheduleEvent(EVENT_SPEW, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_MOBILE); + return; + case EVENT_SLIME_POOL: DoCast(me, SUMMON_SLIME_POOL); - slimePoolTimer = 30*IN_MILLISECONDS; - } else slimePoolTimer -= diff; - - if (submergeTimer <= diff && !enraged) - { - stage = 1; - submergeTimer = 5*IN_MILLISECONDS; - } else submergeTimer -= diff; - - DoMeleeAttackIfReady(); - break; - case 1: // Submerge - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - DoCast(me, SPELL_SUBMERGE_0); - me->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX()+ frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionY() + frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionZ()); - stage = 2; - case 2: // Wait til emerge - if (submergeTimer <= diff) - { - stage = 3; - submergeTimer = 50*IN_MILLISECONDS; - } else submergeTimer -= diff; - break; - case 3: // Emerge - me->SetDisplayId(modelStationary); - me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0); - DoCast(me, SPELL_EMERGE_0); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); - SetCombatMovement(false); - me->GetMotionMaster()->MoveIdle(); - stage = 4; - break; - case 4: // Stationary - if (sprayTimer <= diff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, spraySpell); - sprayTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else sprayTimer -= diff; - - if (sweepTimer <= diff) - { + events.ScheduleEvent(EVENT_SLIME_POOL, 30*IN_MILLISECONDS, 0, PHASE_MOBILE); + return; + case EVENT_SUMMON_ACIDMAW: + if (Creature* acidmaw = me->SummonCreature(NPC_ACIDMAW, ToCCommonLoc[9].GetPositionX(), ToCCommonLoc[9].GetPositionY(), ToCCommonLoc[9].GetPositionZ(), 5, TEMPSUMMON_MANUAL_DESPAWN)) + { + acidmaw->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + acidmaw->SetReactState(REACT_AGGRESSIVE); + acidmaw->SetInCombatWithZone(); + acidmaw->CastSpell(acidmaw, SPELL_EMERGE_0); + } + return; + case EVENT_SPRAY: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + DoCast(target, SpraySpell); + events.ScheduleEvent(EVENT_SPRAY, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + return; + case EVENT_SWEEP: DoCastAOE(SPELL_SWEEP_0); - sweepTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else sweepTimer -= diff; - - if (submergeTimer <= diff) - { - stage = 5; - submergeTimer = 10*IN_MILLISECONDS; - } else submergeTimer -= diff; - - DoSpellAttackIfReady(spitSpell); - break; - case 5: // Submerge - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - DoCast(me, SPELL_SUBMERGE_0); - me->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX() + frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionY() + frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionZ()); - stage = 6; - case 6: // Wait til emerge - if (submergeTimer <= diff) - { - stage = 7; - submergeTimer = 45*IN_MILLISECONDS; - } else submergeTimer -= diff; - break; - case 7: // Emerge - me->SetDisplayId(modelMobile); - me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0); - DoCast(me, SPELL_EMERGE_0); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); - SetCombatMovement(true); - me->GetMotionMaster()->MoveChase(me->getVictim()); - stage = 0; - break; + events.ScheduleEvent(EVENT_SWEEP, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + return; + default: + return; + } } + if (events.GetPhaseMask() & PHASE_MASK_MOBILE) + DoMeleeAttackIfReady(); + if (events.GetPhaseMask() & PHASE_MASK_STATIONARY) + DoSpellAttackIfReady(SpitSpell); } - InstanceScript* instanceScript; + void Submerge() + { + DoCast(me, SPELL_SUBMERGE_0); + me->RemoveAurasDueToSpell(SPELL_EMERGE_0); + me->SetInCombatWithZone(); + events.SetPhase(PHASE_SUBMERGED); + events.ScheduleEvent(EVENT_EMERGE, 5*IN_MILLISECONDS, 0, PHASE_SUBMERGED); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX()+ frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionY() + frand(-40.0f, 40.0f), ToCCommonLoc[1].GetPositionZ()); + WasMobile = !WasMobile; + } - uint32 otherWormEntry; + void Emerge() + { + DoCast(me, SPELL_EMERGE_0); + me->SetDisplayId(ModelMobile); + me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->GetMotionMaster()->Clear(); + + // if the worm was mobile before submerging, make him stationary now + if (WasMobile) + { + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); + SetCombatMovement(false); + me->SetDisplayId(ModelStationary); + events.SetPhase(PHASE_STATIONARY); + events.ScheduleEvent(EVENT_SUBMERGE, 45*IN_MILLISECONDS, 0, PHASE_STATIONARY); + events.ScheduleEvent(EVENT_SPIT, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + events.ScheduleEvent(EVENT_SPRAY, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + events.ScheduleEvent(EVENT_SWEEP, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_STATIONARY); + } + else + { + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); + SetCombatMovement(true); + me->GetMotionMaster()->MoveChase(me->getVictim()); + me->SetDisplayId(ModelMobile); + events.SetPhase(PHASE_MOBILE); + events.ScheduleEvent(EVENT_SUBMERGE, 45*IN_MILLISECONDS, 0, PHASE_MOBILE); + events.ScheduleEvent(EVENT_BITE, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_MOBILE); + events.ScheduleEvent(EVENT_SPEW, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS), 0, PHASE_MOBILE); + events.ScheduleEvent(EVENT_SLIME_POOL, 15*IN_MILLISECONDS, 0, PHASE_MOBILE); + } + } - uint32 modelStationary; - uint32 modelMobile; + protected: + uint32 OtherWormEntry; + uint32 ModelStationary; + uint32 ModelMobile; - uint32 biteSpell; - uint32 spewSpell; - uint32 spitSpell; - uint32 spraySpell; + uint32 BiteSpell; + uint32 SpewSpell; + uint32 SpitSpell; + uint32 SpraySpell; - uint32 biteTimer; - uint32 spewTimer; - uint32 slimePoolTimer; - uint32 spitTimer; - uint32 sprayTimer; - uint32 sweepTimer; - uint32 submergeTimer; - uint8 stage; - bool enraged; + Phases Phase; + bool Enraged; + bool WasMobile; }; class boss_acidmaw : public CreatureScript { public: - boss_acidmaw() : CreatureScript("boss_acidmaw") { } + boss_acidmaw() : CreatureScript("boss_acidmaw") { } - struct boss_acidmawAI : public boss_jormungarAI - { - boss_acidmawAI(Creature* creature) : boss_jormungarAI(creature) { } + struct boss_acidmawAI : public boss_jormungarAI + { + boss_acidmawAI(Creature* creature) : boss_jormungarAI(creature) { } - void Reset() + void Reset() + { + boss_jormungarAI::Reset(); + BiteSpell = SPELL_PARALYTIC_BITE; + SpewSpell = SPELL_ACID_SPEW; + SpitSpell = SPELL_ACID_SPIT; + SpraySpell = SPELL_PARALYTIC_SPRAY; + ModelStationary = MODEL_ACIDMAW_STATIONARY; + ModelMobile = MODEL_ACIDMAW_MOBILE; + OtherWormEntry = NPC_DREADSCALE; + + WasMobile = true; + Emerge(); + } + }; + + CreatureAI* GetAI(Creature* creature) const { - boss_jormungarAI::Reset(); - biteSpell = SPELL_PARALYTIC_BITE; - spewSpell = SPELL_ACID_SPEW; - spitSpell = SPELL_ACID_SPIT; - spraySpell = SPELL_PARALYTIC_SPRAY; - modelStationary = MODEL_ACIDMAW_STATIONARY; - modelMobile = MODEL_ACIDMAW_MOBILE; - otherWormEntry = NPC_DREADSCALE; - - submergeTimer = 500; - DoCast(me, SPELL_SUBMERGE_0); - stage = 2; + return new boss_acidmawAI(creature); } - }; - - CreatureAI* GetAI(Creature* creature) const - { - return new boss_acidmawAI(creature); - } }; class boss_dreadscale : public CreatureScript { -public: - boss_dreadscale() : CreatureScript("boss_dreadscale") { } + public: + boss_dreadscale() : CreatureScript("boss_dreadscale") { } - struct boss_dreadscaleAI : public boss_jormungarAI - { - boss_dreadscaleAI(Creature* creature) : boss_jormungarAI(creature) + struct boss_dreadscaleAI : public boss_jormungarAI { - instanceScript = creature->GetInstanceScript(); - } + boss_dreadscaleAI(Creature* creature) : boss_jormungarAI(creature) + { + } - InstanceScript* instanceScript; + void Reset() + { + boss_jormungarAI::Reset(); + BiteSpell = SPELL_BURNING_BITE; + SpewSpell = SPELL_MOLTEN_SPEW; + SpitSpell = SPELL_FIRE_SPIT; + SpraySpell = SPELL_BURNING_SPRAY; + ModelStationary = MODEL_DREADSCALE_STATIONARY; + ModelMobile = MODEL_DREADSCALE_MOBILE; + OtherWormEntry = NPC_ACIDMAW; + + events.SetPhase(PHASE_MOBILE); + events.ScheduleEvent(EVENT_SUMMON_ACIDMAW, 3*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SUBMERGE, 45*IN_MILLISECONDS, 0, PHASE_MOBILE); + WasMobile = false; + } - void Reset() - { - boss_jormungarAI::Reset(); - biteSpell = SPELL_BURNING_BITE; - spewSpell = SPELL_MOLTEN_SPEW; - spitSpell = SPELL_FIRE_SPIT; - spraySpell = SPELL_BURNING_SPRAY; - modelStationary = MODEL_DREADSCALE_STATIONARY; - modelMobile = MODEL_DREADSCALE_MOBILE; - otherWormEntry = NPC_ACIDMAW; - - submergeTimer = 45 * IN_MILLISECONDS; - stage = 0; - } + void MovementInform(uint32 type, uint32 pointId) + { + if (type != POINT_MOTION_TYPE) + return; - void MovementInform(uint32 type, uint32 pointId) - { - if (type != POINT_MOTION_TYPE) - return; + switch (pointId) + { + case 0: + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + me->SetInCombatWithZone(); + break; + default: + break; + } + } - switch (pointId) + void EnterEvadeMode() { - case 0: - instanceScript->DoUseDoorOrButton(instanceScript->GetData64(GO_MAIN_GATE_DOOR)); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_AGGRESSIVE); - me->SetInCombatWithZone(); - if (Creature* otherWorm = Unit::GetCreature(*me, instanceScript->GetData64(otherWormEntry))) - { - otherWorm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - otherWorm->SetReactState(REACT_AGGRESSIVE); - otherWorm->SetVisible(true); - otherWorm->SetInCombatWithZone(); - } - break; + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + boss_jormungarAI::EnterEvadeMode(); } - } - void EnterEvadeMode() - { - instanceScript->DoUseDoorOrButton(instanceScript->GetData64(GO_MAIN_GATE_DOOR)); - boss_jormungarAI::EnterEvadeMode(); - } + void JustReachedHome() + { + if (instance) + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - void JustReachedHome() - { - if (instanceScript) - instanceScript->DoUseDoorOrButton(instanceScript->GetData64(GO_MAIN_GATE_DOOR)); + boss_jormungarAI::JustReachedHome(); + } + }; - boss_jormungarAI::JustReachedHome(); + CreatureAI* GetAI(Creature* creature) const + { + return new boss_dreadscaleAI(creature); } - }; - - CreatureAI* GetAI(Creature* creature) const - { - return new boss_dreadscaleAI(creature); - } }; class mob_slime_pool : public CreatureScript { -public: - mob_slime_pool() : CreatureScript("mob_slime_pool") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_slime_poolAI(creature); - } - - struct mob_slime_poolAI : public ScriptedAI - { - mob_slime_poolAI(Creature* creature) : ScriptedAI(creature) - { - } + public: + mob_slime_pool() : CreatureScript("mob_slime_pool") { } - bool casted; - void Reset() + struct mob_slime_poolAI : public ScriptedAI { - casted = false; - me->SetReactState(REACT_PASSIVE); - } + mob_slime_poolAI(Creature* creature) : ScriptedAI(creature) + { + _instance = creature->GetInstanceScript(); + } - void UpdateAI(uint32 const /*diff*/) - { - if (!casted) + void Reset() { - casted = true; - DoCast(me, SPELL_SLIME_POOL_EFFECT); + _cast = false; + me->SetReactState(REACT_PASSIVE); } - } - }; -}; + void UpdateAI(uint32 const /*diff*/) + { + if (!_cast) + { + _cast = true; + DoCast(me, SPELL_SLIME_POOL_EFFECT); + } -class boss_icehowl : public CreatureScript -{ -public: - boss_icehowl() : CreatureScript("boss_icehowl") { } + if (_instance->GetData(TYPE_NORTHREND_BEASTS) != SNAKES_IN_PROGRESS && _instance->GetData(TYPE_NORTHREND_BEASTS) != SNAKES_SPECIAL) + me->DespawnOrUnsummon(); + } + private: + InstanceScript* _instance; + bool _cast; - CreatureAI* GetAI(Creature* creature) const - { - return new boss_icehowlAI(creature); - } + }; - struct boss_icehowlAI : public ScriptedAI - { - boss_icehowlAI(Creature* creature) : ScriptedAI(creature) + CreatureAI* GetAI(Creature* creature) const { - instance = creature->GetInstanceScript(); + return new mob_slime_poolAI(creature); } +}; - InstanceScript* instance; - - uint32 m_uiFerociousButtTimer; - uint32 m_uiArticBreathTimer; - uint32 m_uiWhirlTimer; - uint32 m_uiMassiveCrashTimer; - uint32 m_uiTrampleTimer; - float m_fTrampleTargetX, m_fTrampleTargetY, m_fTrampleTargetZ; - uint64 m_uiTrampleTargetGUID; - bool m_bMovementStarted; - bool m_bMovementFinish; - bool m_bTrampleCasted; - uint8 m_uiStage; - Unit* target; - - void Reset() +class spell_gormok_fire_bomb : public SpellScriptLoader +{ + public: + spell_gormok_fire_bomb() : SpellScriptLoader("spell_gormok_fire_bomb") {} + + class spell_gormok_fire_bomb_SpellScript : public SpellScript { - m_uiFerociousButtTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - m_uiArticBreathTimer = urand(25*IN_MILLISECONDS, 40*IN_MILLISECONDS); - m_uiWhirlTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - m_uiMassiveCrashTimer = 30*IN_MILLISECONDS; - m_uiTrampleTimer = IN_MILLISECONDS; - m_bMovementStarted = false; - m_bMovementFinish = false; - m_bTrampleCasted = false; - m_uiTrampleTargetGUID = 0; - m_fTrampleTargetX = 0; - m_fTrampleTargetY = 0; - m_fTrampleTargetZ = 0; - m_uiStage = 0; - } + PrepareSpellScript(spell_gormok_fire_bomb_SpellScript); + + void TriggerFireBomb(SpellEffIndex /*effIndex*/) + { + if (const WorldLocation* pos = GetExplTargetDest()) + { + if (Unit* caster = GetCaster()) + caster->SummonCreature(NPC_FIRE_BOMB, pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30*IN_MILLISECONDS); + } + } + + void Register() + { + OnEffectHit += SpellEffectFn(spell_gormok_fire_bomb_SpellScript::TriggerFireBomb, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); + } + }; - void JustDied(Unit* /*killer*/) + SpellScript* GetSpellScript() const { - if (instance) - instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_DONE); + return new spell_gormok_fire_bomb_SpellScript(); } +}; + +class boss_icehowl : public CreatureScript +{ + public: + boss_icehowl() : CreatureScript("boss_icehowl") { } - void MovementInform(uint32 type, uint32 pointId) + struct boss_icehowlAI : public BossAI { - if (type != POINT_MOTION_TYPE && type != EFFECT_MOTION_TYPE) - return; + boss_icehowlAI(Creature* creature) : BossAI(creature, BOSS_BEASTS) + { + } - switch (pointId) + void Reset() { - case 0: - if (me->GetDistance2d(ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY()) < 6.0f) - { - // Middle of the room - m_uiStage = 1; - } - else - { - // Landed from Hop backwards (start trample) - if (Unit::GetPlayer(*me, m_uiTrampleTargetGUID)) + events.ScheduleEvent(EVENT_FEROCIOUS_BUTT, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_ARCTIC_BREATH, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_WHIRL, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + events.ScheduleEvent(EVENT_MASSIVE_CRASH, 30*IN_MILLISECONDS); + _movementStarted = false; + _movementFinish = false; + _trampleCasted = false; + _trampleTargetGUID = 0; + _trampleTargetX = 0; + _trampleTargetY = 0; + _trampleTargetZ = 0; + _stage = 0; + } + + void JustDied(Unit* /*killer*/) + { + _JustDied(); + if (instance) + instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_DONE); + } + + void MovementInform(uint32 type, uint32 pointId) + { + if (type != POINT_MOTION_TYPE && type != EFFECT_MOTION_TYPE) + return; + + switch (pointId) + { + case 0: + if (_stage != 0) { - m_uiStage = 4; + if (me->GetDistance2d(ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY()) < 6.0f) + // Middle of the room + _stage = 1; + else + { + // Landed from Hop backwards (start trample) + if (Unit::GetPlayer(*me, _trampleTargetGUID)) + _stage = 4; + else + _stage = 6; + } } - else - m_uiStage = 6; - } - break; - case 1: // Finish trample - m_bMovementFinish = true; - break; - case 2: - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - me->SetReactState(REACT_AGGRESSIVE); - me->SetInCombatWithZone(); - break; + break; + case 1: // Finish trample + _movementFinish = true; + break; + case 2: + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + me->SetInCombatWithZone(); + break; + default: + break; + } } - } - void EnterEvadeMode() - { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - ScriptedAI::EnterEvadeMode(); - } - - void JustReachedHome() - { - if (instance) + void EnterEvadeMode() { instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - instance->SetData(TYPE_NORTHREND_BEASTS, FAIL); + ScriptedAI::EnterEvadeMode(); } - me->DespawnOrUnsummon(); - } - void KilledUnit(Unit* who) - { - if (who->GetTypeId() == TYPEID_PLAYER) + void JustReachedHome() { if (instance) - instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); + { + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + instance->SetData(TYPE_NORTHREND_BEASTS, FAIL); + } + me->DespawnOrUnsummon(); } - } - - void EnterCombat(Unit* /*who*/) - { - if (instance) - instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_IN_PROGRESS); - me->SetInCombatWithZone(); - } - void SpellHitTarget(Unit* target, SpellInfo const* spell) - { - if (spell->Id == SPELL_TRAMPLE && target->GetTypeId() == TYPEID_PLAYER) + void KilledUnit(Unit* who) { - if (!m_bTrampleCasted) + if (who->GetTypeId() == TYPEID_PLAYER) { - DoCast(me, SPELL_FROTHING_RAGE, true); - m_bTrampleCasted = true; + if (instance) + instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0); } } - } - void UpdateAI(uint32 const diff) - { - if (!UpdateVictim()) - return; + void EnterCombat(Unit* /*who*/) + { + _EnterCombat(); + if (instance) + instance->SetData(TYPE_NORTHREND_BEASTS, ICEHOWL_IN_PROGRESS); + } - switch (m_uiStage) + void SpellHitTarget(Unit* target, SpellInfo const* spell) { - case 0: - if (m_uiFerociousButtTimer <= diff) + if (spell->Id == SPELL_TRAMPLE && target->GetTypeId() == TYPEID_PLAYER) + { + if (!_trampleCasted) { - DoCastVictim(SPELL_FEROCIOUS_BUTT); - m_uiFerociousButtTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiFerociousButtTimer -= diff; + DoCast(me, SPELL_FROTHING_RAGE, true); + _trampleCasted = true; + } + } + } - if (m_uiArticBreathTimer <= diff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_ARCTIC_BREATH); - m_uiArticBreathTimer = urand(25*IN_MILLISECONDS, 40*IN_MILLISECONDS); - } else m_uiArticBreathTimer -= diff; + void UpdateAI(uint32 const diff) + { + if (!UpdateVictim()) + return; - if (m_uiWhirlTimer <= diff) - { - DoCastAOE(SPELL_WHIRL); - m_uiWhirlTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS); - } else m_uiWhirlTimer -= diff; + events.Update(diff); - if (m_uiMassiveCrashTimer <= diff) - { - me->GetMotionMaster()->MoveJump(ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 10.0f, 20.0f); // 1: Middle of the room - SetCombatMovement(false); - me->AttackStop(); - m_uiStage = 7; //Invalid (Do nothing more than move) - m_uiMassiveCrashTimer = 30*IN_MILLISECONDS; - } else m_uiMassiveCrashTimer -= diff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - DoMeleeAttackIfReady(); - break; - case 1: - DoCastAOE(SPELL_MASSIVE_CRASH); - me->StopMoving(); - me->AttackStop(); - m_uiStage = 2; - break; - case 2: - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true)) + switch (_stage) + { + case 0: { + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_FEROCIOUS_BUTT: + DoCastVictim(SPELL_FEROCIOUS_BUTT); + events.ScheduleEvent(EVENT_FEROCIOUS_BUTT, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_ARCTIC_BREATH: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) + DoCast(target, SPELL_ARCTIC_BREATH); + return; + case EVENT_WHIRL: + DoCastAOE(SPELL_WHIRL); + events.ScheduleEvent(EVENT_WHIRL, urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS)); + return; + case EVENT_MASSIVE_CRASH: + me->GetMotionMaster()->MoveJump(ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 20.0f, 20.0f); // 1: Middle of the room + SetCombatMovement(false); + me->AttackStop(); + _stage = 7; //Invalid (Do nothing more than move) + return; + default: + break; + } + } + DoMeleeAttackIfReady(); + break; + } + case 1: + DoCastAOE(SPELL_MASSIVE_CRASH); me->StopMoving(); me->AttackStop(); - m_uiTrampleTargetGUID = target->GetGUID(); - me->SetTarget(m_uiTrampleTargetGUID); - m_bTrampleCasted = false; - //SetCombatMovement(false); - //me->GetMotionMaster()->MoveIdle(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_uiTrampleTimer = 4*IN_MILLISECONDS; - m_uiStage = 3; - } else m_uiStage = 6; - break; - case 3: - me->StopMoving(); - me->AttackStop(); - if (m_uiTrampleTimer <= diff) - { - if (Unit* target = Unit::GetPlayer(*me, m_uiTrampleTargetGUID)) + _stage = 2; + break; + case 2: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true)) { - m_bTrampleCasted = false; - m_bMovementStarted = true; - m_fTrampleTargetX = target->GetPositionX(); - m_fTrampleTargetY = target->GetPositionY(); - m_fTrampleTargetZ = target->GetPositionZ(); - me->GetMotionMaster()->MoveJump(2*me->GetPositionX()-m_fTrampleTargetX, - 2*me->GetPositionY()-m_fTrampleTargetY, - me->GetPositionZ(), - 20.0f, 30.0f); // 2: Hop Backwards - m_uiStage = 7; //Invalid (Do nothing more than move) - } else m_uiStage = 6; - } else m_uiTrampleTimer -= diff; - break; - case 4: - me->StopMoving(); - me->AttackStop(); - Talk(EMOTE_TRAMPLE_START, m_uiTrampleTargetGUID); - me->GetMotionMaster()->MoveCharge(m_fTrampleTargetX, m_fTrampleTargetY, m_fTrampleTargetZ+2, 42, 1); - me->SetTarget(0); - m_uiStage = 5; - break; - case 5: - if (m_bMovementFinish) - { - if (m_uiTrampleTimer <= diff) DoCastAOE(SPELL_TRAMPLE); - m_bMovementFinish = false; - m_uiStage = 6; - return; - } - if (m_uiTrampleTimer <= diff) - { - Map::PlayerList const &lPlayers = me->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr) + me->StopMoving(); + me->AttackStop(); + _trampleTargetGUID = target->GetGUID(); + me->SetTarget(_trampleTargetGUID); + _trampleCasted = false; + SetCombatMovement(false); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); + events.ScheduleEvent(EVENT_TRAMPLE, 4*IN_MILLISECONDS); + _stage = 3; + } + else + _stage = 6; + break; + case 3: + while (uint32 eventId = events.ExecuteEvent()) { - if (Unit* player = itr->getSource()) - if (player->isAlive() && player->IsWithinDistInMap(me, 6.0f)) + switch (eventId) + { + case EVENT_TRAMPLE: { - DoCastAOE(SPELL_TRAMPLE); - m_uiTrampleTimer = IN_MILLISECONDS; + if (Unit* target = Unit::GetPlayer(*me, _trampleTargetGUID)) + { + me->StopMoving(); + me->AttackStop(); + _trampleCasted = false; + _movementStarted = true; + _trampleTargetX = target->GetPositionX(); + _trampleTargetY = target->GetPositionY(); + _trampleTargetZ = target->GetPositionZ(); + // 2: Hop Backwards + me->GetMotionMaster()->MoveJump(2*me->GetPositionX() - _trampleTargetX, 2*me->GetPositionY() - _trampleTargetY, me->GetPositionZ(), 30.0f, 20.0f); + _stage = 7; //Invalid (Do nothing more than move) + } + else + _stage = 6; break; } + default: + break; + } } - } else m_uiTrampleTimer -= diff; - break; - case 6: - if (!m_bTrampleCasted) - { - DoCast(me, SPELL_STAGGERED_DAZE); - Talk(EMOTE_TRAMPLE_CRASH); - } - else - { - DoCast(me, SPELL_FROTHING_RAGE, true); - Talk(EMOTE_TRAMPLE_FAIL); - } - m_bMovementStarted = false; - me->GetMotionMaster()->MovementExpired(); - me->GetMotionMaster()->MoveChase(me->getVictim()); - SetCombatMovement(true); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_uiStage = 0; - break; + break; + case 4: + me->StopMoving(); + me->AttackStop(); + Talk(EMOTE_TRAMPLE_START, _trampleTargetGUID); + me->GetMotionMaster()->MoveCharge(_trampleTargetX, _trampleTargetY, _trampleTargetZ, 42, 1); + me->SetTarget(0); + _stage = 5; + break; + case 5: + if (_movementFinish) + { + DoCastAOE(SPELL_TRAMPLE); + _movementFinish = false; + _stage = 6; + return; + } + if (events.ExecuteEvent() == EVENT_TRAMPLE) + { + Map::PlayerList const &lPlayers = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr) + { + if (Unit* player = itr->getSource()) + { + if (player->isAlive() && player->IsWithinDistInMap(me, 6.0f)) + { + DoCastAOE(SPELL_TRAMPLE); + events.ScheduleEvent(EVENT_TRAMPLE, 4*IN_MILLISECONDS); + break; + } + } + } + } + break; + case 6: + if (!_trampleCasted) + { + DoCast(me, SPELL_STAGGERED_DAZE); + Talk(EMOTE_TRAMPLE_CRASH); + } + else + { + DoCast(me, SPELL_FROTHING_RAGE, true); + Talk(EMOTE_TRAMPLE_FAIL); + } + _movementStarted = false; + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE); + SetCombatMovement(true); + me->GetMotionMaster()->MovementExpired(); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveChase(me->getVictim()); + AttackStart(me->getVictim()); + events.ScheduleEvent(EVENT_MASSIVE_CRASH, 40*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_ARCTIC_BREATH, urand(15*IN_MILLISECONDS, 25*IN_MILLISECONDS)); + _stage = 0; + break; + default: + break; + } } - } - }; + private: + float _trampleTargetX, _trampleTargetY, _trampleTargetZ; + uint64 _trampleTargetGUID; + bool _movementStarted; + bool _movementFinish; + bool _trampleCasted; + uint8 _stage; + Unit* _target; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new boss_icehowlAI(creature); + } }; void AddSC_boss_northrend_beasts() { new boss_gormok(); new mob_snobold_vassal(); + new npc_firebomb(); + new spell_gormok_fire_bomb(); + new boss_acidmaw(); new boss_dreadscale(); new mob_slime_pool(); + new boss_icehowl(); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index a65eaebbc0c..01d3bcbfe90 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: trial_of_the_crusader -SD%Complete: ??% -SDComment: based on /dev/rsa -SDCategory: Crusader Coliseum -EndScriptData */ - // Known bugs: // - They should be floating but they aren't respecting the floor =( // - Hardcoded bullets spawner @@ -48,13 +41,13 @@ enum Yells SAY_TWINK_PACT = 5, SAY_KILL_PLAYER = 6, SAY_BERSERK = 7, - SAY_DEATH = 8, + SAY_DEATH = 8 }; enum Equipment { EQUIP_MAIN_1 = 9423, - EQUIP_MAIN_2 = 37377, + EQUIP_MAIN_2 = 37377 }; enum Summons @@ -62,7 +55,7 @@ enum Summons NPC_BULLET_CONTROLLER = 34743, NPC_BULLET_DARK = 34628, - NPC_BULLET_LIGHT = 34630, + NPC_BULLET_LIGHT = 34630 }; enum BossSpells @@ -72,6 +65,7 @@ enum BossSpells SPELL_LIGHT_SHIELD = 65858, SPELL_LIGHT_TWIN_PACT = 65876, SPELL_LIGHT_VORTEX = 66046, + SPELL_LIGHT_VORTEX_DAMAGE = 66048, SPELL_LIGHT_TOUCH = 67297, SPELL_LIGHT_ESSENCE = 65686, SPELL_EMPOWERED_LIGHT = 65748, @@ -83,17 +77,18 @@ enum BossSpells SPELL_DARK_SHIELD = 65874, SPELL_DARK_TWIN_PACT = 65875, SPELL_DARK_VORTEX = 66058, + SPELL_DARK_VORTEX_DAMAGE = 66059, SPELL_DARK_TOUCH = 67282, SPELL_DARK_ESSENCE = 65684, SPELL_EMPOWERED_DARK = 65724, SPELL_TWIN_EMPATHY_DARK = 66132, SPELL_UNLEASHED_DARK = 65808, - SPELL_CONTROLLER_PERIODIC = 66149, + SPELL_CONTROLLER_PERIODIC = 66149, SPELL_POWER_TWINS = 65879, SPELL_BERSERK = 64238, SPELL_POWERING_UP = 67590, - SPELL_SURGE_OF_SPEED = 65828, + SPELL_SURGE_OF_SPEED = 65828 }; #define SPELL_DARK_ESSENCE_HELPER RAID_MODE<uint32>(65684, 67176, 67177, 67178) @@ -106,13 +101,12 @@ enum BossSpells enum Actions { - ACTION_VORTEX, - ACTION_PACT + ACTION_VORTEX = 0, + ACTION_PACT = 1 }; -/*###### -## boss_twin_base -######*/ +#define ESSENCE_REMOVE 0 +#define ESSENCE_APPLY 1 class OrbsDespawner : public BasicEvent { @@ -145,61 +139,36 @@ class OrbsDespawner : public BasicEvent Creature* _creature; }; -struct boss_twin_baseAI : public ScriptedAI +struct boss_twin_baseAI : public BossAI { - boss_twin_baseAI(Creature* creature) : ScriptedAI(creature), Summons(me) + boss_twin_baseAI(Creature* creature) : BossAI(creature, BOSS_VALKIRIES) { - instance = creature->GetInstanceScript(); } - InstanceScript* instance; - SummonList Summons; - - AuraStateType m_uiAuraState; - - uint8 m_uiStage; - bool m_bIsBerserk; - uint32 m_uiWeapon; - uint32 m_uiSpecialAbilityTimer; - uint32 m_uiSpikeTimer; - uint32 m_uiTouchTimer; - uint32 m_uiBerserkTimer; - - int32 m_uiVortexEmote; - uint32 m_uiSisterNpcId; - uint32 m_uiMyEmphatySpellId; - uint32 m_uiOtherEssenceSpellId; - uint32 m_uiSurgeSpellId; - uint32 m_uiVortexSpellId; - uint32 m_uiShieldSpellId; - uint32 m_uiTwinPactSpellId; - uint32 m_uiSpikeSpellId; - uint32 m_uiTouchSpellId; - void Reset() { - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_PASSIVE); - me->ModifyAuraState(m_uiAuraState, true); - /* Uncomment this once that they are flying above the ground + me->ModifyAuraState(AuraState, true); + /* Uncomment this once that they are floating above the ground me->SetLevitate(true); me->SetFlying(true); */ - m_bIsBerserk = false; + IsBerserk = false; - m_uiSpecialAbilityTimer = MINUTE*IN_MILLISECONDS; - m_uiSpikeTimer = 20*IN_MILLISECONDS; - m_uiTouchTimer = urand(10, 15)*IN_MILLISECONDS; - m_uiBerserkTimer = IsHeroic() ? 6*MINUTE*IN_MILLISECONDS : 10*MINUTE*IN_MILLISECONDS; + SpecialAbilityTimer = 1*MINUTE*IN_MILLISECONDS; + SpikeTimer = 20*IN_MILLISECONDS; + TouchTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); + BerserkTimer = IsHeroic() ? 6*MINUTE*IN_MILLISECONDS : 10*MINUTE*IN_MILLISECONDS; - Summons.DespawnAll(); + summons.DespawnAll(); } void JustReachedHome() { if (instance) - instance->SetData(TYPE_VALKIRIES, FAIL); + instance->SetBossState(BOSS_VALKIRIES, FAIL); - Summons.DespawnAll(); + summons.DespawnAll(); me->DespawnOrUnsummon(); } @@ -211,10 +180,11 @@ struct boss_twin_baseAI : public ScriptedAI switch (uiId) { case 1: - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_AGGRESSIVE); break; + default: + break; } } @@ -224,13 +194,13 @@ struct boss_twin_baseAI : public ScriptedAI { Talk(SAY_KILL_PLAYER); if (instance) - instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE, 0); + instance->SetData(DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE, 0); } } void JustSummoned(Creature* summoned) { - Summons.Summon(summoned); + summons.Summon(summoned); } void SummonedCreatureDespawn(Creature* summoned) @@ -248,8 +218,10 @@ struct boss_twin_baseAI : public ScriptedAI case NPC_BULLET_CONTROLLER: me->m_Events.AddEvent(new OrbsDespawner(me), me->m_Events.CalculateTime(100)); break; + default: + break; } - Summons.Despawn(summoned); + summons.Despawn(summoned); } void JustDied(Unit* /*killer*/) @@ -263,24 +235,22 @@ struct boss_twin_baseAI : public ScriptedAI { me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); pSister->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - - instance->SetData(TYPE_VALKIRIES, DONE); - Summons.DespawnAll(); + _JustDied(); } else { me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - instance->SetData(TYPE_VALKIRIES, SPECIAL); + instance->SetBossState(BOSS_VALKIRIES, SPECIAL); } } } - Summons.DespawnAll(); + summons.DespawnAll(); } // Called when sister pointer needed Creature* GetSister() { - return Unit::GetCreature((*me), instance->GetData64(m_uiSisterNpcId)); + return Unit::GetCreature((*me), instance->GetData64(SisterNpcId)); } void EnterCombat(Unit* /*who*/) @@ -290,14 +260,14 @@ struct boss_twin_baseAI : public ScriptedAI { if (Creature* pSister = GetSister()) { - me->AddAura(m_uiMyEmphatySpellId, pSister); + me->AddAura(MyEmphatySpellId, pSister); pSister->SetInCombatWithZone(); } - instance->SetData(TYPE_VALKIRIES, IN_PROGRESS); + instance->SetBossState(BOSS_VALKIRIES, IN_PROGRESS); } Talk(SAY_AGGRO); - DoCast(me, m_uiSurgeSpellId); + DoCast(me, SurgeSpellId); } void DoAction(const int32 action) @@ -305,45 +275,50 @@ struct boss_twin_baseAI : public ScriptedAI switch (action) { case ACTION_VORTEX: - m_uiStage = me->GetEntry() == NPC_LIGHTBANE ? 2 : 1; + Stage = me->GetEntry() == NPC_LIGHTBANE ? 2 : 1; break; case ACTION_PACT: - m_uiStage = me->GetEntry() == NPC_LIGHTBANE ? 1 : 2; + Stage = me->GetEntry() == NPC_LIGHTBANE ? 1 : 2; + break; + default: break; } } void EnableDualWield(bool mode = true) { - SetEquipmentSlots(false, m_uiWeapon, mode ? m_uiWeapon : int32(EQUIP_UNEQUIP), EQUIP_UNEQUIP); + SetEquipmentSlots(false, Weapon, mode ? Weapon : int32(EQUIP_UNEQUIP), EQUIP_UNEQUIP); me->SetCanDualWield(mode); me->UpdateDamagePhysical(mode ? OFF_ATTACK : BASE_ATTACK); } - void UpdateAI(const uint32 uiDiff) + void UpdateAI(const uint32 diff) { if (!instance || !UpdateVictim()) return; - switch (m_uiStage) + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + switch (Stage) { case 0: break; case 1: // Vortex - if (m_uiSpecialAbilityTimer <= uiDiff) + if (SpecialAbilityTimer <= diff) { if (Creature* pSister = GetSister()) pSister->AI()->DoAction(ACTION_VORTEX); - Talk(m_uiVortexEmote); - DoCastAOE(m_uiVortexSpellId); - m_uiStage = 0; - m_uiSpecialAbilityTimer = MINUTE*IN_MILLISECONDS; + Talk(VortexEmote); + DoCastAOE(VortexSpellId); + Stage = 0; + SpecialAbilityTimer = 1*MINUTE*IN_MILLISECONDS; } else - m_uiSpecialAbilityTimer -= uiDiff; + SpecialAbilityTimer -= diff; break; - case 2: // Shield+Pact - if (m_uiSpecialAbilityTimer <= uiDiff) + case 2: // Shield + Pact + if (SpecialAbilityTimer <= diff) { Talk(EMOTE_TWINK_PACT); Talk(SAY_TWINK_PACT); @@ -352,164 +327,169 @@ struct boss_twin_baseAI : public ScriptedAI pSister->AI()->DoAction(ACTION_PACT); pSister->CastSpell(pSister, SPELL_POWER_TWINS, false); } - DoCast(me, m_uiShieldSpellId); - DoCast(me, m_uiTwinPactSpellId); - m_uiStage = 0; - m_uiSpecialAbilityTimer = MINUTE*IN_MILLISECONDS; + DoCast(me, ShieldSpellId); + DoCast(me, TwinPactSpellId); + Stage = 0; + SpecialAbilityTimer = 1*MINUTE*IN_MILLISECONDS; } else - m_uiSpecialAbilityTimer -= uiDiff; + SpecialAbilityTimer -= diff; break; default: break; } - if (m_uiSpikeTimer <= uiDiff) + if (SpikeTimer <= diff) { - DoCastVictim(m_uiSpikeSpellId); - m_uiSpikeTimer = 20*IN_MILLISECONDS; + DoCastVictim(SpikeSpellId); + SpikeTimer = 20*IN_MILLISECONDS; } else - m_uiSpikeTimer -= uiDiff; + SpikeTimer -= diff; - if (IsHeroic() && m_uiTouchTimer <= uiDiff) + if (IsHeroic() && TouchTimer <= diff) { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true, m_uiOtherEssenceSpellId)) - me->CastCustomSpell(m_uiTouchSpellId, SPELLVALUE_MAX_TARGETS, 1, target, false); - m_uiTouchTimer = urand(10, 15)*IN_MILLISECONDS; + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true, OtherEssenceSpellId)) + me->CastCustomSpell(TouchSpellId, SPELLVALUE_MAX_TARGETS, 1, target, false); + TouchTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS); } else - m_uiTouchTimer -= uiDiff; + TouchTimer -= diff; - if (!m_bIsBerserk && m_uiBerserkTimer <= uiDiff) + if (!IsBerserk && BerserkTimer <= diff) { DoCast(me, SPELL_BERSERK); Talk(SAY_BERSERK); - m_bIsBerserk = true; + IsBerserk = true; } else - m_uiBerserkTimer -= uiDiff; + BerserkTimer -= diff; DoMeleeAttackIfReady(); } -}; -/*###### -## boss_fjola -######*/ + protected: + AuraStateType AuraState; + + uint8 Stage; + bool IsBerserk; + + uint32 Weapon; + uint32 SpecialAbilityTimer; + uint32 SpikeTimer; + uint32 TouchTimer; + uint32 BerserkTimer; + + int32 VortexEmote; + uint32 SisterNpcId; + uint32 MyEmphatySpellId; + uint32 OtherEssenceSpellId; + uint32 SurgeSpellId; + uint32 VortexSpellId; + uint32 ShieldSpellId; + uint32 TwinPactSpellId; + uint32 SpikeSpellId; + uint32 TouchSpellId; +}; class boss_fjola : public CreatureScript { -public: - boss_fjola() : CreatureScript("boss_fjola") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new boss_fjolaAI(creature); - } + public: + boss_fjola() : CreatureScript("boss_fjola") { } - struct boss_fjolaAI : public boss_twin_baseAI - { - boss_fjolaAI(Creature* creature) : boss_twin_baseAI(creature) + struct boss_fjolaAI : public boss_twin_baseAI { - instance = creature->GetInstanceScript(); - } + boss_fjolaAI(Creature* creature) : boss_twin_baseAI(creature) + { + } - InstanceScript* instance; - - void Reset() { - boss_twin_baseAI::Reset(); - SetEquipmentSlots(false, EQUIP_MAIN_1, EQUIP_UNEQUIP, EQUIP_NO_CHANGE); - m_uiStage = 0; - m_uiWeapon = EQUIP_MAIN_1; - m_uiAuraState = AURA_STATE_UNKNOWN22; - m_uiVortexEmote = EMOTE_VORTEX; - m_uiSisterNpcId = NPC_DARKBANE; - m_uiMyEmphatySpellId = SPELL_TWIN_EMPATHY_DARK; - m_uiOtherEssenceSpellId = SPELL_DARK_ESSENCE_HELPER; - m_uiSurgeSpellId = SPELL_LIGHT_SURGE; - m_uiVortexSpellId = SPELL_LIGHT_VORTEX; - m_uiShieldSpellId = SPELL_LIGHT_SHIELD; - m_uiTwinPactSpellId = SPELL_LIGHT_TWIN_PACT; - m_uiTouchSpellId = SPELL_LIGHT_TOUCH; - m_uiSpikeSpellId = SPELL_LIGHT_TWIN_SPIKE; + void Reset() + { + SetEquipmentSlots(false, EQUIP_MAIN_1, EQUIP_UNEQUIP, EQUIP_NO_CHANGE); + Stage = 0; + Weapon = EQUIP_MAIN_1; + AuraState = AURA_STATE_UNKNOWN22; + VortexEmote = EMOTE_VORTEX; + SisterNpcId = NPC_DARKBANE; + MyEmphatySpellId = SPELL_TWIN_EMPATHY_DARK; + OtherEssenceSpellId = SPELL_DARK_ESSENCE_HELPER; + SurgeSpellId = SPELL_LIGHT_SURGE; + VortexSpellId = SPELL_LIGHT_VORTEX; + ShieldSpellId = SPELL_LIGHT_SHIELD; + TwinPactSpellId = SPELL_LIGHT_TWIN_PACT; + TouchSpellId = SPELL_LIGHT_TOUCH; + SpikeSpellId = SPELL_LIGHT_TWIN_SPIKE; + + if (instance) + instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT); + boss_twin_baseAI::Reset(); + } - if (instance) + void EnterCombat(Unit* who) { - instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT); + if (instance) + instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT); + + me->SummonCreature(NPC_BULLET_CONTROLLER, ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 0.0f, TEMPSUMMON_MANUAL_DESPAWN); + boss_twin_baseAI::EnterCombat(who); } - } - void EnterCombat(Unit* who) - { - if (instance) + void EnterEvadeMode() { - instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EVENT_START_TWINS_FIGHT); + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + boss_twin_baseAI::EnterEvadeMode(); } - me->SummonCreature(NPC_BULLET_CONTROLLER, ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 0.0f, TEMPSUMMON_MANUAL_DESPAWN); - boss_twin_baseAI::EnterCombat(who); - } + void JustReachedHome() + { + if (instance) + instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - void EnterEvadeMode() - { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - boss_twin_baseAI::EnterEvadeMode(); - } + boss_twin_baseAI::JustReachedHome(); + } + }; - void JustReachedHome() + CreatureAI* GetAI(Creature* creature) const { - if (instance) - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - - boss_twin_baseAI::JustReachedHome(); + return new boss_fjolaAI(creature); } - }; - }; -/*###### -## boss_eydis -######*/ - class boss_eydis : public CreatureScript { -public: - boss_eydis() : CreatureScript("boss_eydis") { } + public: + boss_eydis() : CreatureScript("boss_eydis") { } - CreatureAI* GetAI(Creature* creature) const - { - return new boss_eydisAI(creature); - } + struct boss_eydisAI : public boss_twin_baseAI + { + boss_eydisAI(Creature* creature) : boss_twin_baseAI(creature) {} - struct boss_eydisAI : public boss_twin_baseAI - { - boss_eydisAI(Creature* creature) : boss_twin_baseAI(creature) {} - - void Reset() { - boss_twin_baseAI::Reset(); - SetEquipmentSlots(false, EQUIP_MAIN_2, EQUIP_UNEQUIP, EQUIP_NO_CHANGE); - m_uiStage = 1; - m_uiWeapon = EQUIP_MAIN_2; - m_uiAuraState = AURA_STATE_UNKNOWN19; - m_uiVortexEmote = EMOTE_VORTEX; - m_uiSisterNpcId = NPC_LIGHTBANE; - m_uiMyEmphatySpellId = SPELL_TWIN_EMPATHY_LIGHT; - m_uiOtherEssenceSpellId = SPELL_LIGHT_ESSENCE_HELPER; - m_uiSurgeSpellId = SPELL_DARK_SURGE; - m_uiVortexSpellId = SPELL_DARK_VORTEX; - m_uiShieldSpellId = SPELL_DARK_SHIELD; - m_uiTwinPactSpellId = SPELL_DARK_TWIN_PACT; - m_uiTouchSpellId = SPELL_DARK_TOUCH; - m_uiSpikeSpellId = SPELL_DARK_TWIN_SPIKE; - } - }; + void Reset() + { + SetEquipmentSlots(false, EQUIP_MAIN_2, EQUIP_UNEQUIP, EQUIP_NO_CHANGE); + Stage = 1; + Weapon = EQUIP_MAIN_2; + AuraState = AURA_STATE_UNKNOWN19; + VortexEmote = EMOTE_VORTEX; + SisterNpcId = NPC_LIGHTBANE; + MyEmphatySpellId = SPELL_TWIN_EMPATHY_LIGHT; + OtherEssenceSpellId = SPELL_LIGHT_ESSENCE_HELPER; + SurgeSpellId = SPELL_DARK_SURGE; + VortexSpellId = SPELL_DARK_VORTEX; + ShieldSpellId = SPELL_DARK_SHIELD; + TwinPactSpellId = SPELL_DARK_TWIN_PACT; + TouchSpellId = SPELL_DARK_TOUCH; + SpikeSpellId = SPELL_DARK_TWIN_SPIKE; + boss_twin_baseAI::Reset(); + } + }; + CreatureAI* GetAI(Creature* creature) const + { + return new boss_eydisAI(creature); + } }; -#define ESSENCE_REMOVE 0 -#define ESSENCE_APPLY 1 - class mob_essence_of_twin : public CreatureScript { public: @@ -519,16 +499,16 @@ class mob_essence_of_twin : public CreatureScript { mob_essence_of_twinAI(Creature* creature) : ScriptedAI(creature) { } - uint32 GetData(uint32 data) + uint32 GetData(uint32 data) const { uint32 spellReturned = 0; switch (me->GetEntry()) { case NPC_LIGHT_ESSENCE: - spellReturned = data == ESSENCE_REMOVE? SPELL_DARK_ESSENCE_HELPER : SPELL_LIGHT_ESSENCE_HELPER; + spellReturned = (data == ESSENCE_REMOVE) ? SPELL_DARK_ESSENCE_HELPER : SPELL_LIGHT_ESSENCE_HELPER; break; case NPC_DARK_ESSENCE: - spellReturned = data == ESSENCE_REMOVE? SPELL_LIGHT_ESSENCE_HELPER : SPELL_DARK_ESSENCE_HELPER; + spellReturned = (data == ESSENCE_REMOVE) ? SPELL_LIGHT_ESSENCE_HELPER : SPELL_DARK_ESSENCE_HELPER; break; default: break; @@ -556,12 +536,8 @@ struct mob_unleashed_ballAI : public ScriptedAI { mob_unleashed_ballAI(Creature* creature) : ScriptedAI(creature) { - instance = creature->GetInstanceScript(); } - InstanceScript* instance; - uint32 m_uiRangeCheckTimer; - void MoveToNextPoint() { float x0 = ToCCommonLoc[1].GetPositionX(), y0 = ToCCommonLoc[1].GetPositionY(), r = 47.0f; @@ -578,13 +554,13 @@ struct mob_unleashed_ballAI : public ScriptedAI void Reset() { - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_PASSIVE); me->SetDisableGravity(true); me->SetCanFly(true); SetCombatMovement(false); MoveToNextPoint(); - m_uiRangeCheckTimer = IN_MILLISECONDS; + RangeCheckTimer = 0.5*IN_MILLISECONDS; } void MovementInform(uint32 uiType, uint32 uiId) @@ -600,160 +576,112 @@ struct mob_unleashed_ballAI : public ScriptedAI else me->DisappearAndDie(); break; + default: + break; } } + + protected: + uint32 RangeCheckTimer; }; class mob_unleashed_dark : public CreatureScript { -public: - mob_unleashed_dark() : CreatureScript("mob_unleashed_dark") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_unleashed_darkAI(creature); - } - - struct mob_unleashed_darkAI : public mob_unleashed_ballAI - { - mob_unleashed_darkAI(Creature* creature) : mob_unleashed_ballAI(creature) {} + public: + mob_unleashed_dark() : CreatureScript("mob_unleashed_dark") { } - void UpdateAI(const uint32 uiDiff) + struct mob_unleashed_darkAI : public mob_unleashed_ballAI { - if (m_uiRangeCheckTimer < uiDiff) + mob_unleashed_darkAI(Creature* creature) : mob_unleashed_ballAI(creature) {} + + void UpdateAI(const uint32 diff) { - if (me->SelectNearestPlayer(2.0f)) + if (RangeCheckTimer < diff) + { + if (me->SelectNearestPlayer(3.0f)) { - DoCastAOE(SPELL_UNLEASHED_DARK); + DoCastAOE(SPELL_UNLEASHED_DARK_HELPER); me->GetMotionMaster()->MoveIdle(); - me->DespawnOrUnsummon(500); + me->DespawnOrUnsummon(1*IN_MILLISECONDS); } - m_uiRangeCheckTimer = IN_MILLISECONDS; + RangeCheckTimer = 0.5*IN_MILLISECONDS; + } + else + RangeCheckTimer -= diff; } - else m_uiRangeCheckTimer -= uiDiff; - } + }; - void SpellHitTarget(Unit* who, SpellInfo const* spell) + CreatureAI* GetAI(Creature* creature) const { - if (spell->Id == SPELL_UNLEASHED_DARK_HELPER) - { - if (who->HasAura(SPELL_DARK_ESSENCE_HELPER)) - who->CastSpell(who, SPELL_POWERING_UP, true); - } + return new mob_unleashed_darkAI(creature); } - }; - }; class mob_unleashed_light : public CreatureScript { -public: - mob_unleashed_light() : CreatureScript("mob_unleashed_light") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_unleashed_lightAI(creature); - } - - struct mob_unleashed_lightAI : public mob_unleashed_ballAI - { - mob_unleashed_lightAI(Creature* creature) : mob_unleashed_ballAI(creature) {} + public: + mob_unleashed_light() : CreatureScript("mob_unleashed_light") { } - void UpdateAI(const uint32 uiDiff) + struct mob_unleashed_lightAI : public mob_unleashed_ballAI { - if (m_uiRangeCheckTimer < uiDiff) + mob_unleashed_lightAI(Creature* creature) : mob_unleashed_ballAI(creature) {} + + void UpdateAI(const uint32 diff) { - if (me->SelectNearestPlayer(2.0f)) + if (RangeCheckTimer < diff) + { + if (me->SelectNearestPlayer(3.0f)) { - DoCastAOE(SPELL_UNLEASHED_LIGHT); + DoCastAOE(SPELL_UNLEASHED_LIGHT_HELPER); me->GetMotionMaster()->MoveIdle(); - me->DespawnOrUnsummon(500); + me->DespawnOrUnsummon(1*IN_MILLISECONDS); } - m_uiRangeCheckTimer = IN_MILLISECONDS; + RangeCheckTimer = 0.5*IN_MILLISECONDS; + } + else + RangeCheckTimer -= diff; } - else m_uiRangeCheckTimer -= uiDiff; - } + }; - void SpellHitTarget(Unit* who, SpellInfo const* spell) + CreatureAI* GetAI(Creature* creature) const { - if (spell->Id == SPELL_UNLEASHED_LIGHT_HELPER) - { - if (who->HasAura(SPELL_LIGHT_ESSENCE_HELPER)) - who->CastSpell(who, SPELL_POWERING_UP, true); - } + return new mob_unleashed_lightAI(creature); } - }; - }; class mob_bullet_controller : public CreatureScript { -public: - mob_bullet_controller() : CreatureScript("mob_bullet_controller") { } - - CreatureAI* GetAI(Creature* creature) const - { - return new mob_bullet_controllerAI(creature); - } - - struct mob_bullet_controllerAI : public Scripted_NoMovementAI - { - mob_bullet_controllerAI(Creature* creature) : Scripted_NoMovementAI(creature) - { - Reset(); - } - - void Reset() - { - DoCastAOE(SPELL_CONTROLLER_PERIODIC); - } - - void UpdateAI(const uint32 /*uiDiff*/) - { - UpdateVictim(); - } - }; -}; - -class spell_powering_up : public SpellScriptLoader -{ public: - spell_powering_up() : SpellScriptLoader("spell_powering_up") { } + mob_bullet_controller() : CreatureScript("mob_bullet_controller") { } - class spell_powering_up_AuraScript : public AuraScript + struct mob_bullet_controllerAI : public Scripted_NoMovementAI { - PrepareAuraScript(spell_powering_up_AuraScript); - - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + mob_bullet_controllerAI(Creature* creature) : Scripted_NoMovementAI(creature) { - if (Unit* target = GetTarget()) - { - if (Aura* pAura = target->GetAura(GetId())) - { - if (pAura->GetStackAmount() == 100) - { - if (target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2206, EFFECT_1)) - target->CastSpell(target, SPELL_EMPOWERED_DARK, true); - - if (target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2845, EFFECT_1)) - target->CastSpell(target, SPELL_EMPOWERED_LIGHT, true); + Reset(); + } - target->RemoveAurasDueToSpell(GetId()); - } - } - } + void Reset() + { + DoCastAOE(SPELL_CONTROLLER_PERIODIC); } - void Register() + void UpdateAI(const uint32 /*diff*/) { - OnEffectApply += AuraEffectApplyFn(spell_powering_up_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + UpdateVictim(); } }; - AuraScript* GetAuraScript() const + CreatureAI* GetAI(Creature* creature) const { - return new spell_powering_up_AuraScript(); + return new mob_bullet_controllerAI(creature); } +}; + +class spell_powering_up : public SpellScriptLoader +{ + public: + spell_powering_up() : SpellScriptLoader("spell_powering_up") { } class spell_powering_up_SpellScript : public SpellScript { @@ -761,20 +689,39 @@ class spell_powering_up : public SpellScriptLoader PrepareSpellScript(spell_powering_up_SpellScript) uint32 spellId; + uint32 poweringUp; bool Load() { spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_SURGE_OF_SPEED, GetCaster()); if (!sSpellMgr->GetSpellInfo(spellId)) return false; + + poweringUp = sSpellMgr->GetSpellIdForDifficulty(SPELL_POWERING_UP, GetCaster()); + if (!sSpellMgr->GetSpellInfo(poweringUp)) + return false; + return true; } void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - if (Unit* target = GetExplTargetUnit()) - if (urand(0, 99) < 15) - target->CastSpell(target, spellId, true); + if (Unit* target = GetHitUnit()) + { + if (Aura* pAura = target->GetAura(poweringUp)) + { + if (pAura->GetStackAmount() >= 100) + { + if (target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2206, EFFECT_1)) + target->CastSpell(target, SPELL_EMPOWERED_DARK, true); + + if (target->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2845, EFFECT_1)) + target->CastSpell(target, SPELL_EMPOWERED_LIGHT, true); + + target->RemoveAurasDueToSpell(poweringUp); + } + } + } } void Register() @@ -808,10 +755,68 @@ class spell_valkyr_essences : public SpellScriptLoader return true; } - void Absorb(AuraEffect* /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & /*absorbAmount*/) + void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & /*absorbAmount*/) { - if (urand(0, 99) < 5) - GetTarget()->CastSpell(GetTarget(), spellId, true); + if (Unit* owner = GetUnitOwner()) + { + if (dmgInfo.GetSpellInfo()) + { + if (uint32 poweringUp = sSpellMgr->GetSpellIdForDifficulty(SPELL_POWERING_UP, owner)) + { + if (urand(0, 99) < 5) + GetTarget()->CastSpell(GetTarget(), spellId, true); + + // Twin Vortex part + uint32 lightVortex = sSpellMgr->GetSpellIdForDifficulty(SPELL_LIGHT_VORTEX_DAMAGE, owner); + uint32 darkVortex = sSpellMgr->GetSpellIdForDifficulty(SPELL_DARK_VORTEX_DAMAGE, owner); + int32 stacksCount = int32(dmgInfo.GetSpellInfo()->Effects[EFFECT_0].CalcValue()) * 0.001 - 1; + + if (lightVortex && darkVortex && stacksCount) + { + if (dmgInfo.GetSpellInfo()->Id == darkVortex || dmgInfo.GetSpellInfo()->Id == lightVortex) + { + Aura* pAura = owner->GetAura(poweringUp); + if (pAura) + { + pAura->ModStackAmount(stacksCount); + owner->CastSpell(owner, poweringUp, true); + } + else + { + owner->CastSpell(owner, poweringUp, true); + if (Aura* pTemp = owner->GetAura(poweringUp)) + pTemp->ModStackAmount(stacksCount); + } + } + } + + // Picking floating balls + uint32 unleashedDark = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNLEASHED_DARK, owner); + uint32 unleashedLight = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNLEASHED_LIGHT, owner); + + if (unleashedDark && unleashedLight) + { + if (dmgInfo.GetSpellInfo()->Id == unleashedDark || dmgInfo.GetSpellInfo()->Id == unleashedLight) + { + // need to do the things in this order, else players might have 100 charges of Powering Up without anything happening + Aura* pAura = owner->GetAura(poweringUp); + if (pAura) + { + // 2 lines together add the correct amount of buff stacks + pAura->ModStackAmount(stacksCount); + owner->CastSpell(owner, poweringUp, true); + } + else + { + owner->CastSpell(owner, poweringUp, true); + if (Aura* pTemp = owner->GetAura(poweringUp)) + pTemp->ModStackAmount(stacksCount); + } + } + } + } + } + } } void Register() @@ -880,6 +885,7 @@ void AddSC_boss_twin_valkyr() new mob_unleashed_dark(); new mob_essence_of_twin(); new mob_bullet_controller(); + new spell_powering_up(); new spell_valkyr_essences(); new spell_power_of_the_twins(); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp index af6104008ff..fb084ec1e3c 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp @@ -16,16 +16,11 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: instance_trial_of_the_crusader -SD%Complete: 80% -SDComment: by /dev/rsa -SDCategory: Trial of the Crusader -EndScriptData */ - #include "ScriptMgr.h" #include "InstanceScript.h" #include "trial_of_the_crusader.h" +#include "Player.h" +#include "TemporarySummon.h" class instance_trial_of_the_crusader : public InstanceMapScript { @@ -36,82 +31,54 @@ class instance_trial_of_the_crusader : public InstanceMapScript { instance_trial_of_the_crusader_InstanceMapScript(Map* map) : InstanceScript(map) {} - uint32 EncounterStatus[MAX_ENCOUNTERS]; - uint32 TrialCounter; - uint32 EventStage; - uint32 EventTimer; - uint32 EventNPCId; - uint32 NorthrendBeasts; - std::string SaveDataBuffer; - bool NeedSave; - - uint64 BarrentGUID; - uint64 TirionGUID; - uint64 TirionFordringGUID; - uint64 FizzlebangGUID; - uint64 GarroshGUID; - uint64 VarianGUID; - - uint64 GormokGUID; - uint64 AcidmawGUID; - uint64 DreadscaleGUID; - uint64 IcehowlGUID; - uint64 JaraxxusGUID; - uint64 ChampionsControllerGUID; - uint64 DarkbaneGUID; - uint64 LightbaneGUID; - uint64 AnubarakGUID; - - uint64 CrusadersCacheGUID; - uint64 FloorGUID; - - uint64 TributeChestGUID; - - uint64 MainGateDoorGUID; - uint64 EastPortcullisGUID; - uint64 WebDoorGUID; - - // Achievement stuff - uint32 NotOneButTwoJormungarsTimer; - uint32 ResilienceWillFixItTimer; - uint8 SnoboldCount; - uint8 MistressOfPainCount; - bool TributeToImmortalityElegible; - void Initialize() { - for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i) - EncounterStatus[i] = NOT_STARTED; - + SetBossNumber(MAX_ENCOUNTERS); TrialCounter = 50; EventStage = 0; - - TirionFordringGUID = 0; - - TributeChestGUID = 0; - - MainGateDoorGUID = 0; - EastPortcullisGUID = 0; - WebDoorGUID = 0; - NorthrendBeasts = NOT_STARTED; - EventTimer = 1000; - NotOneButTwoJormungarsTimer = 0; ResilienceWillFixItTimer = 0; SnoboldCount = 0; MistressOfPainCount = 0; - TributeToImmortalityElegible = true; - + TributeToImmortalityEligible = true; NeedSave = false; + + TirionFordringGUID = 0; + BarrentGUID = 0; + TirionGUID = 0; + FizzlebangGUID = 0; + GarroshGUID = 0; + VarianGUID = 0; + GormokGUID = 0; + AcidmawGUID = 0; + DreadscaleGUID = 0; + IcehowlGUID = 0; + JaraxxusGUID = 0; + ChampionsControllerGUID = 0; + DarkbaneGUID = 0; + LightbaneGUID = 0; + AnubarakGUID = 0; + + TributeChestGUID = 0; + MainGateDoorGUID = 0; + EastPortcullisGUID = 0; + WebDoorGUID = 0; + CrusadersCacheGUID = 0; + FloorGUID = 0; } bool IsEncounterInProgress() const { for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i) - if (EncounterStatus[i] == IN_PROGRESS) + if (GetBossState(i) == IN_PROGRESS) return true; + + // Special state is set at Faction Champions after first champ dead, encounter is still in combat + if (GetBossState(BOSS_CRUSADERS) == SPECIAL) + return true; + return false; } @@ -122,12 +89,26 @@ class instance_trial_of_the_crusader : public InstanceMapScript player->SendUpdateWorldState(UPDATE_STATE_UI_SHOW, 1); player->SendUpdateWorldState(UPDATE_STATE_UI_COUNT, GetData(TYPE_COUNTER)); } + else + player->SendUpdateWorldState(UPDATE_STATE_UI_SHOW, 0); + + // make sure Anub'arak isnt missing and floor is destroyed after a crash + if (GetBossState(BOSS_LICH_KING) == DONE && TrialCounter && GetBossState(BOSS_ANUBARAK) != DONE) + { + Creature* anubArak = Unit::GetCreature(*player, GetData64(NPC_ANUBARAK)); + if (!anubArak) + anubArak = player->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); + + if (GameObject* floor = GameObject::GetGameObject(*player, GetData64(GO_ARGENT_COLISEUM_FLOOR))) + floor->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); + } } void OpenDoor(uint64 guid) { if (!guid) return; + if (GameObject* go = instance->GetGameObject(guid)) go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); } @@ -136,6 +117,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript { if (!guid) return; + if (GameObject* go = instance->GetGameObject(guid)) go->SetGoState(GO_STATE_READY); } @@ -146,6 +128,8 @@ class instance_trial_of_the_crusader : public InstanceMapScript { case NPC_BARRENT: BarrentGUID = creature->GetGUID(); + if (!TrialCounter) + creature->DespawnOrUnsummon(); break; case NPC_TIRION: TirionGUID = creature->GetGUID(); @@ -190,6 +174,8 @@ class instance_trial_of_the_crusader : public InstanceMapScript case NPC_ANUBARAK: AnubarakGUID = creature->GetGUID(); break; + default: + break; } } @@ -236,34 +222,41 @@ class instance_trial_of_the_crusader : public InstanceMapScript case GO_TRIBUTE_CHEST_25H_99: TributeChestGUID = go->GetGUID(); break; + default: + break; } } - void SetData(uint32 type, uint32 data) + bool SetBossState(uint32 type, EncounterState state) { + if (!InstanceScript::SetBossState(type, state)) + return false; + switch (type) { - case TYPE_JARAXXUS: + case BOSS_BEASTS: + break; + case BOSS_JARAXXUS: // Cleanup Icehowl if (Creature* icehowl = instance->GetCreature(IcehowlGUID)) icehowl->DespawnOrUnsummon(); - if (data == DONE) + if (state == DONE) EventStage = 2000; break; - case TYPE_CRUSADERS: + case BOSS_CRUSADERS: // Cleanup Jaraxxus if (Creature* jaraxxus = instance->GetCreature(JaraxxusGUID)) jaraxxus->DespawnOrUnsummon(); if (Creature* fizzlebang = instance->GetCreature(FizzlebangGUID)) fizzlebang->DespawnOrUnsummon(); - switch (data) + switch (state) { case IN_PROGRESS: ResilienceWillFixItTimer = 0; break; case SPECIAL: //Means the first blood ResilienceWillFixItTimer = 60*IN_MILLISECONDS; - data = IN_PROGRESS; + state = IN_PROGRESS; break; case DONE: DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_DEFEAT_FACTION_CHAMPIONS); @@ -272,21 +265,23 @@ class instance_trial_of_the_crusader : public InstanceMapScript DoRespawnGameObject(CrusadersCacheGUID, 7*DAY); EventStage = 3100; break; + default: + break; } break; - case TYPE_VALKIRIES: + case BOSS_VALKIRIES: // Cleanup chest if (GameObject* cache = instance->GetGameObject(CrusadersCacheGUID)) cache->Delete(); - switch (data) + switch (state) { case FAIL: - if (EncounterStatus[TYPE_VALKIRIES] == NOT_STARTED) - data = NOT_STARTED; + if (GetBossState(BOSS_VALKIRIES) == NOT_STARTED) + state = NOT_STARTED; break; case SPECIAL: - if (EncounterStatus[TYPE_VALKIRIES] == SPECIAL) - data = DONE; + if (GetBossState(BOSS_VALKIRIES) == SPECIAL) + state = DONE; break; case DONE: if (instance->GetPlayers().getFirst()->getSource()->GetTeam() == ALLIANCE) @@ -294,50 +289,122 @@ class instance_trial_of_the_crusader : public InstanceMapScript else EventStage = 4030; break; + default: + break; } break; - case TYPE_ANUBARAK: - switch (data) + case BOSS_LICH_KING: + break; + case BOSS_ANUBARAK: + switch (state) { case DONE: + { EventStage = 6000; - break; - case SPECIAL: uint32 tributeChest = 0; if (instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_HEROIC) { if (TrialCounter >= 50) tributeChest = GO_TRIBUTE_CHEST_10H_99; else + { if (TrialCounter >= 45) tributeChest = GO_TRIBUTE_CHEST_10H_50; else + { if (TrialCounter >= 25) tributeChest = GO_TRIBUTE_CHEST_10H_45; else tributeChest = GO_TRIBUTE_CHEST_10H_25; + } + } } else if (instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_HEROIC) { if (TrialCounter >= 50) tributeChest = GO_TRIBUTE_CHEST_25H_99; else + { if (TrialCounter >= 45) tributeChest = GO_TRIBUTE_CHEST_25H_50; else + { if (TrialCounter >= 25) tributeChest = GO_TRIBUTE_CHEST_25H_45; else tributeChest = GO_TRIBUTE_CHEST_25H_25; + } + } } + if (tributeChest) if (Creature* tirion = instance->GetCreature(TirionGUID)) - // need proper location.this one is guessed based on videos - if (GameObject* chest = tirion->SummonGameObject(tributeChest, 643.814f, 136.027f, 141.295f, 0, 0, 0, 0, 0, 90000000)) + if (GameObject* chest = tirion->SummonGameObject(tributeChest, 805.62f, 134.87f, 142.16f, 3.27f, 0, 0, 0, 0, WEEK)) chest->SetRespawnTime(chest->GetRespawnDelay()); break; + } + default: + break; } break; + default: + break; + } + + if (IsEncounterInProgress()) + { + CloseDoor(GetData64(GO_EAST_PORTCULLIS)); + CloseDoor(GetData64(GO_WEB_DOOR)); + } + else + { + OpenDoor(GetData64(GO_EAST_PORTCULLIS)); + OpenDoor(GetData64(GO_WEB_DOOR)); + } + + if (type < MAX_ENCOUNTERS) + { + sLog->outInfo(LOG_FILTER_TSCR, "[ToCr] BossState(type %u) %u = state %u;", type, GetBossState(type), state); + if (state == FAIL) + { + if (instance->IsHeroic()) + { + --TrialCounter; + // decrease attempt counter at wipe + Map::PlayerList const &PlayerList = instance->GetPlayers(); + for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + if (Player* player = itr->getSource()) + player->SendUpdateWorldState(UPDATE_STATE_UI_COUNT, TrialCounter); + + // if theres no more attemps allowed + if (!TrialCounter) + { + if (Unit* announcer = instance->GetCreature(GetData64(NPC_BARRENT))) + announcer->ToCreature()->DespawnOrUnsummon(); + + if (Creature* anubArak = instance->GetCreature(GetData64(NPC_ANUBARAK))) + anubArak->DespawnOrUnsummon(); + } + } + NeedSave = true; + EventStage = (type == BOSS_BEASTS ? 666 : 0); + state = NOT_STARTED; + } + + if (state == DONE || NeedSave) + { + if (Unit* announcer = instance->GetCreature(GetData64(NPC_BARRENT))) + announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + Save(); + } + } + return true; + } + + void SetData(uint32 type, uint32 data) + { + switch (type) + { case TYPE_COUNTER: TrialCounter = data; data = DONE; @@ -357,7 +424,6 @@ class instance_trial_of_the_crusader : public InstanceMapScript case GORMOK_DONE: EventStage = 200; SetData(TYPE_NORTHREND_BEASTS, IN_PROGRESS); - SetData(TYPE_BEASTS, IN_PROGRESS); break; case SNAKES_IN_PROGRESS: NotOneButTwoJormungarsTimer = 0; @@ -370,15 +436,16 @@ class instance_trial_of_the_crusader : public InstanceMapScript DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_WORMS_KILLED_IN_10_SECONDS); EventStage = 300; SetData(TYPE_NORTHREND_BEASTS, IN_PROGRESS); - SetData(TYPE_BEASTS, IN_PROGRESS); break; case ICEHOWL_DONE: EventStage = 400; SetData(TYPE_NORTHREND_BEASTS, DONE); - SetData(TYPE_BEASTS, DONE); + SetBossState(BOSS_BEASTS, DONE); break; case FAIL: - SetData(TYPE_BEASTS, FAIL); + SetBossState(BOSS_BEASTS, FAIL); + break; + default: break; } break; @@ -395,44 +462,15 @@ class instance_trial_of_the_crusader : public InstanceMapScript else if (data == DECREASE) --MistressOfPainCount; break; - case DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE: - TributeToImmortalityElegible = false; + case DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE: + TributeToImmortalityEligible = false; + break; + default: break; - } - if (IsEncounterInProgress()) - { - CloseDoor(GetData64(GO_EAST_PORTCULLIS)); - CloseDoor(GetData64(GO_WEB_DOOR)); - } - else - { - OpenDoor(GetData64(GO_EAST_PORTCULLIS)); - OpenDoor(GetData64(GO_WEB_DOOR)); - } - - if (type < MAX_ENCOUNTERS) - { - sLog->outInfo(LOG_FILTER_TSCR, "[ToCr] EncounterStatus[type %u] %u = data %u;", type, EncounterStatus[type], data); - if (data == FAIL) - { - --TrialCounter; - NeedSave = true; - EventStage = (type == TYPE_BEASTS ? 666 : 0); - data = NOT_STARTED; - } - - EncounterStatus[type] = data; - - if (data == DONE || NeedSave == true) - { - if (Unit* announcer = instance->GetCreature(GetData64(NPC_BARRENT))) - announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - Save(); - } } } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { @@ -483,22 +521,10 @@ class instance_trial_of_the_crusader : public InstanceMapScript return 0; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { - case TYPE_BEASTS: - return EncounterStatus[TYPE_BEASTS]; - case TYPE_JARAXXUS: - return EncounterStatus[TYPE_JARAXXUS]; - case TYPE_CRUSADERS: - return EncounterStatus[TYPE_CRUSADERS]; - case TYPE_VALKIRIES: - return EncounterStatus[TYPE_VALKIRIES]; - case TYPE_LICH_KING: - return EncounterStatus[TYPE_LICH_KING]; - case TYPE_ANUBARAK: - return EncounterStatus[TYPE_ANUBARAK]; case TYPE_COUNTER: return TrialCounter; case TYPE_EVENT: @@ -549,7 +575,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript case 6000: case 6005: case 6010: - EventNPCId = NPC_TIRION; + return NPC_TIRION; break; case 5010: case 5030: @@ -558,7 +584,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript case 5060: case 5070: case 5080: - EventNPCId = NPC_LICH_KING_1; + return NPC_LICH_KING_1; break; case 120: case 122: @@ -567,7 +593,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript case 3051: case 3071: case 4020: - EventNPCId = NPC_VARIAN; + return NPC_VARIAN; break; case 130: case 132: @@ -576,7 +602,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript case 3070: case 3081: case 4030: - EventNPCId = NPC_GARROSH; + return NPC_GARROSH; break; case 1110: case 1120: @@ -588,13 +614,12 @@ class instance_trial_of_the_crusader : public InstanceMapScript case 1142: case 1144: case 1150: - EventNPCId = NPC_FIZZLEBANG; + return NPC_FIZZLEBANG; break; default: - EventNPCId = NPC_TIRION; + return NPC_TIRION; break; }; - return EventNPCId; default: break; } @@ -612,7 +637,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript NotOneButTwoJormungarsTimer -= diff; } - if (GetData(TYPE_CRUSADERS) == IN_PROGRESS && ResilienceWillFixItTimer) + if (GetBossState(BOSS_CRUSADERS) == SPECIAL && ResilienceWillFixItTimer) { if (ResilienceWillFixItTimer <= diff) ResilienceWillFixItTimer = 0; @@ -628,7 +653,7 @@ class instance_trial_of_the_crusader : public InstanceMapScript std::ostringstream saveStream; for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i) - saveStream << EncounterStatus[i] << ' '; + saveStream << GetBossState(i) << ' '; saveStream << TrialCounter; SaveDataBuffer = saveStream.str(); @@ -657,10 +682,11 @@ class instance_trial_of_the_crusader : public InstanceMapScript for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i) { - loadStream >> EncounterStatus[i]; - - if (EncounterStatus[i] == IN_PROGRESS) - EncounterStatus[i] = NOT_STARTED; + uint32 tmpState; + loadStream >> tmpState; + if (tmpState == IN_PROGRESS || tmpState > SPECIAL) + tmpState = NOT_STARTED; + SetBossState(i, EncounterState(tmpState)); } loadStream >> TrialCounter; @@ -696,13 +722,54 @@ class instance_trial_of_the_crusader : public InstanceMapScript return TrialCounter == 50; case A_TRIBUTE_TO_IMMORTALITY_HORDE: case A_TRIBUTE_TO_IMMORTALITY_ALLIANCE: - return TrialCounter == 50 && TributeToImmortalityElegible; + return TrialCounter == 50 && TributeToImmortalityEligible; case A_TRIBUTE_TO_DEDICATED_INSANITY: return false/*uiGrandCrusaderAttemptsLeft == 50 && !bHasAtAnyStagePlayerEquippedTooGoodItem*/; + default: + break; } return false; } + + protected: + uint32 TrialCounter; + uint32 EventStage; + uint32 EventTimer; + uint32 NorthrendBeasts; + bool NeedSave; + std::string SaveDataBuffer; + + uint64 BarrentGUID; + uint64 TirionGUID; + uint64 TirionFordringGUID; + uint64 FizzlebangGUID; + uint64 GarroshGUID; + uint64 VarianGUID; + + uint64 GormokGUID; + uint64 AcidmawGUID; + uint64 DreadscaleGUID; + uint64 IcehowlGUID; + uint64 JaraxxusGUID; + uint64 ChampionsControllerGUID; + uint64 DarkbaneGUID; + uint64 LightbaneGUID; + uint64 AnubarakGUID; + + uint64 CrusadersCacheGUID; + uint64 FloorGUID; + uint64 TributeChestGUID; + uint64 MainGateDoorGUID; + uint64 EastPortcullisGUID; + uint64 WebDoorGUID; + + // Achievement stuff + uint32 NotOneButTwoJormungarsTimer; + uint32 ResilienceWillFixItTimer; + uint8 SnoboldCount; + uint8 MistressOfPainCount; + bool TributeToImmortalityEligible; }; InstanceScript* GetInstanceScript(InstanceMap* map) const diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp index 0476b2cbacb..b4d35afa8fb 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp @@ -16,13 +16,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* ScriptData -SDName: Trial Of the crusader -SD%Complete: ??% -SDComment: event script based on /dev/rsa -SDCategory: trial_of_the_crusader -EndScriptData */ - //Known Bugs: // - Need better implementation of Gossip and correct gossip text and option @@ -30,6 +23,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "trial_of_the_crusader.h" +#include "Player.h" enum eYells { @@ -84,7 +78,7 @@ enum eYells // Highlord Tirion Fordring - 36095 SAY_STAGE_4_06 = 0, - SAY_STAGE_4_07 = 1, + SAY_STAGE_4_07 = 1 }; struct _Messages @@ -97,23 +91,22 @@ struct _Messages static _Messages _GossipMessage[]= { - {MSG_BEASTS, GOSSIP_ACTION_INFO_DEF+1, false, TYPE_BEASTS}, - {MSG_JARAXXUS, GOSSIP_ACTION_INFO_DEF+2, false, TYPE_JARAXXUS}, - {MSG_CRUSADERS, GOSSIP_ACTION_INFO_DEF+3, false, TYPE_CRUSADERS}, - {MSG_VALKIRIES, GOSSIP_ACTION_INFO_DEF+4, false, TYPE_VALKIRIES}, - {MSG_LICH_KING, GOSSIP_ACTION_INFO_DEF+5, false, TYPE_ANUBARAK}, - {MSG_ANUBARAK, GOSSIP_ACTION_INFO_DEF+6, true, TYPE_ANUBARAK} + {MSG_BEASTS, GOSSIP_ACTION_INFO_DEF + 1, false, BOSS_BEASTS}, + {MSG_JARAXXUS, GOSSIP_ACTION_INFO_DEF + 2, false, BOSS_JARAXXUS}, + {MSG_CRUSADERS, GOSSIP_ACTION_INFO_DEF + 3, false, BOSS_CRUSADERS}, + {MSG_VALKIRIES, GOSSIP_ACTION_INFO_DEF + 4, false, BOSS_VALKIRIES}, + {MSG_LICH_KING, GOSSIP_ACTION_INFO_DEF + 5, false, BOSS_ANUBARAK}, + {MSG_ANUBARAK, GOSSIP_ACTION_INFO_DEF + 6, true, BOSS_ANUBARAK} }; enum { - NUM_MESSAGES = 6, + NUM_MESSAGES = 6 }; class npc_announcer_toc10 : public CreatureScript { public: - npc_announcer_toc10() : CreatureScript("npc_announcer_toc10") { } struct npc_announcer_toc10AI : public ScriptedAI @@ -136,20 +129,20 @@ class npc_announcer_toc10 : public CreatureScript bool OnGossipHello(Player* player, Creature* creature) { - InstanceScript* instanceScript = creature->GetInstanceScript(); - if (!instanceScript) + InstanceScript* instance = creature->GetInstanceScript(); + if (!instance) return true; char const* _message = "We are ready!"; - if (player->isInCombat() || instanceScript->IsEncounterInProgress() || instanceScript->GetData(TYPE_EVENT)) + if (player->isInCombat() || instance->IsEncounterInProgress() || instance->GetData(TYPE_EVENT)) return true; uint8 i = 0; for (; i < NUM_MESSAGES; ++i) { - if ((!_GossipMessage[i].state && instanceScript->GetData(_GossipMessage[i].encounter) != DONE) - || (_GossipMessage[i].state && instanceScript->GetData(_GossipMessage[i].encounter) == DONE)) + if ((!_GossipMessage[i].state && instance->GetBossState(_GossipMessage[i].encounter) != DONE) + || (_GossipMessage[i].state && instance->GetBossState(_GossipMessage[i].encounter) == DONE)) { player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, _message, GOSSIP_SENDER_MAIN, _GossipMessage[i].id); break; @@ -160,75 +153,65 @@ class npc_announcer_toc10 : public CreatureScript return true; } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 /*action*/) { player->PlayerTalkClass->ClearMenus(); player->CLOSE_GOSSIP_MENU(); - InstanceScript* instanceScript = creature->GetInstanceScript(); - if (!instanceScript) + InstanceScript* instance = creature->GetInstanceScript(); + if (!instance) return true; - switch (action) + if (instance->GetBossState(BOSS_BEASTS) != DONE) { - case GOSSIP_ACTION_INFO_DEF+1: - if (instanceScript->GetData(TYPE_BEASTS) != DONE) - { - instanceScript->SetData(TYPE_EVENT, 110); - instanceScript->SetData(TYPE_NORTHREND_BEASTS, NOT_STARTED); - instanceScript->SetData(TYPE_BEASTS, NOT_STARTED); - } - break; - case GOSSIP_ACTION_INFO_DEF+2: - if (Creature* jaraxxus = Unit::GetCreature(*player, instanceScript->GetData64(NPC_JARAXXUS))) - { - jaraxxus->RemoveAurasDueToSpell(SPELL_JARAXXUS_CHAINS); - jaraxxus->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - jaraxxus->SetReactState(REACT_AGGRESSIVE); - jaraxxus->SetInCombatWithZone(); - } - else if (instanceScript->GetData(TYPE_JARAXXUS) != DONE) - { - instanceScript->SetData(TYPE_EVENT, 1010); - instanceScript->SetData(TYPE_JARAXXUS, NOT_STARTED); - } - break; - case GOSSIP_ACTION_INFO_DEF+3: - if (instanceScript->GetData(TYPE_CRUSADERS) != DONE) - { - if (player->GetTeam() == ALLIANCE) - instanceScript->SetData(TYPE_EVENT, 3000); - else - instanceScript->SetData(TYPE_EVENT, 3001); - instanceScript->SetData(TYPE_CRUSADERS, NOT_STARTED); - } - break; - case GOSSIP_ACTION_INFO_DEF+4: - if (instanceScript->GetData(TYPE_VALKIRIES) != DONE) - { - instanceScript->SetData(TYPE_EVENT, 4000); - instanceScript->SetData(TYPE_VALKIRIES, NOT_STARTED); - } - break; - case GOSSIP_ACTION_INFO_DEF+5: + instance->SetData(TYPE_EVENT, 110); + instance->SetData(TYPE_NORTHREND_BEASTS, NOT_STARTED); + instance->SetBossState(BOSS_BEASTS, NOT_STARTED); + } + else if (instance->GetBossState(BOSS_JARAXXUS) != DONE) + { + // if Jaraxxus is spawned, but the raid wiped + if (Creature* jaraxxus = Unit::GetCreature(*player, instance->GetData64(NPC_JARAXXUS))) { - if (instanceScript->GetData(TYPE_LICH_KING) != DONE && !player->isGameMaster()) - return true; - - if (GameObject* floor = GameObject::GetGameObject(*player, instanceScript->GetData64(GO_ARGENT_COLISEUM_FLOOR))) - floor->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); + jaraxxus->RemoveAurasDueToSpell(SPELL_JARAXXUS_CHAINS); + jaraxxus->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + jaraxxus->SetReactState(REACT_DEFENSIVE); + jaraxxus->SetInCombatWithZone(); + } + else + { + instance->SetData(TYPE_EVENT, 1010); + instance->SetBossState(BOSS_JARAXXUS, NOT_STARTED); + } + } + else if (instance->GetBossState(BOSS_CRUSADERS) != DONE) + { + if (player->GetTeam() == ALLIANCE) + instance->SetData(TYPE_EVENT, 3000); + else + instance->SetData(TYPE_EVENT, 3001); + instance->SetBossState(BOSS_CRUSADERS, NOT_STARTED); + } + else if (instance->GetBossState(BOSS_VALKIRIES) != DONE) + { + instance->SetData(TYPE_EVENT, 4000); + instance->SetBossState(BOSS_VALKIRIES, NOT_STARTED); + } + else if (instance->GetBossState(BOSS_LICH_KING) != DONE) + { + if (GameObject* floor = GameObject::GetGameObject(*player, instance->GetData64(GO_ARGENT_COLISEUM_FLOOR))) + floor->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); - creature->CastSpell(creature, 69016, false); + creature->CastSpell(creature, SPELL_CORPSE_TELEPORT, false); + creature->CastSpell(creature, SPELL_DESTROY_FLOOR_KNOCKUP, false); - Creature* anubArak = Unit::GetCreature(*creature, instanceScript->GetData64(NPC_ANUBARAK)); - if (!anubArak || !anubArak->isAlive()) - anubArak = creature->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); + Creature* anubArak = Unit::GetCreature(*creature, instance->GetData64(NPC_ANUBARAK)); + if (!anubArak || !anubArak->isAlive()) + anubArak = creature->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); - instanceScript->SetData(TYPE_ANUBARAK, NOT_STARTED); + instance->SetBossState(BOSS_ANUBARAK, NOT_STARTED); - if (creature->IsVisible()) - creature->SetVisible(false); - break; - } + if (creature->IsVisible()) + creature->SetVisible(false); } creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); return true; @@ -243,112 +226,130 @@ class npc_announcer_toc10 : public CreatureScript class boss_lich_king_toc : public CreatureScript { public: - boss_lich_king_toc() : CreatureScript("boss_lich_king_toc") { } struct boss_lich_king_tocAI : public ScriptedAI { boss_lich_king_tocAI(Creature* creature) : ScriptedAI(creature) { - instance = creature->GetInstanceScript(); + _instance = creature->GetInstanceScript(); } - InstanceScript* instance; - uint32 m_uiUpdateTimer; - void Reset() { - m_uiUpdateTimer = 0; + _updateTimer = 0; me->SetReactState(REACT_PASSIVE); - if (Creature* summoned = me->SummonCreature(NPC_TRIGGER, ToCCommonLoc[2].GetPositionX(), ToCCommonLoc[2].GetPositionY(), ToCCommonLoc[2].GetPositionZ(), 5, TEMPSUMMON_TIMED_DESPAWN, 60000)) + if (Creature* summoned = me->SummonCreature(NPC_TRIGGER, ToCCommonLoc[2].GetPositionX(), ToCCommonLoc[2].GetPositionY(), ToCCommonLoc[2].GetPositionZ(), 5, TEMPSUMMON_TIMED_DESPAWN, 1*MINUTE*IN_MILLISECONDS)) { summoned->CastSpell(summoned, 51807, false); - summoned->SetDisplayId(11686); + summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid2); } - if (instance) instance->SetData(TYPE_LICH_KING, IN_PROGRESS); + if (_instance) + _instance->SetBossState(BOSS_LICH_KING, IN_PROGRESS); me->SetWalk(true); } void MovementInform(uint32 uiType, uint32 uiId) { - if (uiType != POINT_MOTION_TYPE || !instance) + if (uiType != POINT_MOTION_TYPE || !_instance) return; + switch (uiId) { case 0: - instance->SetData(TYPE_EVENT, 5030); + _instance->SetData(TYPE_EVENT, 5030); break; case 1: - instance->SetData(TYPE_EVENT, 5050); + _instance->SetData(TYPE_EVENT, 5050); + break; + default: break; } } void UpdateAI(const uint32 uiDiff) { - if (!instance) + if (!_instance) return; - if (instance->GetData(TYPE_EVENT_NPC) != NPC_LICH_KING_1) + if (_instance->GetData(TYPE_EVENT_NPC) != NPC_LICH_KING_1) return; - m_uiUpdateTimer = instance->GetData(TYPE_EVENT_TIMER); - if (m_uiUpdateTimer <= uiDiff) + _updateTimer = _instance->GetData(TYPE_EVENT_TIMER); + if (_updateTimer <= uiDiff) { - switch (instance->GetData(TYPE_EVENT)) + switch (_instance->GetData(TYPE_EVENT)) { case 5010: Talk(SAY_STAGE_4_02); - m_uiUpdateTimer = 3000; + _updateTimer = 3*IN_MILLISECONDS; me->GetMotionMaster()->MovePoint(0, LichKingLoc[0]); - instance->SetData(TYPE_EVENT, 5020); + _instance->SetData(TYPE_EVENT, 5020); break; case 5030: Talk(SAY_STAGE_4_04); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); - m_uiUpdateTimer = 10000; - instance->SetData(TYPE_EVENT, 5040); + _updateTimer = 10*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 5040); break; case 5040: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); me->GetMotionMaster()->MovePoint(1, LichKingLoc[1]); - m_uiUpdateTimer = 1000; - instance->SetData(TYPE_EVENT, 0); + _updateTimer = 1*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 0); break; case 5050: me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 5060); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 5060); break; case 5060: Talk(SAY_STAGE_4_05); me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); - m_uiUpdateTimer = 2500; - instance->SetData(TYPE_EVENT, 5070); + _updateTimer = 2.5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 5070); break; case 5070: me->CastSpell(me, 68198, false); - m_uiUpdateTimer = 1500; - instance->SetData(TYPE_EVENT, 5080); + _updateTimer = 1.5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 5080); break; case 5080: - if (GameObject* go = instance->instance->GetGameObject(instance->GetData64(GO_ARGENT_COLISEUM_FLOOR))) - go->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); - me->CastSpell(me, 69016, false); - instance->SetData(TYPE_LICH_KING, DONE); - Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_ANUBARAK)); - if (!temp || !temp->isAlive()) - temp = me->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); - - instance->SetData(TYPE_EVENT, 0); + if (GameObject* go = _instance->instance->GetGameObject(_instance->GetData64(GO_ARGENT_COLISEUM_FLOOR))) + { + go->SetDisplayId(DISPLAYID_DESTROYED_FLOOR); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN); + go->SetGoState(GO_STATE_ACTIVE); + } + + me->CastSpell(me, SPELL_CORPSE_TELEPORT, false); + me->CastSpell(me, SPELL_DESTROY_FLOOR_KNOCKUP, false); + + if (_instance) + { + _instance->SetBossState(BOSS_LICH_KING, DONE); + Creature* temp = Unit::GetCreature(*me, _instance->GetData64(NPC_ANUBARAK)); + if (!temp || !temp->isAlive()) + temp = me->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); + + _instance->SetData(TYPE_EVENT, 0); + } me->DespawnOrUnsummon(); - m_uiUpdateTimer = 20000; + _updateTimer = 20*IN_MILLISECONDS; + break; + default: break; } - } else m_uiUpdateTimer -= uiDiff; + } + else + _updateTimer -= uiDiff; - instance->SetData(TYPE_EVENT_TIMER, m_uiUpdateTimer); + _instance->SetData(TYPE_EVENT_TIMER, _updateTimer); } + + private: + InstanceScript* _instance; + uint32 _updateTimer; }; CreatureAI* GetAI(Creature* creature) const @@ -360,27 +361,20 @@ class boss_lich_king_toc : public CreatureScript class npc_fizzlebang_toc : public CreatureScript { public: - npc_fizzlebang_toc() : CreatureScript("npc_fizzlebang_toc") { } struct npc_fizzlebang_tocAI : public ScriptedAI { - npc_fizzlebang_tocAI(Creature* creature) : ScriptedAI(creature), Summons(me) + npc_fizzlebang_tocAI(Creature* creature) : ScriptedAI(creature), _summons(me) { - instance = me->GetInstanceScript(); + _instance = me->GetInstanceScript(); } - InstanceScript* instance; - SummonList Summons; - uint32 m_uiUpdateTimer; - uint64 m_uiPortalGUID; - uint64 m_uiTriggerGUID; - void JustDied(Unit* killer) { Talk(SAY_STAGE_1_06, killer->GetGUID()); - instance->SetData(TYPE_EVENT, 1180); - if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_JARAXXUS))) + _instance->SetData(TYPE_EVENT, 1180); + if (Creature* temp = Unit::GetCreature(*me, _instance->GetData64(NPC_JARAXXUS))) { temp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); temp->SetReactState(REACT_AGGRESSIVE); @@ -391,7 +385,7 @@ class npc_fizzlebang_toc : public CreatureScript void Reset() { me->SetWalk(true); - m_uiPortalGUID = 0; + _portalGUID = 0; me->GetMotionMaster()->MovePoint(1, ToCCommonLoc[10].GetPositionX(), ToCCommonLoc[10].GetPositionY()-60, ToCCommonLoc[10].GetPositionZ()); } @@ -404,42 +398,44 @@ class npc_fizzlebang_toc : public CreatureScript { case 1: me->SetWalk(false); - if (instance) + if (_instance) { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - instance->SetData(TYPE_EVENT, 1120); - instance->SetData(TYPE_EVENT_TIMER, 1000); + _instance->DoUseDoorOrButton(_instance->GetData64(GO_MAIN_GATE_DOOR)); + _instance->SetData(TYPE_EVENT, 1120); + _instance->SetData(TYPE_EVENT_TIMER, 1*IN_MILLISECONDS); } break; + default: + break; } } void JustSummoned(Creature* summoned) { - Summons.Summon(summoned); + _summons.Summon(summoned); } void UpdateAI(const uint32 uiDiff) { - if (!instance) + if (!_instance) return; - if (instance->GetData(TYPE_EVENT_NPC) != NPC_FIZZLEBANG) + if (_instance->GetData(TYPE_EVENT_NPC) != NPC_FIZZLEBANG) return; - m_uiUpdateTimer = instance->GetData(TYPE_EVENT_TIMER); - if (m_uiUpdateTimer <= uiDiff) + _updateTimer = _instance->GetData(TYPE_EVENT_TIMER); + if (_updateTimer <= uiDiff) { - switch (instance->GetData(TYPE_EVENT)) + switch (_instance->GetData(TYPE_EVENT)) { case 1110: - instance->SetData(TYPE_EVENT, 1120); - m_uiUpdateTimer = 4000; + _instance->SetData(TYPE_EVENT, 1120); + _updateTimer = 4*IN_MILLISECONDS; break; case 1120: Talk(SAY_STAGE_1_02); - instance->SetData(TYPE_EVENT, 1130); - m_uiUpdateTimer = 12000; + _instance->SetData(TYPE_EVENT, 1130); + _updateTimer = 12*IN_MILLISECONDS; break; case 1130: me->GetMotionMaster()->MovementExpired(); @@ -447,18 +443,18 @@ class npc_fizzlebang_toc : public CreatureScript me->HandleEmoteCommand(EMOTE_ONESHOT_SPELL_CAST_OMNI); if (Unit* pTrigger = me->SummonCreature(NPC_TRIGGER, ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 4.69494f, TEMPSUMMON_MANUAL_DESPAWN)) { - m_uiTriggerGUID = pTrigger->GetGUID(); + _triggerGUID = pTrigger->GetGUID(); pTrigger->SetObjectScale(2.0f); - pTrigger->SetDisplayId(22862); + pTrigger->SetDisplayId(pTrigger->ToCreature()->GetCreatureTemplate()->Modelid1); pTrigger->CastSpell(pTrigger, SPELL_WILFRED_PORTAL, false); } - instance->SetData(TYPE_EVENT, 1132); - m_uiUpdateTimer = 4000; + _instance->SetData(TYPE_EVENT, 1132); + _updateTimer = 4*IN_MILLISECONDS; break; case 1132: me->GetMotionMaster()->MovementExpired(); - instance->SetData(TYPE_EVENT, 1134); - m_uiUpdateTimer = 4000; + _instance->SetData(TYPE_EVENT, 1134); + _updateTimer = 4*IN_MILLISECONDS; break; case 1134: me->HandleEmoteCommand(EMOTE_ONESHOT_SPELL_CAST_OMNI); @@ -467,14 +463,14 @@ class npc_fizzlebang_toc : public CreatureScript pPortal->SetReactState(REACT_PASSIVE); pPortal->SetObjectScale(2.0f); pPortal->CastSpell(pPortal, SPELL_WILFRED_PORTAL, false); - m_uiPortalGUID = pPortal->GetGUID(); + _portalGUID = pPortal->GetGUID(); } - m_uiUpdateTimer = 4000; - instance->SetData(TYPE_EVENT, 1135); + _updateTimer = 4*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 1135); break; case 1135: - instance->SetData(TYPE_EVENT, 1140); - m_uiUpdateTimer = 3000; + _instance->SetData(TYPE_EVENT, 1140); + _updateTimer = 3*IN_MILLISECONDS; break; case 1140: Talk(SAY_STAGE_1_04); @@ -484,27 +480,27 @@ class npc_fizzlebang_toc : public CreatureScript temp->SetReactState(REACT_PASSIVE); temp->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY()-10, ToCCommonLoc[1].GetPositionZ()); } - instance->SetData(TYPE_EVENT, 1142); - m_uiUpdateTimer = 5000; + _instance->SetData(TYPE_EVENT, 1142); + _updateTimer = 5*IN_MILLISECONDS; break; case 1142: - if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_JARAXXUS))) + if (Creature* temp = Unit::GetCreature(*me, _instance->GetData64(NPC_JARAXXUS))) temp->SetTarget(me->GetGUID()); - if (Creature* pTrigger = Unit::GetCreature(*me, m_uiTriggerGUID)) + if (Creature* pTrigger = Unit::GetCreature(*me, _triggerGUID)) pTrigger->DespawnOrUnsummon(); - if (Creature* pPortal = Unit::GetCreature(*me, m_uiPortalGUID)) + if (Creature* pPortal = Unit::GetCreature(*me, _portalGUID)) pPortal->DespawnOrUnsummon(); - instance->SetData(TYPE_EVENT, 1144); - m_uiUpdateTimer = 10000; + _instance->SetData(TYPE_EVENT, 1144); + _updateTimer = 10*IN_MILLISECONDS; break; case 1144: - if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_JARAXXUS))) + if (Creature* temp = Unit::GetCreature(*me, _instance->GetData64(NPC_JARAXXUS))) temp->AI()->Talk(SAY_STAGE_1_05); - instance->SetData(TYPE_EVENT, 1150); - m_uiUpdateTimer = 5000; + _instance->SetData(TYPE_EVENT, 1150); + _updateTimer = 5*IN_MILLISECONDS; break; case 1150: - if (Creature* temp = Unit::GetCreature(*me, instance->GetData64(NPC_JARAXXUS))) + if (Creature* temp = Unit::GetCreature(*me, _instance->GetData64(NPC_JARAXXUS))) { //1-shot Fizzlebang temp->CastSpell(me, 67888, false); @@ -512,13 +508,22 @@ class npc_fizzlebang_toc : public CreatureScript temp->AddThreat(me, 1000.0f); temp->AI()->AttackStart(me); } - instance->SetData(TYPE_EVENT, 1160); - m_uiUpdateTimer = 3000; + _instance->SetData(TYPE_EVENT, 1160); + _updateTimer = 3*IN_MILLISECONDS; break; } - } else m_uiUpdateTimer -= uiDiff; - instance->SetData(TYPE_EVENT_TIMER, m_uiUpdateTimer); + } + else + _updateTimer -= uiDiff; + _instance->SetData(TYPE_EVENT_TIMER, _updateTimer); } + + private: + InstanceScript* _instance; + SummonList _summons; + uint32 _updateTimer; + uint64 _portalGUID; + uint64 _triggerGUID; }; CreatureAI* GetAI(Creature* creature) const @@ -530,53 +535,49 @@ class npc_fizzlebang_toc : public CreatureScript class npc_tirion_toc : public CreatureScript { public: - npc_tirion_toc() : CreatureScript("npc_tirion_toc") { } struct npc_tirion_tocAI : public ScriptedAI { npc_tirion_tocAI(Creature* creature) : ScriptedAI(creature) { - instance = me->GetInstanceScript(); + _instance = me->GetInstanceScript(); } - InstanceScript* instance; - uint32 m_uiUpdateTimer; - void Reset() {} void AttackStart(Unit* /*who*/) {} void UpdateAI(const uint32 uiDiff) { - if (!instance) + if (!_instance) return; - if (instance->GetData(TYPE_EVENT_NPC) != NPC_TIRION) + if (_instance->GetData(TYPE_EVENT_NPC) != NPC_TIRION) return; - m_uiUpdateTimer = instance->GetData(TYPE_EVENT_TIMER); - if (m_uiUpdateTimer <= uiDiff) + _updateTimer = _instance->GetData(TYPE_EVENT_TIMER); + if (_updateTimer <= uiDiff) { - switch (instance->GetData(TYPE_EVENT)) + switch (_instance->GetData(TYPE_EVENT)) { case 110: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); Talk(SAY_STAGE_0_01); - m_uiUpdateTimer = 22000; - instance->SetData(TYPE_EVENT, 120); + _updateTimer = 22*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 120); break; case 140: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); Talk(SAY_STAGE_0_02); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 150); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 150); break; case 150: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); - if (instance->GetData(TYPE_BEASTS) != DONE) + if (_instance->GetBossState(BOSS_BEASTS) != DONE) { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + _instance->DoUseDoorOrButton(_instance->GetData64(GO_MAIN_GATE_DOOR)); if (Creature* temp = me->SummonCreature(NPC_GORMOK, ToCSpawnLoc[0].GetPositionX(), ToCSpawnLoc[0].GetPositionY(), ToCSpawnLoc[0].GetPositionZ(), 5, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30*IN_MILLISECONDS)) { @@ -585,154 +586,133 @@ class npc_tirion_toc : public CreatureScript temp->SetReactState(REACT_PASSIVE); } } - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 155); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 155); break; case 155: - instance->SetData(TYPE_BEASTS, IN_PROGRESS); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 160); + // keep the raid in combat for the whole encounter, pauses included + me->SetInCombatWithZone(); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 160); break; case 200: Talk(SAY_STAGE_0_04); - m_uiUpdateTimer = 8000; - instance->SetData(TYPE_EVENT, 205); - break; - case 205: - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 210); - break; - case 210: - if (instance->GetData(TYPE_BEASTS) != DONE) + if (_instance->GetBossState(BOSS_BEASTS) != DONE) { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + _instance->DoUseDoorOrButton(_instance->GetData64(GO_MAIN_GATE_DOOR)); if (Creature* temp = me->SummonCreature(NPC_DREADSCALE, ToCSpawnLoc[1].GetPositionX(), ToCSpawnLoc[1].GetPositionY(), ToCSpawnLoc[1].GetPositionZ(), 5, TEMPSUMMON_MANUAL_DESPAWN)) { - temp->GetMotionMaster()->MovePoint(0, ToCCommonLoc[8].GetPositionX(), ToCCommonLoc[8].GetPositionY(), ToCCommonLoc[8].GetPositionZ()); - temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - temp->SetReactState(REACT_PASSIVE); - } - if (Creature* temp = me->SummonCreature(NPC_ACIDMAW, ToCCommonLoc[9].GetPositionX(), ToCCommonLoc[9].GetPositionY(), ToCCommonLoc[9].GetPositionZ(), 5, TEMPSUMMON_MANUAL_DESPAWN)) - { - temp->SetVisible(true); + temp->GetMotionMaster()->MovePoint(0, ToCCommonLoc[5].GetPositionX(), ToCCommonLoc[5].GetPositionY(), ToCCommonLoc[5].GetPositionZ()); temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); temp->SetReactState(REACT_PASSIVE); } } - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 220); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 220); break; case 220: - instance->SetData(TYPE_EVENT, 230); + _instance->SetData(TYPE_EVENT, 230); break; case 300: Talk(SAY_STAGE_0_05); - m_uiUpdateTimer = 8000; - instance->SetData(TYPE_EVENT, 305); - break; - case 305: - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 310); - break; - case 310: - if (instance->GetData(TYPE_BEASTS) != DONE) + if (_instance->GetBossState(BOSS_BEASTS) != DONE) { - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + _instance->DoUseDoorOrButton(_instance->GetData64(GO_MAIN_GATE_DOOR)); if (Creature* temp = me->SummonCreature(NPC_ICEHOWL, ToCSpawnLoc[0].GetPositionX(), ToCSpawnLoc[0].GetPositionY(), ToCSpawnLoc[0].GetPositionZ(), 5, TEMPSUMMON_DEAD_DESPAWN)) { temp->GetMotionMaster()->MovePoint(2, ToCCommonLoc[5].GetPositionX(), ToCCommonLoc[5].GetPositionY(), ToCCommonLoc[5].GetPositionZ()); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_PASSIVE); - } } - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 315); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 315); break; case 315: - instance->SetData(TYPE_EVENT, 320); + _instance->SetData(TYPE_EVENT, 320); break; case 400: Talk(SAY_STAGE_0_06); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 0); + me->getThreatManager().clearReferences(); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 0); break; case 666: Talk(SAY_STAGE_0_WIPE); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 0); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 0); break; case 1010: Talk(SAY_STAGE_1_01); - m_uiUpdateTimer = 7000; - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); + _updateTimer = 7*IN_MILLISECONDS; + _instance->DoUseDoorOrButton(_instance->GetData64(GO_MAIN_GATE_DOOR)); me->SummonCreature(NPC_FIZZLEBANG, ToCSpawnLoc[0].GetPositionX(), ToCSpawnLoc[0].GetPositionY(), ToCSpawnLoc[0].GetPositionZ(), 2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); - instance->SetData(TYPE_EVENT, 0); + _instance->SetData(TYPE_EVENT, 0); break; case 1180: Talk(SAY_STAGE_1_07); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 0); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 0); break; case 2000: Talk(SAY_STAGE_1_08); - m_uiUpdateTimer = 18000; - instance->SetData(TYPE_EVENT, 2010); + _updateTimer = 18*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 2010); break; case 2030: Talk(SAY_STAGE_1_11); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 0); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 0); break; case 3000: Talk(SAY_STAGE_2_01); - m_uiUpdateTimer = 12000; - instance->SetData(TYPE_EVENT, 3050); + _updateTimer = 12*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3050); break; case 3001: Talk(SAY_STAGE_2_01); - m_uiUpdateTimer = 12000; - instance->SetData(TYPE_EVENT, 3051); + _updateTimer = 10*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3051); break; case 3060: Talk(SAY_STAGE_2_03); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 3070); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3070); break; case 3061: Talk(SAY_STAGE_2_03); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 3071); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3071); break; //Summoning crusaders case 3091: if (Creature* pChampionController = me->SummonCreature(NPC_CHAMPIONS_CONTROLLER, ToCCommonLoc[1])) pChampionController->AI()->SetData(0, HORDE); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 3092); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3092); break; //Summoning crusaders case 3090: if (Creature* pChampionController = me->SummonCreature(NPC_CHAMPIONS_CONTROLLER, ToCCommonLoc[1])) pChampionController->AI()->SetData(0, ALLIANCE); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 3092); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3092); break; case 3092: - if (Creature* pChampionController = Unit::GetCreature((*me), instance->GetData64(NPC_CHAMPIONS_CONTROLLER))) + if (Creature* pChampionController = Unit::GetCreature((*me), _instance->GetData64(NPC_CHAMPIONS_CONTROLLER))) pChampionController->AI()->SetData(1, NOT_STARTED); - instance->SetData(TYPE_EVENT, 3095); + _instance->SetData(TYPE_EVENT, 3095); break; //Crusaders battle end case 3100: Talk(SAY_STAGE_2_06); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 0); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 0); break; case 4000: Talk(SAY_STAGE_3_01); - m_uiUpdateTimer = 13000; - instance->SetData(TYPE_EVENT, 4010); + _updateTimer = 13*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 4010); break; case 4010: Talk(SAY_STAGE_3_02); @@ -750,78 +730,88 @@ class npc_tirion_toc : public CreatureScript temp->SummonCreature(NPC_DARK_ESSENCE, TwinValkyrsLoc[2].GetPositionX(), TwinValkyrsLoc[2].GetPositionY(), TwinValkyrsLoc[2].GetPositionZ()); temp->SummonCreature(NPC_DARK_ESSENCE, TwinValkyrsLoc[3].GetPositionX(), TwinValkyrsLoc[3].GetPositionY(), TwinValkyrsLoc[3].GetPositionZ()); } - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 4015); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 4015); break; case 4015: - instance->DoUseDoorOrButton(instance->GetData64(GO_MAIN_GATE_DOOR)); - if (Creature* temp = Unit::GetCreature((*me), instance->GetData64(NPC_LIGHTBANE))) + _instance->DoUseDoorOrButton(_instance->GetData64(GO_MAIN_GATE_DOOR)); + if (Creature* temp = Unit::GetCreature((*me), _instance->GetData64(NPC_LIGHTBANE))) { temp->GetMotionMaster()->MovePoint(1, ToCCommonLoc[8].GetPositionX(), ToCCommonLoc[8].GetPositionY(), ToCCommonLoc[8].GetPositionZ()); temp->SetVisible(true); } - if (Creature* temp = Unit::GetCreature((*me), instance->GetData64(NPC_DARKBANE))) + if (Creature* temp = Unit::GetCreature((*me), _instance->GetData64(NPC_DARKBANE))) { temp->GetMotionMaster()->MovePoint(1, ToCCommonLoc[9].GetPositionX(), ToCCommonLoc[9].GetPositionY(), ToCCommonLoc[9].GetPositionZ()); temp->SetVisible(true); } - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 4016); + _updateTimer = 10*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 4016); break; case 4016: - instance->SetData(TYPE_EVENT, 4017); + _instance->DoUseDoorOrButton(_instance->GetData64(GO_MAIN_GATE_DOOR)); + _instance->SetData(TYPE_EVENT, 4017); break; case 4040: - m_uiUpdateTimer = 60000; - instance->SetData(TYPE_EVENT, 5000); + _updateTimer = 1*MINUTE*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 5000); break; case 5000: Talk(SAY_STAGE_4_01); - m_uiUpdateTimer = 10000; - instance->SetData(TYPE_EVENT, 5005); + _updateTimer = 10*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 5005); break; case 5005: - m_uiUpdateTimer = 8000; - instance->SetData(TYPE_EVENT, 5010); + _updateTimer = 8*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 5010); me->SummonCreature(NPC_LICH_KING_1, ToCCommonLoc[2].GetPositionX(), ToCCommonLoc[2].GetPositionY(), ToCCommonLoc[2].GetPositionZ(), 5); break; case 5020: Talk(SAY_STAGE_4_03); - m_uiUpdateTimer = 1000; - instance->SetData(TYPE_EVENT, 0); + _updateTimer = 1*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 0); break; case 6000: me->SummonCreature(NPC_TIRION_FORDRING, EndSpawnLoc[0].GetPositionX(), EndSpawnLoc[0].GetPositionY(), EndSpawnLoc[0].GetPositionZ()); me->SummonCreature(NPC_ARGENT_MAGE, EndSpawnLoc[1].GetPositionX(), EndSpawnLoc[1].GetPositionY(), EndSpawnLoc[1].GetPositionZ()); me->SummonGameObject(GO_PORTAL_TO_DALARAN, EndSpawnLoc[2].GetPositionX(), EndSpawnLoc[2].GetPositionY(), EndSpawnLoc[2].GetPositionZ(), 5, 0, 0, 0, 0, 0); - m_uiUpdateTimer = 20000; - instance->SetData(TYPE_EVENT, 6005); + _updateTimer = 20*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 6005); break; case 6005: - if (Creature* tirionFordring = Unit::GetCreature((*me), instance->GetData64(NPC_TIRION_FORDRING))) + if (Creature* tirionFordring = Unit::GetCreature((*me), _instance->GetData64(NPC_TIRION_FORDRING))) tirionFordring->AI()->Talk(SAY_STAGE_4_06); - m_uiUpdateTimer = 20000; - instance->SetData(TYPE_EVENT, 6010); + _updateTimer = 20*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 6010); break; case 6010: if (IsHeroic()) { - if (Creature* tirionFordring = Unit::GetCreature((*me), instance->GetData64(NPC_TIRION_FORDRING))) + if (Creature* tirionFordring = Unit::GetCreature((*me), _instance->GetData64(NPC_TIRION_FORDRING))) tirionFordring->AI()->Talk(SAY_STAGE_4_07); - m_uiUpdateTimer = 60000; - instance->SetData(TYPE_ANUBARAK, SPECIAL); - instance->SetData(TYPE_EVENT, 6020); - } else instance->SetData(TYPE_EVENT, 6030); + _updateTimer = 1*MINUTE*IN_MILLISECONDS; + _instance->SetBossState(BOSS_ANUBARAK, SPECIAL); + _instance->SetData(TYPE_EVENT, 6020); + } + else + _instance->SetData(TYPE_EVENT, 6030); break; case 6020: me->DespawnOrUnsummon(); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 6030); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 6030); + break; + default: break; } - } else m_uiUpdateTimer -= uiDiff; - instance->SetData(TYPE_EVENT_TIMER, m_uiUpdateTimer); + } + else + _updateTimer -= uiDiff; + _instance->SetData(TYPE_EVENT_TIMER, _updateTimer); } + private: + InstanceScript* _instance; + uint32 _updateTimer; }; CreatureAI* GetAI(Creature* creature) const @@ -833,76 +823,79 @@ class npc_tirion_toc : public CreatureScript class npc_garrosh_toc : public CreatureScript { public: - npc_garrosh_toc() : CreatureScript("npc_garrosh_toc") { } struct npc_garrosh_tocAI : public ScriptedAI { npc_garrosh_tocAI(Creature* creature) : ScriptedAI(creature) { - instance = me->GetInstanceScript(); + _instance = me->GetInstanceScript(); } - InstanceScript* instance; - uint32 m_uiUpdateTimer; - void Reset() {} void AttackStart(Unit* /*who*/) {} void UpdateAI(const uint32 uiDiff) { - if (!instance) + if (!_instance) return; - if (instance->GetData(TYPE_EVENT_NPC) != NPC_GARROSH) + if (_instance->GetData(TYPE_EVENT_NPC) != NPC_GARROSH) return; - m_uiUpdateTimer = instance->GetData(TYPE_EVENT_TIMER); - if (m_uiUpdateTimer <= uiDiff) + _updateTimer = _instance->GetData(TYPE_EVENT_TIMER); + if (_updateTimer <= uiDiff) { - switch (instance->GetData(TYPE_EVENT)) + switch (_instance->GetData(TYPE_EVENT)) { case 130: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); Talk(SAY_STAGE_0_03h); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 132); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 132); break; case 132: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 140); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 140); break; case 2010: Talk(SAY_STAGE_1_09); - m_uiUpdateTimer = 9000; - instance->SetData(TYPE_EVENT, 2020); + _updateTimer = 9*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 2020); break; case 3050: Talk(SAY_STAGE_2_02h); - m_uiUpdateTimer = 15000; - instance->SetData(TYPE_EVENT, 3060); + _updateTimer = 15*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3060); break; case 3070: Talk(SAY_STAGE_2_04h); - m_uiUpdateTimer = 6000; - instance->SetData(TYPE_EVENT, 3080); + _updateTimer = 6*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3080); break; case 3081: Talk(SAY_STAGE_2_05h); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 3091); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3091); break; case 4030: Talk(SAY_STAGE_3_03h); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 4040); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 4040); + break; + default: break; } - } else m_uiUpdateTimer -= uiDiff; - instance->SetData(TYPE_EVENT_TIMER, m_uiUpdateTimer); + } + else + _updateTimer -= uiDiff; + _instance->SetData(TYPE_EVENT_TIMER, _updateTimer); } + private: + InstanceScript* _instance; + uint32 _updateTimer; }; CreatureAI* GetAI(Creature* creature) const @@ -914,76 +907,79 @@ class npc_garrosh_toc : public CreatureScript class npc_varian_toc : public CreatureScript { public: - npc_varian_toc() : CreatureScript("npc_varian_toc") { } struct npc_varian_tocAI : public ScriptedAI { npc_varian_tocAI(Creature* creature) : ScriptedAI(creature) { - instance = me->GetInstanceScript(); + _instance = me->GetInstanceScript(); } - InstanceScript* instance; - uint32 m_uiUpdateTimer; - void Reset() {} void AttackStart(Unit* /*who*/) {} void UpdateAI(const uint32 uiDiff) { - if (!instance) + if (!_instance) return; - if (instance->GetData(TYPE_EVENT_NPC) != NPC_VARIAN) + if (_instance->GetData(TYPE_EVENT_NPC) != NPC_VARIAN) return; - m_uiUpdateTimer = instance->GetData(TYPE_EVENT_TIMER); - if (m_uiUpdateTimer <= uiDiff) + _updateTimer = _instance->GetData(TYPE_EVENT_TIMER); + if (_updateTimer <= uiDiff) { - switch (instance->GetData(TYPE_EVENT)) + switch (_instance->GetData(TYPE_EVENT)) { case 120: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_TALK); Talk(SAY_STAGE_0_03a); - m_uiUpdateTimer = 2000; - instance->SetData(TYPE_EVENT, 122); + _updateTimer = 2*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 122); break; case 122: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 130); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 130); break; case 2020: Talk(SAY_STAGE_1_10); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 2030); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 2030); break; case 3051: Talk(SAY_STAGE_2_02a); - m_uiUpdateTimer = 10000; - instance->SetData(TYPE_EVENT, 3061); + _updateTimer = 17*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3061); break; case 3071: Talk(SAY_STAGE_2_04a); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 3081); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3081); break; case 3080: Talk(SAY_STAGE_2_05a); - m_uiUpdateTimer = 3000; - instance->SetData(TYPE_EVENT, 3090); + _updateTimer = 3*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 3090); break; case 4020: Talk(SAY_STAGE_3_03a); - m_uiUpdateTimer = 5000; - instance->SetData(TYPE_EVENT, 4040); + _updateTimer = 5*IN_MILLISECONDS; + _instance->SetData(TYPE_EVENT, 4040); + break; + default: break; } - } else m_uiUpdateTimer -= uiDiff; - instance->SetData(TYPE_EVENT_TIMER, m_uiUpdateTimer); + } + else + _updateTimer -= uiDiff; + _instance->SetData(TYPE_EVENT_TIMER, _updateTimer); } + private: + InstanceScript* _instance; + uint32 _updateTimer; }; CreatureAI* GetAI(Creature* creature) const @@ -994,8 +990,8 @@ class npc_varian_toc : public CreatureScript void AddSC_trial_of_the_crusader() { - new npc_announcer_toc10(); new boss_lich_king_toc(); + new npc_announcer_toc10(); new npc_fizzlebang_toc(); new npc_tirion_toc(); new npc_garrosh_toc(); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h index 58cbd727963..70fe03c5e0f 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.h @@ -7,12 +7,12 @@ enum { - TYPE_BEASTS = 0, - TYPE_JARAXXUS = 1, - TYPE_CRUSADERS = 2, - TYPE_VALKIRIES = 3, - TYPE_LICH_KING = 4, - TYPE_ANUBARAK = 5, + BOSS_BEASTS = 0, + BOSS_JARAXXUS = 1, + BOSS_CRUSADERS = 2, + BOSS_VALKIRIES = 3, + BOSS_LICH_KING = 4, // not really a boss but oh well + BOSS_ANUBARAK = 5, MAX_ENCOUNTERS = 6, TYPE_COUNTER = 8, @@ -24,22 +24,26 @@ enum DATA_SNOBOLD_COUNT = 301, DATA_MISTRESS_OF_PAIN_COUNT = 302, - DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE = 303, + DATA_TRIBUTE_TO_IMMORTALITY_ELIGIBLE = 303, INCREASE = 501, DECREASE = 502, SPELL_WILFRED_PORTAL = 68424, SPELL_JARAXXUS_CHAINS = 67924, + SPELL_CORPSE_TELEPORT = 69016, + SPELL_DESTROY_FLOOR_KNOCKUP = 68193, DESPAWN_TIME = 300000, + + DISPLAYID_DESTROYED_FLOOR = 9060 }; const Position ToCSpawnLoc[]= { {563.912f, 261.625f, 394.73f, 4.70437f}, // 0 Center {575.451f, 261.496f, 394.73f, 4.6541f}, // 1 Left - {549.951f, 261.55f, 394.73f, 4.74835f}, // 2 Right + {549.951f, 261.55f, 394.73f, 4.74835f} // 2 Right }; const Position ToCCommonLoc[]= @@ -68,7 +72,7 @@ const Position ToCCommonLoc[]= {558.811610f, 195.985779f, 394.671661f, 0}, // 13 {567.641724f, 195.351501f, 394.659943f, 0}, // 14 {560.633972f, 195.391708f, 395.137543f, 0}, // 15 - {565.816956f, 195.477921f, 395.136810f, 0}, // 16 + {565.816956f, 195.477921f, 395.136810f, 0} // 16 }; const Position JaraxxusLoc[]= @@ -76,7 +80,7 @@ const Position JaraxxusLoc[]= {508.104767f, 138.247345f, 395.128052f, 0}, // 0 - Fizzlebang start location {548.610596f, 139.807800f, 394.321838f, 0}, // 1 - fizzlebang end {581.854187f, 138.0f, 394.319f, 0}, // 2 - Portal Right - {550.558838f, 138.0f, 394.319f, 0}, // 3 - Portal Left + {550.558838f, 138.0f, 394.319f, 0} // 3 - Portal Left }; const Position FactionChampionLoc[]= @@ -102,21 +106,21 @@ const Position FactionChampionLoc[]= {528.958f, 131.47f, 394.73f, 0}, // 16 - Horde Final Pos 6 {526.309f, 116.667f, 394.833f, 0}, // 17 - Horde Final Pos 7 {524.238f, 122.411f, 394.819f, 0}, // 18 - Horde Final Pos 8 - {521.901f, 128.488f, 394.832f, 0}, // 19 - Horde Final Pos 9 + {521.901f, 128.488f, 394.832f, 0} // 19 - Horde Final Pos 9 }; const Position TwinValkyrsLoc[]= { - {586.060242f, 117.514809f, 394.314026f, 0}, // 0 - Dark essence 1 - {541.602112f, 161.879837f, 394.587952f, 0}, // 1 - Dark essence 2 - {541.021118f, 117.262932f, 395.314819f, 0}, // 2 - Light essence 1 - {586.200562f, 162.145523f, 394.626129f, 0}, // 3 - Light essence 2 + {586.060242f, 117.514809f, 394.41f, 0}, // 0 - Dark essence 1 + {541.602112f, 161.879837f, 394.41f, 0}, // 1 - Dark essence 2 + {541.021118f, 117.262932f, 394.41f, 0}, // 2 - Light essence 1 + {586.200562f, 162.145523f, 394.41f, 0} // 3 - Light essence 2 }; const Position LichKingLoc[]= { {563.549f, 152.474f, 394.393f, 0}, // 0 - Lich king start - {563.547f, 141.613f, 393.908f, 0}, // 1 - Lich king end + {563.547f, 141.613f, 393.908f, 0} // 1 - Lich king end }; const Position AnubarakLoc[]= @@ -126,20 +130,20 @@ const Position AnubarakLoc[]= {694.886353f, 102.484665f, 142.119614f, 0}, // 3 - Nerub Spawn {694.500671f, 185.363968f, 142.117905f, 0}, // 5 - Nerub Spawn {731.987244f, 83.3824690f, 142.119614f, 0}, // 2 - Nerub Spawn - {740.184509f, 193.443390f, 142.117584f, 0}, // 4 - Nerub Spawn + {740.184509f, 193.443390f, 142.117584f, 0} // 4 - Nerub Spawn }; const Position EndSpawnLoc[]= { {648.9167f, 131.0208f, 141.6161f, 0}, // 0 - Highlord Tirion Fordring {649.1614f, 142.0399f, 141.3057f ,0}, // 1 - Argent Mage - {644.6250f, 149.2743f, 140.6015f ,0}, // 2 - Portal to Dalaran + {644.6250f, 149.2743f, 140.6015f ,0} // 2 - Portal to Dalaran }; enum euiWorldStates { UPDATE_STATE_UI_SHOW = 4390, - UPDATE_STATE_UI_COUNT = 4389, + UPDATE_STATE_UI_COUNT = 4389 }; enum eNorthrendBeasts @@ -152,7 +156,7 @@ enum eNorthrendBeasts SNAKES_SPECIAL = 2003, SNAKES_DONE = 2004, ICEHOWL_IN_PROGRESS = 3000, - ICEHOWL_DONE = 3001, + ICEHOWL_DONE = 3001 }; enum eAnnouncerMessages @@ -162,7 +166,7 @@ enum eAnnouncerMessages MSG_CRUSADERS = 724003, MSG_VALKIRIES = 724004, MSG_LICH_KING = 724005, - MSG_ANUBARAK = 724006, + MSG_ANUBARAK = 724006 }; enum eCreature @@ -227,7 +231,7 @@ enum eCreature NPC_DARK_ESSENCE = 34567, NPC_LIGHT_ESSENCE = 34568, - NPC_ANUBARAK = 34564, + NPC_ANUBARAK = 34564 }; enum eGameObject @@ -253,7 +257,7 @@ enum eGameObject GO_MAIN_GATE_DOOR = 195647, GO_EAST_PORTCULLIS = 195648, GO_WEB_DOOR = 195485, - GO_PORTAL_TO_DALARAN = 195682, + GO_PORTAL_TO_DALARAN = 195682 }; enum eAchievementData diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_dred.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_dred.cpp index 8b39fc51766..759f8df7153 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/boss_dred.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/boss_dred.cpp @@ -154,7 +154,7 @@ class boss_dred : public CreatureScript ++raptorsKilled; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_KING_DRED) return raptorsKilled; diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp index 5d9acf4fca7..6ce56958d60 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/boss_novos.cpp @@ -208,7 +208,7 @@ public: ohNovos = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_OH_NOVOS) return ohNovos ? 1 : 0; diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp index 969ccf4a059..79739280055 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/boss_tharon_ja.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "drak_tharon_keep.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp index 31b7787623c..d8c720b6f95 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp @@ -168,7 +168,7 @@ public: instance->SetData(DATA_TROLLGORE_EVENT, DONE); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_CONSUMPTION_JUNCTION) return consumptionJunction ? 1 : 0; diff --git a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp index 99401c1d944..552798e96eb 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp @@ -129,7 +129,7 @@ public: } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -174,7 +174,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index 4fdcf96192b..714e5df6444 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -18,6 +18,8 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "forge_of_souls.h" +#include "Player.h" +#include "SpellInfo.h" /* * TODO: @@ -245,7 +247,7 @@ class boss_devourer_of_souls : public CreatureScript threeFaced = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_THREE_FACED) return threeFaced; diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp index c23479eea22..2f89d3bd503 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "forge_of_souls.h" +#include "Player.h" enum Events { diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp index 618b2b6a9a6..3afc248ab9d 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/instance_forge_of_souls.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "forge_of_souls.h" +#include "Player.h" #define MAX_ENCOUNTER 2 @@ -72,7 +73,7 @@ class instance_forge_of_souls : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -85,7 +86,7 @@ class instance_forge_of_souls : public InstanceMapScript return 0; } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp index 26ec9e53213..4f80fd746ee 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "halls_of_reflection.h" +#include "Player.h" enum Yells { diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp index e3604890e39..2e0c3364bbd 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "halls_of_reflection.h" +#include "Player.h" #define MAX_ENCOUNTER 3 @@ -244,7 +245,7 @@ public: SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -258,7 +259,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp index a12bd96f6df..cdc21eb25ec 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp @@ -186,7 +186,7 @@ class boss_garfrost : public CreatureScript } } - uint32 GetData(uint32 /*type*/) + uint32 GetData(uint32 /*type*/) const { return _permafrostStack; } diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp index 0d6e779c006..41cfc300958 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp @@ -21,6 +21,7 @@ #include "SpellAuraEffects.h" #include "pit_of_saron.h" #include "Vehicle.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp index ef4d9182f82..44d9230a8d2 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp @@ -21,6 +21,7 @@ #include "SpellAuraEffects.h" #include "pit_of_saron.h" #include "Vehicle.h" +#include "Player.h" enum Yells { diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp index a6537c45d6f..df0829b3376 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "pit_of_saron.h" +#include "Player.h" // positions for Martin Victus (37591) and Gorkun Ironskull (37592) Position const SlaveLeaderPos = {689.7158f, -104.8736f, 513.7360f, 0.0f}; @@ -223,7 +224,7 @@ class instance_pit_of_saron : public InstanceMapScript return true; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -236,7 +237,7 @@ class instance_pit_of_saron : public InstanceMapScript return 0; } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp index fd1aba79e83..3724aaf69e2 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp @@ -22,6 +22,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "gundrak.h" +#include "SpellInfo.h" enum Spells { @@ -190,7 +191,7 @@ class boss_drakkari_colossus : public CreatureScript } } - uint32 GetData(uint32 data) + uint32 GetData(uint32 data) const { if (data == DATA_COLOSSUS_PHASE) return phase; diff --git a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp index 0d89c402054..595331d99d7 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_gal_darah.cpp @@ -258,7 +258,7 @@ public: impaledList.push_back(guid); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_SHARE_THE_LOVE) return shareTheLove; diff --git a/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp b/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp index c1301dbd2d0..45c55f7ec9b 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_moorabi.cpp @@ -144,7 +144,7 @@ public: DoMeleeAttackIfReady(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_LESS_RABI) return bPhase ? 0 : 1; diff --git a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp index 251c9ec2b83..f35228d44d9 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "SpellAuras.h" #include "gundrak.h" +#include "Player.h" //Spells enum Spells @@ -324,4 +325,4 @@ void AddSC_boss_slad_ran() new mob_slad_ran_constrictor(); new mob_slad_ran_viper(); new achievement_snakes_whyd_it_have_to_be_snakes(); -}
\ No newline at end of file +} diff --git a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp index 15315c721d7..b8b9c2e9053 100644 --- a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp +++ b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp @@ -18,6 +18,8 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "gundrak.h" +#include "Player.h" +#include "TemporarySummon.h" #define MAX_ENCOUNTER 5 @@ -317,7 +319,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -338,7 +340,7 @@ public: return 0; } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 1b12f17ce64..f28b94c858e 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -20,6 +20,7 @@ #include "ScriptedCreature.h" #include "SpellAuraEffects.h" #include "icecrown_citadel.h" +#include "Player.h" enum Texts { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 5d3a6814eb2..9ee4bcea4d9 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -21,6 +21,7 @@ #include "ScriptedGossip.h" #include "SpellAuras.h" #include "icecrown_citadel.h" +#include "Player.h" enum ScriptTexts { @@ -496,7 +497,7 @@ class boss_deathbringer_saurfang : public CreatureScript DoMeleeAttackIfReady(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_MADE_A_MESS) if (_fallenChampionCastCount < RAID_MODE<uint32>(3, 5, 3, 5)) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index 58856f9fb44..9c0f2139b1b 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -244,7 +244,7 @@ class boss_festergut : public CreatureScript _maxInoculatedStack = data; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_INOCULATED_STACK) return uint32(_maxInoculatedStack); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index e2f9faf6a97..8e7f891663e 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -22,6 +22,7 @@ #include "Group.h" #include "icecrown_citadel.h" #include "SpellInfo.h" +#include "Player.h" enum ScriptTexts { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 0c5cb0aba52..263d70c6a50 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -21,6 +21,7 @@ #include "SpellAuras.h" #include "MapManager.h" #include "icecrown_citadel.h" +#include "Player.h" enum ScriptTexts { @@ -246,7 +247,7 @@ class boss_lord_marrowgar : public CreatureScript return &_coldflameLastPos; } - uint64 GetGUID(int32 type/* = 0 */) + uint64 GetGUID(int32 type/* = 0 */) const { if (type == DATA_COLDFLAME_GUID) return _coldflameTarget; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 64f49c6e0e7..4727504a4bd 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -536,21 +536,15 @@ class boss_professor_putricide : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { case DATA_EXPERIMENT_STAGE: - { - // ALSO MODIFIES! - uint32 ret = uint32(_experimentState); - _experimentState ^= true; - return ret; - } + return _experimentState; case DATA_PHASE: return _phase; case DATA_ABOMINATION: - summons.RemoveNotExisting(); return uint32(summons.HasEntry(NPC_MUTATED_ABOMINATION_10) || summons.HasEntry(NPC_MUTATED_ABOMINATION_25)); default: break; @@ -559,6 +553,12 @@ class boss_professor_putricide : public CreatureScript return 0; } + void SetData(uint32 id, uint32 data) + { + if (id == DATA_EXPERIMENT_STAGE) + _experimentState = bool(data); + } + void UpdateAI(uint32 const diff) { if ((!(events.GetPhaseMask() & PHASE_MASK_NOT_SELF) && !UpdateVictim()) || !CheckInRoom()) @@ -1010,7 +1010,11 @@ class spell_putricide_unstable_experiment : public SpellScriptLoader if (GetCaster()->GetTypeId() != TYPEID_UNIT) return; - uint32 stage = GetCaster()->ToCreature()->AI()->GetData(DATA_EXPERIMENT_STAGE); + Creature* creature = GetCaster()->ToCreature(); + + uint32 stage = creature->AI()->GetData(DATA_EXPERIMENT_STAGE); + creature->AI()->SetData(DATA_EXPERIMENT_STAGE, stage ^ true); + Creature* target = NULL; std::list<Creature*> creList; GetCreatureListWithEntryInGrid(creList, GetCaster(), NPC_ABOMINATION_WING_MAD_SCIENTIST_STALKER, 200.0f); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index e3c0f2260df..a12a38b2f62 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -290,7 +290,7 @@ class boss_sindragosa : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_MYSTIC_BUFFET_STACK) return _mysticBuffetStack; @@ -978,7 +978,7 @@ class npc_sindragosa_trash : public CreatureScript _isTaunted = data != 0; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_FROSTWYRM_OWNER) return _frostwyrmId; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index ba1a0614cdf..ec5172aeb83 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -636,7 +636,7 @@ class boss_the_lich_king : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 826c62a4390..cc40a076300 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -460,7 +460,7 @@ class boss_valithria_dreamwalker : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == MISSED_PORTALS) return _missedPortals; @@ -1019,7 +1019,7 @@ class npc_dream_portal : public CreatureScript me->DespawnOrUnsummon(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { return (type == MISSED_PORTALS && _used) ? 0 : 1; } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h index 31639a698ef..4e117d9f3e3 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h @@ -21,6 +21,7 @@ #include "SpellScript.h" #include "Map.h" #include "Creature.h" +#include "SpellMgr.h" #define ICCScriptName "instance_icecrown_citadel" diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp index af8aba57a6d..7ff995d4bcf 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel_teleport.cpp @@ -20,6 +20,7 @@ #include "InstanceScript.h" #include "icecrown_citadel.h" #include "Spell.h" +#include "Player.h" #define GOSSIP_SENDER_ICC_PORT 631 diff --git a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp index 650f426d29c..89d7b0f764d 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp @@ -23,6 +23,9 @@ #include "PoolMgr.h" #include "AccountMgr.h" #include "icecrown_citadel.h" +#include "Player.h" +#include "WorldPacket.h" +#include "WorldSession.h" enum EventIds { @@ -589,7 +592,7 @@ class instance_icecrown_citadel : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -614,7 +617,7 @@ class instance_icecrown_citadel : public InstanceMapScript return 0; } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp index 636f2318712..a75f87e91af 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "naxxramas.h" +#include "SpellInfo.h" enum Yells { @@ -117,7 +118,7 @@ class boss_faerlina : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_FRENZY_DISPELS) return _frenzyDispels; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp index 5a55a4f1c4b..7ed9e950b53 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "naxxramas.h" +#include "SpellInfo.h" #define SPELL_BOMBARD_SLIME 28280 diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp index 93eab5df237..e7126ba7e33 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "SpellScript.h" #include "naxxramas.h" +#include "Player.h" #define SAY_AGGRO RAND(-1533109, -1533110, -1533111) #define SAY_SLAY -1533112 @@ -80,7 +81,7 @@ public: safetyDance = data ? true : false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_SAFETY_DANCE) return safetyDance ? 1 : 0; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index c88377da3f3..9167db45d20 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "SpellScript.h" #include "SpellAuraEffects.h" #include "naxxramas.h" +#include "Player.h" enum Yells { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp index 71623cb1959..183d56a48c0 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp @@ -85,7 +85,7 @@ class boss_loatheb : public CreatureScript _sporeLoserData = false; } - uint32 GetData(uint32 id) + uint32 GetData(uint32 id) const { if (id != DATA_ACHIEVEMENT_SPORE_LOSER) return 0; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp index a2acf8a64da..5a8f004788d 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp @@ -18,6 +18,8 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "naxxramas.h" +#include "Player.h" +#include "SpellInfo.h" #define EMOTE_BREATH -1533082 #define EMOTE_ENRAGE -1533083 diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index e45700ebd72..482f8a1200d 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -18,7 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" - +#include "Player.h" #include "naxxramas.h" //Stalagg @@ -215,7 +215,7 @@ public: polaritySwitch = data ? true : false; } - uint32 GetData(uint32 id) + uint32 GetData(uint32 id) const { if (id != DATA_POLARITY_SWITCH) return 0; diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index e806b60c848..b68d8d4a33c 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -316,7 +316,7 @@ public: } } - uint32 GetData(uint32 id) + uint32 GetData(uint32 id) const { switch (id) { @@ -329,7 +329,7 @@ public: return 0; } - uint64 GetData64(uint32 id) + uint64 GetData64(uint32 id) const { switch (id) { diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 28f73ed14b0..5e7104fd83a 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -34,6 +34,7 @@ Script Data End */ #include "PassiveAI.h" #include "eye_of_eternity.h" #include "ScriptedEscortAI.h" +#include "Player.h" enum Achievements { @@ -250,7 +251,7 @@ public: instance->DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT); } - uint32 GetData(uint32 data) + uint32 GetData(uint32 data) const { if (data == DATA_SUMMON_DEATHS) return _summonDeaths; diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp index f6a12eee519..4ca28943be3 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "eye_of_eternity.h" +#include "Player.h" class instance_eye_of_eternity : public InstanceMapScript { @@ -225,7 +226,7 @@ public: } } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp index af0ca6b3a3f..80a5336a30c 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_anomalus.cpp @@ -110,7 +110,7 @@ class boss_anomalus : public CreatureScript instance->SetData(DATA_ANOMALUS_EVENT, DONE); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_CHAOS_THEORY) return chaosTheory ? 1 : 0; diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp index 9e6930118f7..bbd86ec6a9f 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp @@ -21,6 +21,7 @@ #include "SpellScript.h" #include "SpellAuraEffects.h" #include "nexus.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp index 9602d1bc876..317a9845e87 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp @@ -155,7 +155,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_SPLIT_PERSONALITY) return splitPersonality; diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp index eb0b3692f01..11b1bce9ab7 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp @@ -19,96 +19,86 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "nexus.h" +#include "SpellScript.h" enum Spells { - SPELL_CRYSTAL_SPIKES = 47958, //Don't work, using walkaround - H_SPELL_CRYSTAL_SPIKES = 57082, //Don't work, using walkaround - SPELL_CRYSTALL_SPIKE_DAMAGE = 47944, - H_SPELL_CRYSTALL_SPIKE_DAMAGE = 57067, - SPELL_CRYSTAL_SPIKE_PREVISUAL = 50442, - MOB_CRYSTAL_SPIKE = 27099, - SPELL_SPELL_REFLECTION = 47981, - SPELL_TRAMPLE = 48016, - H_SPELL_TRAMPLE = 57066, - SPELL_FRENZY = 48017, - SPELL_SUMMON_CRYSTALLINE_TANGLER = 61564, //summons npc 32665 - SPELL_ROOTS = 28858 //proper spell id is unknown + SPELL_SPELL_REFLECTION = 47981, + SPELL_TRAMPLE = 48016, + SPELL_FRENZY = 48017, + SPELL_SUMMON_CRYSTALLINE_TANGLER = 61564, + SPELL_CRYSTAL_SPIKES = 47958, }; enum Yells { - SAY_AGGRO = -1576020, - SAY_DEATH = -1576021, - SAY_REFLECT = -1576022, - SAY_CRYSTAL_SPIKES = -1576023, - SAY_KILL = -1576024 + SAY_AGGRO = 1, + SAY_DEATH = 2, + SAY_REFLECT = 3, + SAY_CRYSTAL_SPIKES = 4, + SAY_KILL = 5, }; -enum Creatures + +enum Events { - MOB_CRYSTALLINE_TANGLER = 32665 + EVENT_CRYSTAL_SPIKES = 1, + EVENT_TRAMPLE = 2, + EVENT_SPELL_REFLECTION = 3, + EVENT_CRYSTALLINE_TANGLER = 4, }; -#define SPIKE_DISTANCE 5.0f +class OrmorokTanglerPredicate +{ + public: + OrmorokTanglerPredicate(Unit* unit) : me(unit) {} + + bool operator() (WorldObject* object) const + { + return object->GetDistance2d(me) >= 5.0f; + } + + private: + Unit* me; +}; class boss_ormorok : public CreatureScript { public: boss_ormorok() : CreatureScript("boss_ormorok") { } - CreatureAI* GetAI(Creature* creature) const + struct boss_ormorokAI : public BossAI { - return new boss_ormorokAI (creature); - } + boss_ormorokAI(Creature* creature) : BossAI(creature, DATA_ORMOROK_EVENT) {} - struct boss_ormorokAI : public ScriptedAI - { - boss_ormorokAI(Creature* creature) : ScriptedAI(creature) + void EnterCombat(Unit* /*who*/) { - instance = creature->GetInstanceScript(); - } + _EnterCombat(); - InstanceScript* instance; - - bool bFrenzy; - bool bCrystalSpikes; - uint8 uiCrystalSpikesCount; - float fBaseX; - float fBaseY; - float fBaseZ; - float fBaseO; - float fSpikeXY[4][2]; - - uint32 uiCrystalSpikesTimer; - uint32 uiCrystalSpikesTimer2; - uint32 uiTrampleTimer; - uint32 uiFrenzyTimer; - uint32 uiSpellReflectionTimer; - uint32 uiSummonCrystallineTanglerTimer; - - void Reset() - { - uiCrystalSpikesTimer = 12*IN_MILLISECONDS; - uiTrampleTimer = 10*IN_MILLISECONDS; - uiSpellReflectionTimer = 30*IN_MILLISECONDS; - uiSummonCrystallineTanglerTimer = 17*IN_MILLISECONDS; - bFrenzy = false; - bCrystalSpikes = false; + events.ScheduleEvent(EVENT_CRYSTAL_SPIKES, 12000); + events.ScheduleEvent(EVENT_TRAMPLE, 10000); + events.ScheduleEvent(EVENT_SPELL_REFLECTION, 30000); + if (IsHeroic()) + events.ScheduleEvent(EVENT_CRYSTALLINE_TANGLER, 17000); + + Talk(SAY_AGGRO); if (instance) - instance->SetData(DATA_ORMOROK_EVENT, NOT_STARTED); + instance->SetData(DATA_ORMOROK_EVENT, IN_PROGRESS); } - void EnterCombat(Unit* /*who*/) + void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) { - DoScriptText(SAY_AGGRO, me); - - if (instance) - instance->SetData(DATA_ORMOROK_EVENT, IN_PROGRESS); + if (!frenzy && HealthBelowPct(25)) + { + DoCast(me, SPELL_FRENZY); + frenzy = true; + } } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + _JustDied(); + + Talk(SAY_DEATH); if (instance) instance->SetData(DATA_ORMOROK_EVENT, DONE); @@ -116,195 +106,181 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(SAY_KILL, me); + Talk(SAY_KILL); } void UpdateAI(const uint32 diff) { if (!UpdateVictim()) - { return; - } - if (bCrystalSpikes) - { - if (uiCrystalSpikesTimer2 <= diff) - { - fSpikeXY[0][0] = fBaseX+(SPIKE_DISTANCE*uiCrystalSpikesCount* std::cos(fBaseO)); - fSpikeXY[0][1] = fBaseY+(SPIKE_DISTANCE*uiCrystalSpikesCount* std::sin(fBaseO)); - fSpikeXY[1][0] = fBaseX-(SPIKE_DISTANCE*uiCrystalSpikesCount* std::cos(fBaseO)); - fSpikeXY[1][1] = fBaseY-(SPIKE_DISTANCE*uiCrystalSpikesCount* std::sin(fBaseO)); - fSpikeXY[2][0] = fBaseX+(SPIKE_DISTANCE*uiCrystalSpikesCount* std::cos(fBaseO-(M_PI/2))); - fSpikeXY[2][1] = fBaseY+(SPIKE_DISTANCE*uiCrystalSpikesCount* std::sin(fBaseO-(M_PI/2))); - fSpikeXY[3][0] = fBaseX-(SPIKE_DISTANCE*uiCrystalSpikesCount* std::cos(fBaseO-(M_PI/2))); - fSpikeXY[3][1] = fBaseY-(SPIKE_DISTANCE*uiCrystalSpikesCount* std::sin(fBaseO-(M_PI/2))); - for (uint8 i = 0; i < 4; ++i) - me->SummonCreature(MOB_CRYSTAL_SPIKE, fSpikeXY[i][0], fSpikeXY[i][1], fBaseZ, 0, TEMPSUMMON_TIMED_DESPAWN, 7*IN_MILLISECONDS); - if (++uiCrystalSpikesCount >= 13) - bCrystalSpikes = false; - uiCrystalSpikesTimer2 = 200; - } else uiCrystalSpikesTimer2 -= diff; - } - if (!bFrenzy && HealthBelowPct(25)) - { - DoCast(me, SPELL_FRENZY); - bFrenzy = true; - } + events.Update(diff); - if (uiTrampleTimer <= diff) - { - DoCast(me, SPELL_TRAMPLE); - uiTrampleTimer = 10*IN_MILLISECONDS; - } else uiTrampleTimer -= diff; - - if (uiSpellReflectionTimer <= diff) - { - DoScriptText(SAY_REFLECT, me); - DoCast(me, SPELL_SPELL_REFLECTION); - uiSpellReflectionTimer = 30*IN_MILLISECONDS; - } else uiSpellReflectionTimer -= diff; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - if (uiCrystalSpikesTimer <= diff) - { - DoScriptText(SAY_CRYSTAL_SPIKES, me); - bCrystalSpikes = true; - uiCrystalSpikesCount = 1; - uiCrystalSpikesTimer2 = 0; - fBaseX = me->GetPositionX(); - fBaseY = me->GetPositionY(); - fBaseZ = me->GetPositionZ(); - fBaseO = me->GetOrientation(); - uiCrystalSpikesTimer = 20*IN_MILLISECONDS; - } else uiCrystalSpikesTimer -= diff; - - if (IsHeroic() && (uiSummonCrystallineTanglerTimer <= diff)) + while (uint32 eventId = events.ExecuteEvent()) { - Creature* Crystalline_Tangler = me->SummonCreature(MOB_CRYSTALLINE_TANGLER, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); - if (Crystalline_Tangler) + switch (eventId) { - 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<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (; i != me->getThreatManager().getThreatList().end(); ++i) - { - Unit* temp = Unit::GetUnit(*me, (*i)->getUnitGuid()); - if (temp && temp->GetTypeId() == TYPEID_PLAYER && temp->getClass() == Healer) - { - target = temp; - break; - } - } - if (target) - break; - } - if (!target) - target = SelectTarget(SELECT_TARGET_RANDOM, 0); - if (target) - { - Crystalline_Tangler->AI()->AttackStart(target); - Crystalline_Tangler->getThreatManager().addThreat(target, 1000000000.0f); - } + case EVENT_TRAMPLE: + DoCast(me, SPELL_TRAMPLE); + events.ScheduleEvent(EVENT_TRAMPLE, 10000); + break; + case EVENT_SPELL_REFLECTION: + Talk(SAY_REFLECT); + DoCast(me, SPELL_SPELL_REFLECTION); + events.ScheduleEvent(EVENT_SPELL_REFLECTION, 30000); + break; + case EVENT_CRYSTAL_SPIKES: + Talk(SAY_CRYSTAL_SPIKES); + DoCast(SPELL_CRYSTAL_SPIKES); + events.ScheduleEvent(EVENT_CRYSTAL_SPIKES, 12000); + break; + case EVENT_CRYSTALLINE_TANGLER: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, OrmorokTanglerPredicate(me))) + DoCast(target, SPELL_SUMMON_CRYSTALLINE_TANGLER); + events.ScheduleEvent(EVENT_CRYSTALLINE_TANGLER, 17000); + break; + default: + break; } - uiSummonCrystallineTanglerTimer = 17*IN_MILLISECONDS; - } else uiSummonCrystallineTanglerTimer -= diff; + } DoMeleeAttackIfReady(); } + + private: + bool frenzy; + }; + CreatureAI* GetAI(Creature* creature) const + { + return new boss_ormorokAI (creature); + } +}; + +enum CrystalSpikes +{ + NPC_CRYSTAL_SPIKE_INITIAL = 27101, + NPC_CRYSTAL_SPIKE_TRIGGER = 27079, + + DATA_COUNT = 1, + MAX_COUNT = 5, + + SPELL_CRYSTAL_SPIKE_DAMAGE = 47944, + + GO_CRYSTAL_SPIKE_TRAP = 188537, +}; + +uint32 const crystalSpikeSummon[3] = +{ + 47936, + 47942, + 47943 }; -class mob_crystal_spike : public CreatureScript +class npc_crystal_spike_trigger : public CreatureScript { public: - mob_crystal_spike() : CreatureScript("mob_crystal_spike") { } + npc_crystal_spike_trigger() : CreatureScript("npc_crystal_spike_trigger") { } - CreatureAI* GetAI(Creature* creature) const + struct npc_crystal_spike_triggerAI : public ScriptedAI { - return new mob_crystal_spikeAI (creature); - } + npc_crystal_spike_triggerAI(Creature* creature) : ScriptedAI(creature) {} - struct mob_crystal_spikeAI : public Scripted_NoMovementAI - { - mob_crystal_spikeAI(Creature* creature) : Scripted_NoMovementAI(creature) + void IsSummonedBy(Unit* owner) { - } + switch (me->GetEntry()) + { + case NPC_CRYSTAL_SPIKE_INITIAL: + _count = 0; + me->SetFacingToObject(owner); + break; + case NPC_CRYSTAL_SPIKE_TRIGGER: + if (Creature* trigger = owner->ToCreature()) + _count = trigger->AI()->GetData(DATA_COUNT) + 1; + break; + default: + _count = MAX_COUNT; + break; + } - uint32 SpellCrystalSpikeDamageTimer; - uint32 SpellCrystalSpikePrevisualTimer; + if (me->GetEntry() == NPC_CRYSTAL_SPIKE_TRIGGER) + if (GameObject* trap = me->FindNearestGameObject(GO_CRYSTAL_SPIKE_TRAP, 1.0f)) + trap->Use(me); - void Reset() + _despawntimer = 2000; + } + + uint32 GetData(uint32 type) const { - SpellCrystalSpikeDamageTimer = 3700; - SpellCrystalSpikePrevisualTimer = 1*IN_MILLISECONDS; + return type == DATA_COUNT ? _count : 0; } void UpdateAI(const uint32 diff) { - if (SpellCrystalSpikePrevisualTimer <= diff) + if (_despawntimer <= diff) { - DoCast(me, SPELL_CRYSTAL_SPIKE_PREVISUAL); - SpellCrystalSpikePrevisualTimer = 10*IN_MILLISECONDS; - } else SpellCrystalSpikePrevisualTimer -= diff; + if (me->GetEntry() == NPC_CRYSTAL_SPIKE_TRIGGER) + if (GameObject* trap = me->FindNearestGameObject(GO_CRYSTAL_SPIKE_TRAP, 1.0f)) + trap->Delete(); - if (SpellCrystalSpikeDamageTimer <= diff) - { - DoCast(me, SPELL_CRYSTALL_SPIKE_DAMAGE); - SpellCrystalSpikeDamageTimer = 10*IN_MILLISECONDS; - } else SpellCrystalSpikeDamageTimer -= diff; + me->DespawnOrUnsummon(); + } + else + _despawntimer -= diff; } - }; -}; + private: + uint32 _count; + uint32 _despawntimer; -class mob_crystalline_tangler : public CreatureScript -{ -public: - mob_crystalline_tangler() : CreatureScript("mob_crystalline_tangler") { } + }; CreatureAI* GetAI(Creature* creature) const { - return new mob_crystalline_tanglerAI (creature); + return new npc_crystal_spike_triggerAI(creature); } +}; - struct mob_crystalline_tanglerAI : public ScriptedAI - { - mob_crystalline_tanglerAI(Creature* creature) : ScriptedAI(creature) {} - - uint32 uiRootsTimer; +class spell_crystal_spike : public SpellScriptLoader +{ + public: + spell_crystal_spike() : SpellScriptLoader("spell_crystal_spike") { } - void Reset() + class spell_crystal_spike_AuraScript : public AuraScript { - uiRootsTimer = 1*IN_MILLISECONDS; - } + PrepareAuraScript(spell_crystal_spike_AuraScript); - void UpdateAI(const uint32 diff) - { - if (uiRootsTimer <= diff) + void HandlePeriodic(AuraEffect const* /*aurEff*/) { - if (me->IsWithinDist(me->getVictim(), 5.0f, false)) - { - DoCast(me->getVictim(), SPELL_ROOTS); - uiRootsTimer = 15*IN_MILLISECONDS; - } - } else uiRootsTimer -= diff; - } - }; + Unit* target = GetTarget(); + if (target->GetEntry() == NPC_CRYSTAL_SPIKE_INITIAL || target->GetEntry() == NPC_CRYSTAL_SPIKE_TRIGGER) + if (Creature* trigger = target->ToCreature()) + { + uint32 spell = target->GetEntry() == NPC_CRYSTAL_SPIKE_INITIAL ? crystalSpikeSummon[0] : crystalSpikeSummon[urand(0, 2)]; + if (trigger->AI()->GetData(DATA_COUNT) < MAX_COUNT) + trigger->CastSpell(trigger, spell, true); + } + } + void Register() + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_crystal_spike_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_crystal_spike_AuraScript(); + } }; void AddSC_boss_ormorok() { new boss_ormorok(); - new mob_crystal_spike(); - new mob_crystalline_tangler(); + new npc_crystal_spike_trigger(); + new spell_crystal_spike(); } diff --git a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp index 5d430ae048d..f06800cd201 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp @@ -19,6 +19,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "nexus.h" +#include "Player.h" #define NUMBER_OF_ENCOUNTERS 4 @@ -153,7 +154,7 @@ public: } } - uint32 GetData(uint32 identifier) + uint32 GetData(uint32 identifier) const { switch (identifier) { @@ -220,7 +221,7 @@ public: } } - uint64 GetData64(uint32 uiIdentifier) + uint64 GetData64(uint32 uiIdentifier) const { switch (uiIdentifier) { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp index c691db4230c..4bbb4c1a5ed 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_eregos.cpp @@ -117,7 +117,7 @@ public: _amberVoid = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp index 179dedb290b..51e476785ff 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_urom.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "oculus.h" +#include "SpellInfo.h" enum Spells { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp index a0b5aded315..7035e0534aa 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "oculus.h" +#include "Player.h" #define MAX_ENCOUNTER 4 @@ -231,7 +232,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -243,7 +244,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp index f00369fd9e2..0e73e929aef 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp @@ -23,6 +23,7 @@ #include "Vehicle.h" #include "CombatAI.h" #include "oculus.h" +#include "Player.h" #define GOSSIP_ITEM_DRAKES "So where do we go from here?" #define GOSSIP_ITEM_BELGARISTRASZ1 "I want to fly on the wings of the Red Flight" diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp index d964f619a6e..6f54ce50a94 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp @@ -23,6 +23,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "halls_of_lightning.h" +#include "SpellInfo.h" enum Spells { diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp index fe41e7a12dc..33e6e2846e4 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp @@ -26,6 +26,8 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "halls_of_lightning.h" +#include "Player.h" +#include "SpellInfo.h" enum eEnums { diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp index 93b246e9ddc..e399c5548e3 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/instance_halls_of_lightning.cpp @@ -174,7 +174,7 @@ public: SaveToDB(); } - uint32 GetData(uint32 uiType) + uint32 GetData(uint32 uiType) const { switch (uiType) { @@ -190,7 +190,7 @@ public: return 0; } - uint64 GetData64(uint32 uiData) + uint64 GetData64(uint32 uiData) const { switch (uiData) { diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp index 28052a57576..c3e815f57dd 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_sjonnir.cpp @@ -236,7 +236,7 @@ public: ++abuseTheOoze; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_ABUSE_THE_OOZE) return abuseTheOoze; diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp index a90c346e470..3c03508a14c 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/halls_of_stone.cpp @@ -20,6 +20,7 @@ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "halls_of_stone.h" +#include "Player.h" enum Texts { @@ -429,7 +430,7 @@ public: brannSparklinNews = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_BRANN_SPARKLIN_NEWS) return brannSparklinNews ? 1 : 0; diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp index 869cf46e74d..7a2b579dca9 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp @@ -186,7 +186,7 @@ public: SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -199,7 +199,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index 7967a86039e..010b4f43d4d 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -24,6 +24,7 @@ #include "MapManager.h" #include "MoveSplineInit.h" #include "ulduar.h" +#include "Player.h" enum Texts { @@ -373,11 +374,11 @@ class boss_algalon_the_observer : public CreatureScript case ACTION_INIT_ALGALON: _firstPull = false; me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - break;; + break; } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { return type == DATA_HAS_FED_ON_TEARS ? _fedOnTears : 1; } @@ -727,7 +728,7 @@ class npc_living_constellation : public CreatureScript _isActive = false; } - uint32 GetData(uint32 /*type*/) + uint32 GetData(uint32 /*type*/) const { return _isActive ? 1 : 0; } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp index ec3125f7c0a..bfe158051b1 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp @@ -178,7 +178,7 @@ class boss_auriaya : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index 9d5adf39817..a26f5763472 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -349,7 +349,7 @@ class boss_flame_leviathan : public CreatureScript ++Shutdown; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index a3c9cb847e5..f60922c426c 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -381,7 +381,7 @@ class boss_freya : public CreatureScript events.ScheduleEvent(EVENT_SUNBEAM, urand(5000, 15000)); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp index 8090b9e8a3e..1232c1b9051 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp @@ -20,6 +20,7 @@ #include "SpellScript.h" #include "SpellAuraEffects.h" #include "ulduar.h" +#include "Player.h" enum VezaxYells { @@ -234,7 +235,7 @@ class boss_general_vezax : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp index 540876f421b..c0fb4e3ecc8 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp @@ -154,7 +154,7 @@ class boss_ignis : public CreatureScript DoScriptText(SAY_DEATH, me); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_SHATTERED) return _shattered ? 1 : 0; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index 24a9171e29f..9c77bb298a5 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -21,6 +21,7 @@ #include "SpellAuraEffects.h" #include "ulduar.h" #include "Vehicle.h" +#include "Player.h" /* ScriptData SDName: boss_kologarn @@ -488,7 +489,7 @@ class spell_ulduar_squeezed_lifeless : public SpellScriptLoader pos.m_positionX = 1756.25f + irand(-3, 3); pos.m_positionY = -8.3f + irand(-3, 3); pos.m_positionZ = 448.8f; - pos.m_orientation = M_PI; + pos.SetOrientation(M_PI); GetHitPlayer()->DestroyForNearbyPlayers(); GetHitPlayer()->ExitVehicle(&pos); GetHitPlayer()->UpdateObjectVisibility(false); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp index 6038b7ed9d6..5ea2678adfe 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp @@ -23,6 +23,7 @@ #include "SpellScript.h" #include "ulduar.h" #include "SpellInfo.h" +#include "Player.h" enum Says { @@ -377,7 +378,7 @@ class boss_razorscale : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_QUICK_SHAVE) if (FlyCount <= 2) @@ -895,7 +896,7 @@ class npc_darkrune_guardian : public CreatureScript killedByBreath = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { return type == DATA_IRON_DWARF_MEDIUM_RARE ? killedByBreath : 0; } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp index 7ada42144a8..30f60da178a 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp @@ -29,6 +29,9 @@ #include "SpellAuraEffects.h" #include "ulduar.h" #include "Vehicle.h" +#include "Player.h" +#include "WorldPacket.h" +#include "Opcodes.h" enum Spells { @@ -326,7 +329,7 @@ class boss_xt002 : public CreatureScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 2f37fb06f24..7d3b943f7b0 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -19,6 +19,8 @@ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "ulduar.h" +#include "Player.h" +#include "WorldPacket.h" static DoorData const doorData[] = { @@ -654,7 +656,7 @@ class instance_ulduar : public InstanceMapScript { } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { @@ -740,7 +742,7 @@ class instance_ulduar : public InstanceMapScript return 0; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp index 29eb5ad3367..ab2f778ba9d 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp @@ -20,6 +20,7 @@ #include "ScriptedGossip.h" #include "ulduar.h" #include "InstanceScript.h" +#include "Player.h" /* The teleporter appears to be active and stable. diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp index e718942d091..9a50e1cbfa3 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp @@ -185,7 +185,7 @@ public: onTheRocks = value; } - uint32 GetData(uint32 data) + uint32 GetData(uint32 data) const { if (data == DATA_ON_THE_ROCKS) return onTheRocks; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp index 1e79cc1c5bf..c236b36312d 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "utgarde_keep.h" +#include "Player.h" #define MAX_ENCOUNTER 3 @@ -165,7 +166,7 @@ public: } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -246,7 +247,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp index c694aa88338..e587a864fd6 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/utgarde_keep.cpp @@ -143,17 +143,10 @@ public: } } } - - switch (near_f) - { - case 1: return 1; - case 2: return 2; - case 3: return 3; - default: return 0; - } + return near_f > 0 && near_f < 4 ? near_f : 0; } - void UpdateAI(const uint32 /*diff*/) + void UpdateAI(uint32 const /* diff */) { if (fm_Type == 0) fm_Type = GetForgeMasterType(); @@ -239,9 +232,115 @@ class spell_fixate : public SpellScriptLoader return new spell_fixate_SpellScript(); } }; + +enum EnslavedProtoDrake +{ + TYPE_PROTODRAKE_AT = 28, + DATA_PROTODRAKE_MOVE = 6, + + PATH_PROTODRAKE = 125946, + + EVENT_REND = 1, + EVENT_FLAME_BREATH = 2, + EVENT_KNOCKAWAY = 3, + + SPELL_REND = 43931, + SPELL_FLAME_BREATH = 50653, + SPELL_KNOCK_AWAY = 49722, + + POINT_LAST = 5, +}; + +const Position protodrakeCheckPos = {206.24f, -190.28f, 200.11f, 0.f}; + +class npc_enslaved_proto_drake : public CreatureScript +{ +public: + npc_enslaved_proto_drake() : CreatureScript("npc_enslaved_proto_drake") { } + + struct npc_enslaved_proto_drakeAI : public ScriptedAI + { + npc_enslaved_proto_drakeAI(Creature* creature) : ScriptedAI(creature) + { + _setData = false; + } + + void Reset() + { + _events.Reset(); + _events.ScheduleEvent(EVENT_REND, urand(2000, 3000)); + _events.ScheduleEvent(EVENT_FLAME_BREATH, urand(5500, 7000)); + _events.ScheduleEvent(EVENT_KNOCKAWAY, urand(3500, 6000)); + } + + void MovementInform(uint32 type, uint32 id) + { + if (type == WAYPOINT_MOTION_TYPE && id == POINT_LAST) + { + me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER); + } + } + + void SetData(uint32 type, uint32 data) + { + if (type == TYPE_PROTODRAKE_AT && data == DATA_PROTODRAKE_MOVE && !_setData && me->GetDistance(protodrakeCheckPos) < 5.0f) + { + _setData = true; + me->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER); + me->GetMotionMaster()->MovePath(PATH_PROTODRAKE, false); + } + } + + void UpdateAI(uint32 const diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; + + while (uint32 eventid = _events.ExecuteEvent()) + { + switch (eventid) + { + case EVENT_REND: + DoCast(SPELL_REND); + _events.ScheduleEvent(EVENT_REND, urand(15000, 20000)); + break; + case EVENT_FLAME_BREATH: + DoCast(SPELL_FLAME_BREATH); + _events.ScheduleEvent(EVENT_FLAME_BREATH, urand(11000, 12000)); + break; + case EVENT_KNOCKAWAY: + DoCast(SPELL_KNOCK_AWAY); + _events.ScheduleEvent(EVENT_KNOCKAWAY, urand(7000, 8500)); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); + } + + private: + bool _setData; + EventMap _events; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_enslaved_proto_drakeAI(creature); + } +}; + void AddSC_utgarde_keep() { new npc_dragonflayer_forge_master(); + new npc_enslaved_proto_drake(); new spell_ticking_time_bomb(); new spell_fixate(); } diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp index a6ad7befc38..63898e57c08 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp @@ -28,6 +28,8 @@ Script Data End */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "utgarde_pinnacle.h" +#include "Player.h" +#include "SpellInfo.h" //Yell enum eYells diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index f2f03ff602b..fc82ad1b526 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -588,7 +588,7 @@ class npc_scourge_hulk : public CreatureScript killedByRitualStrike = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { return type == DATA_INCREDIBLE_HULK ? killedByRitualStrike : 0; } diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp index 39fd01a9269..0278125deb3 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp @@ -26,6 +26,7 @@ Script Data End */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "utgarde_pinnacle.h" +#include "SpellInfo.h" enum Spells { @@ -201,7 +202,7 @@ public: kingsBane = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_KINGS_BANE) return kingsBane ? 1 : 0; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp index c5d50d4e7fd..a76c5a61109 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp @@ -180,7 +180,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -192,7 +192,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp index d1209b40a19..de557e10e7f 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp @@ -62,7 +62,7 @@ class instance_archavon : public InstanceMapScript } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp index f6d918e0493..cea00417233 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp @@ -197,7 +197,7 @@ public: me->GetMotionMaster()->MoveChase(me->getVictim()); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_DEHYDRATION) return dehydration ? 1 : 0; diff --git a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp index a01b41bfbcf..58d7b59c7dd 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_xevozz.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "violet_hold.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp index d1c65259738..408a7083383 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp @@ -158,7 +158,7 @@ public: voidDance = false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_VOID_DANCE) return voidDance ? 1 : 0; diff --git a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp index 4b6fed181e4..5e3bbc01025 100644 --- a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp @@ -18,6 +18,8 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "violet_hold.h" +#include "Player.h" +#include "TemporarySummon.h" #define MAX_ENCOUNTER 3 @@ -417,7 +419,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -438,7 +440,7 @@ public: return 0; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { diff --git a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp index 870ea893b78..c73cb97f2d1 100644 --- a/src/server/scripts/Northrend/VioletHold/violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/violet_hold.cpp @@ -20,6 +20,7 @@ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "violet_hold.h" +#include "Player.h" #define GOSSIP_START_EVENT "Get your people to safety, we'll keep the Blue Dragonflight's forces at bay." #define GOSSIP_ITEM_1 "Activate the crystals when we get in trouble, right" diff --git a/src/server/scripts/Northrend/borean_tundra.cpp b/src/server/scripts/Northrend/borean_tundra.cpp index 224d06e9d3c..6eed82991b8 100644 --- a/src/server/scripts/Northrend/borean_tundra.cpp +++ b/src/server/scripts/Northrend/borean_tundra.cpp @@ -42,6 +42,9 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.h" +#include "SpellInfo.h" +#include "WorldSession.h" /*###### ## npc_sinkhole_kill_credit diff --git a/src/server/scripts/Northrend/crystalsong_forest.cpp b/src/server/scripts/Northrend/crystalsong_forest.cpp index 7b8eb331702..09df0acc467 100644 --- a/src/server/scripts/Northrend/crystalsong_forest.cpp +++ b/src/server/scripts/Northrend/crystalsong_forest.cpp @@ -25,6 +25,7 @@ Script Data End */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" /******************************************************* * npc_warmage_violetstand @@ -108,4 +109,4 @@ public: void AddSC_crystalsong_forest() { new npc_warmage_violetstand; -}
\ No newline at end of file +} diff --git a/src/server/scripts/Northrend/dalaran.cpp b/src/server/scripts/Northrend/dalaran.cpp index c19effbab1b..b662442ef93 100644 --- a/src/server/scripts/Northrend/dalaran.cpp +++ b/src/server/scripts/Northrend/dalaran.cpp @@ -26,6 +26,8 @@ Script Data End */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "WorldSession.h" /******************************************************* * npc_mageguard_dalaran diff --git a/src/server/scripts/Northrend/dragonblight.cpp b/src/server/scripts/Northrend/dragonblight.cpp index a26ee4e9270..13a8370690e 100644 --- a/src/server/scripts/Northrend/dragonblight.cpp +++ b/src/server/scripts/Northrend/dragonblight.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "SpellScript.h" #include "SpellAuraEffects.h" #include "ScriptedEscortAI.h" +#include "Player.h" enum eEnums { diff --git a/src/server/scripts/Northrend/grizzly_hills.cpp b/src/server/scripts/Northrend/grizzly_hills.cpp index 4ca12bc82a1..0363e0c892d 100644 --- a/src/server/scripts/Northrend/grizzly_hills.cpp +++ b/src/server/scripts/Northrend/grizzly_hills.cpp @@ -19,6 +19,8 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## Quest 12027: Mr. Floppy's Perilous Adventure diff --git a/src/server/scripts/Northrend/howling_fjord.cpp b/src/server/scripts/Northrend/howling_fjord.cpp index ffe38d6aade..e04531954ea 100644 --- a/src/server/scripts/Northrend/howling_fjord.cpp +++ b/src/server/scripts/Northrend/howling_fjord.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_apothecary_hanes diff --git a/src/server/scripts/Northrend/icecrown.cpp b/src/server/scripts/Northrend/icecrown.cpp index 5989b5bad2e..030df23028c 100644 --- a/src/server/scripts/Northrend/icecrown.cpp +++ b/src/server/scripts/Northrend/icecrown.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "SpellAuras.h" +#include "Player.h" /*###### ## npc_arete diff --git a/src/server/scripts/Northrend/isle_of_conquest.cpp b/src/server/scripts/Northrend/isle_of_conquest.cpp index 1cf8f54b4fe..88d262a1579 100644 --- a/src/server/scripts/Northrend/isle_of_conquest.cpp +++ b/src/server/scripts/Northrend/isle_of_conquest.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "PassiveAI.h" #include "BattlegroundIC.h" +#include "Player.h" // TO-DO: This should be done with SmartAI, but yet it does not correctly support vehicles's AIs. // Even adding ReactState Passive we still have issues using SmartAI. diff --git a/src/server/scripts/Northrend/sholazar_basin.cpp b/src/server/scripts/Northrend/sholazar_basin.cpp index 63960f13bb7..8404413ad9d 100644 --- a/src/server/scripts/Northrend/sholazar_basin.cpp +++ b/src/server/scripts/Northrend/sholazar_basin.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "ScriptedEscortAI.h" #include "SpellScript.h" #include "SpellAuras.h" +#include "Player.h" /*###### ## npc_injured_rainspeaker_oracle diff --git a/src/server/scripts/Northrend/storm_peaks.cpp b/src/server/scripts/Northrend/storm_peaks.cpp index 1733af17580..b3a379d903d 100644 --- a/src/server/scripts/Northrend/storm_peaks.cpp +++ b/src/server/scripts/Northrend/storm_peaks.cpp @@ -23,6 +23,8 @@ #include "SpellAuraEffects.h" #include "Vehicle.h" #include "CombatAI.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npc_agnetta_tyrsdottar diff --git a/src/server/scripts/Northrend/wintergrasp.cpp b/src/server/scripts/Northrend/wintergrasp.cpp index d4a3f83ab70..8935c77b30e 100644 --- a/src/server/scripts/Northrend/wintergrasp.cpp +++ b/src/server/scripts/Northrend/wintergrasp.cpp @@ -25,6 +25,7 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "SpellScript.h" +#include "Player.h" #define GOSSIP_HELLO_DEMO1 "Build catapult." #define GOSSIP_HELLO_DEMO2 "Build demolisher." @@ -560,7 +561,7 @@ public: if (Battlefield* wg = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG)) if (Player* target = GetExplTargetUnit()->ToPlayer()) // check if we are in Wintergrasp at all, SotA uses same teleport spells - if ((target->GetZoneId() == 4197) && target->GetTeamId() != wg->GetDefenderTeam() || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER)) + if ((target->GetZoneId() == 4197 && target->GetTeamId() != wg->GetDefenderTeam()) || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER)) return SPELL_FAILED_BAD_TARGETS; return SPELL_CAST_OK; } diff --git a/src/server/scripts/Northrend/zuldrak.cpp b/src/server/scripts/Northrend/zuldrak.cpp index 6af96f3fdfd..e5763e5baf6 100644 --- a/src/server/scripts/Northrend/zuldrak.cpp +++ b/src/server/scripts/Northrend/zuldrak.cpp @@ -19,6 +19,8 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "SpellInfo.h" /*#### ## npc_drakuru_shackles diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp index c70e4168826..9411bd8a363 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp @@ -23,6 +23,7 @@ #include "MapManager.h" #include "ObjectMgr.h" #include "OutdoorPvPMgr.h" +#include "ReputationMgr.h" #include "Language.h" #include "World.h" diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp index f678cf9c198..d6465bfe006 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" #define SPELL_INHIBITMAGIC 32264 #define SPELL_ATTRACTMAGIC 32265 diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index a1780d1d4a8..303a30bea8f 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "shadow_labyrinth.h" +#include "Player.h" #define SAY_INTRO -1555028 #define SAY_AGGRO1 -1555029 diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp index 0f3bcce6493..1503c9f7234 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "shadow_labyrinth.h" +#include "SpellInfo.h" #define EMOTE_SONIC_BOOM -1555036 diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp index 9facb42107b..9fa90be9765 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/instance_shadow_labyrinth.cpp @@ -179,7 +179,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -191,7 +191,7 @@ public: return false; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { if (identifier == DATA_GRANDMASTERVORPIL) return m_uiGrandmasterVorpil; diff --git a/src/server/scripts/Outland/BlackTemple/black_temple.cpp b/src/server/scripts/Outland/BlackTemple/black_temple.cpp index 5fe5b8aab0c..a100f5848af 100644 --- a/src/server/scripts/Outland/BlackTemple/black_temple.cpp +++ b/src/server/scripts/Outland/BlackTemple/black_temple.cpp @@ -29,8 +29,9 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" - #include "ScriptedGossip.h" +#include "ScriptedGossip.h" #include "black_temple.h" +#include "Player.h" /*### # npc_spirit_of_olum diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index f812b1b35cd..1029648561f 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -28,6 +28,8 @@ EndScriptData */ #include "ScriptedGossip.h" #include "PassiveAI.h" #include "black_temple.h" +#include "Player.h" +#include "SpellInfo.h" #define GETGO(obj, guid) GameObject* obj = instance->instance->GetGameObject(guid) #define GETUNIT(unit, guid) Unit* unit = Unit::GetUnit(*me, guid) diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index 2757a862c93..6e770249cf0 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "black_temple.h" +#include "Player.h" #define SAY_DEATH -1564013 #define SAY_LOW_HEALTH -1564014 diff --git a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp index e8bee95865f..9924bf1ffab 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp @@ -26,6 +26,8 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "black_temple.h" +#include "Player.h" +#include "SpellInfo.h" enum eEnums { diff --git a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp index 98d90aa1818..8a2e25b176a 100644 --- a/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp +++ b/src/server/scripts/Outland/BlackTemple/instance_black_temple.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "black_temple.h" +#include "Player.h" #define MAX_ENCOUNTER 9 @@ -237,7 +238,7 @@ public: } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -347,7 +348,7 @@ public: } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp index 3b94feda02b..a934d03349c 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp @@ -27,6 +27,8 @@ EndScriptData */ #include "ScriptedCreature.h" #include "serpent_shrine.h" #include "Spell.h" +#include "Player.h" +#include "WorldSession.h" #define SAY_INTRO -1548042 #define SAY_AGGRO1 -1548043 diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 9b739a1a6ac..1221e59b96e 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "serpent_shrine.h" +#include "Player.h" // --- Spells used by Leotheras The Blind #define SPELL_WHIRLWIND 37640 @@ -103,7 +104,7 @@ public: victimGUID = guid; } - uint64 GetGUID(int32 id/* = 0 */) + uint64 GetGUID(int32 id/* = 0 */) const { if (id == INNER_DEMON_VICTIM) return victimGUID; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index b9e530996af..5bc2344fd70 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "serpent_shrine.h" #include "Spell.h" +#include "Player.h" #define SPELL_SPOUT 37433 #define SPELL_SPOUT_ANIM 42835 diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp index 87053d1de1c..4af38888758 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/instance_serpent_shrine.cpp @@ -26,6 +26,8 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "serpent_shrine.h" +#include "Player.h" +#include "TemporarySummon.h" #define MAX_ENCOUNTER 6 #define SPELL_SCALDINGWATER 37284 @@ -242,7 +244,7 @@ class instance_serpent_shrine : public InstanceMapScript LeotherasEventStarter = data; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -340,7 +342,7 @@ class instance_serpent_shrine : public InstanceMapScript SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp index d81a021c4bc..ac730292545 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_warlord_kalithresh.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "steam_vault.h" +#include "SpellInfo.h" #define SAY_INTRO -1545016 #define SAY_REGEN -1545017 diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp index dd0b5ea9160..e8a096a83a1 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/instance_steam_vault.cpp @@ -167,7 +167,7 @@ public: SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -183,7 +183,7 @@ public: return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp index fa67659ca66..120e550bd4e 100644 --- a/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp +++ b/src/server/scripts/Outland/GruulsLair/instance_gruuls_lair.cpp @@ -117,7 +117,7 @@ public: MaulgarEvent_Tank = data; } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -156,7 +156,7 @@ public: SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp index 233a8d82497..11e75f054ad 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp @@ -175,7 +175,7 @@ class instance_blood_furnace : public InstanceMapScript BroggokLeverGUID = go->GetGUID(); //Broggok lever } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { @@ -231,7 +231,7 @@ class instance_blood_furnace : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp index 714ea275471..56365216be5 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" enum eSays { diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp index 3bb0858d2be..f0c4330c9a3 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "SpellInfo.h" enum eSpells { diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp index bbf03e39f9b..94272e4a50f 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp @@ -26,6 +26,8 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "magtheridons_lair.h" +#include "Player.h" +#include "SpellInfo.h" struct Yell { diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp index 640e4439593..0bb949d3b90 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/instance_magtheridons_lair.cpp @@ -123,7 +123,7 @@ class instance_magtheridons_lair : public InstanceMapScript } } - uint64 GetData64(uint32 type) + uint64 GetData64(uint32 type) const { switch (type) { @@ -211,7 +211,7 @@ class instance_magtheridons_lair : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { if (type == DATA_MAGTHERIDON_EVENT) return m_auiEncounter[0]; diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp index 4105a7d5821..c7c1cbba880 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp @@ -87,7 +87,7 @@ class instance_shattered_halls : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -99,7 +99,7 @@ class instance_shattered_halls : public InstanceMapScript return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index 3770ac3ba09..a8be934c710 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "the_eye.h" +#include "SpellInfo.h" enum eSpells { diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 29c87e57c83..2dbfb7b46c5 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "the_eye.h" #include "WorldPacket.h" +#include "Opcodes.h" enum eEnums { @@ -926,8 +927,7 @@ class boss_kaelthas : public CreatureScript unit->CastSpell(unit, SPELL_GRAVITY_LAPSE_AURA, true, 0, 0, me->GetGUID()); //Using packet workaround - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); + WorldPacket data(SMSG_MOVE_SET_CAN_FLY, 12); data.append(unit->GetPackGUID()); data << uint32(0); unit->SendMessageToSet(&data, true); @@ -953,8 +953,7 @@ class boss_kaelthas : public CreatureScript if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { //Using packet workaround - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); + WorldPacket data(SMSG_MOVE_UNSET_CAN_FLY, 12); data.append(unit->GetPackGUID()); data << uint32(0); unit->SendMessageToSet(&data, true); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp b/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp index 1230b7e88cf..e9ee5a62bb8 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/instance_the_eye.cpp @@ -113,7 +113,7 @@ class instance_the_eye : public InstanceMapScript } } - uint64 GetData64(uint32 identifier) + uint64 GetData64(uint32 identifier) const { switch (identifier) { @@ -151,7 +151,7 @@ class instance_the_eye : public InstanceMapScript SaveToDB(); } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp index d2b0475fa77..697d2c9f9f9 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp @@ -20,6 +20,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp index a96666705d1..37e314b6576 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/instance_mechanar.cpp @@ -57,7 +57,7 @@ class instance_mechanar : public InstanceMapScript return false; } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -67,7 +67,7 @@ class instance_mechanar : public InstanceMapScript return false; } - uint64 GetData64(uint32 /*identifier*/) + uint64 GetData64(uint32 /*identifier*/) const { return 0; } diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp index d5b61b87fc2..e956ea0ed85 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/instance_arcatraz.cpp @@ -230,7 +230,7 @@ class instance_arcatraz : public InstanceMapScript } } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { switch (type) { @@ -244,7 +244,7 @@ class instance_arcatraz : public InstanceMapScript return 0; } - uint64 GetData64(uint32 data) + uint64 GetData64(uint32 data) const { switch (data) { diff --git a/src/server/scripts/Outland/hellfire_peninsula.cpp b/src/server/scripts/Outland/hellfire_peninsula.cpp index 4c44d4e828e..4da98281eb2 100644 --- a/src/server/scripts/Outland/hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/hellfire_peninsula.cpp @@ -37,6 +37,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npc_aeranas diff --git a/src/server/scripts/Outland/nagrand.cpp b/src/server/scripts/Outland/nagrand.cpp index 977ec57e2df..0c9a60603f5 100644 --- a/src/server/scripts/Outland/nagrand.cpp +++ b/src/server/scripts/Outland/nagrand.cpp @@ -32,6 +32,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "SpellInfo.h" /*###### ## npc_greatmother_geyah diff --git a/src/server/scripts/Outland/netherstorm.cpp b/src/server/scripts/Outland/netherstorm.cpp index 8533491c15f..eaea4960712 100644 --- a/src/server/scripts/Outland/netherstorm.cpp +++ b/src/server/scripts/Outland/netherstorm.cpp @@ -36,6 +36,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_manaforge_control_console diff --git a/src/server/scripts/Outland/shadowmoon_valley.cpp b/src/server/scripts/Outland/shadowmoon_valley.cpp index c84df2ee3d4..dc91fb2c14f 100644 --- a/src/server/scripts/Outland/shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/shadowmoon_valley.cpp @@ -46,6 +46,8 @@ EndContentData */ #include "ScriptedEscortAI.h" #include "Group.h" #include "SpellScript.h" +#include "Player.h" +#include "WorldSession.h" /*##### # mob_mature_netherwing_drake diff --git a/src/server/scripts/Outland/shattrath_city.cpp b/src/server/scripts/Outland/shattrath_city.cpp index 8ad2c311fc5..76cffa9e1fe 100644 --- a/src/server/scripts/Outland/shattrath_city.cpp +++ b/src/server/scripts/Outland/shattrath_city.cpp @@ -38,6 +38,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npc_raliq_the_drunk diff --git a/src/server/scripts/Outland/terokkar_forest.cpp b/src/server/scripts/Outland/terokkar_forest.cpp index 707cabfcf0c..2298f676692 100644 --- a/src/server/scripts/Outland/terokkar_forest.cpp +++ b/src/server/scripts/Outland/terokkar_forest.cpp @@ -38,6 +38,8 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "Group.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## mob_unkor_the_ruthless diff --git a/src/server/scripts/Outland/zangarmarsh.cpp b/src/server/scripts/Outland/zangarmarsh.cpp index a48866a2f83..03e40b8d7dc 100644 --- a/src/server/scripts/Outland/zangarmarsh.cpp +++ b/src/server/scripts/Outland/zangarmarsh.cpp @@ -36,6 +36,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## npcs_ashyen_and_keleth diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index b46d2083ecd..224e909ca57 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_dk_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 6119c9050fa..0fe6c367a9a 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_dru_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 519d79add6d..026a0c7b280 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -23,16 +23,19 @@ */ #include "ScriptMgr.h" -#include "SpellScript.h" -#include "SpellAuraEffects.h" -#include "SkillDiscovery.h" +#include "Battleground.h" #include "Cell.h" #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "InstanceScript.h" #include "Group.h" +#include "InstanceScript.h" #include "LFGMgr.h" +#include "Pet.h" +#include "ReputationMgr.h" +#include "SkillDiscovery.h" +#include "SpellScript.h" +#include "SpellAuraEffects.h" class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader { diff --git a/src/server/scripts/Spells/spell_holiday.cpp b/src/server/scripts/Spells/spell_holiday.cpp index a1ecac6256a..5b1cbe0c36a 100644 --- a/src/server/scripts/Spells/spell_holiday.cpp +++ b/src/server/scripts/Spells/spell_holiday.cpp @@ -20,6 +20,7 @@ * Scriptnames in this file should be prefixed with "spell_#holidayname_". */ +#include "Player.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 9d0e084cfb8..a73af6892ca 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_hun_". */ +#include "Pet.h" #include "ScriptMgr.h" #include "Cell.h" #include "CellImpl.h" diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index ef810b50b6f..e0c88ad6846 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -21,11 +21,13 @@ * Scriptnames of files in this file should be prefixed with "spell_item_". */ +#include "Player.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" #include "SkillDiscovery.h" +#include "Battleground.h" // Generic script for handling item dummy effects which trigger another spell. class spell_item_trigger_spell : public SpellScriptLoader diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index f4bbccc8587..cd096ebed5e 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -21,11 +21,11 @@ * Scriptnames of files in this file should be prefixed with "spell_mage_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" - enum MageSpells { SPELL_MAGE_COLD_SNAP = 11958, diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 41bda3c163d..58f94edb387 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -21,12 +21,12 @@ * Scriptnames of files in this file should be prefixed with "spell_pal_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" #include "Group.h" - enum PaladinSpells { PALADIN_SPELL_DIVINE_PLEA = 54428, diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index df6c311ca67..876d7c80a44 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -1706,7 +1706,7 @@ public: if (pet->isGuardian()) ((Guardian*)pet)->SetBonusDamage(owner->GetTotalAttackPowerValue(BASE_ATTACK)); - amount += owner->CalculateDamage(BASE_ATTACK, true, true);; + amount += owner->CalculateDamage(BASE_ATTACK, true, true); } } diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index aee3889e93b..a15eb7ddc2c 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_pri_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 06d3602d8e8..da80ec8f1da 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_q#questID_". */ +#include "Player.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 68cc50a3022..0294533bdcd 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_rog_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index e107ea954e4..1ba962982e4 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_sha_". */ +#include "Player.h" #include "ScriptMgr.h" #include "GridNotifiers.h" #include "Unit.h" diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index aa56f8300bc..f83056aa8b6 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_warl_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index cc8dbe35703..613bf0fef5d 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -21,6 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_warr_". */ +#include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" diff --git a/src/server/scripts/World/achievement_scripts.cpp b/src/server/scripts/World/achievement_scripts.cpp index a6f4f7f64f9..178df2078f8 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -23,6 +23,8 @@ #include "BattlegroundSA.h" #include "BattlegroundAV.h" #include "Vehicle.h" +#include "Player.h" +#include "Creature.h" class achievement_resilient_victory : public AchievementCriteriaScript { diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index 67aeda314bf..db3c6dd2274 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -37,6 +37,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" /*###### ## at_coilfang_waterfall diff --git a/src/server/scripts/World/boss_emerald_dragons.cpp b/src/server/scripts/World/boss_emerald_dragons.cpp index abb20130ef8..a8f65b0bc9b 100644 --- a/src/server/scripts/World/boss_emerald_dragons.cpp +++ b/src/server/scripts/World/boss_emerald_dragons.cpp @@ -22,6 +22,7 @@ #include "SpellScript.h" #include "Spell.h" #include "SpellAuraEffects.h" +#include "PassiveAI.h" // // Emerald Dragon NPCs and IDs (kept here for reference) @@ -91,14 +92,12 @@ struct emerald_dragonAI : public WorldBossAI { emerald_dragonAI(Creature* creature) : WorldBossAI(creature) { -// me->m_CombatDistance = 12.0f; -// me->m_SightDistance = 60.0f; } void Reset() { - _Reset(); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_NON_ATTACKABLE); + WorldBossAI::Reset(); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); me->SetReactState(REACT_AGGRESSIVE); DoCast(me, SPELL_MARK_OF_NATURE_AURA, true); events.ScheduleEvent(EVENT_TAIL_SWEEP, 4000); @@ -109,7 +108,8 @@ struct emerald_dragonAI : public WorldBossAI // Target killed during encounter, mark them as suspectible for Aura Of Nature void KilledUnit(Unit* who) { - who->CastSpell(who, SPELL_MARK_OF_NATURE, true); + if (who->GetTypeId() == TYPEID_PLAYER) + who->CastSpell(who, SPELL_MARK_OF_NATURE, true); } // Execute and reschedule base events shared between all Emerald Dragons @@ -216,109 +216,6 @@ class npc_dream_fog : public CreatureScript }; /* - * --- Spell: Dream Fog - */ - -class DreamFogTargetSelector -{ - public: - DreamFogTargetSelector() { } - - bool operator()(WorldObject* object) const - { - return object->ToUnit() && object->ToUnit()->HasAura(SPELL_SLEEP); - } -}; - -class spell_dream_fog_sleep : public SpellScriptLoader -{ - public: - spell_dream_fog_sleep() : SpellScriptLoader("spell_dream_fog_sleep") { } - - class spell_dream_fog_sleep_SpellScript : public SpellScript - { - PrepareSpellScript(spell_dream_fog_sleep_SpellScript); - - void FilterTargets(std::list<WorldObject*>& unitList) - { - unitList.remove_if(DreamFogTargetSelector()); - } - - void Register() - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dream_fog_sleep_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const - { - return new spell_dream_fog_sleep_SpellScript(); - } -}; - -/* - * --- Spell: Mark of Nature - */ - -class MarkOfNatureTargetSelector -{ - public: - MarkOfNatureTargetSelector() { } - - bool operator()(WorldObject* object) const - { - if (Unit* unit = object->ToUnit()) - // return anyone that isn't tagged or already under the influence of Aura of Nature - return !(unit->HasAura(SPELL_MARK_OF_NATURE) && !unit->HasAura(SPELL_AURA_OF_NATURE)); - return true; - } -}; - -class spell_mark_of_nature : public SpellScriptLoader -{ - public: - spell_mark_of_nature() : SpellScriptLoader("spell_mark_of_nature") { } - - class spell_mark_of_nature_SpellScript : public SpellScript - { - PrepareSpellScript(spell_mark_of_nature_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_MARK_OF_NATURE)) - return false; - if (!sSpellMgr->GetSpellInfo(SPELL_AURA_OF_NATURE)) - return false; - return true; - } - - void FilterTargets(std::list<WorldObject*>& targets) - { - targets.remove_if(MarkOfNatureTargetSelector()); - } - - void HandleEffect(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - - if (GetHitUnit()) - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_AURA_OF_NATURE, true); - } - - void Register() - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mark_of_nature_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_mark_of_nature_SpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - } - }; - - SpellScript* GetSpellScript() const - { - return new spell_mark_of_nature_SpellScript(); - } -}; - -/* * --- * --- Dragonspecific scripts and handling: YSONDRE * --- @@ -355,7 +252,6 @@ class boss_ysondre : public CreatureScript void Reset() { _stage = 1; - _Reset(); emerald_dragonAI::Reset(); events.ScheduleEvent(EVENT_LIGHTNING_WAVE, 12000); } @@ -394,7 +290,7 @@ class boss_ysondre : public CreatureScript } private: - uint8 _stage; + uint8 _stage; }; CreatureAI* GetAI(Creature* creature) const @@ -409,8 +305,6 @@ class boss_ysondre : public CreatureScript * --- * * TODO: - * - NPC helper for spirit shades(?) - * - Spirit shade NPC moves towards Lethon and heals him if close enough (each shade heals for 15000 HP) * - Spell: Shadow bolt whirl casts needs custom handling (spellscript) */ @@ -424,7 +318,12 @@ enum LethonSpells { SPELL_DRAW_SPIRIT = 24811, SPELL_SHADOW_BOLT_WHIRL = 24834, - SPELL_SPIRIT_SHADE_VISUAL = 24908, + SPELL_DARK_OFFERING = 24804, +}; + +enum LethonCreatures +{ + NPC_SPIRIT_SHADE = 15261, }; class boss_lethon : public CreatureScript @@ -441,7 +340,6 @@ class boss_lethon : public CreatureScript void Reset() { _stage = 1; - _Reset(); emerald_dragonAI::Reset(); events.ScheduleEvent(EVENT_SHADOW_BOLT_WHIRL, 10000); } @@ -462,12 +360,22 @@ class boss_lethon : public CreatureScript } } + void SpellHitTarget(Unit* target, SpellInfo const* spell) + { + if (spell->Id == SPELL_DRAW_SPIRIT && target->GetTypeId() == TYPEID_PLAYER) + { + Position targetPos; + target->GetPosition(&targetPos); + me->SummonCreature(NPC_SPIRIT_SHADE, targetPos, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 50000); + } + } + void ExecuteEvent(uint32 const eventId) { switch (eventId) { case EVENT_SHADOW_BOLT_WHIRL: - DoCast(me, SPELL_SHADOW_BOLT_WHIRL, true); + me->CastSpell((Unit*)NULL, SPELL_SHADOW_BOLT_WHIRL, false); events.ScheduleEvent(EVENT_SHADOW_BOLT_WHIRL, urand(15000, 30000)); break; default: @@ -477,7 +385,7 @@ class boss_lethon : public CreatureScript } private: - uint8 _stage; + uint8 _stage; }; CreatureAI* GetAI(Creature* creature) const @@ -486,6 +394,42 @@ class boss_lethon : public CreatureScript } }; +class npc_spirit_shade : public CreatureScript +{ + public: + npc_spirit_shade() : CreatureScript("npc_spirit_shade") { } + + struct npc_spirit_shadeAI : public PassiveAI + { + npc_spirit_shadeAI(Creature* creature) : PassiveAI(creature), _summonerGuid(0) + { + } + + void IsSummonedBy(Unit* summoner) + { + _summonerGuid = summoner->GetGUID(); + me->GetMotionMaster()->MoveFollow(summoner, 0.0f, 0.0f); + } + + void MovementInform(uint32 moveType, uint32 data) + { + if (moveType == FOLLOW_MOTION_TYPE && data == _summonerGuid) + { + me->CastSpell((Unit*)NULL, SPELL_DARK_OFFERING, false); + me->DespawnOrUnsummon(1000); + } + } + + private: + uint64 _summonerGuid; + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_spirit_shadeAI(creature); + } +}; + /* * --- * --- Dragonspecific scripts and handling: EMERISS @@ -519,7 +463,6 @@ class boss_emeriss : public CreatureScript void Reset() { _stage = 1; - _Reset(); emerald_dragonAI::Reset(); events.ScheduleEvent(EVENT_VOLATILE_INFECTION, 12000); } @@ -562,7 +505,7 @@ class boss_emeriss : public CreatureScript } private: - uint8 _stage; + uint8 _stage; }; CreatureAI* GetAI(Creature* creature) const @@ -607,10 +550,6 @@ class boss_taerar : public CreatureScript { boss_taerarAI(Creature* creature) : emerald_dragonAI(creature) { - _stage = 1; - _shades = 0; - _banished = false; - _banishedTimer = 0; } void Reset() @@ -622,7 +561,6 @@ class boss_taerar : public CreatureScript _banished = false; _banishedTimer = 0; - _Reset(); emerald_dragonAI::Reset(); events.ScheduleEvent(EVENT_ARCANE_BLAST, 12000); events.ScheduleEvent(EVENT_BELLOWING_ROAR, 30000); @@ -655,11 +593,11 @@ class boss_taerar : public CreatureScript uint32 count = sizeof(TaerarShadeSpells) / sizeof(uint32); for (uint32 i = 0; i < count; ++i) - DoCastVictim(TaerarShadeSpells[i], true); + DoCast(me->getVictim(), TaerarShadeSpells[i], true); _shades += count; DoCast(SPELL_SHADE); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_NON_ATTACKABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); me->SetReactState(REACT_PASSIVE); ++_stage; @@ -696,7 +634,7 @@ class boss_taerar : public CreatureScript { _banished = false; - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_NON_ATTACKABLE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); me->RemoveAurasDueToSpell(SPELL_SHADE); me->SetReactState(REACT_AGGRESSIVE); } @@ -714,10 +652,10 @@ class boss_taerar : public CreatureScript } private: - bool _banished; // used for shades activation testing - uint32 _banishedTimer; // counter for banishment timeout - uint8 _shades; // keep track of how many shades are dead - uint8 _stage; // check which "shade phase" we're at (75-50-25 percentage counters) + bool _banished; // used for shades activation testing + uint32 _banishedTimer; // counter for banishment timeout + uint8 _shades; // keep track of how many shades are dead + uint8 _stage; // check which "shade phase" we're at (75-50-25 percentage counters) }; CreatureAI* GetAI(Creature* creature) const @@ -726,18 +664,122 @@ class boss_taerar : public CreatureScript } }; +/* + * --- Spell: Dream Fog + */ + +class DreamFogTargetSelector +{ + public: + DreamFogTargetSelector() { } + + bool operator()(WorldObject* object) + { + if (Unit* unit = object->ToUnit()) + return unit->HasAura(SPELL_SLEEP); + return true; + } +}; + +class spell_dream_fog_sleep : public SpellScriptLoader +{ + public: + spell_dream_fog_sleep() : SpellScriptLoader("spell_dream_fog_sleep") { } + + class spell_dream_fog_sleep_SpellScript : public SpellScript + { + PrepareSpellScript(spell_dream_fog_sleep_SpellScript); + + void FilterTargets(std::list<WorldObject*>& targets) + { + targets.remove_if(DreamFogTargetSelector()); + } + + void Register() + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dream_fog_sleep_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_dream_fog_sleep_SpellScript(); + } +}; + +/* + * --- Spell: Mark of Nature + */ + +class MarkOfNatureTargetSelector +{ + public: + MarkOfNatureTargetSelector() { } + + bool operator()(WorldObject* object) + { + // return those not tagged or already under the influence of Aura of Nature + if (Unit* unit = object->ToUnit()) + return !(unit->HasAura(SPELL_MARK_OF_NATURE) && !unit->HasAura(SPELL_AURA_OF_NATURE)); + return true; + } +}; + +class spell_mark_of_nature : public SpellScriptLoader +{ + public: + spell_mark_of_nature() : SpellScriptLoader("spell_mark_of_nature") { } + + class spell_mark_of_nature_SpellScript : public SpellScript + { + PrepareSpellScript(spell_mark_of_nature_SpellScript); + + bool Validate(SpellInfo const* /*spellInfo*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_MARK_OF_NATURE)) + return false; + if (!sSpellMgr->GetSpellInfo(SPELL_AURA_OF_NATURE)) + return false; + return true; + } + + void FilterTargets(std::list<WorldObject*>& targets) + { + targets.remove_if(MarkOfNatureTargetSelector()); + } + + void HandleEffect(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_AURA_OF_NATURE, true); + } + + void Register() + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mark_of_nature_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_mark_of_nature_SpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_mark_of_nature_SpellScript(); + } +}; + void AddSC_emerald_dragons() { // helper NPC scripts new npc_dream_fog(); - - // dragon spellscripts - new spell_dream_fog_sleep(); - new spell_mark_of_nature(); + new npc_spirit_shade(); // dragons new boss_ysondre(); new boss_taerar(); new boss_emeriss(); new boss_lethon(); + + // dragon spellscripts + new spell_dream_fog_sleep(); + new spell_mark_of_nature(); }; diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index ddb0044a888..dac67b566e3 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -55,6 +55,8 @@ EndContentData */ #include "ScriptedGossip.h" #include "GameObjectAI.h" #include "Spell.h" +#include "Player.h" +#include "WorldSession.h" /*###### ## go_cat_figurine diff --git a/src/server/scripts/World/guards.cpp b/src/server/scripts/World/guards.cpp index 4b0433fe0c7..951c0ed9688 100644 --- a/src/server/scripts/World/guards.cpp +++ b/src/server/scripts/World/guards.cpp @@ -32,6 +32,8 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "GuardAI.h" +#include "Player.h" +#include "SpellInfo.h" enum GuardGeneric { diff --git a/src/server/scripts/World/item_scripts.cpp b/src/server/scripts/World/item_scripts.cpp index d888e6cb56b..535bebd9415 100644 --- a/src/server/scripts/World/item_scripts.cpp +++ b/src/server/scripts/World/item_scripts.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "Spell.h" +#include "Player.h" /*##### # item_only_for_flight diff --git a/src/server/scripts/World/npc_innkeeper.cpp b/src/server/scripts/World/npc_innkeeper.cpp index f57af517db2..502ecb1acb2 100644 --- a/src/server/scripts/World/npc_innkeeper.cpp +++ b/src/server/scripts/World/npc_innkeeper.cpp @@ -27,6 +27,8 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "GameEventMgr.h" +#include "Player.h" +#include "WorldSession.h" #define HALLOWEEN_EVENTID 12 #define SPELL_TRICK_OR_TREATED 24755 diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp index 175cfb190d7..4e0818c7c82 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -26,6 +26,9 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "SpellInfo.h" +#include "WorldSession.h" /* A few notes for future developement: diff --git a/src/server/scripts/World/npc_taxi.cpp b/src/server/scripts/World/npc_taxi.cpp index efdd4da73d6..4ed5b0d9276 100644 --- a/src/server/scripts/World/npc_taxi.cpp +++ b/src/server/scripts/World/npc_taxi.cpp @@ -27,6 +27,8 @@ EndScriptData #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" +#include "WorldSession.h" #define GOSSIP_SUSURRUS "I am ready." #define GOSSIP_NETHER_DRAKE "I'm ready to fly! Take me up, dragon!" @@ -51,8 +53,6 @@ EndScriptData #define GOSSIP_TARIOLSTRASZ2 "Can you spare a drake to travel to Lord Of Afrasastrasz, in the middle of the temple?" #define GOSSIP_TORASTRASZA1 "I would like to see Lord Of Afrasastrasz, in the middle of the temple." #define GOSSIP_TORASTRASZA2 "Yes, Please. I would like to return to the ground floor of the temple." -#define GOSSIP_CAMILLE1 "I need to fly to the Windrunner Official business!" -#define GOSSIP_CAMILLE2 "<The riding bat for the special task is necessary to me.>" #define GOSSIP_CRIMSONWING "<Ride the gryphons to Survey Alcaz Island>" #define GOSSIP_THRICESTAR1 "Do you think I could take a ride on one of those flying machines?" #define GOSSIP_THRICESTAR2 "Kara, I need to be flown out the Dens of Dying to find Bixie." @@ -159,12 +159,6 @@ public: // top -> ground player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_TORASTRASZA2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); break; - case 23816: // Howling Fjord - Bat Handler Camille - if (!player->GetQuestRewardStatus(11229)) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CAMILLE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 23); - if (player->GetQuestStatus(11170) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CAMILLE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 24); - break; case 23704: // Dustwallow Marsh - Cassa Crimsonwing if (player->GetQuestStatus(11142) == QUEST_STATUS_INCOMPLETE) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CRIMSONWING, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+25); diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 4f0687ef11d..b38530b2a4a 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -58,6 +58,7 @@ EndContentData */ #include "Cell.h" #include "CellImpl.h" #include "SpellAuras.h" +#include "Pet.h" /*######## # npc_air_force_bots @@ -2284,7 +2285,7 @@ class npc_wormhole : public CreatureScript _showUnderground = urand(0, 100) == 0; // Guessed value, it is really rare though } - uint32 GetData(uint32 type) + uint32 GetData(uint32 type) const { return (type == DATA_SHOW_UNDERGROUND && _showUnderground) ? 1 : 0; } diff --git a/src/server/shared/AutoPtr.h b/src/server/shared/AutoPtr.h index f4199880abd..9afa05325c9 100644 --- a/src/server/shared/AutoPtr.h +++ b/src/server/shared/AutoPtr.h @@ -22,32 +22,32 @@ namespace Trinity { - template <class Pointer, class Lock> - class AutoPtr : public ACE_Strong_Bound_Ptr<Pointer, Lock> + +template <class Pointer, class Lock> +class AutoPtr : public ACE_Strong_Bound_Ptr<Pointer, Lock> +{ + typedef ACE_Strong_Bound_Ptr<Pointer, Lock> Base; + +public: + AutoPtr() + : Base() + { } + + AutoPtr(Pointer* x) + : Base(x) + { } + + operator bool() const + { + return !Base::null(); + } + + bool operator !() const { - public: - AutoPtr() : ACE_Strong_Bound_Ptr<Pointer, Lock>() {} - - AutoPtr(Pointer* x) - { - ACE_Strong_Bound_Ptr<Pointer, Lock>::reset(x); - } - - operator bool() const - { - return ACE_Strong_Bound_Ptr<Pointer, Lock>::get() != NULL; - } - - bool operator !() const - { - return ACE_Strong_Bound_Ptr<Pointer, Lock>::get() == NULL; - } - - bool operator !=(Pointer* x) const - { - return ACE_Strong_Bound_Ptr<Pointer, Lock>::get() != x; - } - }; -} + return Base::null(); + } +}; + +} // namespace Trinity #endif diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt index e016ad249b3..7143c8bcd47 100644 --- a/src/server/shared/CMakeLists.txt +++ b/src/server/shared/CMakeLists.txt @@ -28,11 +28,9 @@ file(GLOB sources_localdir *.cpp *.h) # Build shared sourcelist # -if( USE_COREPCH AND MSVC ) - set(shared_STAT_SRCS - PrecompiledHeaders/sharedPCH.cpp - PrecompiledHeaders/sharedPCH.h - ) +if (USE_COREPCH) + set(shared_STAT_PCH_HDR PrecompiledHeaders/sharedPCH.h) + set(shared_STAT_PCH_SRC PrecompiledHeaders/sharedPCH.cpp) endif() set(shared_STAT_SRCS @@ -74,18 +72,16 @@ include_directories( ${OPENSSL_INCLUDE_DIR} ) -add_library(shared STATIC ${shared_STAT_SRCS}) +add_library(shared STATIC + ${shared_STAT_SRCS} + ${shared_STAT_PCH_SRC} +) target_link_libraries(shared ${ACE_LIBRARY} ) # Generate precompiled header -if( USE_COREPCH ) - if(CMAKE_COMPILER_IS_GNUCXX) - add_precompiled_header(shared ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/sharedPCH.h) - elseif(MSVC) - add_native_precompiled_header(shared ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/sharedPCH) - endif() -endif() - +if (USE_COREPCH) + add_cxx_pch(shared ${shared_STAT_PCH_HDR} ${shared_STAT_PCH_SRC}) +endif () diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp index 8e424e9bcdb..def0a7fd02e 100755 --- a/src/server/shared/Cryptography/BigNumber.cpp +++ b/src/server/shared/Cryptography/BigNumber.cpp @@ -192,12 +192,12 @@ uint8 *BigNumber::AsByteArray(int minSize, bool reverse) return _array; } -const char *BigNumber::AsHexStr() +char * BigNumber::AsHexStr() const { return BN_bn2hex(_bn); } -const char *BigNumber::AsDecStr() +char * BigNumber::AsDecStr() const { return BN_bn2dec(_bn); } diff --git a/src/server/shared/Cryptography/BigNumber.h b/src/server/shared/Cryptography/BigNumber.h index a27d74fb5c7..36a618056a5 100755 --- a/src/server/shared/Cryptography/BigNumber.h +++ b/src/server/shared/Cryptography/BigNumber.h @@ -84,8 +84,8 @@ class BigNumber uint32 AsDword(); uint8* AsByteArray(int minSize = 0, bool reverse = true); - const char *AsHexStr(); - const char *AsDecStr(); + char * AsHexStr() const; + char * AsDecStr() const; private: struct bignum_st *_bn; diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index db9a5646a69..5210ee6f39d 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -535,4 +535,10 @@ void CharacterDatabaseConnection::DoPrepareStatements() PREPARE_STATEMENT(CHAR_INS_CHAR_TALENT, "INSERT INTO character_talent (guid, spell, spec) VALUES (?, ?, ?)", CONNECTION_ASYNC); PREPARE_STATEMENT(CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC, "DELETE FROM character_action WHERE spec<>? AND guid = ?", CONNECTION_ASYNC); PREPARE_STATEMENT(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT, "SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, CreatedBySpell, PetType FROM character_pet WHERE owner = ? AND slot = ?", CONNECTION_SYNCH); + + // Calendar + PREPARE_STATEMENT(CHAR_REP_CALENDAR_EVENT, "REPLACE INTO calendar_events (id, creator, title, description, type, dungeon, eventtime, flags, time2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PREPARE_STATEMENT(CHAR_DEL_CALENDAR_EVENT, "DELETE FROM calendar_events WHERE id = ?", CONNECTION_ASYNC); + PREPARE_STATEMENT(CHAR_REP_CALENDAR_INVITE, "REPLACE INTO calendar_invites (id, event, invitee, sender, status, statustime, rank, text) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PREPARE_STATEMENT(CHAR_DEL_CALENDAR_INVITE, "DELETE FROM calendar_invites WHERE id = ?", CONNECTION_ASYNC); } diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index e421a7917ca..7e4fe6a0b0e 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -496,6 +496,11 @@ enum CharacterDatabaseStatements CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC, CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT, + CHAR_REP_CALENDAR_EVENT, + CHAR_DEL_CALENDAR_EVENT, + CHAR_REP_CALENDAR_INVITE, + CHAR_DEL_CALENDAR_INVITE, + MAX_CHARACTERDATABASE_STATEMENTS }; diff --git a/src/server/shared/Database/PreparedStatement.h b/src/server/shared/Database/PreparedStatement.h index 11ece3e3032..90ea435d1f9 100755 --- a/src/server/shared/Database/PreparedStatement.h +++ b/src/server/shared/Database/PreparedStatement.h @@ -21,6 +21,10 @@ #include "SQLOperation.h" #include <ace/Future.h> +#ifdef __APPLE__ +#undef TYPE_BOOL +#endif + //- Union for data buffer (upper-level bind -> queue -> lower-level bind) union PreparedStatementDataUnion { @@ -157,4 +161,4 @@ class PreparedStatementTask : public SQLOperation bool m_has_result; PreparedQueryResultFuture m_result; }; -#endif
\ No newline at end of file +#endif diff --git a/src/server/shared/Database/QueryResult.h b/src/server/shared/Database/QueryResult.h index e32b16555bc..be7fa7b649c 100755 --- a/src/server/shared/Database/QueryResult.h +++ b/src/server/shared/Database/QueryResult.h @@ -23,7 +23,6 @@ #include <ace/Thread_Mutex.h> #include "Field.h" -#include "Log.h" #ifdef _WIN32 #include <winsock2.h> diff --git a/src/server/shared/Dynamic/LinkedReference/Reference.h b/src/server/shared/Dynamic/LinkedReference/Reference.h index 6c9710381b9..22921b075fe 100755 --- a/src/server/shared/Dynamic/LinkedReference/Reference.h +++ b/src/server/shared/Dynamic/LinkedReference/Reference.h @@ -20,6 +20,7 @@ #define _REFERENCE_H #include "Dynamic/LinkedList.h" +#include <assert.h> //===================================================== diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 1fa3148504a..e79544e7315 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -372,7 +372,7 @@ class ByteBuffer lt.tm_mon = (packedDate >> 20) & 0xF; lt.tm_year = ((packedDate >> 24) & 0x1F) + 100; - return mktime(<) + timezone; + return uint32(mktime(<) + timezone); } ByteBuffer& ReadPackedTime(uint32& time) diff --git a/src/server/shared/Threading/DelayExecutor.cpp b/src/server/shared/Threading/DelayExecutor.cpp index cfc4987387f..685e86e2a2f 100644 --- a/src/server/shared/Threading/DelayExecutor.cpp +++ b/src/server/shared/Threading/DelayExecutor.cpp @@ -59,7 +59,7 @@ int DelayExecutor::svc() return 0; } -int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, ACE_Method_Request* post_svc_hook) +int DelayExecutor::start(int num_threads, ACE_Method_Request* pre_svc_hook, ACE_Method_Request* post_svc_hook) { if (activated()) return -1; diff --git a/src/server/shared/Threading/DelayExecutor.h b/src/server/shared/Threading/DelayExecutor.h index 664d8ca78a2..5eaaacdb98b 100644 --- a/src/server/shared/Threading/DelayExecutor.h +++ b/src/server/shared/Threading/DelayExecutor.h @@ -16,7 +16,7 @@ class DelayExecutor : protected ACE_Task_Base int execute(ACE_Method_Request* new_req); - int activate(int num_threads = 1, ACE_Method_Request* pre_svc_hook = NULL, ACE_Method_Request* post_svc_hook = NULL); + int start(int num_threads = 1, ACE_Method_Request* pre_svc_hook = NULL, ACE_Method_Request* post_svc_hook = NULL); int deactivate(); diff --git a/src/server/worldserver/CMakeLists.txt b/src/server/worldserver/CMakeLists.txt index 45442123258..13679cce866 100644 --- a/src/server/worldserver/CMakeLists.txt +++ b/src/server/worldserver/CMakeLists.txt @@ -14,15 +14,9 @@ file(GLOB_RECURSE sources_TCSoap TCSoap/*.cpp TCSoap/*.h) file(GLOB_RECURSE sources_WorldThread WorldThread/*.cpp WorldThread/*.h) file(GLOB sources_localdir *.cpp *.h) -if( USE_COREPCH ) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) -endif() - -if ( USE_COREPCH AND MSVC ) - set(worldserver_SRCS - PrecompiledHeaders/worldPCH.cpp - PrecompiledHeaders/worldPCH.h - ) +if (USE_COREPCH) + set(worldserver_PCH_HDR PrecompiledHeaders/worldPCH.h) + set(worldserver_PCH_SRC PrecompiledHeaders/worldPCH.cpp) endif() set(worldserver_SRCS @@ -144,17 +138,21 @@ include_directories( ${OPENSSL_INCLUDE_DIR} ) -set(worldserver_LINK_FLAGS "") - -add_executable(worldserver ${worldserver_SRCS}) +add_executable(worldserver + ${worldserver_SRCS} + ${worldserver_PCH_SRC} +) if( NOT WIN32 ) - add_definitions(-D_TRINITY_CORE_CONFIG='"${CONF_DIR}/worldserver.conf"') + set_target_properties(worldserver PROPERTIES + COMPILE_DEFINITIONS _TRINITY_CORE_CONFIG="${CONF_DIR}/worldserver.conf" + ) endif() add_dependencies(worldserver revision.h) -if( UNIX ) + +if( UNIX AND NOT NOJEM ) set(worldserver_LINK_FLAGS "-pthread -lncurses ${worldserver_LINK_FLAGS}") endif() @@ -174,9 +172,7 @@ target_link_libraries(worldserver ${ACE_LIBRARY} ${MYSQL_LIBRARY} ${OPENSSL_LIBRARIES} - ${OPENSSL_EXTRA_LIBRARIES} ${ZLIB_LIBRARIES} - ${OSX_LIBS} ) if( WIN32 ) @@ -196,9 +192,5 @@ endif() # Generate precompiled header if( USE_COREPCH ) - if(CMAKE_COMPILER_IS_GNUCXX) - add_precompiled_header(worldserver ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/worldPCH.h) - elseif(MSVC) - add_native_precompiled_header(worldserver ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/worldPCH) - endif() + add_cxx_pch(worldserver ${worldserver_PCH_HDR} ${worldserver_PCH_SRC}) endif() |