diff options
author | Spp <spp@jorge.gr> | 2012-11-19 10:09:58 +0100 |
---|---|---|
committer | Spp <spp@jorge.gr> | 2012-11-19 10:09:58 +0100 |
commit | 7f061fc57fac4b48417d25579e833e9b66364237 (patch) | |
tree | cdbe2ff223967034dd9f236da4ca38cc73c30a7b /src | |
parent | 09ab26ac946bc7b5458d92fbadfb66e442744098 (diff) | |
parent | d42212b595ad01be0a839405d853f7db2b9f88de (diff) |
Merge branch 'master' into 4.3.4
Conflicts:
src/server/game/AI/EventAI/CreatureEventAI.cpp
src/server/game/AI/EventAI/CreatureEventAIMgr.cpp
src/server/game/AI/EventAI/CreatureEventAIMgr.h
src/server/game/Battlegrounds/Battleground.h
src/server/game/Chat/Chat.h
src/server/game/Entities/Player/Player.cpp
src/server/game/Globals/ObjectMgr.cpp
src/server/game/Globals/ObjectMgr.h
src/server/game/Guilds/Guild.cpp
src/server/game/Handlers/CharacterHandler.cpp
src/server/game/Handlers/MailHandler.cpp
src/server/game/Miscellaneous/SharedDefines.h
src/server/game/Server/Protocol/Opcodes.cpp
src/server/game/Spells/SpellInfo.cpp
src/server/game/World/World.cpp
src/server/scripts/Commands/cs_modify.cpp
src/server/scripts/Commands/cs_reload.cpp
src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
src/server/shared/Database/Implementation/CharacterDatabase.cpp
Diffstat (limited to 'src')
339 files changed, 7194 insertions, 5978 deletions
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/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index f30c4516830..2fdb3cd39c6 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/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/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index a1fb2147cc2..b8c0f952df9 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -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); @@ -752,6 +759,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u 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 +890,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/Battlefield/BattlefieldHandler.cpp b/src/server/game/Battlefield/BattlefieldHandler.cpp index 66285fe1b04..79b5f3a7998 100644 --- a/src/server/game/Battlefield/BattlefieldHandler.cpp +++ b/src/server/game/Battlefield/BattlefieldHandler.cpp @@ -26,6 +26,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:(guid) the guid of Bf diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 4468660006e..98833589d00 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -24,6 +24,7 @@ #include "BattlefieldWG.h" #include "SpellAuras.h" #include "Vehicle.h" +#include "Player.h" enum WGVehicles { diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h index 68072a68249..0a81a7af992 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.h +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h @@ -21,11 +21,9 @@ #include "ObjectAccessor.h" #include "WorldPacket.h" -#include "World.h" -#include "Group.h" -#include "GroupMgr.h" #include "Battlefield.h" +class Group; class BattlefieldWG; class WintergraspCapturePoint; diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index a8526985468..e7644805a76 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -22,6 +22,7 @@ #include "World.h" #include "Group.h" #include "ArenaTeamMgr.h" +#include "Player.h" ArenaTeam::ArenaTeam() : TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0), @@ -510,6 +511,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 1c07e377d96..5d8345aec53 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -163,6 +163,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 9365172a4ca..8b2a056f4bb 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 92a6d39a3ca..eb7ce9a64a4 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -407,6 +407,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) { // ********************************************************* @@ -421,13 +432,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()) diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index ea22e2a4dd0..3feeea53ad8 100755 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -168,25 +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_TP = 7, - BATTLEGROUND_QUEUE_BFG = 8, - BATTLEGROUND_QUEUE_RB = 9, - BATTLEGROUND_QUEUE_2v2 = 10, - BATTLEGROUND_QUEUE_3v3 = 11, - BATTLEGROUND_QUEUE_5v5 = 12, - MAX_BATTLEGROUND_QUEUE_TYPES -}; - enum ScoreType { SCORE_KILLING_BLOWS = 1, @@ -255,37 +236,6 @@ enum BattlegroundStartingEventsIds }; #define BG_STARTING_EVENT_COUNT 4 -enum GroupJoinBattlegroundResult -{ - ERR_BATTLEGROUND_NONE = 0, - 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_TIMED_OUT = 12, // same as 11 - //ERR_BATTLEGROUND_TEAM_LEFT_QUEUE = 13, // same as 7 - ERR_LFG_CANT_USE_BATTLEGROUND = 14, // You cannot queue for a battleground or arena while using the dungeon system. - ERR_IN_RANDOM_BG = 15, // Can't do that while in a Random Battleground queue. - ERR_IN_NON_RANDOM_BG = 16, // Can't queue for Random Battleground while in another Battleground queue. - ERR_BG_DEVELOPER_ONLY = 17, - ERR_BATTLEGROUND_INVITATION_DECLINED = 18, - ERR_MEETING_STONE_NOT_FOUND = 19, - ERR_WARGAME_REQUEST_FAILURE = 20, - ERR_BATTLEFIELD_TEAM_PARTY_SIZE = 22, - ERR_NOT_ON_TOURNAMENT_REALM = 23, - ERR_BATTLEGROUND_PLAYERS_FROM_DIFFERENT_REALMS = 24, - ERR_REMOVE_FROM_PVP_QUEUE_GRANT_LEVEL = 33, - ERR_REMOVE_FROM_PVP_QUEUE_FACTION_CHANGE = 34, - ERR_BATTLEGROUND_JOIN_FAILED = 35, - ERR_BATTLEGROUND_DUPE_QUEUE = 43 -}; - struct BattlegroundScore { BattlegroundScore() : KillingBlows(0), Deaths(0), HonorableKills(0), BonusHonor(0), @@ -580,6 +530,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/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 90e44c32eae..fec17b2873e 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -24,6 +24,7 @@ #include "ArenaTeamMgr.h" #include "Log.h" #include "Group.h" +#include "Player.h" /*********************************************************/ /*** BATTLEGROUND QUEUE SYSTEM ***/ @@ -216,7 +217,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 diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index 5a887c647b1..8f7231ba66e 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -548,6 +548,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..95aa0308c7d 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -1695,3 +1695,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(); +}
\ No newline at end of file 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/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.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/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 9f59344843c..663e5aed1e4 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(); +} 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/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..1955eaa63aa 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -15,579 +15,620 @@ * 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" -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 = 1; + _maxInviteId = 1; -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..3ccab6e5c6c 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -23,6 +23,7 @@ #include "World.h" #include "DatabaseEnv.h" #include "AccountMgr.h" +#include "Player.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), @@ -385,7 +386,7 @@ void Channel::Password(uint64 p, const char *pass) if (player) sec = player->GetSession()->GetSecurity(); - ChatHandler chat(player); + ChatHandler chat(player->GetSession()); if (!IsOn(p)) { diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index bd82a7cfc90..5f6be0e36de 100755 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -26,9 +26,10 @@ #include "Common.h" #include "Opcodes.h" -#include "Player.h" #include "WorldPacket.h" +class Player; + enum ChatNotify { CHAT_JOINED_NOTICE = 0x00, //+ "%s joined channel."; diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 78b71744e0e..66111e5a6db 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() diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 4571f261587..8e2bc1fcc7a 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -1182,6 +1182,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 0597ab216ec..167e6ca79d5 100644 --- 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, const char* addonPrefix = NULL); @@ -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 const* 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 7d5078a751e..8c2a3a22a70 100644 --- a/src/server/game/Chat/ChatLink.cpp +++ b/src/server/game/Chat/ChatLink.cpp @@ -19,6 +19,8 @@ #include "SpellMgr.h" #include "ObjectMgr.h" #include "SpellInfo.h" +#include "DBCStores.h" +#include "AchievementMgr.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 diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index a640fae92d4..6c499645e39 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/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 0c77402bf49..f01953a5441 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -26,6 +26,7 @@ #include "SpellInfo.h" #include "ScriptMgr.h" #include "ConditionMgr.h" +#include "Player.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 5b427c48a4b..12bd99a3637 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 e3ea4f77344..6da9bde6d16 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1996,7 +1996,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)) diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 6e00fcbfe83..e7ecadae2f1 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -78,26 +78,6 @@ enum PetTalk 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; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5e2fdae9c2c..d92e848e5d4 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7220,7 +7220,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."); } } @@ -20144,17 +20144,17 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) GetSession()->SendPacket(&data); } else // 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()); 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()) @@ -25726,7 +25726,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; } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 18cc95444c0..b5c397057f4 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -21,29 +21,24 @@ #include <bitset> #include "AchievementMgr.h" -#include "Battleground.h" -#include "Bag.h" #include "Common.h" #include "DatabaseEnv.h" #include "DBCEnums.h" #include "GroupReference.h" -#include "ItemPrototype.h" #include "Item.h" #include "MapReference.h" -#include "NPCHandler.h" #include "Pet.h" #include "QuestDef.h" #include "ReputationMgr.h" #include "Unit.h" -#include "Util.h" // for Tokens typedef #include "WorldSession.h" #include "PhaseMgr.h" // for template #include "SpellMgr.h" -#include<string> -#include<vector> +#include <string> +#include <vector> struct Mail; struct ItemExtendedCostEntry; @@ -377,9 +372,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; @@ -841,13 +834,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, @@ -953,17 +939,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; diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 117b93e8d90..1e849022d01 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/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 7b9a99405e5..5e46d2c9ba7 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..6999eb301f5 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -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 96e0c246f1c..37117c9edf4 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -231,11 +231,27 @@ bool SpellClickInfo::IsFitToRequirements(Unit const* clicker, Unit const* clicke return true; } -ObjectMgr::ObjectMgr(): _auctionId(1), _equipmentSetGuid(1), - _itemTextId(1), _mailId(1), _hiPetNumber(1), _voidItemId(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), + _voidItemId(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) + for (uint8 j = 0; j < MAX_RACES; ++j) + _playerInfo[j][i] = NULL; +} ObjectMgr::~ObjectMgr() { @@ -247,7 +263,10 @@ ObjectMgr::~ObjectMgr() for (int race = 0; race < MAX_RACES; ++race) for (int class_ = 0; class_ < MAX_CLASSES; ++class_) - delete[] _playerInfo[race][class_].levelInfo; + { + delete[] _playerInfo[race][class_]->levelInfo; + delete _playerInfo[race][class_]; + } for (CacheVendorItemContainer::iterator itr = _cacheVendorItemStore.begin(); itr != _cacheVendorItemStore.end(); ++itr) itr->second.Clear(); @@ -257,6 +276,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) @@ -2807,8 +2829,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) @@ -2915,17 +2940,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; } @@ -3048,10 +3072,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; } @@ -3096,8 +3126,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; } @@ -3155,16 +3185,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; @@ -3184,10 +3212,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 @@ -3199,7 +3225,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); @@ -3208,10 +3234,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]; } } } @@ -3305,8 +3331,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)) @@ -3318,7 +3344,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) @@ -5848,7 +5874,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"); @@ -5870,61 +5902,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 (!sAchievementMgr->GetAchievement(ar.achievement)) + if (!sAchievementMgr->GetAchievement(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; } } @@ -8074,9 +8106,9 @@ void ObjectMgr::LoadGossipMenuItems() _gossipMenuItemsStore.clear(); QueryResult result = WorldDatabase.Query( - // 0 1 2 3 4 + // 0 1 2 3 4 5 "SELECT menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, " - // 5 6 7 8 9 + // 6 7 8 9 10 "action_menu_id, action_poi_id, box_coded, box_money, box_text " "FROM gossip_menu_option ORDER BY menu_id, id"); @@ -8179,7 +8211,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount 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; @@ -8190,7 +8222,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount 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); @@ -8204,7 +8236,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount (type == ITEM_VENDOR_TYPE_CURRENCY && !sCurrencyTypesStore.LookupEntry(id))) { if (player) - ChatHandler(player).PSendSysMessage(LANG_ITEM_NOT_FOUND, id, type); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_NOT_FOUND, id, type); else sLog->outError(LOG_FILTER_SQL, "Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u, type %u), ignore", vendor_entry, id, type); return false; @@ -8213,7 +8245,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount 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", id, ExtendedCost, vendor_entry); return false; @@ -8224,7 +8256,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount 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, id, vendor_entry); return false; @@ -8232,7 +8264,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount 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", id, vendor_entry); return false; @@ -8246,7 +8278,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount if (vItems->FindItemCostPair(id, ExtendedCost, type)) { if (player) - ChatHandler(player).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, id, ExtendedCost, type); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, id, ExtendedCost, type); else sLog->outError(LOG_FILTER_SQL, "Table `npc_vendor` has duplicate items %u (with extended cost %u, type %u) for vendor (Entry: %u), ignoring", id, ExtendedCost, type, vendor_entry); return false; @@ -8255,7 +8287,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount if (vItems->GetItemCount() >= MAX_VENDOR_ITEMS) // FIXME: GetItemCount range 0...255 MAX_VENDOR_ITEMS = 300 { 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; @@ -8801,3 +8833,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 e7575bec5d8..ab4306bbc87 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" @@ -46,6 +45,9 @@ class Item; class PhaseMgr; +struct AccessRequirement; +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__) @@ -608,7 +610,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,17 +649,7 @@ class ObjectMgr void GetPlayerClassLevelInfo(uint32 class_, uint8 level, uint32& baseHP, uint32& baseMana) 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; @@ -718,7 +710,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; } @@ -1249,7 +1241,7 @@ class ObjectMgr 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/Groups/Group.h b/src/server/game/Groups/Group.h index 626cba7bb2f..357f5db7136 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 1a73974b906..3d06b266afb 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -27,6 +27,7 @@ #include "Log.h" #include "AccountMgr.h" #include "AchievementMgr.h" +#include "CalendarMgr.h" #define MAX_GUILD_BANK_TAB_TEXT_LEN 500 #define EMBLEM_PRICE 10 * GOLD @@ -1833,6 +1834,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, uint64 guid) @@ -2541,6 +2544,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) { diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index 36d8d56b30c..fc90a492399 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -826,6 +826,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/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 0cecd3d615a..3301b821f2b 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(sCalendarMgr->GetFreeInviteId(), 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(inviteeGuid, 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 7db49e50fa2..6e2314c2e16 100755 --- a/src/server/game/Handlers/ChannelHandler.cpp +++ b/src/server/game/Handlers/ChannelHandler.cpp @@ -18,6 +18,7 @@ #include "ObjectMgr.h" // for normalizePlayerName #include "ChannelMgr.h" +#include "Player.h" void WorldSession::HandleJoinChannel(WorldPacket& recvPacket) { diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index a285b38f46f..5017a2a7c9d 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -45,6 +45,7 @@ #include "AccountMgr.h" #include "DBCStores.h" #include "LFGMgr.h" +#include "CalendarMgr.h" class LoginQueryHolder : public SQLQueryHolder { @@ -753,6 +754,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recvData) } sGuildFinderMgr->RemoveAllMembershipRequestsFromPlayer(guid); + sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid); Player::DeleteFromDB(guid, GetAccountId()); WorldPacket data(SMSG_CHAR_DELETE, 1); @@ -827,7 +829,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/CombatHandler.cpp b/src/server/game/Handlers/CombatHandler.cpp index 1cd86afc6d2..391a6fc0831 100755 --- a/src/server/game/Handlers/CombatHandler.cpp +++ b/src/server/game/Handlers/CombatHandler.cpp @@ -25,6 +25,7 @@ #include "ObjectDefines.h" #include "Vehicle.h" #include "VehicleDefines.h" +#include "Player.h" void WorldSession::HandleAttackSwingOpcode(WorldPacket& recvData) { diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index 5df7b20b596..428eee37db0 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -645,10 +645,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 bf260743d6a..2d34727bfbe 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -887,7 +887,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; diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 2d3af13597a..785f39c4a8e 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -31,6 +31,7 @@ #include "World.h" #include "Group.h" #include "SpellInfo.h" +#include "Player.h" void WorldSession::HandleDismissCritter(WorldPacket& recvData) { diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index 33824fa0b49..d221a8ac80d 100755 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -33,6 +33,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/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 904f571c9d3..68f6626b3b1 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 a514315f748..74394ced53a 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 f3c1a335f5e..cf773ba7ead 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -33,6 +33,7 @@ #include "LFGMgr.h" #include "DynamicTree.h" #include "Vehicle.h" +#include "Battleground.h" union u_map_magic { @@ -144,7 +145,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]; @@ -307,32 +308,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 53588c527e3..e3fa1ac6ae4 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -500,6 +500,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 5fcca05361b..9ca8155e83b 100755 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -24,6 +24,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) { @@ -280,4 +281,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 71f45a8b04e..0ead173ed95 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -33,6 +33,7 @@ #include "Language.h" #include "WorldPacket.h" #include "Group.h" +#include "Player.h" extern GridState* si_GridStates[]; // debugging code, should be deleted some day @@ -439,4 +440,4 @@ void MapManager::FreeInstanceId(uint32 instanceId) SetNextInstanceId(instanceId); _instanceIds[instanceId] = false; -}
\ No newline at end of file +} diff --git a/src/server/game/Maps/PhaseMgr.cpp b/src/server/game/Maps/PhaseMgr.cpp index 194c89fc5c8..38c9b3fc6e9 100644 --- a/src/server/game/Maps/PhaseMgr.cpp +++ b/src/server/game/Maps/PhaseMgr.cpp @@ -18,6 +18,7 @@ #include "PhaseMgr.h" #include "Chat.h" #include "ObjectMgr.h" +#include "Player.h" ////////////////////////////////////////////////////////////////// // Updating @@ -174,31 +175,31 @@ void PhaseMgr::UnRegisterPhasingAuraEffect(AuraEffect const* auraEffect) void PhaseMgr::SendDebugReportToPlayer(Player* const debugger) { - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_REPORT_STATUS, player->GetName().c_str(), player->GetZoneId(), player->getLevel(), player->GetTeamId(), _UpdateFlags); + ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_REPORT_STATUS, player->GetName().c_str(), player->GetZoneId(), player->getLevel(), player->GetTeamId(), _UpdateFlags); PhaseDefinitionStore::const_iterator itr = _PhaseDefinitionStore->find(player->GetZoneId()); if (itr == _PhaseDefinitionStore->end()) - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_NO_DEFINITIONS, player->GetZoneId()); + ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_NO_DEFINITIONS, player->GetZoneId()); else { for (PhaseDefinitionContainer::const_iterator phase = itr->second.begin(); phase != itr->second.end(); ++phase) { if (CheckDefinition(&(*phase))) - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_SUCCESS, phase->entry, phase->IsNegatingPhasemask() ? "negated Phase" : "Phase", phase->phasemask); + ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_SUCCESS, phase->entry, phase->IsNegatingPhasemask() ? "negated Phase" : "Phase", phase->phasemask); else - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_FAILED, phase->phasemask, phase->entry, phase->zoneId); + ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_FAILED, phase->phasemask, phase->entry, phase->zoneId); if (phase->IsLastDefinition()) { - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_LAST_PHASE, phase->phasemask, phase->entry, phase->zoneId); + ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_LAST_PHASE, phase->phasemask, phase->entry, phase->zoneId); break; } } } - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_LIST, phaseData._PhasemaskThroughDefinitions, phaseData._PhasemaskThroughAuras, phaseData._CustomPhasemask); + ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_LIST, phaseData._PhasemaskThroughDefinitions, phaseData._PhasemaskThroughAuras, phaseData._CustomPhasemask); - ChatHandler(debugger).PSendSysMessage(LANG_PHASING_PHASEMASK, phaseData.GetPhaseMaskForSpawn(), player->GetPhaseMask()); + ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_PHASEMASK, phaseData.GetPhaseMaskForSpawn(), player->GetPhaseMask()); } void PhaseMgr::SetCustomPhase(uint32 const phaseMask) diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index 3cf4b1f96b7..6e6668ba4d6 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/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index b5b7bb4a6cf..057895898e5 100755 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -3731,106 +3731,82 @@ enum ProfessionUI MAX_SECONDARY_SKILLS = 5 }; -// 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_TP = 7, + BATTLEGROUND_QUEUE_BFG = 8, + BATTLEGROUND_QUEUE_RB = 9, + BATTLEGROUND_QUEUE_2v2 = 10, + BATTLEGROUND_QUEUE_3v3 = 11, + BATTLEGROUND_QUEUE_5v5 = 12, + 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 +}; #define VOID_STORAGE_UNLOCK 100*GOLD #define VOID_STORAGE_STORE_ITEM 25*GOLD diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index 313a29a1b59..b070e21ed5b 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -23,6 +23,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/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 93dae4c63f2..570a508f7d2 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -30,6 +30,7 @@ #include "SpellScript.h" #include "GossipDef.h" #include "CreatureAI.h" +#include "Player.h" // This is the global static registry of scripts. template<class TScript> diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index b245039dc92..22625d74e10 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" diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 116f953b2a3..93efc8d2132 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -493,7 +493,7 @@ void OpcodeTable::Initialize() DEFINE_OPCODE_HANDLER(CMSG_SET_PREFERED_CEMETERY, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_OPCODE_HANDLER(CMSG_SET_PRIMARY_TALENT_TREE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_OPCODE_HANDLER(CMSG_SET_RELATIVE_POSITION, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); - DEFINE_OPCODE_HANDLER(CMSG_SET_SAVED_INSTANCE_EXTEND, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); + DEFINE_OPCODE_HANDLER(CMSG_SET_SAVED_INSTANCE_EXTEND, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetSavedInstanceExtend ); DEFINE_OPCODE_HANDLER(CMSG_SET_SELECTION, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleSetSelectionOpcode ); DEFINE_OPCODE_HANDLER(CMSG_SET_TAXI_BENCHMARK_MODE, STATUS_AUTHED, PROCESS_THREADUNSAFE, &WorldSession::HandleSetTaxiBenchmarkOpcode ); DEFINE_OPCODE_HANDLER(CMSG_SET_TITLE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetTitleOpcode ); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 885c7017d62..0c4220e9ea6 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -32,8 +32,6 @@ #include "Cryptography/BigNumber.h" #include "Opcodes.h" -class CalendarEvent; -class CalendarInvite; class Creature; class GameObject; class InstanceSave; @@ -933,19 +931,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 Storage void HandleVoidStorageUnlock(WorldPacket& recvData); diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index df3c2d77c02..73f19ba3f3c 100644 --- 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" diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index d66d60fece9..4c22328cd26 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5476,7 +5476,7 @@ 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; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 9faf9a1f850..65eea69714a 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -21,7 +21,8 @@ #include "Spell.h" #include "DBCStores.h" #include "ConditionMgr.h" -#include "Object.h" +#include "Player.h" +#include "Battleground.h" uint32 GetTargetFlagMask(SpellTargetObjectTypes objType) { diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 636ef607e2b..9abb82bbc4b 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -21,6 +21,7 @@ #include "SharedDefines.h" #include "Util.h" #include "DBCStructure.h" +#include "SpellAuraDefines.h" class Unit; class Player; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 600b9dc65a3..38e2155ba4a 100644 --- 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/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index ffcb65bb14b..89dd28f6a30 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -24,6 +24,7 @@ #include "WorldSession.h" #include "Chat.h" #include "World.h" +#include "Player.h" inline float GetAge(uint64 t) { return float(time(NULL) - t) / DAY; } diff --git a/src/server/game/Weather/WeatherMgr.cpp b/src/server/game/Weather/WeatherMgr.cpp index fce078a0a14..6148005ca6b 100755 --- a/src/server/game/Weather/WeatherMgr.cpp +++ b/src/server/game/Weather/WeatherMgr.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include "ObjectMgr.h" #include "AutoPtr.h" +#include "Player.h" namespace WeatherMgr { diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 15a724e69d1..6b6e94f75fb 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "AccountMgr.h" #include "Chat.h" +#include "Player.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 a5dacc7bb00..01246630f62 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" +#include "Player.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..af04a3b7989 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "AccountMgr.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "Player.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..5a45f980c2c 100644 --- a/src/server/scripts/Commands/cs_cast.cpp +++ b/src/server/scripts/Commands/cs_cast.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.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 d0bd7503216..16f0537d5c6 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "AccountMgr.h" #include "ObjectMgr.h" #include "PlayerDump.h" +#include "Player.h" class character_commandscript : public CommandScript { @@ -238,11 +239,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 57293ef5e84..12a3b1bfb7d 100644 --- a/src/server/scripts/Commands/cs_cheat.cpp +++ b/src/server/scripts/Commands/cs_cheat.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ObjectMgr.h" #include "Chat.h" +#include "Player.h" class cheat_commandscript : public CommandScript { @@ -233,7 +234,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 +243,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 +272,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_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 00214ed4b0f..061914d24ff 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -27,6 +27,8 @@ EndScriptData */ #include "Chat.h" #include "DisableMgr.h" #include "OutdoorPvP.h" +#include "SpellMgr.h" +#include "Player.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..8d053a2f061 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "GameEventMgr.h" #include "Chat.h" +#include "Player.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 087a72764dc..d355edc9514 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "Chat.h" #include "AccountMgr.h" #include "World.h" +#include "Player.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 b0f1eed5d5c..34e28d4bec3 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "MapManager.h" #include "TicketMgr.h" #include "Chat.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 fd24e618ef0..c957db3f22a 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "PoolMgr.h" #include "MapManager.h" #include "Chat.h" +#include "Player.h" class gobject_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index 4edc5f6fea0..76f5badb707 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ObjectMgr.h" #include "Chat.h" +#include "Player.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 dcfa6b6b04c..459bc492f1b 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ObjectMgr.h" #include "SpellMgr.h" #include "SpellInfo.h" +#include "Player.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..6739694f228 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -19,6 +19,7 @@ #include "Chat.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 5a0fd28e81a..641c28c3dd3 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "SpellAuraEffects.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 e1bf34fb6cf..92246184fe1 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "GameEventMgr.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "Player.h" class lookup_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index de2fcf26943..d7c2f6117ac 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "ChannelMgr.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 cfa5f6d6f3d..0db7c9994cf 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -29,6 +29,7 @@ #include "TargetedMovementGenerator.h" #include "WeatherMgr.h" #include "ace/INET_Addr.h" +#include "Player.h" class misc_commandscript : public CommandScript { @@ -495,7 +496,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 +607,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()) @@ -1809,7 +1810,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 { @@ -1865,7 +1866,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); @@ -2142,7 +2143,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 5c9280e5956..9799062d80c 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ObjectMgr.h" #include "Chat.h" #include <stdlib.h> +#include "Player.h" class modify_commandscript : public CommandScript { @@ -107,7 +108,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); @@ -145,7 +146,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); @@ -194,7 +195,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); @@ -245,7 +246,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); @@ -279,7 +280,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); @@ -409,7 +410,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); @@ -505,7 +506,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); @@ -553,7 +554,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); @@ -598,7 +599,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); @@ -643,7 +644,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); @@ -679,7 +680,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); @@ -716,7 +717,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); @@ -964,7 +965,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); @@ -1020,7 +1021,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); } @@ -1032,7 +1033,7 @@ public: handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, moneyToAddMsg, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), moneyToAddMsg); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), moneyToAddMsg); target->SetMoney(newmoney); } } @@ -1040,7 +1041,7 @@ public: { handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, uint32(moneyToAdd), handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), uint32(moneyToAdd)); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), uint32(moneyToAdd)); if (moneyToAdd >= MAX_MONEY_AMOUNT) target->SetMoney(MAX_MONEY_AMOUNT); @@ -1381,7 +1382,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 d4d4adad6a0..f4eab77c5b6 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -29,6 +29,7 @@ EndScriptData */ #include "CreatureGroups.h" #include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand #include "CreatureAI.h" +#include "Player.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..5776022e59f 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ObjectMgr.h" #include "Chat.h" +#include "Player.h" class quest_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index b147543bb1a..265f5f5f5ce 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "ObjectAccessor.h" +#include "Player.h" class reset_commandscript : public CommandScript { @@ -165,7 +166,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()); } @@ -217,7 +218,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()); } @@ -233,7 +234,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..131d7a4149a 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "SystemConfig.h" #include "Config.h" #include "ObjectAccessor.h" +#include "Player.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..553559afd1c 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "MapManager.h" #include "Chat.h" #include "Group.h" +#include "Player.h" class tele_commandscript : public CommandScript { @@ -178,7 +179,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 +275,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..72804ed5727 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "AccountMgr.h" #include "ObjectMgr.h" #include "TicketMgr.h" +#include "Player.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 046841128e8..6ab1b952f50 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ObjectMgr.h" #include "Chat.h" +#include "Player.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 259845d82ae..86b1a300afd 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ObjectMgr.h" #include "WaypointManager.h" #include "Chat.h" +#include "Player.h" class wp_commandscript : public CommandScript { diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp index 263897edfad..5c65531c615 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp @@ -20,6 +20,7 @@ #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "blackrock_depths.h" +#include "Player.h" //go_shadowforge_brazier class go_shadowforge_brazier : public GameObjectScript 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/BlackwingLair/boss_vaelastrasz.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp index 8cc42baff8e..359f218cd5c 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" enum Says { diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp index 30638e9edeb..a93519bcbe7 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_victor_nefarius.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" enum Says { diff --git a/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp b/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp index 888171c5415..ae9071f3fd0 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/deadmines.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "deadmines.h" #include "Spell.h" +#include "Player.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 c2dab8d6c9e..7d7329ae255 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "deadmines.h" +#include "TemporarySummon.h" enum Sounds { 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..2e520351150 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 diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index c6587c3cd8a..c3e571ad376 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "karazhan.h" +#include "Player.h" #define EMOTE_PHASE_PORTAL -1532089 #define EMOTE_PHASE_BANISH -1532090 diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index a4f4f603206..2c1d4ac0e71 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "karazhan.h" +#include "Player.h" /***********************************/ /*** OPERA WIZARD OF OZ EVENT *****/ diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index 3bdfeab30da..d2b83c6ac54 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 diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index 7fbd329ab87..047809286f7 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -140,12 +140,7 @@ 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*/) @@ -155,12 +150,11 @@ public: 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,9 +167,8 @@ 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) @@ -367,14 +360,10 @@ public: 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 + DoScriptText(SAY_RECAST_GRAVITY, me); DoCast(me, SPELL_GRAVITY_LAPSE_INITIAL); GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp index 430bbb79bde..74d1b5b9f1b 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp @@ -115,10 +115,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); @@ -196,10 +192,8 @@ public: void EnterCombat(Unit* /*who*/) { DoScriptText(SAY_AGGRO, me); - 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*/) @@ -237,8 +231,6 @@ public: 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(); } diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index da8b24c3985..da15f9020da 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -84,6 +84,7 @@ public: uint64 KaelDoorGUID; uint64 KaelStatue[2]; uint64 EscapeOrbGUID; + uint32 StatuesState; bool InitializedItr; @@ -105,6 +106,7 @@ public: KaelStatue[0] = 0; KaelStatue[1] = 0; EscapeOrbGUID = 0; + StatuesState = 0; InitializedItr = false; } @@ -142,21 +144,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 +181,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,6 +238,44 @@ public: } } + 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) { switch (identifier) @@ -225,10 +286,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,7 +296,6 @@ public: return KaelStatue[1]; case DATA_ESCAPE_ORB: return EscapeOrbGUID; - case DATA_FEL_CRYSTAL: { if (FelCrystals.empty()) diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp index 64b6c8d75b2..37b2dd18afe 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.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_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/instance_molten_core.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/instance_molten_core.cpp index f6a6e647a1d..33719f8f1f6 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] = { diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index c17a059d007..a65edcd63bc 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -23,6 +23,7 @@ #include "ScriptedEscortAI.h" #include "CombatAI.h" #include "PassiveAI.h" +#include "Player.h" /*###### ##Quest 12848 diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp index b4c6268a43e..51581b53e5f 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" //How to win friends and influence enemies // texts signed for creature 28939 but used for 28939, 28940, 28610 diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 4d1552b932e..686f5954e77 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 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_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 34c1c9b2c83..40c8d4ee649 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "SpellMgr.h" #include "scarlet_monastery.h" #include "LFGMgr.h" +#include "Player.h" //this texts are already used by 3975 and 3976 enum Says diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp index b405f9eba85..f219875b057 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "shadowfang_keep.h" +#include "TemporarySummon.h" #define MAX_ENCOUNTER 4 diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp index 9ee3428c7dd..5fc41b3b267 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 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..17eedb87896 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 diff --git a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp index 9b4591bc633..188739a934d 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "stratholme.h" #include "Group.h" +#include "Player.h" /*###### ## go_gauntlet_gate (this is the _first_ of the gauntlet gates, two exist) 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_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 3e503a547d8..53696fbed7a 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "sunwell_plateau.h" +#include "Player.h" enum Yells { diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index 8dabe2b842d..febbc8bc18e 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "sunwell_plateau.h" #include <math.h> +#include "Player.h" /*** Speech and sounds***/ enum Yells diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index 9fd0a5eb5d8..6ce1bf7a414 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -24,6 +24,7 @@ SDComment: all sounds, black hole effect triggers to often (46228) #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "sunwell_plateau.h" +#include "Player.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..bf31557d8a8 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 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/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/instance_zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp index 235bec7cc8a..b113c7c68b9 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/instance_zulaman.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "zulaman.h" +#include "Player.h" #define MAX_ENCOUNTER 6 #define RAND_VENDOR 2 diff --git a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp index f0bea065eb6..2c9b838a2ed 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "zulaman.h" +#include "Player.h" /*###### ## npc_forest_frog diff --git a/src/server/scripts/EasternKingdoms/arathi_highlands.cpp b/src/server/scripts/EasternKingdoms/arathi_highlands.cpp index 1847de91d14..604a88fc70a 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 2ef43ee67ed..740d01fd9e6 100644 --- a/src/server/scripts/EasternKingdoms/burning_steppes.cpp +++ b/src/server/scripts/EasternKingdoms/burning_steppes.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" void AddSC_burning_steppes() 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..c5dcbaba01d 100644 --- a/src/server/scripts/EasternKingdoms/eastern_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/eastern_plaguelands.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.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 93141f2d82c..17e5a418c6e 100644 --- a/src/server/scripts/EasternKingdoms/ghostlands.cpp +++ b/src/server/scripts/EasternKingdoms/ghostlands.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_rathis_tomber diff --git a/src/server/scripts/EasternKingdoms/hinterlands.cpp b/src/server/scripts/EasternKingdoms/hinterlands.cpp index 096c0f2e2a6..0398779655f 100644 --- a/src/server/scripts/EasternKingdoms/hinterlands.cpp +++ b/src/server/scripts/EasternKingdoms/hinterlands.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_00x09hl diff --git a/src/server/scripts/EasternKingdoms/ironforge.cpp b/src/server/scripts/EasternKingdoms/ironforge.cpp index 9cb9ef63693..26006d3bed9 100644 --- a/src/server/scripts/EasternKingdoms/ironforge.cpp +++ b/src/server/scripts/EasternKingdoms/ironforge.cpp @@ -29,6 +29,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" void AddSC_ironforge() { diff --git a/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp b/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp index e448ccda14c..ca5385caffe 100644 --- a/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp +++ b/src/server/scripts/EasternKingdoms/isle_of_queldanas.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" /*###### ## npc_converted_sentry diff --git a/src/server/scripts/EasternKingdoms/loch_modan.cpp b/src/server/scripts/EasternKingdoms/loch_modan.cpp index c5571560b54..b74ac1b5de9 100644 --- a/src/server/scripts/EasternKingdoms/loch_modan.cpp +++ b/src/server/scripts/EasternKingdoms/loch_modan.cpp @@ -29,6 +29,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" void AddSC_loch_modan() { diff --git a/src/server/scripts/EasternKingdoms/redridge_mountains.cpp b/src/server/scripts/EasternKingdoms/redridge_mountains.cpp index 3d47a8e8ed6..1b694f10958 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" void AddSC_redridge_mountains() { diff --git a/src/server/scripts/EasternKingdoms/silvermoon_city.cpp b/src/server/scripts/EasternKingdoms/silvermoon_city.cpp index 954f21f73f5..e56a1e72294 100644 --- a/src/server/scripts/EasternKingdoms/silvermoon_city.cpp +++ b/src/server/scripts/EasternKingdoms/silvermoon_city.cpp @@ -29,6 +29,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" /*####### # npc_blood_knight_stillblade diff --git a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp index 8f5925405ec..3a6fac58945 100644 --- a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp +++ b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp @@ -30,6 +30,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 f6afed67dff..2f3c00cf67a 100644 --- a/src/server/scripts/EasternKingdoms/stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/stormwind_city.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" void AddSC_stormwind_city() diff --git a/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp b/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp index 40f046a5075..26e0dffb5af 100644 --- a/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp +++ b/src/server/scripts/EasternKingdoms/stranglethorn_vale.cpp @@ -29,6 +29,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" /*###### ## mob_yenniku diff --git a/src/server/scripts/EasternKingdoms/swamp_of_sorrows.cpp b/src/server/scripts/EasternKingdoms/swamp_of_sorrows.cpp index 9724588039f..78e4e055ff2 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" void AddSC_swamp_of_sorrows() { diff --git a/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp b/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp index cbefd115739..6a8845ee8b4 100644 --- a/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp +++ b/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp @@ -28,6 +28,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Player.h" void AddSC_tirisfal_glades() diff --git a/src/server/scripts/EasternKingdoms/undercity.cpp b/src/server/scripts/EasternKingdoms/undercity.cpp index 0d44db01592..6aaf2df0b22 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 diff --git a/src/server/scripts/EasternKingdoms/western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/western_plaguelands.cpp index 31dea10453a..285e5bb4e17 100644 --- a/src/server/scripts/EasternKingdoms/western_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/western_plaguelands.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npcs_dithers_and_arbington diff --git a/src/server/scripts/EasternKingdoms/westfall.cpp b/src/server/scripts/EasternKingdoms/westfall.cpp index 478c5f6c0d6..c6cf1b4361c 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 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/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/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..6ab3e42dcb9 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "InstanceScript.h" #include "ScriptedCreature.h" #include "hyjal_trash.h" +#include "Player.h" enum Misc { 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..22ae808e348 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,7 @@ #include "culling_of_stratholme.h" #include "ScriptedEscortAI.h" #include "PassiveAI.h" +#include "Player.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..9a5bc95853c 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,7 @@ #include "InstanceScript.h" #include "CreatureTextMgr.h" #include "culling_of_stratholme.h" +#include "Player.h" #define MAX_ENCOUNTER 5 diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp index bed3cde6fa4..8fa6c239858 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "dark_portal.h" +#include "Player.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..926f48a17a2 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,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "dark_portal.h" +#include "Player.h" #define MAX_ENCOUNTER 2 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..6995ca5add5 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 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/RazorfenDowns/instance_razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp index a0a8bb02d90..a90d465c1ca 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "razorfen_downs.h" +#include "Player.h" #define MAX_ENCOUNTER 1 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..2040ee8b58c 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,259 @@ * 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" + +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 Yells +enum Events { - 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 + EVENT_SILENCE = 1, + EVENT_CYCLONE = 2, + EVENT_STOMP = 3 }; +const uint8 NUM_CRYSTALS = 9; + +// You spin me right round, baby +// right round like a record, baby +// right round round round +Position CrystalCoordinates[NUM_CRYSTALS] = +{ + { -9394.230469, 1951.808594, 85.97733, 0.0 }, + { -9357.931641, 1930.596802, 85.556198, 0.0 }, + { -9383.113281, 2011.042725, 85.556389, 0.0 }, + { -9243.36, 1979.04, 85.556, 0.0 }, + { -9281.68, 1886.66, 85.5558, 0.0 }, + { -9241.8, 1806.39, 85.5557, 0.0 }, + { -9366.78, 1781.76, 85.5561, 0.0 }, + { -9430.37, 1786.86, 85.557, 0.0 }, + { -9406.73, 1863.13, 85.5558, 0.0 } +}; + +float RoomRadius = 165.0f; +const uint8 NUM_TORNADOS = 5; // TODO: This number is completly random! +const uint8 NUM_WEAKNESS = 5; +const uint32 SpellWeakness[NUM_WEAKNESS] = { 25177, 25178, 25180, 25181, 25183 }; +const Position 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(const uint32 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; + } + } + + DoMeleeAttackIfReady(); } }; @@ -58,7 +277,32 @@ 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..1fa2f8bc713 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; @@ -75,17 +75,17 @@ class instance_ruins_of_ahnqiraj : public InstanceMapScript { 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/WailingCaverns/wailing_caverns.cpp b/src/server/scripts/Kalimdor/WailingCaverns/wailing_caverns.cpp index aa7dfb4a864..cc80812a58f 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..4e1508d7cc9 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "zulfarrak.h" +#include "Player.h" #define NPC_GAHZRILLA 7273 #define PATH_ADDS 81553 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 fdc00e04a09..154b497f0ad 100644 --- a/src/server/scripts/Kalimdor/azshara.cpp +++ b/src/server/scripts/Kalimdor/azshara.cpp @@ -29,6 +29,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" void AddSC_azshara() { 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 3330898ebe4..0cd9e2eafc7 100644 --- a/src/server/scripts/Kalimdor/darkshore.cpp +++ b/src/server/scripts/Kalimdor/darkshore.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.h" void AddSC_darkshore() { diff --git a/src/server/scripts/Kalimdor/desolace.cpp b/src/server/scripts/Kalimdor/desolace.cpp index a3da0019a8b..70fed255dfa 100644 --- a/src/server/scripts/Kalimdor/desolace.cpp +++ b/src/server/scripts/Kalimdor/desolace.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" enum DyingKodo { diff --git a/src/server/scripts/Kalimdor/durotar.cpp b/src/server/scripts/Kalimdor/durotar.cpp index 3c66da1917e..126651facc6 100644 --- a/src/server/scripts/Kalimdor/durotar.cpp +++ b/src/server/scripts/Kalimdor/durotar.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" +#include "Player.h" /*###### ## Quest 25134: Lazy Peons diff --git a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp index c2953ba38ef..3baa6908219 100644 --- a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp +++ b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "SpellScript.h" +#include "Player.h" /*###### ## npc_stinky diff --git a/src/server/scripts/Kalimdor/felwood.cpp b/src/server/scripts/Kalimdor/felwood.cpp index 1d504c02149..e0a28ea86a0 100644 --- a/src/server/scripts/Kalimdor/felwood.cpp +++ b/src/server/scripts/Kalimdor/felwood.cpp @@ -29,6 +29,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" void AddSC_felwood() { diff --git a/src/server/scripts/Kalimdor/feralas.cpp b/src/server/scripts/Kalimdor/feralas.cpp index a3b153f5ebb..f2d41e2ae22 100644 --- a/src/server/scripts/Kalimdor/feralas.cpp +++ b/src/server/scripts/Kalimdor/feralas.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" #include "SpellScript.h" +#include "Player.h" void AddSC_feralas() { diff --git a/src/server/scripts/Kalimdor/moonglade.cpp b/src/server/scripts/Kalimdor/moonglade.cpp index 3afed715c09..89c3eb1898c 100644 --- a/src/server/scripts/Kalimdor/moonglade.cpp +++ b/src/server/scripts/Kalimdor/moonglade.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" +#include "Player.h" /*#### # npc_omen diff --git a/src/server/scripts/Kalimdor/mulgore.cpp b/src/server/scripts/Kalimdor/mulgore.cpp index 9aea03de09d..a58ba537fba 100644 --- a/src/server/scripts/Kalimdor/mulgore.cpp +++ b/src/server/scripts/Kalimdor/mulgore.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### # npc_skorn_whitecloud diff --git a/src/server/scripts/Kalimdor/orgrimmar.cpp b/src/server/scripts/Kalimdor/orgrimmar.cpp index 48f0396c5fb..5b8eaeb2c5c 100644 --- a/src/server/scripts/Kalimdor/orgrimmar.cpp +++ b/src/server/scripts/Kalimdor/orgrimmar.cpp @@ -29,6 +29,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" void AddSC_orgrimmar() { diff --git a/src/server/scripts/Kalimdor/silithus.cpp b/src/server/scripts/Kalimdor/silithus.cpp index 570c95a0737..dc06f6f96f3 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 2ac9903aa18..3f0361bb0b4 100644 --- a/src/server/scripts/Kalimdor/stonetalon_mountains.cpp +++ b/src/server/scripts/Kalimdor/stonetalon_mountains.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" void AddSC_stonetalon_mountains() { diff --git a/src/server/scripts/Kalimdor/tanaris.cpp b/src/server/scripts/Kalimdor/tanaris.cpp index 7053f48c851..cbb6339cb9a 100644 --- a/src/server/scripts/Kalimdor/tanaris.cpp +++ b/src/server/scripts/Kalimdor/tanaris.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.h" /*###### ## npc_custodian_of_time 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 5b13fe9591f..04e1f82cf44 100644 --- a/src/server/scripts/Kalimdor/the_barrens.cpp +++ b/src/server/scripts/Kalimdor/the_barrens.cpp @@ -31,6 +31,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*##### ## npc_wizzlecrank_shredder diff --git a/src/server/scripts/Kalimdor/thousand_needles.cpp b/src/server/scripts/Kalimdor/thousand_needles.cpp index 2abef548a94..7db37ff2f5b 100644 --- a/src/server/scripts/Kalimdor/thousand_needles.cpp +++ b/src/server/scripts/Kalimdor/thousand_needles.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" void AddSC_thousand_needles() diff --git a/src/server/scripts/Kalimdor/thunder_bluff.cpp b/src/server/scripts/Kalimdor/thunder_bluff.cpp index 4feca5929b5..dab7b861019 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 d8d6acf3605..6fd19d754d4 100644 --- a/src/server/scripts/Kalimdor/ungoro_crater.cpp +++ b/src/server/scripts/Kalimdor/ungoro_crater.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.h" void AddSC_ungoro_crater() { diff --git a/src/server/scripts/Kalimdor/winterspring.cpp b/src/server/scripts/Kalimdor/winterspring.cpp index 2c4da0fdf7c..483ee472721 100644 --- a/src/server/scripts/Kalimdor/winterspring.cpp +++ b/src/server/scripts/Kalimdor/winterspring.cpp @@ -30,6 +30,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" /*###### ## npc_rivern_frostwind 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..ff05d6c62d7 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,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ahnkahet.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 6b9b388b8d7..9acfb49efa5 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -23,12 +23,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 */ @@ -122,13 +123,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 @@ -152,12 +152,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 @@ -230,9 +228,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() @@ -259,19 +259,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); @@ -318,7 +319,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() @@ -341,7 +341,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)); @@ -407,10 +406,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)) @@ -489,7 +484,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); @@ -553,7 +547,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); @@ -565,10 +559,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); @@ -609,6 +599,8 @@ class npc_halion_controller : public CreatureScript _summons.DespawnAll(); _events.Reset(); _materialCorporealityValue = 5; + _materialDamageTaken = 0; + _twilightDamageTaken = 0; DoCast(me, SPELL_CLEAR_DEBUFFS); } @@ -657,6 +649,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; } @@ -747,36 +767,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; } @@ -807,17 +799,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)) 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..3f710d7fedd 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,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "ruby_sanctum.h" - +#include "Player.h" DoorData const doorData[] = { 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 0e781c6ddc0..b0db72b53c5 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..412951b17d4 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 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..a77f341a49b 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_ELEGIBLE, 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..70fd93df824 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); @@ -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..f8017980766 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_ELEGIBLE, 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 88e0fe5ba66..106abe6fa52 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_ELEGIBLE, 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_ELEGIBLE, 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..4d99429bcb8 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; } } @@ -230,7 +200,7 @@ struct boss_twin_baseAI : public ScriptedAI 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: @@ -525,10 +505,10 @@ class mob_essence_of_twin : public CreatureScript 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..7b0cd31bc67 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,10 @@ * 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" class instance_trial_of_the_crusader : public InstanceMapScript { @@ -36,82 +30,55 @@ 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; - NeedSave = false; + EventNPCId = 0; + + 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; @@ -398,37 +465,8 @@ class instance_trial_of_the_crusader : public InstanceMapScript case DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE: TributeToImmortalityElegible = false; 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(); - } + default: + break; } } @@ -487,18 +525,6 @@ class instance_trial_of_the_crusader : public InstanceMapScript { 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: @@ -612,7 +638,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 +654,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 +683,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; @@ -699,10 +726,52 @@ class instance_trial_of_the_crusader : public InstanceMapScript return TrialCounter == 50 && TributeToImmortalityElegible; case A_TRIBUTE_TO_DEDICATED_INSANITY: return false/*uiGrandCrusaderAttemptsLeft == 50 && !bHasAtAnyStagePlayerEquippedTooGoodItem*/; + default: + break; } return false; } + + protected: + uint32 TrialCounter; + uint32 EventStage; + uint32 EventTimer; + uint32 EventNPCId; + 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 TributeToImmortalityElegible; }; 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..fa38b6b46c1 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, @@ -31,15 +31,19 @@ enum 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_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/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index 4fdcf96192b..9bd0bfc8f6a 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,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "forge_of_souls.h" +#include "Player.h" /* * TODO: 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..135976dde18 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 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..db2f2051f94 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 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..dcca892358d 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}; 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..ae3447b9c68 100644 --- a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp +++ b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "gundrak.h" +#include "Player.h" #define MAX_ENCOUNTER 5 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 9017509781f..6c7caf49f0c 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 { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index 0515ba83480..d635854da8b 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 89a26bde6ff..79d7abfef18 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 { 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..dd0068f6327 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp @@ -23,6 +23,7 @@ #include "PoolMgr.h" #include "AccountMgr.h" #include "icecrown_citadel.h" +#include "Player.h" enum EventIds { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp index 93eab5df237..95839ef134f 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 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_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp index 9822146984f..8af0e63dbe5 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "naxxramas.h" +#include "Player.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..75b851a2b22 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 diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 28f73ed14b0..ab9ed76cb1f 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 { 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..6e85e701a27 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 { 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_ormorok.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp index eb0b3692f01..b17494800f1 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) { - 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..c571def96d7 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 diff --git a/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp index a0b5aded315..0543a317ffa 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 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_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp index 707ea7f138d..f94ae37cdc2 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "halls_of_lightning.h" +#include "Player.h" enum eEnums { 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..3f5f2deb631 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 { 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 89d2f752721..afd31331b7d 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 { 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..845e694e842 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 { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index b414a3fcdcb..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 diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp index 6038b7ed9d6..2830e3ada04 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 { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp index 79e4684f3a6..e8180057cec 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp @@ -29,6 +29,7 @@ #include "SpellAuraEffects.h" #include "ulduar.h" #include "Vehicle.h" +#include "Player.h" enum Spells { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 2f37fb06f24..cc8ff9996f3 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "InstanceScript.h" #include "ulduar.h" +#include "Player.h" static DoorData const doorData[] = { 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/instance_utgarde_keep.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/instance_utgarde_keep.cpp index 1e79cc1c5bf..919b0da5fc0 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 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..1635aaac918 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_skadi.cpp @@ -28,6 +28,7 @@ Script Data End */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "utgarde_pinnacle.h" +#include "Player.h" //Yell enum eYells 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/instance_violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp index 4b6fed181e4..ed039728bb4 100644 --- a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp +++ b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "InstanceScript.h" #include "violet_hold.h" +#include "Player.h" #define MAX_ENCOUNTER 3 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..2a83a03caff 100644 --- a/src/server/scripts/Northrend/borean_tundra.cpp +++ b/src/server/scripts/Northrend/borean_tundra.cpp @@ -42,6 +42,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "ScriptedFollowerAI.h" +#include "Player.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..371ac897e4e 100644 --- a/src/server/scripts/Northrend/dalaran.cpp +++ b/src/server/scripts/Northrend/dalaran.cpp @@ -26,6 +26,7 @@ Script Data End */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.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..400fe58d4c4 100644 --- a/src/server/scripts/Northrend/grizzly_hills.cpp +++ b/src/server/scripts/Northrend/grizzly_hills.cpp @@ -19,6 +19,7 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" +#include "Player.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..7cd87be8370 100644 --- a/src/server/scripts/Northrend/storm_peaks.cpp +++ b/src/server/scripts/Northrend/storm_peaks.cpp @@ -23,6 +23,7 @@ #include "SpellAuraEffects.h" #include "Vehicle.h" #include "CombatAI.h" +#include "Player.h" /*###### ## npc_agnetta_tyrsdottar diff --git a/src/server/scripts/Northrend/wintergrasp.cpp b/src/server/scripts/Northrend/wintergrasp.cpp index b7901f1a44a..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." diff --git a/src/server/scripts/Northrend/zuldrak.cpp b/src/server/scripts/Northrend/zuldrak.cpp index 6af96f3fdfd..7acdcae8a77 100644 --- a/src/server/scripts/Northrend/zuldrak.cpp +++ b/src/server/scripts/Northrend/zuldrak.cpp @@ -19,6 +19,7 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*#### ## npc_drakuru_shackles 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/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..18145df7302 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "ScriptedGossip.h" #include "PassiveAI.h" #include "black_temple.h" +#include "Player.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..10f787bee88 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "black_temple.h" +#include "Player.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..a1e45fa4d15 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 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..ffb4ed3aa12 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,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "serpent_shrine.h" #include "Spell.h" +#include "Player.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..0c6917b320f 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 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..e1cd3e69887 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,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "serpent_shrine.h" +#include "Player.h" #define MAX_ENCOUNTER 6 #define SPELL_SCALDINGWATER 37284 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/MagtheridonsLair/boss_magtheridon.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp index bbf03e39f9b..ebe30166902 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "magtheridons_lair.h" +#include "Player.h" struct Yell { 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/hellfire_peninsula.cpp b/src/server/scripts/Outland/hellfire_peninsula.cpp index 4c44d4e828e..4c0ed3c1d4e 100644 --- a/src/server/scripts/Outland/hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/hellfire_peninsula.cpp @@ -37,6 +37,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.h" /*###### ## npc_aeranas diff --git a/src/server/scripts/Outland/nagrand.cpp b/src/server/scripts/Outland/nagrand.cpp index 977ec57e2df..13adf9182a3 100644 --- a/src/server/scripts/Outland/nagrand.cpp +++ b/src/server/scripts/Outland/nagrand.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.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..5ec017d88b0 100644 --- a/src/server/scripts/Outland/shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/shadowmoon_valley.cpp @@ -46,6 +46,7 @@ EndContentData */ #include "ScriptedEscortAI.h" #include "Group.h" #include "SpellScript.h" +#include "Player.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..e9264233621 100644 --- a/src/server/scripts/Outland/shattrath_city.cpp +++ b/src/server/scripts/Outland/shattrath_city.cpp @@ -38,6 +38,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.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..0963ac63556 100644 --- a/src/server/scripts/Outland/terokkar_forest.cpp +++ b/src/server/scripts/Outland/terokkar_forest.cpp @@ -38,6 +38,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "Group.h" +#include "Player.h" /*###### ## mob_unkor_the_ruthless diff --git a/src/server/scripts/Outland/zangarmarsh.cpp b/src/server/scripts/Outland/zangarmarsh.cpp index a48866a2f83..0d38a49e11d 100644 --- a/src/server/scripts/Outland/zangarmarsh.cpp +++ b/src/server/scripts/Outland/zangarmarsh.cpp @@ -36,6 +36,7 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "Player.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 f8adb13d058..84639322819 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 3bca0d088a4..3183cf7ff5a 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -33,6 +33,7 @@ #include "InstanceScript.h" #include "Group.h" #include "LFGMgr.h" +#include "Battleground.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..0f8fa9614a7 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 "Player.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 35f0e98eef2..1d94cb6caf8 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, @@ -399,7 +399,7 @@ public: { PrepareSpellScript(spell_mage_cone_of_cold_SpellScript); - void HandleConeOfColdScript(SpellEffIndex effIndex) + void HandleConeOfColdScript(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); if (Unit* unitTarget = GetHitUnit()) diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index e09fc074ce9..2a3fcd88778 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_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 645ac164aef..01598f12166 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 d456f2a1f56..39f23fc0516 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 af508dd1fca..939e6371d98 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 42296154634..1150970e8fc 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 ac0e124f53b..fd82171bc68 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..665acbe86c8 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -23,6 +23,7 @@ #include "BattlegroundSA.h" #include "BattlegroundAV.h" #include "Vehicle.h" +#include "Player.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/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index ddb0044a888..4abb06198ba 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -55,6 +55,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "GameObjectAI.h" #include "Spell.h" +#include "Player.h" /*###### ## go_cat_figurine diff --git a/src/server/scripts/World/guards.cpp b/src/server/scripts/World/guards.cpp index 4b0433fe0c7..5ca3984f92a 100644 --- a/src/server/scripts/World/guards.cpp +++ b/src/server/scripts/World/guards.cpp @@ -32,6 +32,7 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "GuardAI.h" +#include "Player.h" enum GuardGeneric { diff --git a/src/server/scripts/World/item_scripts.cpp b/src/server/scripts/World/item_scripts.cpp index e7883f4f11f..5e68507c9fa 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..e02e67e97f6 100644 --- a/src/server/scripts/World/npc_innkeeper.cpp +++ b/src/server/scripts/World/npc_innkeeper.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "GameEventMgr.h" +#include "Player.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 e6ac4a3a2a1..3f2e66bd232 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.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 18f776e7171..5414d896dd0 100644 --- a/src/server/scripts/World/npc_taxi.cpp +++ b/src/server/scripts/World/npc_taxi.cpp @@ -27,6 +27,7 @@ EndScriptData #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" +#include "Player.h" #define GOSSIP_SUSURRUS "I am ready." #define GOSSIP_NETHER_DRAKE "I'm ready to fly! Take me up, dragon!" diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index 91941a02df6..f28f62e6410 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -566,4 +566,10 @@ void CharacterDatabaseConnection::DoPrepareStatements() PREPARE_STATEMENT(CHAR_DEL_GUILD_FINDER_APPLICANT, "DELETE FROM guild_finder_applicant WHERE guildId = ? AND playerGuid = ?", CONNECTION_ASYNC); PREPARE_STATEMENT(CHAR_REP_GUILD_FINDER_GUILD_SETTINGS, "REPLACE INTO guild_finder_guild_settings (guildId, availability, classRoles, interests, level, listed, comment) VALUES(?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PREPARE_STATEMENT(CHAR_DEL_GUILD_FINDER_GUILD_SETTINGS, "DELETE FROM guild_finder_guild_settings WHERE guildId = ?", CONNECTION_ASYNC); + + // 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 5a03ee4767c..06721232ad5 100755 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -522,6 +522,11 @@ enum CharacterDatabaseStatements CHAR_REP_GUILD_FINDER_GUILD_SETTINGS, CHAR_DEL_GUILD_FINDER_GUILD_SETTINGS, + 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/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index e1e0a62db01..c4f709d23dd 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -514,7 +514,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) |