diff options
Diffstat (limited to 'src')
81 files changed, 1378 insertions, 937 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 91de52db9f8..b6517e3396b 100755 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -42,22 +42,26 @@ void UnitAI::DoMeleeAttackIfReady() if (me->HasUnitState(UNIT_STAT_CASTING)) return; + Unit *victim = me->getVictim(); + if (!victim || !victim->IsInWorld()) + return; + //Make sure our attack is ready and we aren't currently casting before checking distance if (me->isAttackReady()) { //If we are within range melee the target - if (me->IsWithinMeleeRange(me->getVictim())) + if (me->IsWithinMeleeRange(victim)) { - me->AttackerStateUpdate(me->getVictim()); + me->AttackerStateUpdate(victim); me->resetAttackTimer(); } } if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK)) { //If we are within range melee the target - if (me->IsWithinMeleeRange(me->getVictim())) + if (me->IsWithinMeleeRange(victim)) { - me->AttackerStateUpdate(me->getVictim(), OFF_ATTACK); + me->AttackerStateUpdate(victim, OFF_ATTACK); me->resetAttackTimer(OFF_ATTACK); } } diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index ec00b53b5ca..3a6240ae2f2 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -120,7 +120,7 @@ class UnitAI virtual void DoAction(int32 const /*param*/) {} virtual uint32 GetData(uint32 /*id = 0*/) { return 0; } virtual void SetData(uint32 /*id*/, uint32 /*value*/) {} - virtual void SetGUID(uint64 const /*guid*/, int32 /*id*/ = 0) {} + virtual void SetGUID(uint64 /*guid*/, int32 /*id*/ = 0) {} virtual uint64 GetGUID(int32 /*id*/ = 0) { return 0; } Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 97bfbd6fb10..470eb54b584 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -687,7 +687,7 @@ void SmartAI::SetData(uint32 id, uint32 value) GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value); } -void SmartAI::SetGUID(const uint64 /*guid*/, int32 /*id*/) +void SmartAI::SetGUID(uint64 /*guid*/, int32 /*id*/) { } diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index a4926226a91..ffa52db8f06 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -157,7 +157,7 @@ class SmartAI : public CreatureAI void SetData(uint32 id, uint32 value); // Used in scripts to share variables - void SetGUID(const uint64 guid, int32 id = 0); + void SetGUID(uint64 guid, int32 id = 0); // Used in scripts to share variables uint64 GetGUID(int32 id = 0); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index cbcbc1e2290..0de13280376 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2846,7 +2846,7 @@ void SmartScript::SetData(uint32 id, uint32 value) { } -void SmartScript::SetGUID(const uint64 guid, int32 id) +void SmartScript::SetGUID(uint64 guid, int32 id) { } diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 78153885fa4..693f8ddae27 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -93,7 +93,7 @@ bool ArenaTeam::Create(uint32 captainGuid, uint8 type, std::string teamName, uin return true; } -bool ArenaTeam::AddMember(const uint64 playerGuid) +bool ArenaTeam::AddMember(uint64 playerGuid) { std::string playerName; uint8 playerClass; @@ -276,7 +276,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result) return true; } -void ArenaTeam::SetCaptain(const uint64 guid) +void ArenaTeam::SetCaptain(uint64 guid) { // Disable remove/promote buttons Player* oldCaptain = ObjectAccessor::FindPlayer(GetCaptain()); @@ -537,7 +537,7 @@ uint8 ArenaTeam::GetSlotByType(uint32 type) return 0xFF; } -bool ArenaTeam::IsMember(const uint64 guid) const +bool ArenaTeam::IsMember(uint64 guid) const { for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) if (itr->Guid == guid) @@ -901,7 +901,7 @@ ArenaTeamMember* ArenaTeam::GetMember(const std::string& name) return NULL; } -ArenaTeamMember* ArenaTeam::GetMember(const uint64 guid) +ArenaTeamMember* ArenaTeam::GetMember(uint64 guid) { for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) if (itr->Guid == guid) diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 2874df84078..c65226a53aa 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -131,10 +131,10 @@ class ArenaTeam uint32 GetRating() const { return Stats.Rating; } uint32 GetAverageMMR(Group* group) const; - void SetCaptain(const uint64 guid); - bool AddMember(const uint64 PlayerGuid); + void SetCaptain(uint64 guid); + bool AddMember(uint64 PlayerGuid); - // Shouldn't be const uint64 ed, because than can reference guid from members on Disband + // Shouldn't be uint64 ed, because than can reference guid from members on Disband // and this method removes given record from list. So invalid reference can happen. void DelMember(uint64 guid, bool cleanDb); @@ -142,9 +142,9 @@ class ArenaTeam bool Empty() const { return Members.empty(); } MemberList::iterator m_membersBegin() { return Members.begin(); } MemberList::iterator m_membersEnd() { return Members.end(); } - bool IsMember(const uint64 guid) const; + bool IsMember(uint64 guid) const; - ArenaTeamMember* GetMember(const uint64 guid); + ArenaTeamMember* GetMember(uint64 guid); ArenaTeamMember* GetMember(const std::string& name); bool IsFighting() const; diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp index f164f56dffd..59f31e36971 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp @@ -53,7 +53,7 @@ ArenaTeam* ArenaTeamMgr::GetArenaTeamByName(const std::string& arenaTeamName) co return NULL; } -ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 const guid) const +ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 guid) const { for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr) if (itr->second->GetCaptain() == guid) @@ -146,18 +146,20 @@ void ArenaTeamMgr::DistributeArenaPoints() if (ArenaTeam * at = teamItr->second) at->UpdateArenaPointsHelper(PlayerPoints); + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + // Cycle that gives points to all players for (std::map<uint32, uint32>::iterator playerItr = PlayerPoints.begin(); playerItr != PlayerPoints.end(); ++playerItr) { - // Update database - CharacterDatabase.PExecute("UPDATE characters SET arenaPoints = arenaPoints + '%u' WHERE guid = '%u'", playerItr->second, playerItr->first); - // Add points to player if online - Player* pl = ObjectAccessor::FindPlayer(playerItr->first); - if (pl) - pl->ModifyArenaPoints(playerItr->second); + if (Player* player = HashMapHolder<Player>::Find(playerItr->first)) + player->ModifyArenaPoints(playerItr->second, &trans); + else // Update database + trans->PAppend("UPDATE characters SET arenaPoints=arenaPoints+%u WHERE guid=%u", playerItr->second, playerItr->first); } + CharacterDatabase.CommitTransaction(trans); + PlayerPoints.clear(); sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END); diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.h b/src/server/game/Battlegrounds/ArenaTeamMgr.h index 1e45158b353..31f0a1773da 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.h +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.h @@ -30,8 +30,8 @@ public: typedef UNORDERED_MAP<uint32, ArenaTeam*> ArenaTeamContainer; ArenaTeam* GetArenaTeamById(uint32 arenaTeamId) const; - ArenaTeam* GetArenaTeamByName(const std::string& arenaTeamName) const; - ArenaTeam* GetArenaTeamByCaptain(uint64 const guid) const; + ArenaTeam* GetArenaTeamByName(std::string const& arenaTeamName) const; + ArenaTeam* GetArenaTeamByCaptain(uint64 guid) const; void LoadArenaTeams(); void AddArenaTeam(ArenaTeam* arenaTeam); diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index b9a92f0cb44..ce7fa8d81a4 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -520,7 +520,7 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId bgTypeId if (selectionWeights) { - if (!selectionWeights->size()) + if (selectionWeights->empty()) return NULL; uint32 Weight = 0; uint32 selectedWeight = 0; diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index 0b0c0ceb2a6..b453ba59170 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -122,7 +122,7 @@ class BattlegroundMgr bool isTesting() const { return m_Testing; } static bool IsArenaType(BattlegroundTypeId bgTypeId); - static bool IsBattlegroundType(BattlegroundTypeId bgTypeId) { return !BattlegroundMgr::IsArenaType(bgTypeId); } + static bool IsBattlegroundType(BattlegroundTypeId bgTypeId) { return !IsArenaType(bgTypeId); } static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType); static BattlegroundTypeId BGTemplateId(BattlegroundQueueTypeId bgQueueTypeId); static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId); diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index c56b975acb9..d39018e69a4 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -377,7 +377,6 @@ void Channel::UnBan(uint64 good, const char *badname) void Channel::Password(uint64 p, const char *pass) { - std::string plName; uint32 sec = 0; Player *plr = ObjectAccessor::FindPlayer(p); if (plr) diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index a0f590eca91..c03433e93b2 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -408,21 +408,31 @@ bool ChatHandler::HandlePInfoCommand(const char* args) // Add map, zone, subzone and phase to output int locale = GetSessionDbcLocale(); + std::string areaName = "<unknown>"; + std::string zoneName = ""; MapEntry const* map = sMapStore.LookupEntry(mapId); AreaTableEntry const* area = GetAreaEntryByAreaID(areaId); - AreaTableEntry const* zone = NULL; + if (area) + { + areaName = area->area_name[locale]; + + AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone); + + if (zone) + zoneName = zone->area_name[locale]; + } if (target) { - if (AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone)) - PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zone->area_name[locale], area->area_name[locale], phase); + if (!zoneName.empty()) + PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], zoneName.c_str(), areaName.c_str(), phase); else - PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], area->area_name[locale], "--", phase); + PSendSysMessage(LANG_PINFO_MAP_ONLINE, map->name[locale], areaName.c_str(), "<unknown>", phase); } else - PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], area->area_name[locale]); + PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str()); return true; } diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index 88477be6115..fc709599da5 100755 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -18,7 +18,7 @@ #include "DBCStores.h" -#include "Logging/Log.h" +#include "Log.h" #include "SharedDefines.h" #include "SpellMgr.h" diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index c08255048b8..a45bafe8a2e 100755 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -1172,12 +1172,12 @@ struct LFGDungeonEntry uint32 reclevel; // 20 uint32 recminlevel; // 21 uint32 recmaxlevel; // 22 - int32 map; // 23 + int32 map; // 23 uint32 difficulty; // 24 - //uint32 unk; // 25 + //uint32 flags; // 25 uint32 type; // 26 - //uint32 unk2; // 27 - //char* unk3; // 28 + //uint32 unk; // 27 + //char* iconname; // 28 uint32 expansion; // 29 //uint32 unk4; // 30 uint32 grouptype; // 31 @@ -1538,7 +1538,7 @@ struct SpellEntry uint32 Effect[MAX_SPELL_EFFECTS]; // 71-73 m_effect int32 EffectDieSides[MAX_SPELL_EFFECTS]; // 74-76 m_effectDieSides float EffectRealPointsPerLevel[MAX_SPELL_EFFECTS]; // 77-79 m_effectRealPointsPerLevel - int32 EffectBasePoints[MAX_SPELL_EFFECTS]; // 80-82 m_effectBasePoints (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints) + int32 EffectBasePoints[MAX_SPELL_EFFECTS]; // 80-82 m_effectBasePoints (must not be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints) uint32 EffectMechanic[MAX_SPELL_EFFECTS]; // 83-85 m_effectMechanic uint32 EffectImplicitTargetA[MAX_SPELL_EFFECTS]; // 86-88 m_implicitTargetA uint32 EffectImplicitTargetB[MAX_SPELL_EFFECTS]; // 89-91 m_implicitTargetB diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 87466436980..c9752c6377b 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -308,7 +308,7 @@ void LFGMgr::Update(uint32 diff) @param[in] guid Player or group guid to add to queue @param[in] queueId Queue Id to add player/group to */ -void LFGMgr::AddToQueue(const uint64 guid, uint8 queueId) +void LFGMgr::AddToQueue(uint64 guid, uint8 queueId) { if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) queueId = 0; @@ -329,7 +329,7 @@ void LFGMgr::AddToQueue(const uint64 guid, uint8 queueId) @param[in] guid Player or group guid to add to queue @return true if guid was found in main queue. */ -bool LFGMgr::RemoveFromQueue(const uint64 guid) +bool LFGMgr::RemoveFromQueue(uint64 guid) { for (LfgGuidListMap::iterator it = m_currentQueue.begin(); it != m_currentQueue.end(); ++it) it->second.remove(guid); @@ -743,7 +743,7 @@ LfgProposal* LFGMgr::FindNewGroups(LfgGuidList& check, LfgGuidList& all) return NULL; // Try to match with queued groups - while (!pProposal && all.size() > 0) + while (!pProposal && !all.empty()) { check.push_back(all.front()); all.pop_front(); @@ -1250,7 +1250,7 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true @param[in] guid Player guid to update answer @param[in] accept Player answer */ -void LFGMgr::UpdateProposal(uint32 proposalId, const uint64 guid, bool accept) +void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) { // Check if the proposal exists LfgProposalMap::iterator itProposal = m_Proposals.find(proposalId); @@ -1364,17 +1364,29 @@ void LFGMgr::UpdateProposal(uint32 proposalId, const uint64 guid, bool accept) switch(role) { case ROLE_DAMAGE: - m_WaitTimeDps = int32((m_WaitTimeDps * m_NumWaitTimeDps + waitTimesMap[plr->GetGUID()]) / ++m_NumWaitTimeDps); + { + uint32 old_number = m_NumWaitTimeDps++; + m_WaitTimeDps = int32((m_WaitTimeDps * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeDps); break; + } case ROLE_HEALER: - m_WaitTimeHealer = int32((m_WaitTimeHealer * m_NumWaitTimeHealer + waitTimesMap[plr->GetGUID()]) / ++m_NumWaitTimeHealer); + { + uint32 old_number = m_NumWaitTimeHealer++; + m_WaitTimeHealer = int32((m_WaitTimeHealer * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeHealer); break; + } case ROLE_TANK: - m_WaitTimeTank = int32((m_WaitTimeTank * m_NumWaitTimeTank + waitTimesMap[plr->GetGUID()]) / ++m_NumWaitTimeTank); + { + uint32 old_number = m_NumWaitTimeTank++; + m_WaitTimeTank = int32((m_WaitTimeTank * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeTank); break; + } default: - m_WaitTimeAvg = int32((m_WaitTimeAvg * m_NumWaitTimeAvg + waitTimesMap[plr->GetGUID()]) / ++m_NumWaitTimeAvg); + { + uint32 old_number = m_NumWaitTimeAvg++; + m_WaitTimeAvg = int32((m_WaitTimeAvg * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeAvg); break; + } } grp->SetLfgRoles(pguid, pProposal->players[pguid]->role); SetState(pguid, LFG_STATE_DUNGEON); @@ -1519,7 +1531,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t @param[in] victim Victim guid @param[in] reason Kick reason */ -void LFGMgr::InitBoot(Group* grp, const uint64 kicker, const uint64 victim, std::string reason) +void LFGMgr::InitBoot(Group* grp, uint64 kicker, uint64 victim, std::string reason) { if (!grp) return; @@ -1889,7 +1901,7 @@ std::string LFGMgr::ConcatenateGuids(LfgGuidList check) return o.str(); } -LfgState LFGMgr::GetState(const uint64 guid) +LfgState LFGMgr::GetState(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetState: [" UI64FMTD "]", guid); if (IS_GROUP(guid)) @@ -1898,61 +1910,61 @@ LfgState LFGMgr::GetState(const uint64 guid) return m_Players[guid].GetState(); } -uint32 LFGMgr::GetDungeon(const uint64 guid, bool asId /*= true*/) +uint32 LFGMgr::GetDungeon(uint64 guid, bool asId /*= true*/) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetDungeon: [" UI64FMTD "] asId: %u", guid, asId); return m_Groups[guid].GetDungeon(asId); } -uint8 LFGMgr::GetRoles(const uint64 guid) +uint8 LFGMgr::GetRoles(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetRoles: [" UI64FMTD "]", guid); return m_Players[guid].GetRoles(); } -const std::string& LFGMgr::GetComment(const uint64 guid) +const std::string& LFGMgr::GetComment(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetComment: [" UI64FMTD "]", guid); return m_Players[guid].GetComment(); } -const LfgDungeonSet& LFGMgr::GetSelectedDungeons(const uint64 guid) +const LfgDungeonSet& LFGMgr::GetSelectedDungeons(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetSelectedDungeons: [" UI64FMTD "]", guid); return m_Players[guid].GetSelectedDungeons(); } -const LfgLockMap& LFGMgr::GetLockedDungeons(const uint64 guid) +const LfgLockMap& LFGMgr::GetLockedDungeons(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetLockedDungeons: [" UI64FMTD "]", guid); return m_Players[guid].GetLockedDungeons(); } -uint8 LFGMgr::GetKicksLeft(const uint64 guid) +uint8 LFGMgr::GetKicksLeft(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetKicksLeft: [" UI64FMTD "]", guid); return m_Groups[guid].GetKicksLeft(); } -uint8 LFGMgr::GetVotesNeeded(const uint64 guid) +uint8 LFGMgr::GetVotesNeeded(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetVotesNeeded: [" UI64FMTD "]", guid); return m_Groups[guid].GetVotesNeeded(); } -void LFGMgr::RestoreState(const uint64 guid) +void LFGMgr::RestoreState(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RestoreState: [" UI64FMTD "]", guid); m_Groups[guid].RestoreState(); } -void LFGMgr::ClearState(const uint64 guid) +void LFGMgr::ClearState(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::ClearState: [" UI64FMTD "]", guid); m_Players[guid].ClearState(); } -void LFGMgr::SetState(const uint64 guid, LfgState state) +void LFGMgr::SetState(uint64 guid, LfgState state) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: [" UI64FMTD "] state %u", guid, state); if (IS_GROUP(guid)) @@ -1961,43 +1973,43 @@ void LFGMgr::SetState(const uint64 guid, LfgState state) m_Players[guid].SetState(state); } -void LFGMgr::SetDungeon(const uint64 guid, uint32 dungeon) +void LFGMgr::SetDungeon(uint64 guid, uint32 dungeon) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetDungeon: [" UI64FMTD "] dungeon %u", guid, dungeon); m_Groups[guid].SetDungeon(dungeon); } -void LFGMgr::SetRoles(const uint64 guid, uint8 roles) +void LFGMgr::SetRoles(uint64 guid, uint8 roles) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetRoles: [" UI64FMTD "] roles: %u", guid, roles); m_Players[guid].SetRoles(roles); } -void LFGMgr::SetComment(const uint64 guid, const std::string& comment) +void LFGMgr::SetComment(uint64 guid, const std::string& comment) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetComment: [" UI64FMTD "] comment: %s", guid, comment.c_str()); m_Players[guid].SetComment(comment); } -void LFGMgr::SetSelectedDungeons(const uint64 guid, const LfgDungeonSet& dungeons) +void LFGMgr::SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetSelectedDungeons: [" UI64FMTD "]", guid); m_Players[guid].SetSelectedDungeons(dungeons); } -void LFGMgr::SetLockedDungeons(const uint64 guid, const LfgLockMap& lock) +void LFGMgr::SetLockedDungeons(uint64 guid, const LfgLockMap& lock) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetLockedDungeons: [" UI64FMTD "]", guid); m_Players[guid].SetLockedDungeons(lock); } -void LFGMgr::DecreaseKicksLeft(const uint64 guid) +void LFGMgr::DecreaseKicksLeft(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::DecreaseKicksLeft: [" UI64FMTD "]", guid); m_Groups[guid].DecreaseKicksLeft(); } -void LFGMgr::RemovePlayerData(const uint64 guid) +void LFGMgr::RemovePlayerData(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemovePlayerData: [" UI64FMTD "]", guid); LfgPlayerDataMap::iterator it = m_Players.find(guid); @@ -2005,7 +2017,7 @@ void LFGMgr::RemovePlayerData(const uint64 guid) m_Players.erase(it); } -void LFGMgr::RemoveGroupData(const uint64 guid) +void LFGMgr::RemoveGroupData(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemoveGroupData: [" UI64FMTD "]", guid); LfgGroupDataMap::iterator it = m_Groups.find(guid); diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 1ca256f5a92..6c42b1728c1 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -272,45 +272,45 @@ class LFGMgr void UpdateRoleCheck(uint64 gguid, uint64 guid = 0, uint8 roles = ROLE_NONE); // Proposals - void UpdateProposal(uint32 proposalId, const uint64 guid, bool accept); + void UpdateProposal(uint32 proposalId, uint64 guid, bool accept); // Teleportation void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false); // Vote kick - void InitBoot(Group* grp, const uint64 kguid, const uint64 vguid, std::string reason); + void InitBoot(Group* grp, uint64 kguid, uint64 vguid, std::string reason); void UpdateBoot(Player* plr, bool accept); void OfferContinue(Group* grp); void InitializeLockedDungeons(Player* plr); - void SetComment(const uint64 guid, const std::string& comment); - const LfgLockMap& GetLockedDungeons(const uint64 guid); - LfgState GetState(const uint64 guid); - const LfgDungeonSet& GetSelectedDungeons(const uint64 guid); - uint32 GetDungeon(const uint64 guid, bool asId = true); - void ClearState(const uint64 guid); - void RemovePlayerData(const uint64 guid); - void RemoveGroupData(const uint64 guid); - uint8 GetKicksLeft(const uint64 gguid); - uint8 GetVotesNeeded(const uint64 gguid); - void SetRoles(const uint64 guid, uint8 roles); + void SetComment(uint64 guid, const std::string& comment); + const LfgLockMap& GetLockedDungeons(uint64 guid); + LfgState GetState(uint64 guid); + const LfgDungeonSet& GetSelectedDungeons(uint64 guid); + uint32 GetDungeon(uint64 guid, bool asId = true); + void ClearState(uint64 guid); + void RemovePlayerData(uint64 guid); + void RemoveGroupData(uint64 guid); + uint8 GetKicksLeft(uint64 gguid); + uint8 GetVotesNeeded(uint64 gguid); + void SetRoles(uint64 guid, uint8 roles); private: - uint8 GetRoles(const uint64 guid); - const std::string& GetComment(const uint64 gguid); - void RestoreState(const uint64 guid); - void SetState(const uint64 guid, LfgState state); - void SetDungeon(const uint64 guid, uint32 dungeon); - void SetSelectedDungeons(const uint64 guid, const LfgDungeonSet& dungeons); - void SetLockedDungeons(const uint64 guid, const LfgLockMap& lock); - void DecreaseKicksLeft(const uint64 guid); + uint8 GetRoles(uint64 guid); + const std::string& GetComment(uint64 gguid); + void RestoreState(uint64 guid); + void SetState(uint64 guid, LfgState state); + void SetDungeon(uint64 guid, uint32 dungeon); + void SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons); + void SetLockedDungeons(uint64 guid, const LfgLockMap& lock); + void DecreaseKicksLeft(uint64 guid); void NoExiste(uint8 lala); // Queue - void AddToQueue(const uint64 guid, uint8 queueId); - bool RemoveFromQueue(const uint64 guid); + void AddToQueue(uint64 guid, uint8 queueId); + bool RemoveFromQueue(uint64 guid); // Proposals void RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index bf61e98bb41..7ad0386dcae 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -740,10 +740,10 @@ class Creature : public Unit, public GridObject<Creature> class AssistDelayEvent : public BasicEvent { public: - AssistDelayEvent(const uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { } + AssistDelayEvent(uint64 victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { } bool Execute(uint64 e_time, uint32 p_time); - void AddAssistant(const uint64 guid) { m_assistants.push_back(guid); } + void AddAssistant(uint64 guid) { m_assistants.push_back(guid); } private: AssistDelayEvent(); diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 92c57009832..d1ad656ba3d 100755 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -203,7 +203,7 @@ void TempSummon::InitStats(uint32 duration) if (m_Properties->Faction) setFaction(m_Properties->Faction); - else if (IsVehicle()) // properties should be vehicle + else if (IsVehicle() && owner) // properties should be vehicle setFaction(owner->getFaction()); } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 5308c30a196..83ece2eda31 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1631,6 +1631,8 @@ void GameObject::CastSpell(Unit* target, uint32 spellId) if (Unit* owner = GetOwner()) { trigger->setFaction(owner->getFaction()); + // needed for GO casts for proper target validation checks + trigger->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner->GetGUID()); trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, owner->GetGUID()); } else diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 4e7be5f140d..aa056e793f0 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -69,8 +69,8 @@ Object::Object() : m_PackGUID(sizeof(uint64)+1) m_objectTypeId = TYPEID_OBJECT; m_objectType = TYPEMASK_OBJECT; - m_uint32Values = 0; - m_uint32Values_mirror = 0; + m_uint32Values = NULL; + _changedFields = NULL; m_valuesCount = 0; m_inWorld = false; @@ -112,17 +112,17 @@ Object::~Object() } delete [] m_uint32Values; - delete [] m_uint32Values_mirror; + delete [] _changedFields; } void Object::_InitValues() { - m_uint32Values = new uint32[ m_valuesCount ]; + m_uint32Values = new uint32[m_valuesCount]; memset(m_uint32Values, 0, m_valuesCount*sizeof(uint32)); - m_uint32Values_mirror = new uint32[ m_valuesCount ]; - memset(m_uint32Values_mirror, 0, m_valuesCount*sizeof(uint32)); + _changedFields = new bool[m_valuesCount]; + memset(_changedFields, 0, m_valuesCount*sizeof(bool)); m_objectUpdated = false; } @@ -159,6 +159,30 @@ std::string Object::_ConcatFields(uint16 startIndex, uint16 size) const return ss.str(); } +void Object::AddToWorld() +{ + if (m_inWorld) + return; + + ASSERT(m_uint32Values); + + m_inWorld = true; + + // synchronize values mirror with values array (changes will send in updatecreate opcode any way + ClearUpdateMask(true); +} + +void Object::RemoveFromWorld() +{ + if (!m_inWorld) + return; + + m_inWorld = false; + + // if we remove from world then sending changes not required + ClearUpdateMask(true); +} + void Object::BuildMovementUpdateBlock(UpdateData * data, uint32 flags) const { ByteBuffer buf(500); @@ -296,17 +320,11 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const *data << ((Unit*)this)->GetSpeed(MOVE_TURN_RATE); *data << ((Unit*)this)->GetSpeed(MOVE_PITCH_RATE); + const Player* player = ToPlayer(); + // 0x08000000 - if (GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->isInFlight()) + if (player && player->isInFlight()) { - //WPAssert(this->ToPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE); - - Player* player = const_cast<Object*>(this)->ToPlayer(); - if (!player) - return; - - FlightPathMovementGenerator *fmg = (FlightPathMovementGenerator*)(player->GetMotionMaster()->top()); - uint32 flags3 = SPLINEFLAG_GLIDE; *data << uint32(flags3); // splines flag? @@ -330,7 +348,9 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const } } - TaxiPathNodeList& path = const_cast<TaxiPathNodeList&>(fmg->GetPath()); + FlightPathMovementGenerator *fmg = + (FlightPathMovementGenerator*)(player->GetMotionMaster()->top()); + TaxiPathNodeList const& path = fmg->GetPath(); float x, y, z; player->GetPosition(x, y, z); @@ -532,7 +552,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask if (index == UNIT_NPC_FLAGS) { // remove custom flag before sending - uint32 appendValue = m_uint32Values[ index ]; + uint32 appendValue = m_uint32Values[index]; if (GetTypeId() == TYPEID_UNIT) { @@ -557,7 +577,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask else if (index >= UNIT_FIELD_BASEATTACKTIME && index <= UNIT_FIELD_RANGEDATTACKTIME) { // convert from float to uint32 and send - *data << uint32(m_floatValues[ index ] < 0 ? 0 : m_floatValues[ index ]); + *data << uint32(m_floatValues[index] < 0 ? 0 : m_floatValues[index]); } // there are some float values which may be negative or can't get negative due to other checks else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) || @@ -565,22 +585,33 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) || (index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4)) { - *data << uint32(m_floatValues[ index ]); + *data << uint32(m_floatValues[index]); } // Gamemasters should be always able to select units - remove not selectable flag else if (index == UNIT_FIELD_FLAGS) { if (target->isGameMaster()) - *data << (m_uint32Values[ index ] & ~UNIT_FLAG_NOT_SELECTABLE); + *data << (m_uint32Values[index] & ~UNIT_FLAG_NOT_SELECTABLE); else - *data << m_uint32Values[ index ]; + *data << m_uint32Values[index]; } // use modelid_a if not gm, _h if gm for CREATURE_FLAG_EXTRA_TRIGGER creatures else if (index == UNIT_FIELD_DISPLAYID) { if (GetTypeId() == TYPEID_UNIT) { - const CreatureTemplate* cinfo = this->ToCreature()->GetCreatureInfo(); + CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo(); + + // this also applies for transform auras + if (SpellInfo const* transform = sSpellMgr->GetSpellInfo(ToUnit()->getTransForm())) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (transform->Effects[i].IsAura(SPELL_AURA_TRANSFORM)) + if (CreatureTemplate const* transformInfo = sObjectMgr->GetCreatureTemplate(transform->Effects[i].MiscValue)) + { + cinfo = transformInfo; + break; + } + if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) { if (target->isGameMaster()) @@ -599,10 +630,10 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask } } else - *data << m_uint32Values[ index ]; + *data << m_uint32Values[index]; } else - *data << m_uint32Values[ index ]; + *data << m_uint32Values[index]; } // hide lootable animation for unallowed players else if (index == UNIT_DYNAMIC_FLAGS) @@ -615,7 +646,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask { if (creature->isTappedBy(target)) { - dynamicFlags |= (UNIT_DYNFLAG_TAPPED|UNIT_DYNFLAG_TAPPED_BY_PLAYER); + dynamicFlags |= (UNIT_DYNFLAG_TAPPED | UNIT_DYNFLAG_TAPPED_BY_PLAYER); } else { @@ -638,17 +669,17 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask // FG: pretend that OTHER players in own group are friendly ("blue") else if (index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE) { - if (((Unit*)this)->IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && ((Unit*)this)->IsInRaidWith(target)) + Unit const* unit = ToUnit(); + if (unit->IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && unit->IsInRaidWith(target)) { - FactionTemplateEntry const *ft1, *ft2; - ft1 = ((Unit*)this)->getFactionTemplateEntry(); - ft2 = target->getFactionTemplateEntry(); + FactionTemplateEntry const* ft1 = unit->getFactionTemplateEntry(); + FactionTemplateEntry const* ft2 = target->getFactionTemplateEntry(); if (ft1 && ft2 && !ft1->IsFriendlyTo(*ft2)) { if (index == UNIT_FIELD_BYTES_2) { // Allow targetting opposite faction in party when enabled in config - *data << (m_uint32Values[ index ] & ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8)); // this flag is at uint8 offset 1 !! + *data << (m_uint32Values[index] & ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8)); // this flag is at uint8 offset 1 !! } else { @@ -658,15 +689,15 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask } } else - *data << m_uint32Values[ index ]; + *data << m_uint32Values[index]; } else - *data << m_uint32Values[ index ]; + *data << m_uint32Values[index]; } else { // send in current format (float as float, uint32 as uint32) - *data << m_uint32Values[ index ]; + *data << m_uint32Values[index]; } } } @@ -682,7 +713,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask { if (IsActivateToQuest) { - switch(((GameObject*)this)->GetGoType()) + switch (ToGameObject()->GetGoType()) { case GAMEOBJECT_TYPE_CHEST: if (target->isGameMaster()) @@ -720,7 +751,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask } } else - *data << m_uint32Values[ index ]; // other cases + *data << m_uint32Values[index]; // other cases } } } @@ -731,7 +762,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask if (updateMask->GetBit(index)) { // send in current format (float as float, uint32 as uint32) - *data << m_uint32Values[ index ]; + *data << m_uint32Values[index]; } } } @@ -739,7 +770,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask void Object::ClearUpdateMask(bool remove) { - memcpy(m_uint32Values_mirror, m_uint32Values, m_valuesCount*sizeof(uint32)); + memset(_changedFields, 0, m_valuesCount*sizeof(bool)); if (m_objectUpdated) { @@ -749,7 +780,7 @@ void Object::ClearUpdateMask(bool remove) } } -void Object::BuildFieldsUpdate(Player *pl, UpdateDataMapType &data_map) const +void Object::BuildFieldsUpdate(Player* pl, UpdateDataMapType& data_map) const { UpdateDataMapType::iterator iter = data_map.find(pl); @@ -763,7 +794,7 @@ void Object::BuildFieldsUpdate(Player *pl, UpdateDataMapType &data_map) const BuildValuesUpdateBlockForPlayer(&iter->second, iter->first); } -void Object::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count) +void Object::_LoadIntoDataField(char const* data, uint32 startOffset, uint32 count) { if (!data) return; @@ -774,24 +805,26 @@ void Object::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 cou return; for (uint32 index = 0; index < count; ++index) + { m_uint32Values[startOffset + index] = atol(tokens[index]); + _changedFields[startOffset + index] = true; + } } -void Object::_SetUpdateBits(UpdateMask *updateMask, Player* /*target*/) const +void Object::_SetUpdateBits(UpdateMask* updateMask, Player* /*target*/) const { - uint32 *value = m_uint32Values; - uint32 *mirror = m_uint32Values_mirror; + bool* indexes = _changedFields; - for (uint16 index = 0; index < m_valuesCount; ++index, ++value, ++mirror) + for (uint16 index = 0; index < m_valuesCount; ++index, ++indexes) { - if (*mirror != *value) + if (*indexes) updateMask->SetBit(index); } } -void Object::_SetCreateBits(UpdateMask *updateMask, Player* /*target*/) const +void Object::_SetCreateBits(UpdateMask* updateMask, Player* /*target*/) const { - uint32 *value = m_uint32Values; + uint32* value = m_uint32Values; for (uint16 index = 0; index < m_valuesCount; ++index, ++value) { @@ -804,17 +837,15 @@ void Object::SetInt32Value(uint16 index, int32 value) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - if (m_int32Values[ index ] != value) + if (m_int32Values[index] != value) { - m_int32Values[ index ] = value; + m_int32Values[index] = value; + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -823,17 +854,15 @@ void Object::SetUInt32Value(uint16 index, uint32 value) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - if (m_uint32Values[ index ] != value) + if (m_uint32Values[index] != value) { - m_uint32Values[ index ] = value; + m_uint32Values[index] = value; + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -842,67 +871,69 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - m_uint32Values[ index ] = value; + m_uint32Values[index] = value; + _changedFields[index] = true; } -void Object::SetUInt64Value(uint16 index, const uint64 value) +void Object::SetUInt64Value(uint16 index, uint64 value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (*((uint64*)&(m_uint32Values[ index ])) != value) + if (*((uint64*)&(m_uint32Values[index])) != value) { - m_uint32Values[ index ] = *((uint32*)&value); - m_uint32Values[ index + 1 ] = *(((uint32*)&value) + 1); + m_uint32Values[index] = PAIR64_LOPART(value); + m_uint32Values[index + 1] = PAIR64_HIPART(value); + _changedFields[index] = true; + _changedFields[index + 1] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } -bool Object::AddUInt64Value(uint16 index, const uint64 value) +bool Object::AddUInt64Value(uint16 index, uint64 value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , true)); if (value && !*((uint64*)&(m_uint32Values[index]))) { - m_uint32Values[ index ] = *((uint32*)&value); - m_uint32Values[ index + 1 ] = *(((uint32*)&value) + 1); + m_uint32Values[index] = PAIR64_LOPART(value); + m_uint32Values[index + 1] = PAIR64_HIPART(value); + _changedFields[index] = true; + _changedFields[index + 1] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } + return true; } + return false; } -bool Object::RemoveUInt64Value(uint16 index, const uint64 value) +bool Object::RemoveUInt64Value(uint16 index, uint64 value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , true)); if (value && *((uint64*)&(m_uint32Values[index])) == value) { - m_uint32Values[ index ] = 0; - m_uint32Values[ index + 1 ] = 0; + m_uint32Values[index] = 0; + m_uint32Values[index + 1] = 0; + _changedFields[index] = true; + _changedFields[index + 1] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } + return true; } + return false; } @@ -910,17 +941,15 @@ void Object::SetFloatValue(uint16 index, float value) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - if (m_floatValues[ index ] != value) + if (m_floatValues[index] != value) { - m_floatValues[ index ] = value; + m_floatValues[index] = value; + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -935,18 +964,16 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value) return; } - if (uint8(m_uint32Values[ index ] >> (offset * 8)) != value) + if (uint8(m_uint32Values[index] >> (offset * 8)) != value) { - m_uint32Values[ index ] &= ~uint32(uint32(0xFF) << (offset * 8)); - m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 8)); + m_uint32Values[index] &= ~uint32(uint32(0xFF) << (offset * 8)); + m_uint32Values[index] |= uint32(uint32(value) << (offset * 8)); + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -961,18 +988,16 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value) return; } - if (uint16(m_uint32Values[ index ] >> (offset * 16)) != value) + if (uint16(m_uint32Values[index] >> (offset * 16)) != value) { - m_uint32Values[ index ] &= ~uint32(uint32(0xFFFF) << (offset * 16)); - m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 16)); + m_uint32Values[index] &= ~uint32(uint32(0xFFFF) << (offset * 16)); + m_uint32Values[index] |= uint32(uint32(value) << (offset * 16)); + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -1028,20 +1053,18 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply) void Object::SetFlag(uint16 index, uint32 newFlag) { ASSERT(index < m_valuesCount || PrintIndexError(index, true)); - uint32 oldval = m_uint32Values[ index ]; + uint32 oldval = m_uint32Values[index]; uint32 newval = oldval | newFlag; if (oldval != newval) { - m_uint32Values[ index ] = newval; + m_uint32Values[index] = newval; + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -1051,20 +1074,18 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag) ASSERT(index < m_valuesCount || PrintIndexError(index, true)); ASSERT(m_uint32Values); - uint32 oldval = m_uint32Values[ index ]; + uint32 oldval = m_uint32Values[index]; uint32 newval = oldval & ~oldFlag; if (oldval != newval) { - m_uint32Values[ index ] = newval; + m_uint32Values[index] = newval; + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -1079,17 +1100,15 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag) return; } - if (!(uint8(m_uint32Values[ index ] >> (offset * 8)) & newFlag)) + if (!(uint8(m_uint32Values[index] >> (offset * 8)) & newFlag)) { - m_uint32Values[ index ] |= uint32(uint32(newFlag) << (offset * 8)); + m_uint32Values[index] |= uint32(uint32(newFlag) << (offset * 8)); + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -1104,17 +1123,15 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag) return; } - if (uint8(m_uint32Values[ index ] >> (offset * 8)) & oldFlag) + if (uint8(m_uint32Values[index] >> (offset * 8)) & oldFlag) { - m_uint32Values[ index ] &= ~uint32(uint32(oldFlag) << (offset * 8)); + m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (offset * 8)); + _changedFields[index] = true; - if (m_inWorld) + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } } @@ -1127,7 +1144,7 @@ bool Object::PrintIndexError(uint32 index, bool set) const return false; } -bool Position::HasInLine(const Unit* const target, float distance, float width) const +bool Position::HasInLine(Unit const* target, float distance, float width) const { if (!HasInArc(M_PI, target) || !target->IsWithinDist3d(m_positionX, m_positionY, m_positionZ, distance)) return false; @@ -1143,14 +1160,14 @@ std::string Position::ToString() const return sstr.str(); } -ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer) +ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer) { float x, y, z, o; buf >> x >> y >> z >> o; streamer.m_pos->Relocate(x, y, z, o); return buf; } -ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer) +ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer) { float x, y, z; streamer.m_pos->GetPosition(x, y, z); @@ -1158,7 +1175,7 @@ ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & s return buf; } -ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer) +ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer) { float x, y, z; buf >> x >> y >> z; @@ -1166,7 +1183,7 @@ ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & st return buf; } -ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer) +ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer) { float x, y, z, o; streamer.m_pos->GetPosition(x, y, z, o); @@ -1192,19 +1209,16 @@ void MovementInfo::OutDebug() if (flags2 & MOVEMENTFLAG2_INTERPOLATED_MOVEMENT) sLog->outString("time2: %u", t_time2); } + if ((flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (flags2 & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING)) - { sLog->outString("pitch: %f", pitch); - } + sLog->outString("fallTime: %u", fallTime); if (flags & MOVEMENTFLAG_JUMPING) - { sLog->outString("j_zspeed: %f j_sinAngle: %f j_cosAngle: %f j_xyspeed: %f", j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed); - } + if (flags & MOVEMENTFLAG_SPLINE_ELEVATION) - { sLog->outString("splineElevation: %f", splineElevation); - } } WorldObject::WorldObject(): WorldLocation(), @@ -1328,7 +1342,9 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const { - if (!IsInMap(obj)) return false; + if (!IsInMap(obj)) + return false; + float ox, oy, oz; obj->GetPosition(ox, oy, oz); return(IsWithinLOS(ox, oy, oz)); @@ -1811,14 +1827,11 @@ void WorldObject::SendPlaySound(uint32 Sound, bool OnlySelf) void Object::ForceValuesUpdateAtIndex(uint32 i) { - m_uint32Values_mirror[i] = GetUInt32Value(i) + 1; // makes server think the field changed - if (m_inWorld) + _changedFields[i] = true; + if (m_inWorld && !m_objectUpdated) { - if (!m_objectUpdated) - { - sObjectAccessor->AddUpdateObject(this); - m_objectUpdated = true; - } + sObjectAccessor->AddUpdateObject(this); + m_objectUpdated = true; } } @@ -2015,6 +2028,12 @@ void Unit::BuildHeartBeatMsg(WorldPacket *data) const BuildMovementPacket(data); } +void WorldObject::SendMessageToSet(WorldPacket *data, bool self) +{ + SendMessageToSetInRange(data, GetVisibilityRange(), self); +} + + void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*self*/) { Trinity::MessageDistDeliverer notifier(this, data, dist); @@ -2368,7 +2387,7 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 return summon; } -Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive) +Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive) const { Creature *creature = NULL; Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range); @@ -2377,7 +2396,7 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive return creature; } -GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) +GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const { GameObject *go = NULL; Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range); @@ -2386,7 +2405,7 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) return go; } -void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) +void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const { CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); Cell cell(pair); @@ -2400,7 +2419,7 @@ void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList cell.Visit(pair, visitor, *(this->GetMap())); } -void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) +void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const { CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); Cell cell(pair); @@ -2749,19 +2768,23 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/) struct WorldObjectChangeAccumulator { - UpdateDataMapType &i_updateDatas; - WorldObject &i_object; + UpdateDataMapType& i_updateDatas; + WorldObject& i_object; std::set<uint64> plr_list; WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d) : i_updateDatas(d), i_object(obj) {} void Visit(PlayerMapType &m) { + Player* source = NULL; for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { - BuildPacket(iter->getSource()); - if (!iter->getSource()->GetSharedVisionList().empty()) + source = iter->getSource(); + + BuildPacket(source); + + if (!source->GetSharedVisionList().empty()) { - SharedVisionList::const_iterator it = iter->getSource()->GetSharedVisionList().begin(); - for (; it != iter->getSource()->GetSharedVisionList().end(); ++it) + SharedVisionList::const_iterator it = source->GetSharedVisionList().begin(); + for (; it != source->GetSharedVisionList().end(); ++it) BuildPacket(*it); } } @@ -2769,30 +2792,37 @@ struct WorldObjectChangeAccumulator void Visit(CreatureMapType &m) { + Creature* source = NULL; for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { - if (!iter->getSource()->GetSharedVisionList().empty()) + source = iter->getSource(); + if (!source->GetSharedVisionList().empty()) { - SharedVisionList::const_iterator it = iter->getSource()->GetSharedVisionList().begin(); - for (; it != iter->getSource()->GetSharedVisionList().end(); ++it) + SharedVisionList::const_iterator it = source->GetSharedVisionList().begin(); + for (; it != source->GetSharedVisionList().end(); ++it) BuildPacket(*it); } } } + void Visit(DynamicObjectMapType &m) { + DynamicObject* source = NULL; for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { - uint64 guid = iter->getSource()->GetCasterGUID(); + source = iter->getSource(); + uint64 guid = source->GetCasterGUID(); + if (IS_PLAYER_GUID(guid)) { //Caster may be NULL if DynObj is in removelist if (Player *caster = ObjectAccessor::FindPlayer(guid)) - if (caster->GetUInt64Value(PLAYER_FARSIGHT) == iter->getSource()->GetGUID()) + if (caster->GetUInt64Value(PLAYER_FARSIGHT) == source->GetGUID()) BuildPacket(caster); } } } + void BuildPacket(Player* plr) { // Only send update once to a player diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index de2184eaaa6..9de040714e5 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -125,29 +125,9 @@ class Object virtual ~Object (); bool IsInWorld() const { return m_inWorld; } - virtual void AddToWorld() - { - if (m_inWorld) - return; - ASSERT(m_uint32Values); - - m_inWorld = true; - - // synchronize values mirror with values array (changes will send in updatecreate opcode any way - ClearUpdateMask(true); - } - - virtual void RemoveFromWorld() - { - if (!m_inWorld) - return; - - m_inWorld = false; - - // if we remove from world then sending changes not required - ClearUpdateMask(true); - } + virtual void AddToWorld(); + virtual void RemoveFromWorld(); uint64 GetGUID() const { return GetUInt64Value(0); } uint32 GetGUIDLow() const { return GUID_LOPART(GetUInt64Value(0)); } @@ -172,54 +152,54 @@ class Object int32 GetInt32Value(uint16 index) const { ASSERT(index < m_valuesCount || PrintIndexError(index , false)); - return m_int32Values[ index ]; + return m_int32Values[index]; } uint32 GetUInt32Value(uint16 index) const { ASSERT(index < m_valuesCount || PrintIndexError(index , false)); - return m_uint32Values[ index ]; + return m_uint32Values[index]; } uint64 GetUInt64Value(uint16 index) const { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , false)); - return *((uint64*)&(m_uint32Values[ index ])); + return *((uint64*)&(m_uint32Values[index])); } float GetFloatValue(uint16 index) const { ASSERT(index < m_valuesCount || PrintIndexError(index , false)); - return m_floatValues[ index ]; + return m_floatValues[index]; } uint8 GetByteValue(uint16 index, uint8 offset) const { ASSERT(index < m_valuesCount || PrintIndexError(index , false)); ASSERT(offset < 4); - return *(((uint8*)&m_uint32Values[ index ])+offset); + return *(((uint8*)&m_uint32Values[index])+offset); } uint16 GetUInt16Value(uint16 index, uint8 offset) const { ASSERT(index < m_valuesCount || PrintIndexError(index , false)); ASSERT(offset < 2); - return *(((uint16*)&m_uint32Values[ index ])+offset); + return *(((uint16*)&m_uint32Values[index])+offset); } - void SetInt32Value(uint16 index, int32 value); - void SetUInt32Value(uint16 index, uint32 value); - void UpdateUInt32Value(uint16 index, uint32 value); - void SetUInt64Value(uint16 index, const uint64 value); - void SetFloatValue(uint16 index, float value); + void SetInt32Value(uint16 index, int32 value); + void SetUInt32Value(uint16 index, uint32 value); + void UpdateUInt32Value(uint16 index, uint32 value); + void SetUInt64Value(uint16 index, uint64 value); + void SetFloatValue(uint16 index, float value); void SetByteValue(uint16 index, uint8 offset, uint8 value); void SetUInt16Value(uint16 index, uint8 offset, uint16 value); void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index, offset, (uint16)value); } void SetStatFloatValue(uint16 index, float value); void SetStatInt32Value(uint16 index, int32 value); - bool AddUInt64Value(uint16 index, const uint64 value); - bool RemoveUInt64Value(uint16 index, const uint64 value); + bool AddUInt64Value(uint16 index, uint64 value); + bool RemoveUInt64Value(uint16 index, uint64 value); void ApplyModUInt32Value(uint16 index, int32 val, bool apply); void ApplyModInt32Value(uint16 index, int32 val, bool apply); @@ -248,7 +228,7 @@ class Object bool HasFlag(uint16 index, uint32 flag) const { if (index >= m_valuesCount && !PrintIndexError(index , false)) return false; - return (m_uint32Values[ index ] & flag) != 0; + return (m_uint32Values[index] & flag) != 0; } void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag); @@ -358,7 +338,7 @@ class Object float *m_floatValues; }; - uint32 *m_uint32Values_mirror; + bool* _changedFields; uint16 m_valuesCount; @@ -471,13 +451,13 @@ struct Position bool IsInDist(const Position *pos, float dist) const { return GetExactDistSq(pos) < dist * dist; } bool HasInArc(float arcangle, const Position *pos) const; - bool HasInLine(const Unit* target, float distance, float width) const; + bool HasInLine(Unit const* target, float distance, float width) const; std::string ToString() const; }; -ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer); -ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer); -ByteBuffer &operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const & streamer); -ByteBuffer & operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const & streamer); +ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer); +ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer); +ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer); +ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer); struct MovementInfo { @@ -725,7 +705,7 @@ class WorldObject : public Object, public WorldLocation virtual void CleanupsBeforeDelete(bool finalCleanup = true); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units - virtual void SendMessageToSet(WorldPacket *data, bool self) { SendMessageToSetInRange(data, GetVisibilityRange(), self); } + virtual void SendMessageToSet(WorldPacket *data, bool self); virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self); virtual void SendMessageToSet(WorldPacket *data, Player const* skipped_rcvr); @@ -806,11 +786,11 @@ class WorldObject : public Object, public WorldLocation GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); - Creature* FindNearestCreature(uint32 entry, float range, bool alive = true); - GameObject* FindNearestGameObject(uint32 entry, float range); + Creature* FindNearestCreature(uint32 entry, float range, bool alive = true) const; + GameObject* FindNearestGameObject(uint32 entry, float range) const; - void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange); - void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange); + void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const; + void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const; void DestroyForNearbyPlayers(); virtual void UpdateObjectVisibility(bool forced = true); @@ -884,11 +864,14 @@ namespace Trinity template<class T> void RandomResizeList(std::list<T> &_list, uint32 _size) { - while (_list.size() > _size) + size_t list_size = _list.size(); + + while (list_size > _size) { typename std::list<T>::iterator itr = _list.begin(); - advance(itr, urand(0, _list.size() - 1)); + std::advance(itr, urand(0, list_size - 1)); _list.erase(itr); + --list_size; } } diff --git a/src/server/game/Entities/Object/ObjectDefines.h b/src/server/game/Entities/Object/ObjectDefines.h index b231cb38e1a..6dd04e1dee4 100755 --- a/src/server/game/Entities/Object/ObjectDefines.h +++ b/src/server/game/Entities/Object/ObjectDefines.h @@ -78,7 +78,7 @@ enum HighGuid #define _GUID_LOPART_2(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF)) #define _GUID_LOPART_3(x) (uint32)(uint64(x) & UI64LIT(0x0000000000FFFFFF)) -inline bool IsGuidHaveEnPart(uint64 const guid) +inline bool IsGuidHaveEnPart(uint64 guid) { switch(GUID_HIPART(guid)) { diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp index 3884ce9f26f..547c415bc73 100755 --- a/src/server/game/Entities/Object/Updates/UpdateData.cpp +++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp @@ -34,7 +34,7 @@ void UpdateData::AddOutOfRangeGUID(std::set<uint64>& guids) m_outOfRangeGUIDs.insert(guids.begin(), guids.end()); } -void UpdateData::AddOutOfRangeGUID(const uint64 guid) +void UpdateData::AddOutOfRangeGUID(uint64 guid) { m_outOfRangeGUIDs.insert(guid); } diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h index f81a0464043..87e98ead61c 100755 --- a/src/server/game/Entities/Object/Updates/UpdateData.h +++ b/src/server/game/Entities/Object/Updates/UpdateData.h @@ -53,7 +53,7 @@ class UpdateData UpdateData(); void AddOutOfRangeGUID(std::set<uint64>& guids); - void AddOutOfRangeGUID(const uint64 guid); + void AddOutOfRangeGUID(uint64 guid); void AddUpdateBlock(const ByteBuffer &block); bool BuildPacket(WorldPacket* packet); bool HasData() { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d4a558d12af..58a297a8b2c 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -19610,8 +19610,8 @@ void Player::SendRemoveControlBar() bool Player::IsAffectedBySpellmod(SpellInfo const *spellInfo, SpellModifier *mod, Spell* spell) { - if (!mod || !spellInfo) - return false; + if (!mod || !spellInfo) + return false; // Mod out of charges if (spell && mod->charges == -1 && spell->m_appliedMods.find(mod->ownerAura) == spell->m_appliedMods.end()) @@ -21157,19 +21157,23 @@ void Player::UpdateTriggerVisibility() if (m_clientGUIDs.empty()) return; + if (!IsInWorld()) + return; + UpdateData udata; WorldPacket packet; - for (ClientGUIDs::iterator itr=m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) + for (ClientGUIDs::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) { if (IS_CREATURE_GUID(*itr)) { - Creature *obj = IsInWorld() ? GetMap()->GetCreature(*itr) : NULL; - if (!obj || !obj->isTrigger()) + Creature *obj = GetMap()->GetCreature(*itr); + if (!obj || !(obj->isTrigger() || obj->HasAuraType(SPELL_AURA_TRANSFORM))) // can transform into triggers continue; obj->BuildCreateUpdateBlockForPlayer(&udata, this); } } + udata.BuildPacket(&packet); GetSession()->SendPacket(&packet); } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index fbfa5333eb1..9a0f35313f6 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1567,7 +1567,7 @@ class Player : public Unit, public GridObject<Player> uint64 GetSelection() const { return m_curSelection; } Unit *GetSelectedUnit() const; Player *GetSelectedPlayer() const; - void SetSelection(const uint64 guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); } + void SetSelection(uint64 guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); } uint8 GetComboPoints() { return m_comboPoints; } uint64 GetComboTarget() const { return m_comboTarget; } @@ -1902,7 +1902,7 @@ class Player : public Unit, public GridObject<Player> void UpdateRuneRegen(RuneType rune); uint64 GetLootGUID() const { return m_lootGuid; } - void SetLootGUID(const uint64 guid) { m_lootGuid = guid; } + void SetLootGUID(uint64 guid) { m_lootGuid = guid; } void RemovedInsignia(Player* looterPlr); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6086d5f9e2d..4cea8f56005 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2402,14 +2402,22 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spell) } // Check for attack from behind - if (!victim->HasInArc(M_PI, this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) + if (!victim->HasInArc(M_PI, this)) { - // Can`t dodge from behind in PvP (but its possible in PvE) - if (victim->GetTypeId() == TYPEID_PLAYER) - canDodge = false; - // Can`t parry or block - canParry = false; - canBlock = false; + if (!victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) + { + // Can`t dodge from behind in PvP (but its possible in PvE) + if (victim->GetTypeId() == TYPEID_PLAYER) + canDodge = false; + // Can`t parry or block + canParry = false; + canBlock = false; + } + else // Only deterrence as of 3.3.5 + { + if (spell->AttributesCu & SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET) + canParry = false; + } } // Check creatures flags_extra for disable parry if (victim->GetTypeId() == TYPEID_UNIT) @@ -5596,16 +5604,6 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere triggered_spell_id = 71203; break; } - // Gaseous Bloat (Professor Putricide add) - case 70215: - case 72858: - case 72859: - case 72860: - { - target = getVictim(); - triggered_spell_id = 70701; - break; - } // Essence of the Blood Queen case 70871: { @@ -6467,16 +6465,14 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere } case SPELLFAMILY_ROGUE: { - switch(dummySpell->Id) + switch (dummySpell->Id) { - // Glyph of Backstab - case 56800: + case 56800: // Glyph of Backstab { triggered_spell_id = 63975; break; } - // Deadly Throw Interrupt - case 32748: + case 32748: // Deadly Throw Interrupt { // Prevent cast Deadly Throw Interrupt on self from last effect (apply dummy) of Deadly Throw if (this == victim) @@ -6486,124 +6482,126 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere break; } } - // Cut to the Chase - if (dummySpell->SpellIconID == 2909) + + switch (dummySpell->SpellIconID) { - // "refresh your Slice and Dice duration to its 5 combo point maximum" - // lookup Slice and Dice - if (AuraEffect const* aur = GetAuraEffect(SPELL_AURA_MOD_MELEE_HASTE, SPELLFAMILY_ROGUE, 0x40000, 0, 0)) + case 2116: // Quick Recovery { - aur->GetBase()->SetDuration(aur->GetSpellInfo()->GetMaxDuration(), true); - return true; - } - return false; - } - // Deadly Brew - else if (dummySpell->SpellIconID == 2963) - { - triggered_spell_id = 3409; - break; - } - // Quick Recovery - else if (dummySpell->SpellIconID == 2116) - { - if (!procSpell) - return false; + if (!procSpell) + return false; - // energy cost save - basepoints0 = CalculatePctN(int32(procSpell->ManaCost), triggerAmount); - if (basepoints0 <= 0) - return false; + // energy cost save + basepoints0 = CalculatePctN(int32(procSpell->ManaCost), triggerAmount); + if (basepoints0 <= 0) + return false; - target = this; - triggered_spell_id = 31663; - break; + target = this; + triggered_spell_id = 31663; + break; + } + case 2909: // Cut to the Chase + { + // "refresh your Slice and Dice duration to its 5 combo point maximum" + // lookup Slice and Dice + if (AuraEffect const* aur = GetAuraEffect(SPELL_AURA_MOD_MELEE_HASTE, SPELLFAMILY_ROGUE, 0x40000, 0, 0)) + { + aur->GetBase()->SetDuration(aur->GetSpellInfo()->GetMaxDuration(), true); + return true; + } + return false; + } + case 2963: // Deadly Brew + { + triggered_spell_id = 3409; + break; + } } break; } case SPELLFAMILY_HUNTER: { - // Thrill of the Hunt - if (dummySpell->SpellIconID == 2236) + switch (dummySpell->SpellIconID) { - if (!procSpell) - return false; + case 267: // Improved Mend Pet + { + int32 chance = triggeredByAura->GetSpellInfo()->Effects[triggeredByAura->GetEffIndex()].CalcValue(); + if (!roll_chance_i(chance)) + return false; - Spell* spell = ToPlayer()->m_spellModTakingSpell; + triggered_spell_id = 24406; + break; + } + case 2236: // Thrill of the Hunt + { + if (!procSpell) + return false; - // Disable charge drop because of Lock and Load - ToPlayer()->SetSpellModTakingSpell(spell, false); + Spell* spell = ToPlayer()->m_spellModTakingSpell; - // Explosive Shot - if (procSpell->SpellFamilyFlags[2] & 0x200) - { - if (AuraEffect const* pEff = victim->GetAuraEffect(SPELL_AURA_PERIODIC_DUMMY, SPELLFAMILY_HUNTER, 0x0, 0x80000000, 0x0, GetGUID())) - basepoints0 = pEff->GetSpellInfo()->CalcPowerCost(this, SpellSchoolMask(pEff->GetSpellInfo()->SchoolMask)) * 4/10/3; - } - else - basepoints0 = procSpell->CalcPowerCost(this, SpellSchoolMask(procSpell->SchoolMask)) * 4/10; + // Disable charge drop because of Lock and Load + ToPlayer()->SetSpellModTakingSpell(spell, false); - ToPlayer()->SetSpellModTakingSpell(spell, true); + // Explosive Shot + if (procSpell->SpellFamilyFlags[2] & 0x200) + { + if (AuraEffect const* pEff = victim->GetAuraEffect(SPELL_AURA_PERIODIC_DUMMY, SPELLFAMILY_HUNTER, 0x0, 0x80000000, 0x0, GetGUID())) + basepoints0 = pEff->GetSpellInfo()->CalcPowerCost(this, SpellSchoolMask(pEff->GetSpellInfo()->SchoolMask)) * 4/10/3; + } + else + basepoints0 = procSpell->CalcPowerCost(this, SpellSchoolMask(procSpell->SchoolMask)) * 4/10; - if (basepoints0 <= 0) - return false; + ToPlayer()->SetSpellModTakingSpell(spell, true); - target = this; - triggered_spell_id = 34720; - break; - } - // Hunting Party - if (dummySpell->SpellIconID == 3406) - { - triggered_spell_id = 57669; - target = this; - break; - } - // Improved Mend Pet - if (dummySpell->SpellIconID == 267) - { - int32 chance = triggeredByAura->GetSpellInfo()->Effects[triggeredByAura->GetEffIndex()].CalcValue(); - if (!roll_chance_i(chance)) - return false; + if (basepoints0 <= 0) + return false; - triggered_spell_id = 24406; - break; - } - // Lock and Load - if (dummySpell->SpellIconID == 3579) - { - // Proc only from periodic (from trap activation proc another aura of this spell) - if (!(procFlag & PROC_FLAG_DONE_PERIODIC) || !roll_chance_i(triggerAmount)) - return false; - triggered_spell_id = 56453; - target = this; - break; - } - // Rapid Recuperation - if (dummySpell->SpellIconID == 3560) - { - // This effect only from Rapid Killing (mana regen) - if (!(procSpell->SpellFamilyFlags[1] & 0x01000000)) - return false; + target = this; + triggered_spell_id = 34720; + break; + } + case 3406: // Hunting Party + { + triggered_spell_id = 57669; + target = this; + break; + } + case 3560: // Rapid Recuperation + { + // This effect only from Rapid Killing (mana regen) + if (!(procSpell->SpellFamilyFlags[1] & 0x01000000)) + return false; - target = this; + target = this; - switch(dummySpell->Id) + switch (dummySpell->Id) + { + case 53228: // Rank 1 + triggered_spell_id = 56654; + break; + case 53232: // Rank 2 + triggered_spell_id = 58882; + break; + } + break; + } + case 3579: // Lock and Load { - case 53228: // Rank 1 - triggered_spell_id = 56654; - break; - case 53232: // Rank 2 - triggered_spell_id = 58882; - break; + // Proc only from periodic (from trap activation proc another aura of this spell) + if (!(procFlag & PROC_FLAG_DONE_PERIODIC) || !roll_chance_i(triggerAmount)) + return false; + triggered_spell_id = 56453; + target = this; + break; } - break; } - // Glyph of Mend Pet - if (dummySpell->Id == 57870) + + switch (dummySpell->Id) { - victim->CastSpell(victim, 57894, true, NULL, NULL, GetGUID()); - return true; + case 57870: // Glyph of Mend Pet + { + victim->CastSpell(victim, 57894, true, NULL, NULL, GetGUID()); + return true; + } } break; } @@ -7906,6 +7904,27 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp RemoveAuraFromStack(71564); *handled = true; break; + // Gaseous Bloat + case 70672: + case 72455: + case 72832: + case 72833: + { + *handled = true; + uint32 stack = triggeredByAura->GetStackAmount(); + int32 const mod = (GetMap()->GetSpawnMode() & 1) ? 1500 : 1250; + int32 dmg = 0; + for (uint8 i = 1; i < stack; ++i) + dmg += mod * stack; + if (Unit* caster = triggeredByAura->GetCaster()) + { + caster->CastCustomSpell(70701, SPELLVALUE_BASE_POINT0, dmg); + if (Creature* creature = caster->ToCreature()) + creature->DespawnOrUnsummon(1); + } + break; + } + // Ball of Flames Proc case 71756: case 72782: case 72783: @@ -8400,76 +8419,42 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg target = this; break; } - // Lightning Capacitor - case 37657: + case 37657: // Lightning Capacitor + case 54841: // Thunder Capacitor + case 67712: // Item - Coliseum 25 Normal Caster Trinket + case 67758: // Item - Coliseum 25 Heroic Caster Trinket { - if (!victim || !victim->isAlive()) + if (!victim || !victim->isAlive() || GetTypeId() != TYPEID_PLAYER) return false; - // stacking - CastSpell(this, 37658, true, NULL, triggeredByAura); - Aura* dummy = GetAura(37658); - // release at 3 aura in stack (cont contain in basepoint of trigger aura) - if (!dummy || dummy->GetStackAmount() < triggerAmount) - return false; - - RemoveAurasDueToSpell(37658); - trigger_spell_id = 37661; - target = victim; - break; - } - // Thunder Capacitor - case 54841: - { - if (!victim || !victim->isAlive()) - return false; - // stacking - CastSpell(this, 54842, true, NULL, triggeredByAura); - - // counting - Aura* dummy = GetAura(54842); - // release at 3 aura in stack (cont contain in basepoint of trigger aura) - if (!dummy || dummy->GetStackAmount() < triggerAmount) - return false; - - RemoveAurasDueToSpell(54842); - trigger_spell_id = 54843; - target = victim; - break; - } - //Item - Coliseum 25 Normal Caster Trinket - case 67712: - { - if (!victim || !victim->isAlive()) - return false; - // stacking - CastSpell(this, 67713, true, NULL, triggeredByAura); - - Aura* dummy = GetAura(67713); - // release at 3 aura in stack (cont contain in basepoint of trigger aura) - if (!dummy || dummy->GetStackAmount() < triggerAmount) - return false; + uint32 stack_spell_id = 0; + switch (auraSpellInfo->Id) + { + case 37657: + stack_spell_id = 37658; + trigger_spell_id = 37661; + break; + case 54841: + stack_spell_id = 54842; + trigger_spell_id = 54843; + break; + case 67712: + stack_spell_id = 67713; + trigger_spell_id = 67714; + break; + case 67758: + stack_spell_id = 67759; + trigger_spell_id = 67760; + break; + } - RemoveAurasDueToSpell(67713); - trigger_spell_id = 67714; - target = victim; - break; - } - //Item - Coliseum 25 Heroic Caster Trinket - case 67758: - { - if (!victim || !victim->isAlive()) - return false; - // stacking - CastSpell(this, 67759, true, NULL, triggeredByAura); + CastSpell(this, stack_spell_id, true, NULL, triggeredByAura); - Aura* dummy = GetAura(67759); - // release at 3 aura in stack (cont contain in basepoint of trigger aura) + Aura* dummy = GetAura(stack_spell_id); if (!dummy || dummy->GetStackAmount() < triggerAmount) return false; - RemoveAurasDueToSpell(67759); - trigger_spell_id = 67760; + RemoveAurasDueToSpell(stack_spell_id); target = victim; break; } @@ -11732,8 +11717,6 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT else TakenFlatBenefit += victim->GetTotalAuraModifier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN); - Player* player = ToPlayer(); - // Done/Taken total percent damage auras float DoneTotalMod = 1.0f; float TakenTotalMod = 1.0f; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index caf1f4e46ad..e777f16b99a 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -174,7 +174,7 @@ enum UnitStandFlags { UNIT_STAND_FLAGS_UNK1 = 0x01, UNIT_STAND_FLAGS_CREEP = 0x02, - UNIT_STAND_FLAGS_UNK3 = 0x04, + UNIT_STAND_FLAGS_UNTRACKABLE = 0x04, UNIT_STAND_FLAGS_UNK4 = 0x08, UNIT_STAND_FLAGS_UNK5 = 0x10, UNIT_STAND_FLAGS_ALL = 0xFF @@ -185,7 +185,7 @@ enum UnitBytes1_Flags { UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01, UNIT_BYTE1_FLAG_UNK_2 = 0x02, - UNIT_BYTE1_FLAG_UNTRACKABLE = 0x04, + UNIT_BYTE1_FLAG_UNK_3 = 0x04, UNIT_BYTE1_FLAG_ALL = 0xFF }; @@ -1866,11 +1866,6 @@ class Unit : public WorldObject void SetShapeshiftForm(ShapeshiftForm form) { SetByteValue(UNIT_FIELD_BYTES_2, 3, form); - - // force update as too quick shapeshifting and back - // causes the value to stay the same serverside - // causes issues clientside (player gets stuck) - ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2); } inline bool IsInFeralForm() const @@ -2055,7 +2050,8 @@ class Unit : public WorldObject static Player* GetPlayer(WorldObject& object, uint64 guid); static Creature* GetCreature(WorldObject& object, uint64 guid); - MotionMaster* GetMotionMaster(){ return &i_motionMaster; } + MotionMaster* GetMotionMaster() { return &i_motionMaster; } + const MotionMaster* GetMotionMaster() const { return &i_motionMaster; } bool IsStopped() const { return !(HasUnitState(UNIT_STAT_MOVING)); } void StopMoving(); diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 4d4f0bfe05e..32ef215a5ee 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -1274,6 +1274,34 @@ namespace Trinity bool _equals; }; + class ObjectGUIDCheck + { + public: + ObjectGUIDCheck(uint64 GUID) : _GUID(GUID) {} + bool operator()(WorldObject* object) + { + return object->GetGUID() == _GUID; + } + + private: + uint64 _GUID; + }; + + class UnitAuraCheck + { + public: + UnitAuraCheck(bool present, uint32 spellId, uint64 casterGUID = 0) : _present(present), _spellId(spellId), _casterGUID(casterGUID) {} + bool operator()(Unit* unit) + { + return unit->HasAura(_spellId, _casterGUID) == _present; + } + + private: + bool _present; + uint32 _spellId; + uint64 _casterGUID; + }; + // Player checks and do // Prepare using Builder localized packets with caching and send to player diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 52f94f10b40..b9e00bc7231 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -270,7 +270,7 @@ void Group::RemoveAllInvites() m_invitees.clear(); } -Player* Group::GetInvited(const uint64 guid) const +Player* Group::GetInvited(uint64 guid) const { for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) { @@ -387,7 +387,7 @@ bool Group::AddMember(Player* player) return true; } -bool Group::RemoveMember(const uint64 guid, const RemoveMethod &method /*= GROUP_REMOVEMETHOD_DEFAULT*/, uint64 kicker /*= 0*/, const char* reason /*= NULL*/) +bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOVEMETHOD_DEFAULT*/, uint64 kicker /*= 0*/, const char* reason /*= NULL*/) { BroadcastGroupUpdate(); @@ -498,7 +498,7 @@ bool Group::RemoveMember(const uint64 guid, const RemoveMethod &method /*= GROUP } } -void Group::ChangeLeader(const uint64 guid) +void Group::ChangeLeader(uint64 guid) { member_witerator slot = _getMemberWSlot(guid); @@ -652,7 +652,7 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r) } } -void Group::SendLootRoll(const uint64 SourceGuid, const uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r) +void Group::SendLootRoll(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r) { WorldPacket data(SMSG_LOOT_ROLL, (8+4+8+4+4+4+1+1+1)); data << uint64(SourceGuid); // guid of the item rolled @@ -676,7 +676,7 @@ void Group::SendLootRoll(const uint64 SourceGuid, const uint64 TargetGuid, uint8 } } -void Group::SendLootRollWon(const uint64 SourceGuid, const uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r) +void Group::SendLootRollWon(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r) { WorldPacket data(SMSG_LOOT_ROLL_WON, (8+4+4+4+4+8+1+1)); data << uint64(SourceGuid); // guid of the item rolled @@ -949,7 +949,7 @@ void Group::MasterLoot(Loot* /*loot*/, WorldObject* pLootedObject) } } -void Group::CountRollVote(const uint64 playerGUID, const uint64 Guid, uint32 NumberOfPlayers, uint8 Choice) +void Group::CountRollVote(uint64 playerGUID, uint64 Guid, uint32 NumberOfPlayers, uint8 Choice) { Rolls::iterator rollI = GetRoll(Guid); if (rollI == RollId.end()) @@ -1295,7 +1295,7 @@ void Group::OfflineReadyCheck() } } -bool Group::_setMembersGroup(const uint64 guid, uint8 group) +bool Group::_setMembersGroup(uint64 guid, uint8 group) { member_witerator slot = _getMemberWSlot(guid); if (slot == m_memberSlots.end()) @@ -1322,7 +1322,7 @@ bool Group::SameSubGroup(Player const* member1, Player const* member2) const } // Allows setting sub groups both for online or offline members -void Group::ChangeMembersGroup(const uint64 guid, uint8 group) +void Group::ChangeMembersGroup(uint64 guid, uint8 group) { // Only raid groups have sub groups if (!isRaidGroup()) @@ -1767,7 +1767,7 @@ void Group::SetLootMethod(LootMethod method) m_lootMethod = method; } -void Group::SetLooterGuid(const uint64 guid) +void Group::SetLooterGuid(uint64 guid) { m_looterGuid = guid; } @@ -1847,12 +1847,12 @@ ItemQualities Group::GetLootThreshold() const return m_lootThreshold; } -bool Group::IsMember(const uint64 guid) const +bool Group::IsMember(uint64 guid) const { return _getMemberCSlot(guid) != m_memberSlots.end(); } -bool Group::IsLeader(const uint64 guid) const +bool Group::IsLeader(uint64 guid) const { return (GetLeaderGUID() == guid); } @@ -1873,7 +1873,7 @@ bool Group::IsAssistant(uint64 guid) const return mslot->flags & MEMBER_FLAG_ASSISTANT; } -bool Group::SameSubGroup(uint64 guid1, const uint64 guid2) const +bool Group::SameSubGroup(uint64 guid1, uint64 guid2) const { member_citerator mslot2 = _getMemberCSlot(guid2); if (mslot2 == m_memberSlots.end()) diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index ff9114b8c71..083e6e15225 100755 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -191,10 +191,10 @@ class Group void RemoveAllInvites(); bool AddLeaderInvite(Player* player); bool AddMember(Player* player); - bool RemoveMember(const uint64 guid, const RemoveMethod &method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = NULL); - void ChangeLeader(const uint64 guid); + bool RemoveMember(uint64 guid, const RemoveMethod &method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = NULL); + void ChangeLeader(uint64 guid); void SetLootMethod(LootMethod method); - void SetLooterGuid(const uint64 guid); + void SetLooterGuid(uint64 guid); void UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed = false); void SetLootThreshold(ItemQualities threshold); void Disband(bool hideDestroy=false); @@ -217,15 +217,15 @@ class Group uint32 GetDbStoreId() { return m_dbStoreId; }; // member manipulation methods - bool IsMember(const uint64 guid) const; - bool IsLeader(const uint64 guid) const; + bool IsMember(uint64 guid) const; + bool IsLeader(uint64 guid) const; uint64 GetMemberGUID(const std::string& name); bool IsAssistant(uint64 guid) const; - Player* GetInvited(const uint64 guid) const; + Player* GetInvited(uint64 guid) const; Player* GetInvited(const std::string& name) const; - bool SameSubGroup(uint64 guid1, const uint64 guid2) const; + bool SameSubGroup(uint64 guid1, uint64 guid2) const; bool SameSubGroup(uint64 guid1, MemberSlot const* slot2) const; bool SameSubGroup(Player const* member1, Player const* member2) const; bool HasFreeSlotSubGroup(uint8 subgroup) const; @@ -241,7 +241,7 @@ class Group void SetBattlegroundGroup(Battleground *bg); GroupJoinBattlegroundResult CanJoinBattlegroundQueue(Battleground const* bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot); - void ChangeMembersGroup(const uint64 guid, uint8 group); + void ChangeMembersGroup(uint64 guid, uint8 group); void ChangeMembersGroup(Player* player, uint8 group); void SetTargetIcon(uint8 id, uint64 whoGuid, uint64 targetGuid); void SetGroupMemberFlag(uint64 guid, bool apply, GroupMemberFlags flag); @@ -272,8 +272,8 @@ class Group bool isRollLootActive() const; void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r); - void SendLootRoll(const uint64 SourceGuid, const uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r); - void SendLootRollWon(const uint64 SourceGuid, const uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r); + void SendLootRoll(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r); + void SendLootRollWon(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r); void SendLootAllPassed(uint32 NumberOfPlayers, const Roll &r); void SendLooter(Creature *pCreature, Player *pLooter); void GroupLoot(Loot *loot, WorldObject* pLootedObject); @@ -281,7 +281,7 @@ class Group void MasterLoot(Loot *loot, WorldObject* pLootedObject); Rolls::iterator GetRoll(uint64 Guid); void CountTheRoll(Rolls::iterator roll, uint32 NumberOfPlayers); - void CountRollVote(const uint64 playerGUID, const uint64 Guid, uint32 NumberOfPlayers, uint8 Choise); + void CountRollVote(uint64 playerGUID, uint64 Guid, uint32 NumberOfPlayers, uint8 Choise); void EndRoll(Loot *loot); // related to disenchant rolls @@ -301,7 +301,7 @@ class Group void BroadcastGroupUpdate(void); protected: - bool _setMembersGroup(const uint64 guid, uint8 group); + bool _setMembersGroup(uint64 guid, uint8 group); void _homebindIfInstance(Player* player); void _initRaidSubGroupsCounter(); diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index accfba7812a..63aa0f88b14 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -1508,7 +1508,7 @@ void Guild::HandleRemoveMember(WorldSession* session, const std::string& name) SendCommandResult(session, GUILD_QUIT_S, ERR_GUILD_RANK_TOO_HIGH_S, name); else { - const uint64 guid = pMember->GetGUID(); + uint64 guid = pMember->GetGUID(); // After call to DeleteMember pointer to member becomes invalid DeleteMember(guid, false, true); _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), GUID_LOPART(guid)); @@ -1790,7 +1790,7 @@ void Guild::SendBankTabText(WorldSession *session, uint8 tabId) const void Guild::SendPermissions(WorldSession *session) const { - const uint64 guid = session->GetPlayer()->GetGUID(); + uint64 guid = session->GetPlayer()->GetGUID(); uint8 rankId = session->GetPlayer()->GetRank(); WorldPacket data(MSG_GUILD_PERMISSIONS, 4 * 15 + 1); @@ -2063,7 +2063,7 @@ void Guild::BroadcastPacket(WorldPacket* packet) const /////////////////////////////////////////////////////////////////////////////// // Members handling -bool Guild::AddMember(const uint64 guid, uint8 rankId) +bool Guild::AddMember(uint64 guid, uint8 rankId) { Player* player = ObjectAccessor::FindPlayer(guid); // Player cannot be in guild @@ -2132,7 +2132,7 @@ bool Guild::AddMember(const uint64 guid, uint8 rankId) return true; } -void Guild::DeleteMember(const uint64 guid, bool isDisbanding, bool isKicked) +void Guild::DeleteMember(uint64 guid, bool isDisbanding, bool isKicked) { uint32 lowguid = GUID_LOPART(guid); Player* player = ObjectAccessor::FindPlayer(guid); @@ -2188,7 +2188,7 @@ void Guild::DeleteMember(const uint64 guid, bool isDisbanding, bool isKicked) _UpdateAccountsNumber(); } -bool Guild::ChangeMemberRank(const uint64 guid, uint8 newRank) +bool Guild::ChangeMemberRank(uint64 guid, uint8 newRank) { if (newRank <= _GetLowestRankId()) // Validate rank (allow only existing ranks) if (Member* pMember = GetMember(guid)) @@ -2352,7 +2352,7 @@ void Guild::_DeleteBankItems(SQLTransaction& trans, bool removeItemsFromDB) m_bankTabs.clear(); } -bool Guild::_ModifyBankMoney(SQLTransaction& trans, const uint64 amount, bool add) +bool Guild::_ModifyBankMoney(SQLTransaction& trans, uint64 amount, bool add) { if (add) m_bankMoney += amount; @@ -2448,21 +2448,21 @@ inline uint8 Guild::_GetRankBankTabRights(uint8 rankId, uint8 tabId) const return 0; } -inline uint32 Guild::_GetMemberRemainingSlots(const uint64 guid, uint8 tabId) const +inline uint32 Guild::_GetMemberRemainingSlots(uint64 guid, uint8 tabId) const { if (const Member* pMember = GetMember(guid)) return pMember->GetBankRemainingValue(tabId, this); return 0; } -inline uint32 Guild::_GetMemberRemainingMoney(const uint64 guid) const +inline uint32 Guild::_GetMemberRemainingMoney(uint64 guid) const { if (const Member* pMember = GetMember(guid)) return pMember->GetBankRemainingValue(GUILD_BANK_MAX_TABS, this); return 0; } -inline void Guild::_DecreaseMemberRemainingSlots(SQLTransaction& trans, const uint64 guid, uint8 tabId) +inline void Guild::_DecreaseMemberRemainingSlots(SQLTransaction& trans, uint64 guid, uint8 tabId) { // Remaining slots must be more then 0 if (uint32 remainingSlots = _GetMemberRemainingSlots(guid, tabId)) @@ -2472,7 +2472,7 @@ inline void Guild::_DecreaseMemberRemainingSlots(SQLTransaction& trans, const ui pMember->DecreaseBankRemainingValue(trans, tabId, 1); } -inline bool Guild::_MemberHasTabRights(const uint64 guid, uint8 tabId, uint32 rights) const +inline bool Guild::_MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) const { if (const Member* pMember = GetMember(guid)) { @@ -2632,7 +2632,7 @@ bool Guild::_DoItemsMove(MoveItemData* pSrc, MoveItemData* pDest, bool sendError void Guild::_SendBankContent(WorldSession *session, uint8 tabId) const { - const uint64 guid = session->GetPlayer()->GetGUID(); + uint64 guid = session->GetPlayer()->GetGUID(); if (_MemberHasTabRights(guid, tabId, GUILD_BANK_RIGHT_VIEW_TAB)) if (const BankTab* pTab = GetBankTab(tabId)) { @@ -2726,7 +2726,7 @@ void Guild::_SendBankContentUpdate(uint8 tabId, SlotIds slots) const } } -void Guild::_BroadcastEvent(GuildEvents guildEvent, const uint64 guid, const char* param1, const char* param2, const char* param3) const +void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* param1, const char* param2, const char* param3) const { uint8 count = !param3 ? (!param2 ? (!param1 ? 0 : 1) : 2) : 3; diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index f38d444bbb4..40a281bf122 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -257,7 +257,7 @@ private: }; public: - Member(uint32 guildId, const uint64 guid, uint8 rankId) : m_guildId(guildId), m_guid(guid), m_logoutTime(::time(NULL)), m_rankId(rankId) { } + Member(uint32 guildId, uint64 guid, uint8 rankId) : m_guildId(guildId), m_guid(guid), m_logoutTime(::time(NULL)), m_rankId(rankId) { } void SetStats(Player* player); void SetStats(const std::string& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId); @@ -280,7 +280,7 @@ private: inline void UpdateLogoutTime() { m_logoutTime = ::time(NULL); } inline bool IsRank(uint8 rankId) const { return m_rankId == rankId; } inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; } - inline bool IsSamePlayer(const uint64 guid) const { return m_guid == guid; } + inline bool IsSamePlayer(uint64 guid) const { return m_guid == guid; } void DecreaseBankRemainingValue(SQLTransaction& trans, uint8 tabId, uint32 amount); uint32 GetBankRemainingValue(uint8 tabId, const Guild* guild) const; @@ -656,9 +656,9 @@ public: // Members // Adds member to guild. If rankId == GUILD_RANK_NONE, lowest rank is assigned. - bool AddMember(const uint64 guid, uint8 rankId = GUILD_RANK_NONE); - void DeleteMember(const uint64 guid, bool isDisbanding = false, bool isKicked = false); - bool ChangeMemberRank(const uint64 guid, uint8 newRank); + bool AddMember(uint64 guid, uint8 rankId = GUILD_RANK_NONE); + void DeleteMember(uint64 guid, bool isDisbanding = false, bool isKicked = false); + bool ChangeMemberRank(uint64 guid, uint8 newRank); // Bank void SwapItems(Player* player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount); @@ -698,12 +698,12 @@ private: inline BankTab* GetBankTab(uint8 tabId) { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : NULL; } inline const BankTab* GetBankTab(uint8 tabId) const { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : NULL; } - inline const Member* GetMember(const uint64 guid) const + inline const Member* GetMember(uint64 guid) const { Members::const_iterator itr = m_members.find(GUID_LOPART(guid)); return itr != m_members.end() ? itr->second : NULL; } - inline Member* GetMember(const uint64 guid) + inline Member* GetMember(uint64 guid) { Members::iterator itr = m_members.find(GUID_LOPART(guid)); return itr != m_members.end() ? itr->second : NULL; @@ -736,7 +736,7 @@ private: void _UpdateAccountsNumber(); bool _IsLeader(Player* player) const; void _DeleteBankItems(SQLTransaction& trans, bool removeItemsFromDB = false); - bool _ModifyBankMoney(SQLTransaction& trans, const uint64 amount, bool add); + bool _ModifyBankMoney(SQLTransaction& trans, uint64 amount, bool add); void _SetLeaderGUID(Member* pLeader); void _SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay); @@ -747,10 +747,10 @@ private: uint32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const; std::string _GetRankName(uint8 rankId) const; - uint32 _GetMemberRemainingSlots(const uint64 guid, uint8 tabId) const; - uint32 _GetMemberRemainingMoney(const uint64 guid) const; - void _DecreaseMemberRemainingSlots(SQLTransaction& trans, const uint64 guid, uint8 tabId); - bool _MemberHasTabRights(const uint64 guid, uint8 tabId, uint32 rights) const; + uint32 _GetMemberRemainingSlots(uint64 guid, uint8 tabId) const; + uint32 _GetMemberRemainingMoney(uint64 guid) const; + void _DecreaseMemberRemainingSlots(SQLTransaction& trans, uint64 guid, uint8 tabId); + bool _MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) const; void _LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2 = 0, uint8 newRank = 0); void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0); @@ -765,6 +765,6 @@ private: void _SendBankContentUpdate(MoveItemData* pSrc, MoveItemData* pDest) const; void _SendBankContentUpdate(uint8 tabId, SlotIds slots) const; - void _BroadcastEvent(GuildEvents guildEvent, const uint64 guid, const char* param1 = NULL, const char* param2 = NULL, const char* param3 = NULL) const; + void _BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* param1 = NULL, const char* param2 = NULL, const char* param3 = NULL) const; }; #endif diff --git a/src/server/game/Guilds/GuildMgr.cpp b/src/server/game/Guilds/GuildMgr.cpp index 68ea5bfbbcb..8eac07918de 100644 --- a/src/server/game/Guilds/GuildMgr.cpp +++ b/src/server/game/Guilds/GuildMgr.cpp @@ -81,7 +81,7 @@ std::string GuildMgr::GetGuildNameById(uint32 guildId) const return ""; } -Guild* GuildMgr::GetGuildByLeader(const uint64 guid) const +Guild* GuildMgr::GetGuildByLeader(uint64 guid) const { for (GuildContainer::const_iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr) if (itr->second->GetLeaderGUID() == guid) diff --git a/src/server/game/Guilds/GuildMgr.h b/src/server/game/Guilds/GuildMgr.h index ce756fceb69..e53c46cb6be 100644 --- a/src/server/game/Guilds/GuildMgr.h +++ b/src/server/game/Guilds/GuildMgr.h @@ -23,13 +23,14 @@ class GuildMgr { friend class ACE_Singleton<GuildMgr, ACE_Null_Mutex>; +private: GuildMgr(); ~GuildMgr(); public: typedef UNORDERED_MAP<uint32, Guild*> GuildContainer; - Guild* GetGuildByLeader(uint64 const guid) const; + Guild* GetGuildByLeader(uint64 guid) const; Guild* GetGuildById(uint32 guildId) const; Guild* GetGuildByName(const std::string& guildName) const; std::string GetGuildNameById(uint32 guildId) const; diff --git a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp index fe7e6a0f104..cf58f16c445 100755 --- a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp @@ -770,7 +770,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & GROUP_UPDATE_FLAG_AURAS) { - const uint64 auramask = player->GetAuraUpdateMaskForRaid(); + uint64 auramask = player->GetAuraUpdateMaskForRaid(); *data << uint64(auramask); for (uint32 i = 0; i < MAX_AURAS; ++i) { @@ -860,7 +860,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke { if (pet) { - const uint64 auramask = pet->GetAuraUpdateMaskForRaid(); + uint64 auramask = pet->GetAuraUpdateMaskForRaid(); *data << uint64(auramask); for (uint32 i = 0; i < MAX_AURAS; ++i) { diff --git a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp index 67272f4d5ec..f763d5bc966 100755 --- a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp @@ -576,7 +576,6 @@ void WorldSession::HandlePetSetAction(WorldPacket & recv_data) for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr) if ((*itr)->GetEntry() == pet->GetEntry()) (*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, false); - } } diff --git a/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp b/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp index 716aaa9e74f..45d4414d9ed 100755 --- a/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/SpellHandler.cpp @@ -295,12 +295,8 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPacket & recv_data) if (_player->m_mover != _player) return; - GameObject *obj = GetPlayer()->GetMap()->GetGameObject(guid); - - if (!obj) - return; - - obj->Use(_player); + if (GameObject *obj = GetPlayer()->GetMap()->GetGameObject(guid)) + obj->Use(_player); } void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h index 96d6505a764..727e48b2041 100755 --- a/src/server/game/Spells/Auras/SpellAuraDefines.h +++ b/src/server/game/Spells/Auras/SpellAuraDefines.h @@ -22,15 +22,15 @@ enum AURA_FLAGS { - AFLAG_NONE = 0x00, - AFLAG_EFF_INDEX_0 = 0x01, - AFLAG_EFF_INDEX_1 = 0x02, - AFLAG_EFF_INDEX_2 = 0x04, - AFLAG_CASTER = 0x08, - AFLAG_POSITIVE = 0x10, - AFLAG_DURATION = 0x20, - AFLAG_UNK2 = 0x40, - AFLAG_NEGATIVE = 0x80 + AFLAG_NONE = 0x00, + AFLAG_EFF_INDEX_0 = 0x01, + AFLAG_EFF_INDEX_1 = 0x02, + AFLAG_EFF_INDEX_2 = 0x04, + AFLAG_CASTER = 0x08, + AFLAG_POSITIVE = 0x10, + AFLAG_DURATION = 0x20, + AFLAG_ANY_EFFECT_AMOUNT_SENT = 0x40, // used with AFLAG_EFF_INDEX_0/1/2 + AFLAG_NEGATIVE = 0x80 }; // these are modes, in which aura effect handler may be called @@ -221,7 +221,7 @@ enum AuraType SPELL_AURA_NO_PVP_CREDIT = 159, SPELL_AURA_MOD_AOE_AVOIDANCE = 160, SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT = 161, - SPELL_AURA_POWER_BURN_MANA = 162, + SPELL_AURA_POWER_BURN = 162, SPELL_AURA_MOD_CRIT_DAMAGE_BONUS = 163, SPELL_AURA_164 = 164, SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS = 165, @@ -276,7 +276,7 @@ enum AuraType SPELL_AURA_214 = 214, SPELL_AURA_ARENA_PREPARATION = 215, SPELL_AURA_HASTE_SPELLS = 216, - SPELL_AURA_217 = 217, + SPELL_AURA_MOD_MELEE_HASTE_2 = 217, // NYI SPELL_AURA_HASTE_RANGED = 218, SPELL_AURA_MOD_MANA_REGEN_FROM_STAT = 219, SPELL_AURA_MOD_RATING_FROM_STAT = 220, @@ -292,7 +292,7 @@ enum AuraType SPELL_AURA_230 = 230, SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE = 231, SPELL_AURA_MECHANIC_DURATION_MOD = 232, - SPELL_AURA_233 = 233, + SPELL_AURA_CHANGE_MODEL_FOR_ALL_HUMANOIDS = 233, // client-side only SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK = 234, SPELL_AURA_MOD_DISPEL_RESIST = 235, SPELL_AURA_CONTROL_VEHICLE = 236, @@ -335,7 +335,7 @@ enum AuraType SPELL_AURA_X_RAY = 273, SPELL_AURA_ABILITY_CONSUME_NO_AMMO = 274, SPELL_AURA_MOD_IGNORE_SHAPESHIFT = 275, - SPELL_AURA_276 = 276, // Only "Test Mod Damage % Mechanic" spell, possible mod damage done + SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC = 276, // NYI SPELL_AURA_MOD_MAX_AFFECTED_TARGETS = 277, SPELL_AURA_MOD_DISARM_RANGED = 278, SPELL_AURA_INITIALIZE_IMAGES = 279, @@ -367,7 +367,7 @@ enum AuraType SPELL_AURA_MOD_MINIMUM_SPEED = 305, SPELL_AURA_306 = 306, SPELL_AURA_HEAL_ABSORB_TEST = 307, - SPELL_AURA_308 = 308, + SPELL_AURA_MOD_CRIT_CHANCE_FOR_CASTER = 308, // NYI SPELL_AURA_309 = 309, SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE = 310, SPELL_AURA_311 = 311, diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 9c363dccfdf..8b68bff0a56 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -215,7 +215,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]= &AuraEffect::HandleNoImmediateEffect, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell &AuraEffect::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult &AuraEffect::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT - &AuraEffect::HandleNoImmediateEffect, //162 SPELL_AURA_POWER_BURN_MANA implemented in AuraEffect::PeriodicTick + &AuraEffect::HandleNoImmediateEffect, //162 SPELL_AURA_POWER_BURN implemented in AuraEffect::PeriodicTick &AuraEffect::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS &AuraEffect::HandleUnused, //164 unused (3.2.0), only one test spell &AuraEffect::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus @@ -372,7 +372,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]= &AuraEffect::HandleNoImmediateEffect, //316 SPELL_AURA_PERIODIC_HASTE implemented in AuraEffect::CalculatePeriodic }; -AuraEffect::AuraEffect(Aura * base, uint8 effIndex, int32 *baseAmount, Unit* caster): +AuraEffect::AuraEffect(Aura* base, uint8 effIndex, int32 *baseAmount, Unit* caster): m_base(base), m_spellInfo(base->GetSpellInfo()), m_effIndex(effIndex), m_baseAmount(baseAmount ? *baseAmount : m_spellInfo->Effects[m_effIndex].BasePoints), m_canBeRecalculated(true), m_spellmod(NULL), m_isPeriodic(false), @@ -785,7 +785,7 @@ void AuraEffect::CalculatePeriodic(Unit* caster, bool create, bool load) case SPELL_AURA_PERIODIC_HEALTH_FUNNEL: case SPELL_AURA_PERIODIC_MANA_LEECH: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: - case SPELL_AURA_POWER_BURN_MANA: + case SPELL_AURA_POWER_BURN: m_isPeriodic = true; break; case SPELL_AURA_PERIODIC_TRIGGER_SPELL: @@ -1326,8 +1326,8 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit* caster) const case SPELL_AURA_PERIODIC_ENERGIZE: HandlePeriodicEnergizeAuraTick(target, caster); break; - case SPELL_AURA_POWER_BURN_MANA: - HandlePeriodicPowerBurnManaAuraTick(target, caster); + case SPELL_AURA_POWER_BURN: + HandlePeriodicPowerBurnAuraTick(target, caster); break; case SPELL_AURA_DUMMY: // Haunting Spirits @@ -2751,13 +2751,13 @@ void AuraEffect::HandleAuraUntrackable(AuraApplication const* aurApp, uint8 mode Unit* target = aurApp->GetTarget(); if (apply) - target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); + target->SetByteFlag(UNIT_FIELD_BYTES_1, 2, UNIT_STAND_FLAGS_UNTRACKABLE); else { // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit if (target->HasAuraType(GetAuraType())) return; - target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); + target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 2, UNIT_STAND_FLAGS_UNTRACKABLE); } } @@ -6661,7 +6661,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellInfo()); } -void AuraEffect::HandlePeriodicPowerBurnManaAuraTick(Unit* target, Unit* caster) const +void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) const { Powers powerType = Powers(GetMiscValue()); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 86bb325aa3c..bdaeefa71c2 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -290,7 +290,7 @@ class AuraEffect void HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) const; void HandleObsModPowerAuraTick(Unit* target, Unit* caster) const; void HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) const; - void HandlePeriodicPowerBurnManaAuraTick(Unit* target, Unit* caster) const; + void HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) const; // aura effect proc handlers void HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index bff4f222895..e3dd1e83105 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1831,7 +1831,7 @@ bool Aura::CanStackWith(Aura const* existingAura) const case SPELL_AURA_PERIODIC_ENERGIZE: case SPELL_AURA_PERIODIC_MANA_LEECH: case SPELL_AURA_PERIODIC_LEECH: - case SPELL_AURA_POWER_BURN_MANA: + case SPELL_AURA_POWER_BURN: case SPELL_AURA_OBS_MOD_POWER: case SPELL_AURA_OBS_MOD_HEALTH: case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE: @@ -2319,7 +2319,7 @@ void UnitAura::FillTargetMap(std::map<Unit *, uint8> & targets, Unit* caster) if (!GetUnitOwner()->HasUnitState(UNIT_STAT_ISOLATED)) { - switch(GetSpellInfo()->Effects[effIndex].Effect) + switch (GetSpellInfo()->Effects[effIndex].Effect) { case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: targetList.push_back(GetUnitOwner()); diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 8192325af90..1c22a31e791 100755 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -175,9 +175,9 @@ class Aura // Helpers for targets ApplicationMap const & GetApplicationMap() {return m_applications;} void GetApplicationList(std::list<AuraApplication*> & applicationList) const; - const AuraApplication * GetApplicationOfTarget (uint64 const guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; } - AuraApplication * GetApplicationOfTarget (uint64 const guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; } - bool IsAppliedOnTarget(uint64 const guid) const { return m_applications.find(guid) != m_applications.end(); } + const AuraApplication * GetApplicationOfTarget (uint64 guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; } + AuraApplication * GetApplicationOfTarget (uint64 guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; } + bool IsAppliedOnTarget(uint64 guid) const { return m_applications.find(guid) != m_applications.end(); } void SetNeedClientUpdateForTargets() const; void HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, bool apply, bool onReapply); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index dce30a29693..ed36a4ae208 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -551,8 +551,8 @@ m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharme m_autoRepeat = m_spellInfo->IsAutoRepeatRangedSpell(); m_runesState = 0; - m_powerCost = 0; // setup to correct value in Spell::prepare, don't must be used before. - m_casttime = 0; // setup to correct value in Spell::prepare, don't must be used before. + m_powerCost = 0; // setup to correct value in Spell::prepare, must not be used before. + m_casttime = 0; // setup to correct value in Spell::prepare, must not be used before. m_timer = 0; // will set to castime in prepare m_channelTargetEffectMask = 0; @@ -1237,18 +1237,16 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) } // Do not take combo points on dodge and miss - if (m_needComboPoints && m_targets.GetUnitTargetGUID() == target->targetGUID) - if (missInfo != SPELL_MISS_NONE) - { - m_needComboPoints = false; - // Restore spell mods for a miss/dodge/parry Cold Blood - // TODO: check how broad this rule should be - if (m_caster->GetTypeId() == TYPEID_PLAYER) - if ((missInfo == SPELL_MISS_MISS) || - (missInfo == SPELL_MISS_DODGE) || - (missInfo == SPELL_MISS_PARRY)) - m_caster->ToPlayer()->RestoreSpellMods(this, 14177); - } + if (missInfo != SPELL_MISS_NONE && m_needComboPoints && + m_targets.GetUnitTargetGUID() == target->targetGUID) + { + m_needComboPoints = false; + // Restore spell mods for a miss/dodge/parry Cold Blood + // TODO: check how broad this rule should be + if (m_caster->GetTypeId() == TYPEID_PLAYER && (missInfo == SPELL_MISS_MISS || + missInfo == SPELL_MISS_DODGE || missInfo == SPELL_MISS_PARRY)) + m_caster->ToPlayer()->RestoreSpellMods(this, 14177); + } // Trigger info was not filled in spell::preparedatafortriggersystem - we do it now if (canEffectTrigger && !procAttacker && !procVictim) @@ -1546,8 +1544,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool ((UnitAura*)m_spellAura)->SetDiminishGroup(m_diminishGroup); bool positive = m_spellAura->GetSpellInfo()->IsPositive(); - AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID()); - if (aurApp) + if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID())) positive = aurApp->IsPositive(); duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive); @@ -3307,6 +3304,11 @@ void Spell::handle_immediate() // Remove used for cast item if need (it can be already NULL after TakeReagents call TakeCastItem(); + // handle ammo consumption for Hunter's volley spell + if (m_spellInfo->IsRangedWeaponSpell() && m_spellInfo->IsChanneled()) + TakeAmmo(); + + if (m_spellState != SPELL_STATE_CASTING) finish(true); // successfully finish spell cast (not last in case autorepeat or channel spell) } @@ -4578,7 +4580,7 @@ void Spell::HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOT SpellCastResult Spell::CheckCast(bool strict) { // check death state - if (!m_caster->isAlive() && !(m_spellInfo->Attributes & SPELL_ATTR0_PASSIVE) && !(m_spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)) + if (!m_caster->isAlive() && !(m_spellInfo->Attributes & SPELL_ATTR0_PASSIVE) && !((m_spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD) || (IsTriggered() && !m_triggeredByAuraSpell))) return SPELL_FAILED_CASTER_DEAD; // check cooldowns to prevent cheating @@ -6377,7 +6379,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const break; } - if (m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) + if (IsTriggered() || m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) return true; // todo: shit below shouldn't be here, but it's temporary @@ -6609,6 +6611,10 @@ void Spell::CalculateDamageDoneForAllTargets() if (!unit) // || !unit->isAlive()) do we need to check alive here? continue; + // do not consume ammo anymore for Hunter's volley spell + if (IsTriggered() && m_spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellInfo->IsAOE()) + usesAmmo = false; + if (usesAmmo) { bool ammoTaken = false; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index dbeb7407031..04e90d2083b 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1648,7 +1648,7 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, Unit const* target, b } // check UNIT_FLAG_NON_ATTACKABLE flag - a player can cast spells on his pet (or other controlled unit) though in any state - if (target != caster && target->GetCharmerOrOwnerGUID() != caster->GetGUID()) + if (!IsPositive() && target != caster && target->GetCharmerOrOwnerGUID() != caster->GetGUID()) { // any unattackable target skipped if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index da96f5df537..85ee259fcc9 100755 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -84,10 +84,10 @@ public: bool IsClosed() const { return _closedBy; } bool IsCompleted() const { return _completed; } - bool IsFromPlayer(const uint64 guid) const { return guid == _playerGuid; } + bool IsFromPlayer(uint64 guid) const { return guid == _playerGuid; } bool IsAssigned() const { return _assignedTo != 0; } - bool IsAssignedTo(const uint64 guid) const { return guid == _assignedTo; } - bool IsAssignedNotTo(const uint64 guid) const { return IsAssigned() && !IsAssignedTo(guid); } + bool IsAssignedTo(uint64 guid) const { return guid == _assignedTo; } + bool IsAssignedNotTo(uint64 guid) const { return IsAssigned() && !IsAssignedTo(guid); } uint32 GetId() const { return _id; } Player* GetPlayer() const { return ObjectAccessor::FindPlayer(_playerGuid); } @@ -108,7 +108,7 @@ public: GMTicketEscalationStatus GetEscalatedStatus() const { return _escalatedStatus; } void SetEscalatedStatus(GMTicketEscalationStatus escalatedStatus) { _escalatedStatus = escalatedStatus; } - void SetAssignedTo(const uint64 guid, bool isAdmin) + void SetAssignedTo(uint64 guid, bool isAdmin) { _assignedTo = guid; if (isAdmin && _escalatedStatus == TICKET_IN_ESCALATION_QUEUE) @@ -178,7 +178,7 @@ public: return NULL; } - GmTicket* GetTicketByPlayer(const uint64 playerGuid) + GmTicket* GetTicketByPlayer(uint64 playerGuid) { for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr) if (itr->second && itr->second->IsFromPlayer(playerGuid) && !itr->second->IsClosed()) diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index c63e47fbc50..17bc0daec5b 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -282,11 +282,7 @@ public: return false; } - std::string password_old = old_pass; - std::string password_new = new_pass; - std::string password_new_c = new_pass_c; - - if (!sAccountMgr->CheckPassword(handler->GetSession()->GetAccountId(), password_old)) + if (!sAccountMgr->CheckPassword(handler->GetSession()->GetAccountId(), std::string(old_pass))) { handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); handler->SetSentErrorMessage(true); @@ -300,7 +296,7 @@ public: return false; } - AccountOpResult result = sAccountMgr->ChangePassword(handler->GetSession()->GetAccountId(), password_new); + AccountOpResult result = sAccountMgr->ChangePassword(handler->GetSession()->GetAccountId(), std::string(new_pass)); switch(result) { case AOR_OK: diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index a3e862c0812..55b85a888d2 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -261,15 +261,58 @@ public: if (ifs.bad()) return false; + // remove comments from file + std::stringstream parsedStream; + while (!ifs.eof()) + { + char commentToken[2]; + ifs.get(commentToken[0]); + if (commentToken[0] == '/' && !ifs.eof()) + { + ifs.get(commentToken[1]); + // /* comment + if (commentToken[1] == '*') + { + while (!ifs.eof()) + { + ifs.get(commentToken[0]); + if (commentToken[0] == '*' && !ifs.eof()) + { + ifs.get(commentToken[1]); + if (commentToken[1] == '/') + break; + else + ifs.putback(commentToken[1]); + } + } + continue; + } + // line comment + else if (commentToken[1] == '/') + { + std::string str; + getline(ifs,str); + continue; + } + // regular data + else + { + ifs.putback(commentToken[1]); + } + } + parsedStream.put(commentToken[0]); + } + ifs.close(); + uint32 opcode; - ifs >> opcode; + parsedStream >> opcode; WorldPacket data(opcode, 0); - while (!ifs.eof()) + while (!parsedStream.eof()) { std::string type; - ifs >> type; + parsedStream >> type; if (type == "") break; @@ -277,37 +320,37 @@ public: if (type == "uint8") { uint16 val1; - ifs >> val1; + parsedStream >> val1; data << uint8(val1); } else if (type == "uint16") { uint16 val2; - ifs >> val2; + parsedStream >> val2; data << val2; } else if (type == "uint32") { uint32 val3; - ifs >> val3; + parsedStream >> val3; data << val3; } else if (type == "uint64") { uint64 val4; - ifs >> val4; + parsedStream >> val4; data << val4; } else if (type == "float") { float val5; - ifs >> val5; + parsedStream >> val5; data << val5; } else if (type == "string") { std::string val6; - ifs >> val6; + parsedStream >> val6; data << val6; } else if (type == "appitsguid") @@ -350,7 +393,7 @@ public: { data << uint64(unit->GetGUID()); } - else if (type == "pos") + else if (type == "itspos") { data << unit->GetPositionX(); data << unit->GetPositionY(); @@ -368,7 +411,6 @@ public: break; } } - ifs.close(); sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending opcode %u", data.GetOpcode()); data.hexlike(); player->GetSession()->SendPacket(&data); @@ -1012,20 +1054,19 @@ public: handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); return false; } - uint32 iValue; - float fValue; + bool isint32 = true; if (pz) isint32 = (bool)atoi(pz); if (isint32) { - iValue = (uint32)atoi(py); + uint32 iValue = (uint32)atoi(py); target->SetUInt32Value(Opcode , iValue); handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); } else { - fValue = (float)atof(py); + float fValue = (float)atof(py); target->SetFloatValue(Opcode , fValue); handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); } @@ -1060,20 +1101,19 @@ public: handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); return false; } - uint32 iValue; - float fValue; + bool isint32 = true; if (pz) isint32 = (bool)atoi(pz); if (isint32) { - iValue = target->GetUInt32Value(Opcode); + uint32 iValue = target->GetUInt32Value(Opcode); handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); } else { - fValue = target->GetFloatValue(Opcode); + float fValue = target->GetFloatValue(Opcode); handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); } diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 4dbc47de4ce..184e24c1488 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -199,7 +199,7 @@ public: } static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/) { - uint32 guidlow = 0; + Creature* target = handler->getSelectedCreature(); if (!target) @@ -208,11 +208,13 @@ public: return true; } + uint32 guidlow = target->GetDBTableGUIDLow(); + if (target->GetCreatureAddon()) { if (target->GetCreatureAddon()->path_id != 0) { - WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow()); + WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", guidlow); target->UpdateWaypointID(0); WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow); target->LoadPath(0); @@ -373,8 +375,6 @@ public: return true; } - float coord; - if (arg_str_2 == "setid") { uint32 newid = atoi(arg_3); @@ -394,33 +394,29 @@ public: if (arg_str_2 == "posx") { - coord = (float)(atof(arg_3)); WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'", - coord, id); + (float)(atof(arg_3)), id); handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id); return true; } else if (arg_str_2 == "posy") { - coord = (float)(atof(arg_3)); WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'", - coord, id); + (float)(atof(arg_3)), id); handler->PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id); return true; } else if (arg_str_2 == "posz") { - coord = (float)(atof(arg_3)); WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'", - coord, id); + (float)(atof(arg_3)), id); handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id); return true; } else if (arg_str_2 == "orientation") { - coord = (float)(atof(arg_3)); WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'", - coord, id); + (float)(atof(arg_3)), id); handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id); return true; } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index dfa28111935..c8a38164126 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -189,7 +189,7 @@ public: std::vector<Unit*> targets; std::list<HostileReference *> t_list = me->getThreatManager().getThreatList(); - if (!t_list.size()) + if (t_list.empty()) return; //store the threat list in a different container diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 493e4b8f28e..7faa8df44bf 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -297,7 +297,7 @@ public: uint64 prisonerGUID; - void SetGUID(const uint64 guid, int32 /*id*/) + void SetGUID(uint64 guid, int32 /*id*/) { if (!prisonerGUID) prisonerGUID = guid; @@ -883,7 +883,7 @@ public: uint64 minerGUID; - void SetGUID(const uint64 guid, int32 /*id*/) + void SetGUID(uint64 guid, int32 /*id*/) { minerGUID = guid; } diff --git a/src/server/scripts/Kalimdor/the_barrens.cpp b/src/server/scripts/Kalimdor/the_barrens.cpp index f341e47c5e8..4fb76c9c610 100644 --- a/src/server/scripts/Kalimdor/the_barrens.cpp +++ b/src/server/scripts/Kalimdor/the_barrens.cpp @@ -490,7 +490,7 @@ public: if (Wave_Timer <= diff) { - if (AffrayChallenger[Wave] && Wave < 6 && !EventBigWill) + if (Wave < 6 && AffrayChallenger[Wave] && !EventBigWill) { DoScriptText(SAY_TWIGGY_FLATHEAD_FRAY, me); Creature* creature = Unit::GetCreature((*me), AffrayChallenger[Wave]); diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp index a4ded3f65b0..e3f6bbbfdd0 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp @@ -195,7 +195,7 @@ public: case NORMAL: if (uiBloodthirstTimer <= diff) { - DoCast(me->getVictim(), SPELL_BLOODTHIRST); + DoCast(me, SPELL_BLOODTHIRST); uiBloodthirstTimer = 10*IN_MILLISECONDS; } else uiBloodthirstTimer -= diff; 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 44385ea83e2..6d1c2b5d991 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -25,8 +25,7 @@ EndScriptData */ // Known bugs: // - They should be floating but they aren't respecting the floor =( -// - Lacks the powering up effect that leads to Empowering -// - There's a workaround for the shared life effect +// - Hardcoded bullets spawner #include "ScriptPCH.h" #include "trial_of_the_crusader.h" @@ -48,26 +47,26 @@ enum Yells enum Equipment { - EQUIP_MAIN_1 = 49303, - EQUIP_OFFHAND_1 = 47146, - EQUIP_RANGED_1 = 47267, - EQUIP_MAIN_2 = 45990, - EQUIP_OFFHAND_2 = 47470, - EQUIP_RANGED_2 = 47267, - EQUIP_DONE = EQUIP_NO_CHANGE, + EQUIP_MAIN_1 = 9423, + EQUIP_MAIN_2 = 37377, }; enum Summons { - NPC_DARK_ESSENCE = 34567, - NPC_LIGHT_ESSENCE = 34568, - NPC_UNLEASHED_DARK = 34628, NPC_UNLEASHED_LIGHT = 34630, + + // Future Development + NPC_BULLET_CONTROLLER = 34743, // Npc controller for all bullets + + NPC_BULLET_STALKER_DARK = 34704, // Npc spawner for dark bullets + NPC_BULLET_STALKER_LIGHT = 34720, // Npc spawner for light bullets }; enum BossSpells { + SPELL_CONTROLLER_PERIODIC = 66149, // Future Development + SPELL_LIGHT_TWIN_SPIKE = 66075, SPELL_LIGHT_SURGE = 65766, SPELL_LIGHT_SHIELD = 65858, @@ -79,6 +78,7 @@ enum BossSpells SPELL_DARK_SURGE = 65768, SPELL_DARK_SHIELD = 65874, SPELL_DARK_TWIN_PACT = 65875, + SPELL_POWER_TWINS = 65879, SPELL_DARK_VORTEX = 66058, SPELL_DARK_TOUCH = 67282, @@ -93,12 +93,19 @@ enum BossSpells SPELL_UNLEASHED_DARK = 65808, SPELL_UNLEASHED_LIGHT = 65795, - //PowerUp 67604 + + SPELL_TWIN_EMPATHY_1 = 66132, + SPELL_TWIN_EMPATHY_2 = 66133, + + SPELL_POWERING_UP = 67590, + SPELL_SURGE_OF_SPEED = 65828, }; #define SPELL_DARK_ESSENCE_HELPER RAID_MODE<uint32>(65684, 67176, 67177, 67178) #define SPELL_LIGHT_ESSENCE_HELPER RAID_MODE<uint32>(65686, 67222, 67223, 67224) +#define SPELL_POWERING_UP_HELPER RAID_MODE(67590, 67602, 67603, 67604) + #define SPELL_EMPOWERED_DARK_HELPER RAID_MODE<uint32>(65724,67213,67214,67215) #define SPELL_EMPOWERED_LIGHT_HELPER RAID_MODE<uint32>(65748, 67216, 67217, 67218) @@ -122,9 +129,12 @@ struct boss_twin_baseAI : public ScriptedAI InstanceScript* m_pInstance; SummonList Summons; + AuraStateType m_uiAuraState; + uint8 m_uiStage; bool m_bIsBerserk; uint8 m_uiWaveCount; + uint32 m_uiWeapon; uint32 m_uiColorballsTimer; uint32 m_uiSpecialAbilityTimer; uint32 m_uiSpikeTimer; @@ -135,6 +145,7 @@ struct boss_twin_baseAI : public ScriptedAI int32 m_uiVortexEmote; uint32 m_uiSisterNpcId; uint32 m_uiColorballNpcId; + uint32 m_uiMyEmphatySpellId; uint32 m_uiEssenceNpcId; uint32 m_uiMyEssenceSpellId; uint32 m_uiOtherEssenceSpellId; @@ -152,6 +163,7 @@ struct boss_twin_baseAI : public ScriptedAI void Reset() { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_OOC_NOT_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->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->SetFlying(true); */ @@ -172,7 +184,6 @@ struct boss_twin_baseAI : public ScriptedAI if (m_pInstance) { m_pInstance->SetData(TYPE_VALKIRIES, FAIL); - m_pInstance->SetData(DATA_HEALTH_TWIN_SHARED, me->GetMaxHealth()); } me->DespawnOrUnsummon(); } @@ -190,7 +201,6 @@ struct boss_twin_baseAI : public ScriptedAI case 1: me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_OOC_NOT_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_AGGRESSIVE); - me->SetInCombatWithZone(); break; } } @@ -223,45 +233,16 @@ struct boss_twin_baseAI : public ScriptedAI { case NPC_LIGHT_ESSENCE: m_pInstance->DoRemoveAurasDueToSpellOnPlayers(SPELL_LIGHT_ESSENCE_HELPER); + m_pInstance->DoRemoveAurasDueToSpellOnPlayers(SPELL_POWERING_UP_HELPER); break; case NPC_DARK_ESSENCE: m_pInstance->DoRemoveAurasDueToSpellOnPlayers(SPELL_DARK_ESSENCE_HELPER); + m_pInstance->DoRemoveAurasDueToSpellOnPlayers(SPELL_POWERING_UP_HELPER); break; } Summons.Despawn(summoned); } - void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) - { - if (!me || !me->isAlive()) - return; - - if (pDoneBy->GetGUID() == me->GetGUID()) - return; - - if (pDoneBy->GetTypeId() == TYPEID_PLAYER) - { - if (pDoneBy->HasAura(m_uiOtherEssenceSpellId)) - uiDamage += uiDamage/2; - if (pDoneBy->HasAura(m_uiEmpoweredWeaknessSpellId)) - uiDamage += uiDamage; - else - if (pDoneBy->HasAura(m_uiMyEssenceSpellId)) - uiDamage /= 2; - } - - if (m_pInstance) - m_pInstance->SetData(DATA_HEALTH_TWIN_SHARED, me->GetHealth() >= uiDamage ? me->GetHealth() - uiDamage : 0); - } - - void SpellHit(Unit* caster, const SpellInfo* spell) - { - if (caster->ToCreature() == me) - if (spell->Effects[0].Effect == 136) //Effect Heal - if (m_pInstance) - m_pInstance->SetData(DATA_HEALTH_TWIN_SHARED, me->GetHealth() + me->CountPctFromMaxHealth(spell->Effects[EFFECT_0].CalcValue())); - } - void SummonColorballs(uint8 quantity) { float x0 = ToCCommonLoc[1].GetPositionX(), y0 = ToCCommonLoc[1].GetPositionY(), r = 47.0f; @@ -282,7 +263,6 @@ struct boss_twin_baseAI : public ScriptedAI DoScriptText(SAY_DEATH, me); if (m_pInstance) { - m_pInstance->SetData(DATA_HEALTH_TWIN_SHARED, 0); if (Creature* pSister = GetSister()) { if (!pSister->isAlive()) @@ -307,8 +287,10 @@ struct boss_twin_baseAI : public ScriptedAI me->SetInCombatWithZone(); if (m_pInstance) { + if (Creature* pSister = GetSister()) + me->AddAura(m_uiMyEmphatySpellId, pSister); + m_pInstance->SetData(TYPE_VALKIRIES, IN_PROGRESS); - m_pInstance->SetData(DATA_HEALTH_TWIN_SHARED, me->GetMaxHealth()); } if (me->isAlive()) { @@ -333,16 +315,18 @@ struct boss_twin_baseAI : public ScriptedAI } } + void EnableDualWield(bool mode) + { + SetEquipmentSlots(false, m_uiWeapon, mode ? m_uiWeapon : EQUIP_UNEQUIP, EQUIP_UNEQUIP); + me->SetCanDualWield(mode); + me->UpdateDamagePhysical(mode ? OFF_ATTACK : BASE_ATTACK); + } + void UpdateAI(const uint32 uiDiff) { if (!m_pInstance || !UpdateVictim()) return; - if (m_pInstance->GetData(DATA_HEALTH_TWIN_SHARED) != 0) - me->SetHealth(m_pInstance->GetData(DATA_HEALTH_TWIN_SHARED)); - else - me->SetHealth(1); - switch (m_uiStage) { case 0: @@ -364,10 +348,13 @@ struct boss_twin_baseAI : public ScriptedAI case 2: // Shield+Pact if (m_uiSpecialAbilityTimer <= uiDiff) { - if (Creature* pSister = GetSister()) - pSister->AI()->DoAction(ACTION_PACT); DoScriptText(EMOTE_SHIELD, me); DoScriptText(SAY_SHIELD, me); + if (Creature* pSister = GetSister()) + { + pSister->AI()->DoAction(ACTION_PACT); + pSister->CastSpell(pSister, SPELL_POWER_TWINS, false); + } DoCast(me, m_uiShieldSpellId); DoCast(me, m_uiTwinPactSpellId); m_uiStage = 0; @@ -447,13 +434,16 @@ public: void Reset() { boss_twin_baseAI::Reset(); - SetEquipmentSlots(false, EQUIP_MAIN_1, EQUIP_OFFHAND_1, EQUIP_RANGED_1); + 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_LIGHT_VORTEX; m_uiVortexSay = SAY_LIGHT_VORTEX; m_uiSisterNpcId = NPC_DARKBANE; m_uiColorballNpcId = NPC_UNLEASHED_LIGHT; m_uiEssenceNpcId = NPC_LIGHT_ESSENCE; + m_uiMyEmphatySpellId = SPELL_TWIN_EMPATHY_1; m_uiMyEssenceSpellId = SPELL_LIGHT_ESSENCE_HELPER; m_uiOtherEssenceSpellId = SPELL_DARK_ESSENCE_HELPER; m_uiEmpoweredWeaknessSpellId = SPELL_EMPOWERED_DARK_HELPER; @@ -506,13 +496,16 @@ public: void Reset() { boss_twin_baseAI::Reset(); - SetEquipmentSlots(false, EQUIP_MAIN_2, EQUIP_OFFHAND_2, EQUIP_RANGED_2); + 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_DARK_VORTEX; m_uiVortexSay = SAY_DARK_VORTEX; m_uiSisterNpcId = NPC_LIGHTBANE; m_uiColorballNpcId = NPC_UNLEASHED_DARK; m_uiEssenceNpcId = NPC_DARK_ESSENCE; + m_uiMyEmphatySpellId = SPELL_TWIN_EMPATHY_2; m_uiMyEssenceSpellId = SPELL_DARK_ESSENCE_HELPER; m_uiOtherEssenceSpellId = SPELL_LIGHT_ESSENCE_HELPER; m_uiEmpoweredWeaknessSpellId = SPELL_EMPOWERED_LIGHT_HELPER; @@ -654,6 +647,12 @@ public: } else m_uiRangeCheckTimer -= uiDiff; } + + void SpellHitTarget(Unit* who, const SpellInfo* spell) + { + if (who->HasAura(SPELL_DARK_ESSENCE_HELPER)) + who->CastSpell(who, SPELL_POWERING_UP, true); + } }; }; @@ -687,10 +686,173 @@ public: } else m_uiRangeCheckTimer -= uiDiff; } + + void SpellHitTarget(Unit* who, const SpellInfo* spell) + { + if (who->HasAura(SPELL_LIGHT_ESSENCE_HELPER)) + who->CastSpell(who, SPELL_POWERING_UP, true); + } }; }; +class spell_powering_up : public SpellScriptLoader +{ + public: + spell_powering_up() : SpellScriptLoader("spell_powering_up") { } + + class spell_powering_up_AuraScript : public AuraScript + { + PrepareAuraScript(spell_powering_up_AuraScript); + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + 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); + + target->RemoveAurasDueToSpell(GetId()); + } + } + } + } + + void Register() + { + OnEffectApply += AuraEffectApplyFn(spell_powering_up_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_powering_up_AuraScript(); + } + + class spell_powering_up_SpellScript : public SpellScript + { + public: + PrepareSpellScript(spell_powering_up_SpellScript) + + uint32 spellId; + + bool Validate(SpellEntry const * /*spellEntry*/) + { + spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_SURGE_OF_SPEED, GetCaster()); + if (!sSpellMgr->GetSpellInfo(spellId)) + return false; + return true; + } + + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetTargetUnit()) + if (urand(0, 99) < 15) + target->CastSpell(target, spellId, true); + } + + void Register() + { + OnEffect += SpellEffectFn(spell_powering_up_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_powering_up_SpellScript(); + } +}; + +class spell_valkyr_essences : public SpellScriptLoader +{ + public: + spell_valkyr_essences() : SpellScriptLoader("spell_valkyr_essences") { } + + class spell_valkyr_essences_AuraScript : public AuraScript + { + PrepareAuraScript(spell_valkyr_essences_AuraScript); + + uint32 spellId; + + bool Load() + { + spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_SURGE_OF_SPEED, GetCaster()); + if (!sSpellMgr->GetSpellInfo(spellId)) + return false; + return true; + } + + void Absorb(AuraEffect * /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & /*absorbAmount*/) + { + if (urand(0, 99) < 5) + GetTarget()->CastSpell(GetTarget(), spellId, true); + } + + void Register() + { + OnEffectAbsorb += AuraEffectAbsorbFn(spell_valkyr_essences_AuraScript::Absorb, EFFECT_0); + } + }; + + AuraScript *GetAuraScript() const + { + return new spell_valkyr_essences_AuraScript(); + } +}; + +class spell_power_of_the_twins : public SpellScriptLoader +{ + public: + spell_power_of_the_twins() : SpellScriptLoader("spell_power_of_the_twins") { } + + class spell_power_of_the_twins_AuraScript : public AuraScript + { + PrepareAuraScript(spell_power_of_the_twins_AuraScript); + + bool Load() + { + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } + + void HandleEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + { + if (Creature* Valk = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(GetCaster()->GetEntry()))) + CAST_AI(boss_twin_baseAI, Valk->AI())->EnableDualWield(true); + } + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + { + if (Creature* Valk = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(GetCaster()->GetEntry()))) + CAST_AI(boss_twin_baseAI, Valk->AI())->EnableDualWield(false); + } + } + + void Register() + { + AfterEffectApply += AuraEffectApplyFn(spell_power_of_the_twins_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_power_of_the_twins_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + + } + }; + + AuraScript *GetAuraScript() const + { + return new spell_power_of_the_twins_AuraScript(); + } +}; + void AddSC_boss_twin_valkyr() { new boss_fjola(); @@ -698,4 +860,7 @@ void AddSC_boss_twin_valkyr() new mob_unleashed_light(); new mob_unleashed_dark(); new mob_essence_of_twin(); + 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 e4d7d051676..91cd8dee55c 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 @@ -44,10 +44,6 @@ class instance_trial_of_the_crusader : public InstanceMapScript std::string SaveDataBuffer; bool NeedSave; - uint32 DataDamageTwin; - uint32 FjolaCasting; - uint32 EydisCasting; - uint64 BarrentGUID; uint64 TirionGUID; uint64 FizzlebangGUID; @@ -368,11 +364,6 @@ class instance_trial_of_the_crusader : public InstanceMapScript break; } break; - case DATA_HEALTH_TWIN_SHARED: - DataDamageTwin = data; - data = NOT_STARTED; - break; - //Achievements case DATA_SNOBOLD_COUNT: if (data == INCREASE) @@ -584,8 +575,6 @@ class instance_trial_of_the_crusader : public InstanceMapScript break; }; return EventNPCId; - case DATA_HEALTH_TWIN_SHARED: - return DataDamageTwin; default: break; } 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 bdccc540bb6..34c065f5649 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 @@ -745,24 +745,36 @@ class npc_tirion_toc : public CreatureScript break; case 4010: DoScriptText(SAY_STAGE_3_02, me); - m_pInstance->DoUseDoorOrButton(m_pInstance->GetData64(GO_MAIN_GATE_DOOR)); + if(Creature* pTemp = me->SummonCreature(NPC_LIGHTBANE, ToCCommonLoc[3].GetPositionX(), ToCCommonLoc[3].GetPositionY(), ToCCommonLoc[3].GetPositionZ(), 5, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME)) + { + pTemp->SetVisible(false); + pTemp->SetReactState(REACT_PASSIVE); + pTemp->SummonCreature(NPC_LIGHT_ESSENCE, TwinValkyrsLoc[0].GetPositionX(), TwinValkyrsLoc[0].GetPositionY(), TwinValkyrsLoc[0].GetPositionZ()); + pTemp->SummonCreature(NPC_LIGHT_ESSENCE, TwinValkyrsLoc[1].GetPositionX(), TwinValkyrsLoc[1].GetPositionY(), TwinValkyrsLoc[1].GetPositionZ()); + } + if(Creature* pTemp = me->SummonCreature(NPC_DARKBANE, ToCCommonLoc[4].GetPositionX(), ToCCommonLoc[4].GetPositionY(), ToCCommonLoc[4].GetPositionZ(), 5, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME)) + { + pTemp->SetVisible(false); + pTemp->SetReactState(REACT_PASSIVE); + pTemp->SummonCreature(NPC_DARK_ESSENCE, TwinValkyrsLoc[2].GetPositionX(), TwinValkyrsLoc[2].GetPositionY(), TwinValkyrsLoc[2].GetPositionZ()); + pTemp->SummonCreature(NPC_DARK_ESSENCE, TwinValkyrsLoc[3].GetPositionX(), TwinValkyrsLoc[3].GetPositionY(), TwinValkyrsLoc[3].GetPositionZ()); + } m_uiUpdateTimer = 3000; m_pInstance->SetData(TYPE_EVENT, 4015); break; case 4015: - me->SummonCreature(NPC_LIGHTBANE, ToCCommonLoc[3].GetPositionX(), ToCCommonLoc[3].GetPositionY(), ToCCommonLoc[3].GetPositionZ(), 5, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); + m_pInstance->DoUseDoorOrButton(m_pInstance->GetData64(GO_MAIN_GATE_DOOR)); if (Creature* pTemp = Unit::GetCreature((*me), m_pInstance->GetData64(NPC_LIGHTBANE))) { pTemp->GetMotionMaster()->MovePoint(0, ToCCommonLoc[6].GetPositionX(), ToCCommonLoc[6].GetPositionY(), ToCCommonLoc[6].GetPositionZ()); pTemp->AddUnitMovementFlag(MOVEMENTFLAG_WALKING); - me->SetReactState(REACT_PASSIVE); + pTemp->SetVisible(true); } - me->SummonCreature(NPC_DARKBANE, ToCCommonLoc[4].GetPositionX(), ToCCommonLoc[4].GetPositionY(), ToCCommonLoc[4].GetPositionZ(), 5, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME); if (Creature* pTemp = Unit::GetCreature((*me), m_pInstance->GetData64(NPC_DARKBANE))) { pTemp->GetMotionMaster()->MovePoint(0, ToCCommonLoc[7].GetPositionX(), ToCCommonLoc[7].GetPositionY(), ToCCommonLoc[7].GetPositionZ()); pTemp->AddUnitMovementFlag(MOVEMENTFLAG_WALKING); - me->SetReactState(REACT_PASSIVE); + pTemp->SetVisible(true); } m_uiUpdateTimer = 5000; m_pInstance->SetData(TYPE_EVENT, 4016); 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 ab9087c0ca8..a0ee721a26a 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 @@ -22,8 +22,6 @@ enum TYPE_EVENT_NPC = 102, TYPE_NORTHREND_BEASTS = 103, - DATA_HEALTH_TWIN_SHARED = 201, - DATA_SNOBOLD_COUNT = 301, DATA_MISTRESS_OF_PAIN_COUNT = 302, DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE = 303, @@ -210,6 +208,9 @@ enum eCreature NPC_LIGHTBANE = 34497, NPC_DARKBANE = 34496, + NPC_DARK_ESSENCE = 34567, + NPC_LIGHT_ESSENCE = 34568, + NPC_ANUBARAK = 34564, }; diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp index f8aaf0ee363..c34528530bd 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp @@ -204,12 +204,11 @@ class mob_corrupted_soul_fragment : public CreatureScript if (type != TARGETED_MOTION_TYPE) return; - uint64 BronjahmGUID = 0; if (instance) { if (TempSummon* summ = me->ToTempSummon()) { - BronjahmGUID = instance->GetData64(DATA_BRONJAHM); + uint64 BronjahmGUID = instance->GetData64(DATA_BRONJAHM); if (GUID_LOPART(BronjahmGUID) != id) return; 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 fcee11c8774..7a6aefe90fb 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp @@ -318,7 +318,7 @@ class boss_rimefang : public CreatureScript _EnterEvadeMode(); } - void SetGUID(const uint64 guid, int32 type) + void SetGUID(uint64 guid, int32 type) { if (type == GUID_HOARFROST) { @@ -384,7 +384,7 @@ class player_overlord_brandAI : public PlayerAI tyrannus = NULL; } - void SetGUID(const uint64 guid, int32 /*type*/) + void SetGUID(uint64 guid, int32 /*type*/) { tyrannus = ObjectAccessor::GetCreature(*me, guid); if (!tyrannus) 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 411f9cc7d04..35c2d40494a 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -425,6 +425,9 @@ class boss_prince_keleseth_icc : public CreatureScript void JustDied(Unit* /*killer*/) { + events.Reset(); + summons.DespawnAll(); + Talk(SAY_KELESETH_DEATH); instance->SendEncounterUnit(ENCOUNTER_FRAME_REMOVE, me); } @@ -646,6 +649,9 @@ class boss_prince_taldaram_icc : public CreatureScript void JustDied(Unit* /*killer*/) { + events.Reset(); + summons.DespawnAll(); + Talk(EMOTE_TALDARAM_DEATH); instance->SendEncounterUnit(ENCOUNTER_FRAME_REMOVE, me); } @@ -866,6 +872,9 @@ class boss_prince_valanar_icc : public CreatureScript void JustDied(Unit* /*killer*/) { + events.Reset(); + summons.DespawnAll(); + Talk(SAY_VALANAR_DEATH); instance->SendEncounterUnit(ENCOUNTER_FRAME_REMOVE, me); } @@ -1176,7 +1185,7 @@ class npc_ball_of_flame : public CreatureScript } } - void SetGUID(uint64 const guid, int32 /*type*/) + void SetGUID(uint64 guid, int32 /*type*/) { _chaseGUID = guid; } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index 1954e18bafd..25c804f2eed 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -81,6 +81,7 @@ uint32 const vampireAuras[3][MAX_DIFFICULTY] = #define ESSENCE_OF_BLOOD_QUEEN RAID_MODE<uint32>(70867, 71473, 71532, 71533) #define ESSENCE_OF_BLOOD_QUEEN_PLR RAID_MODE<uint32>(70879, 71525, 71530, 71531) #define FRENZIED_BLOODTHIRST RAID_MODE<uint32>(70877, 71474, 70877, 71474) +#define DELIRIOUS_SLASH RAID_MODE<uint32>(71623, 71624, 71625, 71626) enum Events { @@ -185,7 +186,7 @@ class boss_blood_queen_lana_thel : public CreatureScript instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_BLOOD_MIRROR_DAMAGE); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_BLOOD_MIRROR_VISUAL); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_BLOOD_MIRROR_DUMMY); - instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_DELIRIOUS_SLASH); + instance->DoRemoveAurasDueToSpellOnPlayers(DELIRIOUS_SLASH); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_PACT_OF_THE_DARKFALLEN); // Blah, credit the quest if (_creditBloodQuickening) @@ -257,7 +258,7 @@ class boss_blood_queen_lana_thel : public CreatureScript Talk(SAY_KILL); } - void SetGUID(uint64 const guid, int32 type = 0) + void SetGUID(uint64 guid, int32 type = 0) { switch (type) { @@ -355,6 +356,7 @@ class boss_blood_queen_lana_thel : public CreatureScript _offtank = newOfftank; if (_offtank) { + // both spells have SPELL_ATTR5_SINGLE_TARGET_SPELL, no manual removal needed _offtank->CastSpell(me->getVictim(), SPELL_BLOOD_MIRROR_DAMAGE, true); me->getVictim()->CastSpell(_offtank, SPELL_BLOOD_MIRROR_DUMMY, true); DoCastVictim(SPELL_BLOOD_MIRROR_VISUAL); @@ -416,7 +418,7 @@ class boss_blood_queen_lana_thel : public CreatureScript case EVENT_AIR_PHASE: DoStopAttack(); me->SetReactState(REACT_PASSIVE); - events.DelayEvents(7000, EVENT_GROUP_NORMAL); + events.DelayEvents(10000, EVENT_GROUP_NORMAL); events.CancelEventGroup(EVENT_GROUP_CANCELLABLE); me->GetMotionMaster()->MovePoint(POINT_CENTER, centerPos); break; @@ -655,21 +657,24 @@ class spell_blood_queen_bloodbolt : public SpellScriptLoader void FilterTargets(std::list<Unit*>& targets) { - uint32 targetCount = targets.size() / 3 + 1; + uint32 targetCount = (targets.size() + 2) / 3; targets.remove_if(BloodboltHitCheck(static_cast<LanaThelAI*>(GetCaster()->GetAI()))); Trinity::RandomResizeList(targets, targetCount); + // mark targets now, effect hook has missile travel time delay (might cast next in that time) + for (std::list<Unit*>::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) + GetCaster()->GetAI()->SetGUID((*itr)->GetGUID(), GUID_BLOODBOLT); } - void HandleDummy() + void HandleScript(SpellEffIndex effIndex) { + PreventHitDefaultEffect(effIndex); GetCaster()->CastSpell(GetHitUnit(), SPELL_TWILIGHT_BLOODBOLT, true); - GetCaster()->GetAI()->SetGUID(GetHitUnit()->GetGUID(), GUID_BLOODBOLT); } void Register() { - OnUnitTargetSelect += SpellUnitTargetFn(spell_blood_queen_bloodbolt_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - AfterHit += SpellHitFn(spell_blood_queen_bloodbolt_SpellScript::HandleDummy); + OnUnitTargetSelect += SpellUnitTargetFn(spell_blood_queen_bloodbolt_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffect += SpellEffectFn(spell_blood_queen_bloodbolt_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -679,20 +684,6 @@ class spell_blood_queen_bloodbolt : public SpellScriptLoader } }; -class PactOfTheDarkfallenCheck -{ - public: - PactOfTheDarkfallenCheck(bool hasPact) : _hasPact(hasPact) { } - - bool operator() (Unit* unit) - { - return unit->HasAura(SPELL_PACT_OF_THE_DARKFALLEN) == _hasPact; - } - - private: - bool _hasPact; -}; - class spell_blood_queen_pact_of_the_darkfallen : public SpellScriptLoader { public: @@ -704,7 +695,7 @@ class spell_blood_queen_pact_of_the_darkfallen : public SpellScriptLoader void FilterTargets(std::list<Unit*>& unitList) { - unitList.remove_if(PactOfTheDarkfallenCheck(false)); + unitList.remove_if(Trinity::UnitAuraCheck(false, SPELL_PACT_OF_THE_DARKFALLEN)); bool remove = true; std::list<Unit*>::const_iterator itrEnd = unitList.end(), itr, itr2; @@ -790,7 +781,7 @@ class spell_blood_queen_pact_of_the_darkfallen_dmg_target : public SpellScriptLo void FilterTargets(std::list<Unit*>& unitList) { - unitList.remove_if(PactOfTheDarkfallenCheck(true)); + unitList.remove_if(Trinity::UnitAuraCheck(true, SPELL_PACT_OF_THE_DARKFALLEN)); unitList.push_back(GetCaster()); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index 89869040e6d..56613d59e99 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -549,7 +549,7 @@ class boss_lady_deathwhisper : public CreatureScript summon->AI()->DoCast(summon, SPELL_TELEPORT_VISUAL); } - void SetGUID(uint64 const guid, int32 id/* = 0*/) + void SetGUID(uint64 guid, int32 id/* = 0*/) { if (id != GUID_CULTIST) return; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 1898fa253f6..f418726aedf 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -77,6 +77,8 @@ enum MovementPoints POINT_TARGET_COLDFLAME = 36672631, }; +#define DATA_COLDFLAME_GUID 0 + class boss_lord_marrowgar : public CreatureScript { public: @@ -165,8 +167,9 @@ class boss_lord_marrowgar : public CreatureScript break; case EVENT_COLDFLAME: _coldflameLastPos.Relocate(me); + _coldflameTarget = 0LL; if (!me->HasAura(SPELL_BONE_STORM)) - me->CastCustomSpell(SPELL_COLDFLAME_NORMAL, SPELLVALUE_MAX_TARGETS, 1, me); + DoCastAOE(SPELL_COLDFLAME_NORMAL); else DoCast(me, SPELL_COLDFLAME_BONE_STORM); events.ScheduleEvent(EVENT_COLDFLAME, 5000, EVENT_GROUP_SPECIAL); @@ -242,8 +245,24 @@ class boss_lord_marrowgar : public CreatureScript return &_coldflameLastPos; } + uint64 GetGUID(int32 type/* = 0 */) + { + if (type == DATA_COLDFLAME_GUID) + return _coldflameTarget; + return 0LL; + } + + void SetGUID(uint64 guid, int32 type/* = 0 */) + { + if (type != DATA_COLDFLAME_GUID) + return; + + _coldflameTarget = guid; + } + private: Position _coldflameLastPos; + uint64 _coldflameTarget; uint32 _boneStormDuration; float _baseSpeed; bool _introDone; @@ -277,22 +296,7 @@ class npc_coldflame : public CreatureScript Creature* creOwner = owner->ToCreature(); Position pos; // random target case - if (!owner->HasAura(SPELL_BONE_STORM)) - { - // select any unit but not the tank (by owners threatlist) - Unit* target = creOwner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 1, -owner->GetObjectSize(), true, -SPELL_IMPALED); - if (!target) - target = creOwner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true); // or the tank if its solo - if (!target) - { - me->DespawnOrUnsummon(); - return; - } - - me->SetOrientation(me->GetAngle(target)); - owner->GetNearPosition(pos, owner->GetObjectSize() / 2.0f, 0.0f); - } - else + if (owner->HasAura(SPELL_BONE_STORM)) { if (MarrowgarAI* marrowgarAI = CAST_AI(MarrowgarAI, creOwner->AI())) { @@ -303,6 +307,18 @@ class npc_coldflame : public CreatureScript owner->GetNearPosition(pos, 2.5f, 0.0f); } } + else + { + Player* target = ObjectAccessor::GetPlayer(*owner, owner->GetAI()->GetGUID(DATA_COLDFLAME_GUID)); + if (!target) + { + me->DespawnOrUnsummon(); + return; + } + + me->SetOrientation(owner->GetAngle(target)); + owner->GetNearPosition(pos, owner->GetObjectSize() / 2.0f, 0.0f); + } me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), me->GetPositionZ(), me->GetOrientation()); _events.ScheduleEvent(EVENT_COLDFLAME_TRIGGER, 450); @@ -399,16 +415,53 @@ class spell_marrowgar_coldflame : public SpellScriptLoader { PrepareSpellScript(spell_marrowgar_coldflame_SpellScript); + void SelectTarget(std::list<Unit*>& targets) + { + targets.clear(); + // select any unit but not the tank (by owners threatlist) + Unit* target = GetCaster()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 1, -GetCaster()->GetObjectSize(), true, -SPELL_IMPALED); + if (!target) + target = GetCaster()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true); // or the tank if its solo + if (!target) + return; + + GetCaster()->GetAI()->SetGUID(target->GetGUID(), DATA_COLDFLAME_GUID); + targets.push_back(target); + } + void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - Unit* caster = GetCaster(); - uint8 count = 1; - if (GetSpellInfo()->Id == 72705) - count = 4; + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + } - for (uint8 i = 0; i < count; ++i) - caster->CastSpell(caster, uint32(GetEffectValue() + i), true); + void Register() + { + OnUnitTargetSelect += SpellUnitTargetFn(spell_marrowgar_coldflame_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + OnEffect += SpellEffectFn(spell_marrowgar_coldflame_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_marrowgar_coldflame_SpellScript(); + } +}; + +class spell_marrowgar_coldflame_bonestorm : public SpellScriptLoader +{ + public: + spell_marrowgar_coldflame_bonestorm() : SpellScriptLoader("spell_marrowgar_coldflame_bonestorm") { } + + class spell_marrowgar_coldflame_SpellScript : public SpellScript + { + PrepareSpellScript(spell_marrowgar_coldflame_SpellScript); + + void HandleScriptEffect(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + for (uint8 i = 0; i < 4; ++i) + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue() + i), true); } void Register() @@ -534,6 +587,7 @@ void AddSC_boss_lord_marrowgar() new npc_coldflame(); new npc_bone_spike(); new spell_marrowgar_coldflame(); + new spell_marrowgar_coldflame_bonestorm(); new spell_marrowgar_coldflame_damage(); new spell_marrowgar_bone_spike_graveyard(); new spell_marrowgar_bone_storm(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index e2fdb7a1b99..b5bcd93d257 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -68,8 +68,8 @@ enum Spells SPELL_GUZZLE_POTIONS = 71893, SPELL_OOZE_TANK_PROTECTION = 71770, // protects the tank SPELL_CHOKING_GAS_BOMB = 71255, - SPELL_OOZE_VARIABLE = 70352, - SPELL_GAS_VARIABLE = 70353, + SPELL_OOZE_VARIABLE = 74118, + SPELL_GAS_VARIABLE = 74119, SPELL_UNBOUND_PLAGUE = 70911, SPELL_UNBOUND_PLAGUE_SEARCHER = 70917, SPELL_PLAGUE_SICKNESS = 70953, @@ -256,14 +256,14 @@ class boss_professor_putricide : public CreatureScript break; case NPC_GAS_CLOUD: // no possible aura seen in sniff adding the aurastate - summon->SetFlag(UNIT_FIELD_AURASTATE, 1 << (AURA_STATE_UNKNOWN22 - 1)); + summon->ModifyAuraState(AURA_STATE_UNKNOWN22, true); summon->CastSpell(summon, SPELL_GASEOUS_BLOAT_PROC, true); summon->CastCustomSpell(SPELL_GASEOUS_BLOAT, SPELLVALUE_AURA_STACK, 10, summon, false); summon->SetReactState(REACT_PASSIVE); return; case NPC_VOLATILE_OOZE: // no possible aura seen in sniff adding the aurastate - summon->SetFlag(UNIT_FIELD_AURASTATE, 1 << (AURA_STATE_UNKNOWN19 - 1)); + summon->ModifyAuraState(AURA_STATE_UNKNOWN19, true); summon->CastSpell(summon, SPELL_OOZE_ERUPTION_SEARCH_PERIODIC, true); summon->CastSpell(summon, SPELL_VOLATILE_OOZE_ADHESIVE, false); summon->SetReactState(REACT_PASSIVE); @@ -450,13 +450,13 @@ class boss_professor_putricide : public CreatureScript while (half < targetList.size()) { std::list<Unit*>::iterator itr = targetList.begin(); - advance(itr, urand(0, targetList.size()-1)); - DoCast(*itr, SPELL_OOZE_VARIABLE); + advance(itr, urand(0, targetList.size() - 1)); + (*itr)->CastSpell(*itr, SPELL_OOZE_VARIABLE, true); targetList.erase(itr); } // and half gets gas for (std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr) - DoCast(*itr, SPELL_GAS_VARIABLE); + (*itr)->CastSpell(*itr, SPELL_GAS_VARIABLE, true); } me->GetMotionMaster()->MovePoint(POINT_TABLE, tablePos); } @@ -570,6 +570,8 @@ class boss_professor_putricide : public CreatureScript // remove Tear Gas instance->DoRemoveAurasDueToSpellOnPlayers(71615); instance->DoRemoveAurasDueToSpellOnPlayers(71618); + instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_GAS_VARIABLE); + instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_OOZE_VARIABLE); break; case EVENT_MALLEABLE_GOO: if (Is25ManRaid()) @@ -738,20 +740,6 @@ class spell_putricide_gaseous_bloat : public SpellScriptLoader } }; -class BeamProtectionCheck -{ - public: - explicit BeamProtectionCheck(uint32 excludeAura) : _excludeAura(excludeAura) { } - - bool operator()(Unit* unit) - { - return unit->HasAura(_excludeAura); - } - - private: - uint32 _excludeAura; -}; - class spell_putricide_ooze_channel : public SpellScriptLoader { public: @@ -780,7 +768,6 @@ class spell_putricide_ooze_channel : public SpellScriptLoader void SelectTarget(std::list<Unit*>& targetList) { - targetList.remove_if(BeamProtectionCheck(GetSpellInfo()->ExcludeTargetAuraSpell)); if (targetList.empty()) { FinishCast(SPELL_FAILED_NO_VALID_TARGETS); @@ -826,59 +813,6 @@ class spell_putricide_ooze_channel : public SpellScriptLoader } }; -class spell_putricide_expunged_gas : public SpellScriptLoader -{ - public: - spell_putricide_expunged_gas() : SpellScriptLoader("spell_putricide_expunged_gas") { } - - class spell_putricide_expunged_gas_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_expunged_gas_SpellScript); - - bool Load() - { - return GetCaster()->GetTypeId() == TYPEID_UNIT && GetCaster()->GetInstanceScript(); - } - - void CalcDamage(SpellEffIndex /*effIndex*/) - { - // checked in script loading, cant be NULL here - InstanceScript* instance = GetCaster()->GetInstanceScript(); - Creature* professor = Unit::GetCreature(*GetCaster(), instance->GetData64(DATA_PROFESSOR_PUTRICIDE)); - if (!professor) - return; - - int32 dmg = 0; - uint32 bloatId = sSpellMgr->GetSpellIdForDifficulty(SPELL_GASEOUS_BLOAT, GetCaster()); - if (Aura* gasBloat = GetTargetUnit()->GetAura(bloatId)) - { - uint32 stack = gasBloat->GetStackAmount(); - int32 const mod = (GetCaster()->GetMap()->GetSpawnMode() & 1) ? 1500 : 1250; - for (uint8 i = 1; i < stack; ++i) - dmg += mod * stack; - } - - SetHitDamage(dmg); - } - - void DespawnAfterCast() - { - GetCaster()->ToCreature()->DespawnOrUnsummon(100); - } - - void Register() - { - OnEffect += SpellEffectFn(spell_putricide_expunged_gas_SpellScript::CalcDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - AfterHit += SpellHitFn(spell_putricide_expunged_gas_SpellScript::DespawnAfterCast); - } - }; - - SpellScript* GetSpellScript() const - { - return new spell_putricide_expunged_gas_SpellScript(); - } -}; - class spell_putricide_slime_puddle : public SpellScriptLoader { public: @@ -1432,29 +1366,29 @@ class spell_putricide_mutated_transformation : public SpellScriptLoader class spell_putricide_mutated_transformation_dmg : public SpellScriptLoader { -public: - spell_putricide_mutated_transformation_dmg() : SpellScriptLoader("spell_putricide_mutated_transformation_dmg") { } - - class spell_putricide_mutated_transformation_dmg_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_mutated_transformation_dmg_SpellScript); + public: + spell_putricide_mutated_transformation_dmg() : SpellScriptLoader("spell_putricide_mutated_transformation_dmg") { } - void FilterTargetsInitial(std::list<Unit*>& unitList) + class spell_putricide_mutated_transformation_dmg_SpellScript : public SpellScript { - if (Unit* owner = ObjectAccessor::GetUnit(*GetCaster(), GetCaster()->GetCreatorGUID())) - unitList.remove(owner); - } + PrepareSpellScript(spell_putricide_mutated_transformation_dmg_SpellScript); - void Register() + void FilterTargetsInitial(std::list<Unit*>& unitList) + { + if (Unit* owner = ObjectAccessor::GetUnit(*GetCaster(), GetCaster()->GetCreatorGUID())) + unitList.remove(owner); + } + + void Register() + { + OnUnitTargetSelect += SpellUnitTargetFn(spell_putricide_mutated_transformation_dmg_SpellScript::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + } + }; + + SpellScript* GetSpellScript() const { - OnUnitTargetSelect += SpellUnitTargetFn(spell_putricide_mutated_transformation_dmg_SpellScript::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + return new spell_putricide_mutated_transformation_dmg_SpellScript(); } - }; - - SpellScript* GetSpellScript() const - { - return new spell_putricide_mutated_transformation_dmg_SpellScript(); - } }; class spell_putricide_regurgitated_ooze : public SpellScriptLoader @@ -1522,7 +1456,6 @@ void AddSC_boss_professor_putricide() new npc_volatile_ooze(); new spell_putricide_gaseous_bloat(); new spell_putricide_ooze_channel(); - new spell_putricide_expunged_gas(); new spell_putricide_slime_puddle(); new spell_putricide_slime_puddle_aura(); new spell_putricide_unstable_experiment(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index b341a87c176..dd645562501 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -125,6 +125,7 @@ class boss_rotface : public CreatureScript { _JustDied(); Talk(SAY_DEATH); + instance->DoRemoveAurasDueToSpellOnPlayers(MUTATED_INFECTION); if (Creature* professor = Unit::GetCreature(*me, instance->GetData64(DATA_PROFESSOR_PUTRICIDE))) professor->AI()->DoAction(ACTION_ROTFACE_DEATH); } @@ -191,18 +192,9 @@ class boss_rotface : public CreatureScript } break; case EVENT_MUTATED_INFECTION: - { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true, -MUTATED_INFECTION); - if (!target) - target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -MUTATED_INFECTION); - if (target) - { - me->CastCustomSpell(SPELL_MUTATED_INFECTION, SPELLVALUE_MAX_TARGETS, 1, target, false); - Talk(EMOTE_MUTATED_INFECTION, target->GetGUID()); - } + me->CastCustomSpell(SPELL_MUTATED_INFECTION, SPELLVALUE_MAX_TARGETS, 1, NULL, false); events.ScheduleEvent(EVENT_MUTATED_INFECTION, infectionCooldown); break; - } default: break; } @@ -478,6 +470,68 @@ class spell_rotface_ooze_flood : public SpellScriptLoader } }; +class spell_rotface_mutated_infection : public SpellScriptLoader +{ + public: + spell_rotface_mutated_infection() : SpellScriptLoader("spell_rotface_mutated_infection") { } + + class spell_rotface_mutated_infection_SpellScript : public SpellScript + { + PrepareSpellScript(spell_rotface_mutated_infection_SpellScript); + + bool Load() + { + _target = NULL; + return true; + } + + void FilterTargets(std::list<Unit*>& targets) + { + // remove targets with this aura already + // tank is not on this list + targets.remove_if(Trinity::UnitAuraCheck(true, GetSpellInfo()->Id)); + if (targets.empty()) + return; + + std::list<Unit*>::iterator itr = targets.begin(); + std::advance(itr, urand(0, targets.size() - 1)); + Unit* target = *itr; + targets.clear(); + targets.push_back(target); + _target = target; + } + + void ReplaceTargets(std::list<Unit*>& targets) + { + targets.clear(); + if (_target) + targets.push_back(_target); + } + + void NotifyTargets() + { + if (Creature* caster = GetCaster()->ToCreature()) + if (Unit* target = GetHitUnit()) + caster->AI()->Talk(EMOTE_MUTATED_INFECTION, target->GetGUID()); + } + + void Register() + { + OnUnitTargetSelect += SpellUnitTargetFn(spell_rotface_mutated_infection_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnUnitTargetSelect += SpellUnitTargetFn(spell_rotface_mutated_infection_SpellScript::ReplaceTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnUnitTargetSelect += SpellUnitTargetFn(spell_rotface_mutated_infection_SpellScript::ReplaceTargets, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); + AfterHit += SpellHitFn(spell_rotface_mutated_infection_SpellScript::NotifyTargets); + } + + Unit* _target; + }; + + SpellScript* GetSpellScript() const + { + return new spell_rotface_mutated_infection_SpellScript(); + } +}; + class spell_rotface_little_ooze_combine : public SpellScriptLoader { public: @@ -659,15 +713,17 @@ class spell_rotface_unstable_ooze_explosion : public SpellScriptLoader void CheckTarget(SpellEffIndex effIndex) { PreventHitDefaultEffect(EFFECT_0); - if (!GetTargetUnit()) + if (!GetTargetDest()) return; uint32 triggered_spell_id = GetSpellInfo()->Effects[effIndex].TriggerSpell; + float x, y, z; + GetTargetDest()->GetPosition(x, y, z); // let Rotface handle the cast - caster dies before this executes - if (InstanceScript* script = GetTargetUnit()->GetInstanceScript()) + if (InstanceScript* script = GetCaster()->GetInstanceScript()) if (Creature* rotface = script->instance->GetCreature(script->GetData64(DATA_ROTFACE))) - rotface->CastSpell(GetTargetUnit(), triggered_spell_id, true, NULL, NULL, GetCaster()->GetGUID()); + rotface->CastSpell(x, y, z, triggered_spell_id, true, NULL, NULL, GetCaster()->GetGUID()); } void Register() @@ -722,6 +778,7 @@ void AddSC_boss_rotface() new npc_big_ooze(); new npc_precious_icc(); new spell_rotface_ooze_flood(); + new spell_rotface_mutated_infection(); new spell_rotface_little_ooze_combine(); new spell_rotface_large_ooze_combine(); new spell_rotface_large_ooze_buff_combine(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 0c2d1e8fe00..e0b8afdbfd5 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -523,7 +523,7 @@ class npc_ice_tomb : public CreatureScript me->SetReactState(REACT_PASSIVE); } - void SetGUID(uint64 const guid, int32 type/* = 0 */) + void SetGUID(uint64 guid, int32 type/* = 0 */) { if (type == DATA_TRAPPED_PLAYER) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index a237f239386..c167dfc8e95 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -212,15 +212,6 @@ class AuraRemoveEvent : public BasicEvent uint32 _spellId; }; -class SummonTargetSelector -{ - public: - bool operator()(Unit* unit) const - { - return unit->HasAura(SPELL_RECENTLY_SPAWNED); - } -}; - class ValithriaDespawner : public BasicEvent { public: @@ -249,6 +240,7 @@ class ValithriaDespawner : public BasicEvent case NPC_GLUTTONOUS_ABOMINATION: case NPC_MANA_VOID: case NPC_COLUMN_OF_FROST: + case NPC_ROT_WORM: creature->DespawnOrUnsummon(); return; case NPC_RISEN_ARCHMAGE: @@ -310,6 +302,8 @@ class boss_valithria_dreamwalker : public CreatureScript // immune to percent heals me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_OBS_MOD_HEALTH, true); me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_HEAL_PCT, true); + // Glyph of Dispel Magic - not a percent heal by effect, its cast with custom basepoints + me->ApplySpellImmune(0, IMMUNITY_ID, 56131, true); _instance->SendEncounterUnit(ENCOUNTER_FRAME_REMOVE, me); _missedPortals = 0; _under25PercentTalkDone = false; @@ -506,8 +500,15 @@ class npc_green_dragon_combat_trigger : public CreatureScript me->SetReactState(REACT_PASSIVE); } - void EnterCombat(Unit* /*target*/) + void EnterCombat(Unit* target) { + if (!instance->CheckRequiredBosses(DATA_VALITHRIA_DREAMWALKER, target->ToPlayer())) + { + EnterEvadeMode(); + instance->DoCastSpellOnPlayers(LIGHT_S_HAMMER_TELEPORT); + return; + } + me->setActive(true); DoZoneInCombat(); instance->SetBossState(DATA_VALITHRIA_DREAMWALKER, IN_PROGRESS); @@ -1177,7 +1178,7 @@ class spell_dreamwalker_summoner : public SpellScriptLoader void FilterTargets(std::list<Unit*>& targets) { - targets.remove_if(SummonTargetSelector()); + targets.remove_if(Trinity::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); if (targets.empty()) return; @@ -1218,7 +1219,7 @@ class spell_dreamwalker_summon_suppresser : public SpellScriptLoader std::list<Creature*> summoners; GetCreatureListWithEntryInGrid(summoners, caster, 22515, 100.0f); - summoners.remove_if(SummonTargetSelector()); + summoners.remove_if(Trinity::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); Trinity::RandomResizeList(summoners, 2); if (summoners.empty()) return; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index 56c42f4f285..1e061c38c08 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -971,7 +971,7 @@ class npc_crok_scourgebane : public CreatureScript } } - void SetGUID(uint64 const guid, int32 type/* = 0*/) + void SetGUID(uint64 guid, int32 type/* = 0*/) { if (type == ACTION_VRYKUL_DEATH) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h index 7a1ab3e4f19..f5973fc0c8c 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h @@ -228,6 +228,7 @@ enum CreaturesIds NPC_GLUTTONOUS_ABOMINATION = 37886, NPC_MANA_VOID = 38068, NPC_COLUMN_OF_FROST = 37918, + NPC_ROT_WORM = 37907, NPC_THE_LICH_KING_VALITHRIA = 16980, NPC_DREAM_PORTAL_PRE_EFFECT = 38186, NPC_NIGHTMARE_PORTAL_PRE_EFFECT = 38429, diff --git a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp index 2122e4d9179..9384eb04bc8 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp @@ -163,7 +163,7 @@ public: uint64 victimGUID; - void SetGUID(const uint64 guid, int32 /*param*/) + void SetGUID(uint64 guid, int32 /*param*/) { victimGUID = guid; if (me->m_spells[0] && victimGUID) diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp index cd742b11d58..cf653284e6a 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp @@ -157,7 +157,7 @@ public: } } - void SetGUID(uint64 const guid, int32 id/* = 0 */) + void SetGUID(uint64 guid, int32 id/* = 0 */) { if (id == DATA_INTENSE_COLD) intenseColdList.push_back(guid); diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp index e7dffae5c9d..748de08f5e0 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp @@ -78,6 +78,7 @@ class instance_ulduar : public InstanceMapScript // Miscellaneous uint32 TeamInInstance; uint32 HodirRareCacheData; + uint32 ColossusData; uint8 elderCount; bool conSpeedAtory; @@ -117,6 +118,7 @@ class instance_ulduar : public InstanceMapScript ArchivumDoorGUID = 0; TeamInInstance = 0; HodirRareCacheData = 0; + ColossusData = 0; elderCount = 0; conSpeedAtory = false; @@ -473,7 +475,7 @@ class instance_ulduar : public InstanceMapScript switch (type) { case DATA_COLOSSUS: - Encounter[DATA_COLOSSUS] = data; + ColossusData = data; if (data == 2) { if (Creature* Leviathan = instance->GetCreature(LeviathanGUID)) @@ -589,7 +591,7 @@ class instance_ulduar : public InstanceMapScript switch (type) { case DATA_COLOSSUS: - return Encounter[type]; + return ColossusData; case DATA_HODIR_RARE_CACHE: return HodirRareCacheData; default: diff --git a/src/server/scripts/Northrend/borean_tundra.cpp b/src/server/scripts/Northrend/borean_tundra.cpp index aa08e4230ab..205dcdb5347 100644 --- a/src/server/scripts/Northrend/borean_tundra.cpp +++ b/src/server/scripts/Northrend/borean_tundra.cpp @@ -2431,7 +2431,7 @@ public: uiEventPhase = 1; } - void SetGUID(const uint64 uiGuid, int32 /*iId*/) + void SetGUID(uint64 uiGuid, int32 /*iId*/) { uiPlayerGUID = uiGuid; } diff --git a/src/server/scripts/Northrend/icecrown.cpp b/src/server/scripts/Northrend/icecrown.cpp index 86b375fc274..dc55c2f6ad3 100644 --- a/src/server/scripts/Northrend/icecrown.cpp +++ b/src/server/scripts/Northrend/icecrown.cpp @@ -381,6 +381,51 @@ public: } }; +/*###### +## npc_vereth_the_cunning +######*/ + +enum eVerethTheCunning +{ + NPC_GEIST_RETURN_BUNNY_KC = 31049, + NPC_LITHE_STALKER = 30894, + SPELL_SUBDUED_LITHE_STALKER = 58151, +}; + +class npc_vereth_the_cunning : public CreatureScript +{ +public: + npc_vereth_the_cunning() : CreatureScript("npc_vereth_the_cunning") { } + + struct npc_vereth_the_cunningAI : public ScriptedAI + { + npc_vereth_the_cunningAI(Creature* pCreature) : ScriptedAI(pCreature) {} + + void MoveInLineOfSight(Unit* who) + { + ScriptedAI::MoveInLineOfSight(who); + + if (who->GetEntry() == NPC_LITHE_STALKER && me->IsWithinDistInMap(who, 10.0f)) + { + if (Unit* owner = who->GetCharmer()) + { + if (who->HasAura(SPELL_SUBDUED_LITHE_STALKER)) + { + owner->ToPlayer()->KilledMonsterCredit(NPC_GEIST_RETURN_BUNNY_KC, 0); + who->ToCreature()->DisappearAndDie(); + + } + } + } + } + }; + + CreatureAI *GetAI(Creature *creature) const + { + return new npc_vereth_the_cunningAI(creature); + } +}; + void AddSC_icecrown() { new npc_arete; @@ -389,4 +434,5 @@ void AddSC_icecrown() new npc_argent_valiant; new npc_alorah_and_grimmin; new npc_guardian_pavilion; + new npc_vereth_the_cunning; } diff --git a/src/server/scripts/Northrend/zuldrak.cpp b/src/server/scripts/Northrend/zuldrak.cpp index b8e0d31d49b..16567be9636 100644 --- a/src/server/scripts/Northrend/zuldrak.cpp +++ b/src/server/scripts/Northrend/zuldrak.cpp @@ -361,7 +361,7 @@ public: bRemoveFlag = false; } - void SetGUID(const uint64 guid, int32 /*id*/) + void SetGUID(uint64 guid, int32 /*id*/) { uiPlayerGUID = guid; } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp index d827533610d..d4f9803b800 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_void_reaver.cpp @@ -132,7 +132,7 @@ class boss_void_reaver : public CreatureScript target = NULL; } - if (target_list.size()) + if (!target_list.empty()) target = *(target_list.begin()+rand()%target_list.size()); else target = me->getVictim(); diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 19dd7f6c2e3..16d147a4000 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -39,6 +39,58 @@ enum HunterSpells HUNTER_SPELL_CHIMERA_SHOT_SERPENT = 53353, HUNTER_SPELL_CHIMERA_SHOT_VIPER = 53358, HUNTER_SPELL_CHIMERA_SHOT_SCORPID = 53359, + HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET = 61669, +}; + +// 13161 Aspect of the Beast +class spell_hun_aspect_of_the_beast : public SpellScriptLoader +{ +public: + spell_hun_aspect_of_the_beast() : SpellScriptLoader("spell_hun_aspect_of_the_beast") { } + + class spell_hun_aspect_of_the_beast_AuraScript : public AuraScript + { + PrepareAuraScript(spell_hun_aspect_of_the_beast_AuraScript) + bool Validate(SpellInfo const* /*entry*/) + { + if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET)) + return false; + return true; + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (!GetCaster()) + return; + + Unit* caster = GetCaster(); + if (caster->ToPlayer()) + if (Pet* pet = caster->ToPlayer()->GetPet()) + pet->RemoveAurasDueToSpell(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET); + } + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (!GetCaster()) + return; + + Unit* caster = GetCaster(); + if (caster->ToPlayer()) + if (Pet* pet = caster->ToPlayer()->GetPet()) + caster->CastSpell(caster, HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET, true); + } + + void Register() + { + AfterEffectApply += AuraEffectApplyFn(spell_hun_aspect_of_the_beast_AuraScript::OnApply, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_hun_aspect_of_the_beast_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript *GetAuraScript() const + { + return new spell_hun_aspect_of_the_beast_AuraScript(); + } }; // 53209 Chimera Shot @@ -512,6 +564,7 @@ public: void AddSC_hunter_spell_scripts() { + new spell_hun_aspect_of_the_beast(); new spell_hun_chimera_shot(); new spell_hun_invigoration(); new spell_hun_last_stand_pet(); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index e2f37912931..5300849d0ec 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -1088,7 +1088,7 @@ class spell_magic_eater_food : public SpellScriptLoader { PrepareAuraScript(spell_magic_eater_food_AuraScript); - void HandleTriggerSpell(AuraEffect const* aurEff) + void HandleTriggerSpell(AuraEffect const* /*aurEff*/) { PreventDefaultAction(); Unit* target = GetTarget(); diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 623bfe0a5da..77048d6ea29 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -23,6 +23,7 @@ #include "ScriptPCH.h" #include "SpellAuraEffects.h" +#include "GridNotifiers.h" enum PriestSpells { @@ -130,7 +131,7 @@ class spell_pri_mind_sear : public SpellScriptLoader void FilterTargets(std::list<Unit*>& unitList) { - unitList.remove(GetTargetUnit()); + unitList.remove_if(Trinity::ObjectGUIDCheck(GetCaster()->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT))); } void Register() diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index ae8069747e3..a9ffe2e0f47 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -22,6 +22,7 @@ */ #include "ScriptPCH.h" +#include "Vehicle.h" class spell_generic_quest_update_entry_SpellScript : public SpellScript { @@ -939,6 +940,44 @@ class spell_q12805_lifeblood_dummy : public SpellScriptLoader }; }; +/* + http://www.wowhead.com/quest=13283 King of the Mountain + http://www.wowhead.com/quest=13280 King of the Mountain + 59643 Plant Horde Battle Standard + 4338 Plant Alliance Battle Standard + */ +enum eBattleStandard +{ + NPC_KING_OF_THE_MOUNTAINT_KC = 31766, +}; +class spell_q13280_13283_plant_battle_standard: public SpellScriptLoader +{ +public: + spell_q13280_13283_plant_battle_standard() : SpellScriptLoader("spell_q13280_13283_plant_battle_standard") { } + + class spell_q13280_13283_plant_battle_standard_SpellScript : public SpellScript + { + PrepareSpellScript(spell_q13280_13283_plant_battle_standard_SpellScript) + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (caster->IsVehicle()) + if (Unit* player = caster->GetVehicleKit()->GetPassenger(0)) + player->ToPlayer()->KilledMonsterCredit(NPC_KING_OF_THE_MOUNTAINT_KC,0); + } + + void Register() + { + OnEffect += SpellEffectFn(spell_q13280_13283_plant_battle_standard_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_q13280_13283_plant_battle_standard_SpellScript(); + } +}; + void AddSC_quest_spell_scripts() { new spell_q55_sacred_cleansing(); @@ -961,4 +1000,5 @@ void AddSC_quest_spell_scripts() new spell_q12659_ahunaes_knife(); new spell_q9874_liquid_fire(); new spell_q12805_lifeblood_dummy(); + new spell_q13280_13283_plant_battle_standard(); } |