diff options
| -rw-r--r-- | src/game/AI/CoreAI/CombatAI.cpp | 2 | ||||
| -rw-r--r-- | src/game/AI/CreatureAISelector.cpp | 10 | ||||
| -rw-r--r-- | src/game/AI/ScriptedAI/ScriptedEscortAI.cpp | 2 | ||||
| -rw-r--r-- | src/game/AI/SmartScripts/SmartScript.cpp | 2 | ||||
| -rw-r--r-- | src/game/AI/SmartScripts/SmartScriptMgr.h | 2 | ||||
| -rw-r--r-- | src/game/AuctionHouse/AuctionHouseMgr.cpp | 6 | ||||
| -rw-r--r-- | src/game/Battlegrounds/Zones/BattlegroundAV.cpp | 30 | ||||
| -rw-r--r-- | src/game/Chat/ChatLink.cpp | 9 | ||||
| -rw-r--r-- | src/game/Entities/Creature/CreatureGroups.cpp | 4 | ||||
| -rw-r--r-- | src/game/Entities/Unit/Unit.cpp | 965 | ||||
| -rw-r--r-- | src/game/Events/GameEventMgr.cpp | 1 | ||||
| -rw-r--r-- | src/game/Handlers/AddonHandler.cpp | 2 | ||||
| -rw-r--r-- | src/game/Handlers/DuelHandler.cpp | 2 | ||||
| -rw-r--r-- | src/game/Handlers/MiscHandler.cpp | 7 | ||||
| -rw-r--r-- | src/game/Movement/MotionMaster.cpp | 10 | ||||
| -rw-r--r-- | src/game/Warden/WardenMac.cpp | 10 | ||||
| -rw-r--r-- | src/game/Warden/WardenWin.cpp | 16 |
17 files changed, 511 insertions, 569 deletions
diff --git a/src/game/AI/CoreAI/CombatAI.cpp b/src/game/AI/CoreAI/CombatAI.cpp index 989d3d0076..3d7d67665c 100644 --- a/src/game/AI/CoreAI/CombatAI.cpp +++ b/src/game/AI/CoreAI/CombatAI.cpp @@ -280,8 +280,8 @@ void VehicleAI::OnCharmed(bool apply) void VehicleAI::LoadConditions() { conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry()); - //if (!conditions.empty()) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (!conditions.empty()) sLog->outDebug(LOG_FILTER_CONDITIONSYS, "VehicleAI::LoadConditions: loaded %u conditions", uint32(conditions.size())); #endif } diff --git a/src/game/AI/CreatureAISelector.cpp b/src/game/AI/CreatureAISelector.cpp index 3970ee9e46..85f0bc75ad 100644 --- a/src/game/AI/CreatureAISelector.cpp +++ b/src/game/AI/CreatureAISelector.cpp @@ -82,11 +82,9 @@ namespace FactorySelector } } - // select NullCreatureAI if not another cases - // xinef: unused - // ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key(); - #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + // select NullCreatureAI if not another cases + ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key(); sLog->outDebug(LOG_FILTER_TSCR, "Creature %u used AI is %s.", creature->GetGUIDLow(), ainame.c_str()); #endif return (ai_factory == NULL ? new NullCreatureAI(creature) : ai_factory->Create(creature)); @@ -133,10 +131,8 @@ namespace FactorySelector //future goAI types go here - // xinef: unused - std::string ainame = (ai_factory == NULL || go->GetScriptId()) ? "NullGameObjectAI" : ai_factory->key(); - #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + std::string ainame = (ai_factory == NULL || go->GetScriptId()) ? "NullGameObjectAI" : ai_factory->key(); sLog->outDebug(LOG_FILTER_TSCR, "GameObject %u used AI is %s.", go->GetGUIDLow(), ainame.c_str()); #endif diff --git a/src/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 763c8644a2..4e0d88fe79 100644 --- a/src/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -438,8 +438,8 @@ void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false m_bCanInstantRespawn = instantRespawn; m_bCanReturnToStart = canLoopPath; - //if (m_bCanReturnToStart && m_bCanInstantRespawn) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (m_bCanReturnToStart && m_bCanInstantRespawn) sLog->outDebug(LOG_FILTER_TSCR, "TSCR: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn."); #endif diff --git a/src/game/AI/SmartScripts/SmartScript.cpp b/src/game/AI/SmartScripts/SmartScript.cpp index 0bcdeb1d2f..ed7868baf3 100644 --- a/src/game/AI/SmartScripts/SmartScript.cpp +++ b/src/game/AI/SmartScripts/SmartScript.cpp @@ -4103,9 +4103,7 @@ void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEn #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) if (obj) sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript: EventMap for Entry %u is empty but is using SmartScript.", obj->GetEntry()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) if (at) sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript: EventMap for AreaTrigger %u is empty but is using SmartScript.", at->id); #endif diff --git a/src/game/AI/SmartScripts/SmartScriptMgr.h b/src/game/AI/SmartScripts/SmartScriptMgr.h index ecacd1b211..66b713d594 100644 --- a/src/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/game/AI/SmartScripts/SmartScriptMgr.h @@ -1634,8 +1634,8 @@ class SmartAIMgr return mEventMap[uint32(type)][entry]; else { - //if (entry > 0)//first search is for guid (negative), do not drop error if not found #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (entry > 0) //first search is for guid (negative), do not drop error if not found sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartAIMgr::GetScript: Could not load Script for Entry %d ScriptType %u.", entry, uint32(type)); #endif return temp; diff --git a/src/game/AuctionHouse/AuctionHouseMgr.cpp b/src/game/AuctionHouse/AuctionHouseMgr.cpp index 5626a9dc86..500c44d85b 100644 --- a/src/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouse/AuctionHouseMgr.cpp @@ -67,14 +67,8 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_AUCTIONHOUSE, "MSV: %u", MSV); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_AUCTIONHOUSE, "Items: %u", count); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_AUCTIONHOUSE, "Multiplier: %f", multiplier); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_AUCTIONHOUSE, "Deposit: %u", deposit); #endif diff --git a/src/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/game/Battlegrounds/Zones/BattlegroundAV.cpp index f035bd5dcc..11416b1df4 100644 --- a/src/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -170,8 +170,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) case AV_QUEST_H_COMMANDER1: m_Team_QuestStatus[teamId][1]++; RewardReputationToTeam(teamId, 1, teamId); - //if (m_Team_QuestStatus[team][1] == 30) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (m_Team_QuestStatus[teamId][1] == 30) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); #endif break; @@ -179,8 +179,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) case AV_QUEST_H_COMMANDER2: m_Team_QuestStatus[teamId][2]++; RewardReputationToTeam(teamId, 1, teamId); - //if (m_Team_QuestStatus[team][2] == 60) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (m_Team_QuestStatus[teamId][2] == 60) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); #endif break; @@ -188,8 +188,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) case AV_QUEST_H_COMMANDER3: m_Team_QuestStatus[teamId][3]++; RewardReputationToTeam(teamId, 1, teamId); - //if (m_Team_QuestStatus[team][3] == 120) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (m_Team_QuestStatus[teamId][3] == 120) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); #endif break; @@ -199,8 +199,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) case AV_QUEST_A_BOSS2: case AV_QUEST_H_BOSS2: m_Team_QuestStatus[teamId][4]++; - //if (m_Team_QuestStatus[team][4] >= 200) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (m_Team_QuestStatus[teamId][4] >= 200) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); #endif break; @@ -211,9 +211,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); -#endif - //if (m_Team_QuestStatus[team][6] == 7) -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + + if (m_Team_QuestStatus[teamId][6] == 7) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here - ground assault ready", questid); #endif } @@ -225,9 +224,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); -#endif - //if (m_Team_QuestStatus[team][5] == 20) -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + + if (m_Team_QuestStatus[teamId][5] == 20) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here - ground assault ready", questid); #endif } @@ -239,9 +237,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); -#endif - //if (m_Team_QuestStatus[team][8] == 25) -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + + if (m_Team_QuestStatus[teamId][8] == 25) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here - rider assault ready", questid); #endif } @@ -253,9 +250,8 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); -#endif - //if (m_Team_QuestStatus[team][7] == 25) -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + + if (m_Team_QuestStatus[teamId][7] == 25) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here - rider assault ready", questid); #endif } @@ -1394,7 +1390,7 @@ bool BattlegroundAV::SetupBattleground() SpawnBGObject(i, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_AV_OBJECT_AURA_N_SNOWFALL_GRAVE, RESPAWN_IMMEDIATELY); - + // Handpacked snowdrift, only during holiday if (IsHolidayActive(HOLIDAY_FEAST_OF_WINTER_VEIL)) for (i = BG_AV_OBJECT_HANDPACKED_SNOWDRIFT_MIN ; i <= BG_AV_OBJECT_HANDPACKED_SNOWDRIFT_MAX; i++) diff --git a/src/game/Chat/ChatLink.cpp b/src/game/Chat/ChatLink.cpp index b82fc1af9f..eec88d0f4f 100644 --- a/src/game/Chat/ChatLink.cpp +++ b/src/game/Chat/ChatLink.cpp @@ -201,8 +201,9 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context) } } } - //if (!res) + #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (!res) sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId); #endif return res; @@ -258,8 +259,8 @@ bool QuestChatLink::ValidateName(char* buffer, const char* context) bool res = (_quest->GetTitle() == buffer); - //if (!res) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (!res) sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked quest (id: %u) title wasn't found in any localization", context, _quest->GetQuestId()); #endif return res; @@ -346,8 +347,8 @@ bool SpellChatLink::ValidateName(char* buffer, const char* context) break; } - //if (!res) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (!res) sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked spell (id: %u) name wasn't found in any localization", context, _spell->Id); #endif return res; @@ -418,8 +419,8 @@ bool AchievementChatLink::ValidateName(char* buffer, const char* context) break; } - //if (!res) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (!res) sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked achievement (id: %u) name wasn't found in any localization", context, _achievement->ID); #endif return res; diff --git a/src/game/Entities/Creature/CreatureGroups.cpp b/src/game/Entities/Creature/CreatureGroups.cpp index 90527ca7ff..dc3d0cbbb5 100644 --- a/src/game/Entities/Creature/CreatureGroups.cpp +++ b/src/game/Entities/Creature/CreatureGroups.cpp @@ -176,8 +176,8 @@ void CreatureGroup::MemberAttackStart(Creature* member, Unit* target) for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { - //if (m_leader) // avoid crash if leader was killed and reset. #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (m_leader) // avoid crash if leader was killed and reset. sLog->outDebug(LOG_FILTER_UNITS, "GROUP ATTACK: group instance id %u calls member instid %u", m_leader->GetInstanceId(), member->GetInstanceId()); #endif @@ -200,7 +200,7 @@ void CreatureGroup::FormationReset(bool dismiss) { if (m_members.size() && m_members.begin()->second->groupAI == 5) return; - + for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { if (itr->first != m_leader && itr->first->IsAlive()) diff --git a/src/game/Entities/Unit/Unit.cpp b/src/game/Entities/Unit/Unit.cpp index a70577101a..4cc593a4a4 100644 --- a/src/game/Entities/Unit/Unit.cpp +++ b/src/game/Entities/Unit/Unit.cpp @@ -334,7 +334,7 @@ Unit::~Unit() } void Unit::Update(uint32 p_time) -{ +{ // WARNING! Order of execution here is important, do not change. // Spells must be processed with event system BEFORE they go to _UpdateSpells. // Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad. @@ -415,7 +415,7 @@ void Unit::Update(uint32 p_time) } bool Unit::haveOffhandWeapon() const -{ +{ if (Player const* player = ToPlayer()) return player->GetWeaponForAttack(OFF_ATTACK, true); @@ -423,7 +423,7 @@ bool Unit::haveOffhandWeapon() const } void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed) -{ +{ Movement::MoveSplineInit init(this); init.MoveTo(x,y,z); init.SetVelocity(speed); @@ -431,7 +431,7 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed) } void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 TransitTime, SplineFlags sf) -{ +{ WorldPacket data(SMSG_MONSTER_MOVE, 1+12+4+1+4+4+4+12+GetPackGUID().size()); data.append(GetPackGUID()); @@ -454,7 +454,7 @@ class SplineHandler bool operator()(Movement::MoveSpline::UpdateResult result) { - if ((result & (Movement::MoveSpline::Result_NextSegment|Movement::MoveSpline::Result_JustArrived)) && + if ((result & (Movement::MoveSpline::Result_NextSegment|Movement::MoveSpline::Result_JustArrived)) && _unit->GetTypeId() == TYPEID_UNIT && _unit->GetMotionMaster()->GetCurrentMovementGeneratorType() == ESCORT_MOTION_TYPE && _unit->movespline->GetId() == _unit->GetMotionMaster()->GetCurrentSplineId()) { @@ -469,7 +469,7 @@ class SplineHandler }; void Unit::UpdateSplineMovement(uint32 t_diff) -{ +{ if (movespline->Finalized()) return; @@ -496,7 +496,7 @@ void Unit::UpdateSplineMovement(uint32 t_diff) } void Unit::UpdateSplinePosition() -{ +{ //static uint32 const positionUpdateDelay = 400; //m_movesplineTimer.Reset(positionUpdateDelay); @@ -525,19 +525,19 @@ void Unit::UpdateSplinePosition() } void Unit::DisableSpline() -{ +{ m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD)); movespline->_Interrupt(); } void Unit::resetAttackTimer(WeaponAttackType type) -{ +{ int32 time = int32(GetAttackTime(type) * m_modAttackSpeedPct[type]); m_attackTimer[type] = std::min(m_attackTimer[type]+time, time); } bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const -{ +{ if (!obj || !IsInMap(obj) || !InSamePhase(obj)) return false; @@ -553,7 +553,7 @@ bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const } bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const -{ +{ if (!obj || !IsInMap(obj) || !InSamePhase(obj)) return false; @@ -569,7 +569,7 @@ bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const } bool Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, bool force) const -{ +{ float combat_reach = GetCombatReach(); if (combat_reach < 0.1f) // sometimes bugged for players combat_reach = DEFAULT_COMBAT_REACH; @@ -609,7 +609,7 @@ bool Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, } void Unit::UpdateInterruptMask() -{ +{ m_interruptMask = 0; for (AuraApplicationList::const_iterator i = m_interruptableAuras.begin(); i != m_interruptableAuras.end(); ++i) m_interruptMask |= (*i)->GetBase()->GetSpellInfo()->AuraInterruptFlags; @@ -620,7 +620,7 @@ void Unit::UpdateInterruptMask() } bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const -{ +{ if (!HasAuraType(auraType)) return false; AuraEffectList const& auras = GetAuraEffectsByType(auraType); @@ -632,7 +632,7 @@ bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint } bool Unit::HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura) const -{ +{ AuraEffectList const& auras = GetAuraEffectsByType(type); for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) if ((!excludeAura || excludeAura != (*itr)->GetSpellInfo()->Id) && //Avoid self interrupt of channeled Crowd Control spells like Seduction @@ -642,7 +642,7 @@ bool Unit::HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura) const } bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) const -{ +{ uint32 excludeAura = 0; if (Spell* currentChanneledSpell = excludeCasterChannel ? excludeCasterChannel->GetCurrentSpell(CURRENT_CHANNELED_SPELL) : NULL) excludeAura = currentChanneledSpell->GetSpellInfo()->Id; //Avoid self interrupt of channeled Crowd Control spells like Seduction @@ -678,10 +678,10 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage if (attacker && attacker->IsAIEnabled) attacker->GetAI()->DamageDealt(victim, damage, damagetype); } - + // Hook for OnDamage Event sScriptMgr->OnDamage(attacker, victim, damage); - + if (victim->GetTypeId() == TYPEID_PLAYER && attacker != victim) { // Signal to pets that their owner was attacked @@ -970,14 +970,14 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage } void Unit::CastStop(uint32 except_spellid, bool withInstant) -{ +{ for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id != except_spellid) InterruptSpell(CurrentSpellTypes(i),false, withInstant); } void Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ if (!spellInfo) { sLog->outError("CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"), (GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); @@ -999,12 +999,12 @@ void Unit::CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo } void Unit::CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ CastSpell(victim, spellId, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } void Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags /*= TRIGGER_NONE*/, Item* castItem /*= NULL*/, AuraEffect const* triggeredByAura /*= NULL*/, uint64 originalCaster /*= 0*/) -{ +{ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { @@ -1016,19 +1016,19 @@ void Unit::CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags } void Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem/*= NULL*/, AuraEffect const* triggeredByAura /*= NULL*/, uint64 originalCaster /*= 0*/) -{ +{ CastSpell(victim, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } void Unit::CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ SpellCastTargets targets; targets.SetUnitTarget(victim); CastSpell(targets, spellInfo, NULL, triggerFlags, castItem, triggeredByAura, originalCaster); } void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ CustomSpellValues values; if (bp0) values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0); @@ -1040,21 +1040,21 @@ void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 } void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ CustomSpellValues values; values.AddSpellMod(mod, value); CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ CustomSpellValues values; values.AddSpellMod(mod, value); CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster); } void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { @@ -1068,7 +1068,7 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* } void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) -{ +{ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { @@ -1082,7 +1082,7 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, } void Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem, AuraEffect* triggeredByAura, uint64 originalCaster) -{ +{ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { @@ -1096,7 +1096,7 @@ void Unit::CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castI } void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType, bool crit) -{ +{ if (damage < 0) return; @@ -1192,10 +1192,10 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama default: break; } - + // Script Hook For CalculateSpellDamageTaken -- Allow scripts to change the Damage post class mitigation calculations sScriptMgr->ModifySpellDamageTaken(damageInfo->target, damageInfo->attacker, damage); - + // Calculate absorb resist if (damage > 0) { @@ -1209,7 +1209,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama } void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss) -{ +{ if (damageInfo == 0) return; @@ -1237,7 +1237,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss) // TODO for melee need create structure as in void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* damageInfo, WeaponAttackType attackType) -{ +{ damageInfo->attacker = this; damageInfo->target = victim; damageInfo->damageSchoolMask = GetMeleeDamageSchoolMask(); @@ -1293,10 +1293,10 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam // Add melee damage bonus damage = MeleeDamageBonusDone(damageInfo->target, damage, damageInfo->attackType); damage = damageInfo->target->MeleeDamageBonusTaken(this, damage, damageInfo->attackType); - + // Script Hook For CalculateMeleeDamage -- Allow scripts to change the Damage pre class mitigation calculations sScriptMgr->ModifyMeleeDamage(damageInfo->target, damageInfo->attacker, damage); - + // Calculate armor reduction if (IsDamageReducedByArmor((SpellSchoolMask)(damageInfo->damageSchoolMask))) { @@ -1448,7 +1448,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam } void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) -{ +{ Unit* victim = damageInfo->target; if (!victim->IsAlive() || victim->IsInFlight() || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode())) @@ -1573,7 +1573,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) } void Unit::HandleEmoteCommand(uint32 anim_id) -{ +{ WorldPacket data(SMSG_EMOTE, 4 + 8); data << uint32(anim_id); data << uint64(GetGUID()); @@ -2126,7 +2126,7 @@ void Unit::CalcHealAbsorb(Unit const* victim, const SpellInfo* healSpell, uint32 } void Unit::AttackerStateUpdate (Unit* victim, WeaponAttackType attType, bool extra) -{ +{ if (HasUnitState(UNIT_STATE_CANNOT_AUTOATTACK) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) return; @@ -2154,25 +2154,23 @@ void Unit::AttackerStateUpdate (Unit* victim, WeaponAttackType attType, bool ext SendAttackStateUpdate(&damageInfo); //TriggerAurasProcOnEvent(damageInfo); - + DealMeleeDamage(&damageInfo, true); ProcDamageAndSpell(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, damageInfo.procEx, damageInfo.damage, damageInfo.attackType); - /*if (GetTypeId() == TYPEID_PLAYER) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (GetTypeId() == TYPEID_PLAYER) sLog->outStaticDebug("AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", -#endif GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); else -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", + GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); #endif - GetGUIDLow(), victim->GetGUIDLow(), victim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);*/ } } void Unit::HandleProcExtraAttackFor(Unit* victim) -{ +{ while (m_extraAttacks) { AttackerStateUpdate(victim, BASE_ATTACK, true); @@ -2181,7 +2179,7 @@ void Unit::HandleProcExtraAttackFor(Unit* victim) } MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackType attType) const -{ +{ // This is only wrapper // Miss chance based on melee @@ -2204,7 +2202,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackTy } MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const -{ +{ if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode()) return MELEE_HIT_EVADE; @@ -2283,7 +2281,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackTy // parry & block chances // check if attack comes from behind, nobody can parry or block if attacker is behind - if (!victim->HasInArc(M_PI, this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) + if (!victim->HasInArc(M_PI, this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("RollMeleeOutcomeAgainst: attack came from behind."); @@ -2393,7 +2391,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackTy #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum); #endif - if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) + if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("RollMeleeOutcomeAgainst: CRIT DISABLED)"); @@ -2410,7 +2408,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* victim, WeaponAttackTy } uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool addTotalPct) -{ +{ float minDamage = 0.0f; float maxDamage = 0.0f; @@ -2448,7 +2446,7 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add } float Unit::CalculateLevelPenalty(SpellInfo const* spellProto) const -{ +{ if (GetTypeId() != TYPEID_PLAYER) return 1.0f; @@ -2469,7 +2467,7 @@ float Unit::CalculateLevelPenalty(SpellInfo const* spellProto) const } void Unit::SendMeleeAttackStart(Unit* victim, Player* sendTo) -{ +{ WorldPacket data(SMSG_ATTACKSTART, 8 + 8); data << uint64(GetGUID()); data << uint64(victim->GetGUID()); @@ -2483,7 +2481,7 @@ void Unit::SendMeleeAttackStart(Unit* victim, Player* sendTo) } void Unit::SendMeleeAttackStop(Unit* victim) -{ +{ // pussywizard: calling SendMeleeAttackStop without clearing UNIT_STATE_MELEE_ATTACKING and then AttackStart the same player may spoil npc rotating! // pussywizard: this happens in some boss scripts, just add clearing here // ClearUnitState(UNIT_STATE_MELEE_ATTACKING); // ZOMG! commented out for now @@ -2495,21 +2493,16 @@ void Unit::SendMeleeAttackStop(Unit* victim) SendMessageToSet(&data, true); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTOP"); -#endif - /*if (victim) -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (victim) sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); -#endif else -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDetail("%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow()); #endif -*/ } bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType attackType) -{ +{ // These spells can't be blocked if (spellProto && spellProto->HasAttribute(SPELL_ATTR0_IMPOSSIBLE_DODGE_PARRY_BLOCK)) return false; @@ -2535,14 +2528,14 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac } bool Unit::isBlockCritical() -{ +{ if (roll_chance_i(GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_CRIT_CHANCE))) return true; return false; } int32 Unit::GetMechanicResistChance(const SpellInfo* spell) -{ +{ if (!spell) return 0; int32 resist_mech = 0; @@ -2563,7 +2556,7 @@ int32 Unit::GetMechanicResistChance(const SpellInfo* spell) // Melee based spells hit result calculations SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spell) -{ +{ // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will additionally fully ignore // resist and deflect chances if (spell->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT)) @@ -2729,7 +2722,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spell) } SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spell) -{ +{ // Can`t miss on dead target (on skinning for example) if (!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER) return SPELL_MISS_NONE; @@ -2858,7 +2851,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spell) // For spells // Resist SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spell, bool CanReflect) -{ +{ // Check for immune if (victim->IsImmunedToSpell(spell)) return SPELL_MISS_IMMUNE; @@ -2920,7 +2913,7 @@ SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spell, bool Ca } uint32 Unit::GetDefenseSkillValue(Unit const* target) const -{ +{ if (GetTypeId() == TYPEID_PLAYER) { // in PvP use full skill instead current skill value @@ -2935,7 +2928,7 @@ uint32 Unit::GetDefenseSkillValue(Unit const* target) const } float Unit::GetUnitDodgeChance() const -{ +{ if (GetTypeId() == TYPEID_PLAYER) return ToPlayer()->GetRealDodge(); //GetFloatValue(PLAYER_DODGE_PERCENTAGE); else @@ -2952,7 +2945,7 @@ float Unit::GetUnitDodgeChance() const } float Unit::GetUnitParryChance() const -{ +{ float chance = 0.0f; if (Player const* player = ToPlayer()) @@ -2982,7 +2975,7 @@ float Unit::GetUnitParryChance() const } float Unit::GetUnitMissChance(WeaponAttackType attType) const -{ +{ float miss_chance = 5.00f; if (Player const* player = ToPlayer()) @@ -2997,7 +2990,7 @@ float Unit::GetUnitMissChance(WeaponAttackType attType) const } float Unit::GetUnitBlockChance() const -{ +{ if (Player const* player = ToPlayer()) { if (player->CanBlock()) @@ -3023,7 +3016,7 @@ float Unit::GetUnitBlockChance() const } float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit* victim) const -{ +{ float crit; if (GetTypeId() == TYPEID_PLAYER) @@ -3085,7 +3078,7 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit* victi } uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) const -{ +{ uint32 value = 0; if (Player const* player = ToPlayer()) { @@ -3125,7 +3118,7 @@ uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) } void Unit::_DeleteRemovedAuras() -{ +{ while (!m_removedAuras.empty()) { delete m_removedAuras.front(); @@ -3134,7 +3127,7 @@ void Unit::_DeleteRemovedAuras() } void Unit::_UpdateSpells(uint32 time) -{ +{ if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) _UpdateAutoRepeatSpell(); @@ -3190,7 +3183,7 @@ void Unit::_UpdateSpells(uint32 time) } void Unit::_UpdateAutoRepeatSpell() -{ +{ // check "realtime" interrupts if ((GetTypeId() == TYPEID_PLAYER && ToPlayer()->isMoving()) || IsNonMeleeSpellCast(false, false, true, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == 75)) { @@ -3226,7 +3219,7 @@ void Unit::_UpdateAutoRepeatSpell() } void Unit::SetCurrentCastedSpell(Spell* pSpell) -{ +{ ASSERT(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells CurrentSpellTypes CSpellType = pSpell->GetCurrentContainer(); @@ -3331,7 +3324,7 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi } void Unit::FinishSpell(CurrentSpellTypes spellType, bool ok /*= true*/) -{ +{ Spell* spell = m_currentSpells[spellType]; if (!spell) return; @@ -3373,7 +3366,7 @@ bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled, bool skipAu } void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withInstant, bool bySelf) -{ +{ // generic spells are interrupted if they are not finished or delayed if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id == spell_id)) InterruptSpell(CURRENT_GENERIC_SPELL, withDelayed, withInstant, bySelf); @@ -3388,7 +3381,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withI } Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const -{ +{ for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id == spell_id) return m_currentSpells[i]; @@ -3396,24 +3389,24 @@ Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const } int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const -{ +{ if (Spell const* spell = FindCurrentSpellBySpellId(spell_id)) return spell->GetCastTime(); return 0; } bool Unit::isInFrontInMap(Unit const* target, float distance, float arc) const -{ +{ return IsWithinDistInMap(target, distance) && HasInArc(arc, target); } bool Unit::isInBackInMap(Unit const* target, float distance, float arc) const -{ +{ return IsWithinDistInMap(target, distance) && !HasInArc(2 * M_PI - arc, target); } bool Unit::isInAccessiblePlaceFor(Creature const* c) const -{ +{ if (c->GetMapId() == 618) // Ring of Valor { // skip transport check, check for being below floor level @@ -3431,7 +3424,7 @@ bool Unit::isInAccessiblePlaceFor(Creature const* c) const return false; // special handling for ICC (map 631), for non-flying pets in Gunship Battle, for trash npcs this is done via CanAIAttack - if (IS_PLAYER_GUID(c->GetOwnerGUID()) && !c->CanFly()) + if (IS_PLAYER_GUID(c->GetOwnerGUID()) && !c->CanFly()) { if ((c->GetTransport() && !this->GetTransport()) || (!c->GetTransport() && this->GetTransport())) return false; @@ -3466,7 +3459,7 @@ bool Unit::isInAccessiblePlaceFor(Creature const* c) const } void Unit::UpdateEnvironmentIfNeeded(const uint8 option) -{ +{ if (m_is_updating_environment) return; @@ -3704,7 +3697,7 @@ void SafeUnitPointer::UnitDeleted() } void Unit::HandleSafeUnitPointersOnDelete(Unit* thisUnit) -{ +{ if (thisUnit->SafeUnitPointerSet.empty()) return; for (std::set<SafeUnitPointer*>::iterator itr = thisUnit->SafeUnitPointerSet.begin(); itr != thisUnit->SafeUnitPointerSet.end(); ++itr) @@ -3716,28 +3709,28 @@ void Unit::HandleSafeUnitPointersOnDelete(Unit* thisUnit) } bool Unit::IsInWater(bool allowAbove) const -{ +{ const_cast<Unit*>(this)->UpdateEnvironmentIfNeeded(1); return m_last_isinwater_status || (allowAbove && m_last_islittleabovewater_status); } bool Unit::IsUnderWater() const -{ +{ const_cast<Unit*>(this)->UpdateEnvironmentIfNeeded(1); return m_last_isunderwater_status; } void Unit::UpdateUnderwaterState(Map* /*m*/, float /*x*/, float /*y*/, float /*z*/) -{ +{ } void Unit::DeMorph() -{ +{ SetDisplayId(GetNativeDisplayId()); } Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/, bool periodicReset /*= false*/) -{ +{ ASSERT(casterGUID || caster); if (!casterGUID) casterGUID = caster->GetGUID(); @@ -3796,7 +3789,7 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 } void Unit::_AddAura(UnitAura* aura, Unit* caster) -{ +{ ASSERT(!m_cleanupDone); m_ownedAuras.insert(AuraMap::value_type(aura->GetId(), aura)); @@ -3835,7 +3828,7 @@ void Unit::_AddAura(UnitAura* aura, Unit* caster) // creates aura application instance and registers it in lists // aura application effects are handled separately to prevent aura list corruption AuraApplication * Unit::_CreateAuraApplication(Aura* aura, uint8 effMask) -{ +{ // can't apply aura on unit which is going to be deleted - to not create a memory leak ASSERT(!m_cleanupDone); // aura musn't be removed @@ -3873,7 +3866,7 @@ AuraApplication * Unit::_CreateAuraApplication(Aura* aura, uint8 effMask) } void Unit::_ApplyAuraEffect(Aura* aura, uint8 effIndex) -{ +{ ASSERT(aura); ASSERT(aura->HasEffect(effIndex)); AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID()); @@ -3887,7 +3880,7 @@ void Unit::_ApplyAuraEffect(Aura* aura, uint8 effIndex) // handles effects of aura application // should be done after registering aura in lists void Unit::_ApplyAura(AuraApplication * aurApp, uint8 effMask) -{ +{ Aura* aura = aurApp->GetBase(); _RemoveNoStackAurasDueToAura(aura); @@ -3898,7 +3891,7 @@ void Unit::_ApplyAura(AuraApplication * aurApp, uint8 effMask) Unit * caster = aura->GetCaster(); // Update target aura state flag - const SpellInfo* spellInfo = aura->GetSpellInfo(); + const SpellInfo* spellInfo = aura->GetSpellInfo(); if (AuraStateType aState = spellInfo->GetAuraState()) { if (aState != AURA_STATE_CONFLAGRATE) @@ -3938,7 +3931,7 @@ void Unit::_ApplyAura(AuraApplication * aurApp, uint8 effMask) // removes aura application from lists and unapplies effects void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMode) -{ +{ AuraApplication * aurApp = i->second; ASSERT(aurApp); ASSERT(!aurApp->GetRemoveMode()); @@ -4020,7 +4013,7 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMo } void Unit::_UnapplyAura(AuraApplication * aurApp, AuraRemoveMode removeMode) -{ +{ // aura can be removed from unit only if it's applied on it, shouldn't happen ASSERT(aurApp->GetBase()->GetApplicationOfTarget(GetGUID()) == aurApp); @@ -4041,7 +4034,7 @@ void Unit::_UnapplyAura(AuraApplication * aurApp, AuraRemoveMode removeMode) } void Unit::_RemoveNoStackAurasDueToAura(Aura* aura) -{ +{ //SpellInfo const* spellProto = aura->GetSpellInfo(); // passive spell special case (only non stackable with ranks) @@ -4070,7 +4063,7 @@ void Unit::_RemoveNoStackAurasDueToAura(Aura* aura) } void Unit::_RegisterAuraEffect(AuraEffect* aurEff, bool apply) -{ +{ if (apply) m_modAuras[aurEff->GetAuraType()].push_back(aurEff); else @@ -4079,7 +4072,7 @@ void Unit::_RegisterAuraEffect(AuraEffect* aurEff, bool apply) // All aura base removes should go threw this function! void Unit::RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode) -{ +{ Aura* aura = i->second; ASSERT(!aura->IsRemoved()); @@ -4100,7 +4093,7 @@ void Unit::RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode) } void Unit::RemoveOwnedAura(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) -{ +{ for (AuraMap::iterator itr = m_ownedAuras.lower_bound(spellId); itr != m_ownedAuras.upper_bound(spellId);) if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || itr->second->GetCasterGUID() == casterGUID)) { @@ -4112,7 +4105,7 @@ void Unit::RemoveOwnedAura(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, } void Unit::RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode) -{ +{ if (aura->IsRemoved()) return; @@ -4134,7 +4127,7 @@ void Unit::RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode) } Aura* Unit::GetOwnedAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, Aura* except) const -{ +{ AuraMapBounds range = m_ownedAuras.equal_range(spellId); for (AuraMap::const_iterator itr = range.first; itr != range.second; ++itr) { @@ -4150,7 +4143,7 @@ Aura* Unit::GetOwnedAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUI } void Unit::RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode) -{ +{ AuraApplication * aurApp = i->second; // Do not remove aura which is already being removed if (aurApp->GetRemoveMode()) @@ -4163,7 +4156,7 @@ void Unit::RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode) } void Unit::RemoveAura(uint32 spellId, uint64 caster, uint8 reqEffMask, AuraRemoveMode removeMode) -{ +{ AuraApplicationMapBoundsNonConst range = m_appliedAuras.equal_range(spellId); for (AuraApplicationMap::iterator iter = range.first; iter != range.second;) { @@ -4180,7 +4173,7 @@ void Unit::RemoveAura(uint32 spellId, uint64 caster, uint8 reqEffMask, AuraRemov } void Unit::RemoveAura(AuraApplication * aurApp, AuraRemoveMode mode) -{ +{ // we've special situation here, RemoveAura called while during aura removal // this kind of call is needed only when aura effect removal handler // or event triggered by it expects to remove @@ -4215,7 +4208,7 @@ void Unit::RemoveAura(AuraApplication * aurApp, AuraRemoveMode mode) } void Unit::RemoveAura(Aura* aura, AuraRemoveMode mode) -{ +{ if (aura->IsRemoved()) return; if (AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID())) @@ -4223,7 +4216,7 @@ void Unit::RemoveAura(Aura* aura, AuraRemoveMode mode) } void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode) -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);) { Aura const* aura = iter->second->GetBase(); @@ -4239,7 +4232,7 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID, uint8 reqEff } void Unit::RemoveAuraFromStack(uint32 spellId, uint64 casterGUID, AuraRemoveMode removeMode) -{ +{ AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (AuraMap::iterator iter = range.first; iter != range.second;) { @@ -4256,7 +4249,7 @@ void Unit::RemoveAuraFromStack(uint32 spellId, uint64 casterGUID, AuraRemoveMode } void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved/*= 1*/) -{ +{ AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (AuraMap::iterator iter = range.first; iter != range.second;) { @@ -4320,7 +4313,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId } void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer) -{ +{ AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (AuraMap::iterator iter = range.first; iter != range.second;) { @@ -4399,7 +4392,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* } void Unit::RemoveAurasDueToItemSpell(uint32 spellId, uint64 castItemGuid) -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);) { if (iter->second->GetBase()->GetCastItemGUID() == castItemGuid) @@ -4413,7 +4406,7 @@ void Unit::RemoveAurasDueToItemSpell(uint32 spellId, uint64 castItemGuid) } void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura* except, bool negative, bool positive) -{ +{ // simple check if list is empty if (m_modAuras[auraType].empty()) return; @@ -4436,7 +4429,7 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura* except, } void Unit::RemoveAurasWithAttribute(uint32 flags) -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { SpellInfo const* spell = iter->second->GetBase()->GetSpellInfo(); @@ -4448,7 +4441,7 @@ void Unit::RemoveAurasWithAttribute(uint32 flags) } void Unit::RemoveNotOwnSingleTargetAuras() -{ +{ // single target auras from other casters // Iterate m_ownedAuras - aura is marked as single target in Unit::AddAura (and pushed to m_ownedAuras). // m_appliedAuras will NOT contain the aura before first Unit::Update after adding it to m_ownedAuras. @@ -4484,7 +4477,7 @@ void Unit::RemoveNotOwnSingleTargetAuras() } void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) -{ +{ if (!(m_interruptMask & flag)) return; @@ -4513,7 +4506,7 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) } void Unit::RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID) -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); @@ -4555,7 +4548,7 @@ void Unit::RemoveMovementImpairingAuras(bool withRoot) } void Unit::RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemode, uint32 except) -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); @@ -4577,7 +4570,7 @@ void Unit::RemoveAurasByShapeShift() for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); - if ((aura->GetSpellInfo()->GetAllEffectsMechanicMask() & mechanic_mask) && + if ((aura->GetSpellInfo()->GetAllEffectsMechanicMask() & mechanic_mask) && (!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_AURA_CC) || (aura->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_WARRIOR && (aura->GetSpellInfo()->SpellFamilyFlags[1] & 0x20)))) { RemoveAura(iter); @@ -4588,7 +4581,7 @@ void Unit::RemoveAurasByShapeShift() } void Unit::RemoveAreaAurasDueToLeaveWorld() -{ +{ // make sure that all area auras not applied on self are removed - prevent access to deleted pointer later for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();) { @@ -4621,7 +4614,7 @@ void Unit::RemoveAreaAurasDueToLeaveWorld() } void Unit::RemoveAllAuras() -{ +{ // this may be a dead loop if some events on aura remove will continiously apply aura on remove // we want to have all auras removed, so use your brain when linking events while (!m_appliedAuras.empty() || !m_ownedAuras.empty()) @@ -4637,7 +4630,7 @@ void Unit::RemoveAllAuras() } void Unit::RemoveArenaAuras() -{ +{ // in join, remove positive buffs, on end, remove negative // used to remove positive visible auras in arenas for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) @@ -4660,7 +4653,7 @@ void Unit::RemoveArenaAuras() } void Unit::RemoveAllAurasOnDeath() -{ +{ // used just after dieing to remove all visible auras // and disable the mods for the passive ones for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) @@ -4683,7 +4676,7 @@ void Unit::RemoveAllAurasOnDeath() } void Unit::RemoveAllAurasRequiringDeadTarget() -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); @@ -4704,7 +4697,7 @@ void Unit::RemoveAllAurasRequiringDeadTarget() } void Unit::RemoveAllAurasExceptType(AuraType type) -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); @@ -4726,7 +4719,7 @@ void Unit::RemoveAllAurasExceptType(AuraType type) // pussywizard: replaced with Unit::RemoveEvadeAuras() /*void Unit::RemoveAllAurasExceptType(AuraType type1, AuraType type2) -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); @@ -4748,7 +4741,7 @@ void Unit::RemoveAllAurasExceptType(AuraType type) // Xinef: We should not remove passive auras on evade, if npc has player owner (scripted one cast auras) void Unit::RemoveEvadeAuras() -{ +{ for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) { Aura const* aura = iter->second->GetBase(); @@ -4769,7 +4762,7 @@ void Unit::RemoveEvadeAuras() } void Unit::DelayOwnedAuras(uint32 spellId, uint64 caster, int32 delaytime) -{ +{ AuraMapBoundsNonConst range = m_ownedAuras.equal_range(spellId); for (; range.first != range.second; ++range.first) { @@ -4791,19 +4784,19 @@ void Unit::DelayOwnedAuras(uint32 spellId, uint64 caster, int32 delaytime) } void Unit::_RemoveAllAuraStatMods() -{ +{ for (AuraApplicationMap::iterator i = m_appliedAuras.begin(); i != m_appliedAuras.end(); ++i) (*i).second->GetBase()->HandleAllEffects(i->second, AURA_EFFECT_HANDLE_STAT, false); } void Unit::_ApplyAllAuraStatMods() -{ +{ for (AuraApplicationMap::iterator i = m_appliedAuras.begin(); i != m_appliedAuras.end(); ++i) (*i).second->GetBase()->HandleAllEffects(i->second, AURA_EFFECT_HANDLE_STAT, true); } AuraEffect* Unit::GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) const -{ +{ AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) { @@ -4817,7 +4810,7 @@ AuraEffect* Unit::GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) c } AuraEffect* Unit::GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, uint64 caster) const -{ +{ uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId); while (rankSpell) { @@ -4829,7 +4822,7 @@ AuraEffect* Unit::GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, uin } AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const -{ +{ AuraEffectList const& auras = GetAuraEffectsByType(type); for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { @@ -4843,7 +4836,7 @@ AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 ico } AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID) const -{ +{ AuraEffectList const& auras = GetAuraEffectsByType(type); for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i) { @@ -4859,7 +4852,7 @@ AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 f } AuraEffect* Unit::GetAuraEffectDummy(uint32 spellid) const -{ +{ AuraEffectList const& auras = GetAuraEffectsByType(SPELL_AURA_DUMMY); for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { @@ -4871,7 +4864,7 @@ AuraEffect* Unit::GetAuraEffectDummy(uint32 spellid) const } AuraApplication * Unit::GetAuraApplication(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, AuraApplication * except) const -{ +{ AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); for (; range.first != range.second; ++range.first) { @@ -4890,13 +4883,13 @@ AuraApplication * Unit::GetAuraApplication(uint32 spellId, uint64 casterGUID, ui } Aura* Unit::GetAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask) const -{ +{ AuraApplication * aurApp = GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask); return aurApp ? aurApp->GetBase() : NULL; } AuraApplication * Unit::GetAuraApplicationOfRankedSpell(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask, AuraApplication* except) const -{ +{ uint32 rankSpell = sSpellMgr->GetFirstSpellInChain(spellId); while (rankSpell) { @@ -4908,13 +4901,13 @@ AuraApplication * Unit::GetAuraApplicationOfRankedSpell(uint32 spellId, uint64 c } Aura* Unit::GetAuraOfRankedSpell(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask) const -{ +{ AuraApplication * aurApp = GetAuraApplicationOfRankedSpell(spellId, casterGUID, itemCasterGUID, reqEffMask); return aurApp ? aurApp->GetBase() : NULL; } void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList) -{ +{ // we should not be able to dispel diseases if the target is affected by unholy blight if (dispelMask & (1 << DISPEL_DISEASE) && HasAura(50536)) dispelMask &= ~(1 << DISPEL_DISEASE); @@ -4951,7 +4944,7 @@ void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelCharges } bool Unit::HasAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) const -{ +{ AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); for (AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) { @@ -4965,7 +4958,7 @@ bool Unit::HasAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster) const } uint32 Unit::GetAuraCount(uint32 spellId) const -{ +{ uint32 count = 0; AuraApplicationMapBounds range = m_appliedAuras.equal_range(spellId); @@ -4981,19 +4974,19 @@ uint32 Unit::GetAuraCount(uint32 spellId) const } bool Unit::HasAura(uint32 spellId, uint64 casterGUID, uint64 itemCasterGUID, uint8 reqEffMask) const -{ +{ if (GetAuraApplication(spellId, casterGUID, itemCasterGUID, reqEffMask)) return true; return false; } bool Unit::HasAuraType(AuraType auraType) const -{ +{ return (!m_modAuras[auraType].empty()); } bool Unit::HasAuraTypeWithCaster(AuraType auratype, uint64 caster) const -{ +{ AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) if (caster == (*i)->GetCasterGUID()) @@ -5002,7 +4995,7 @@ bool Unit::HasAuraTypeWithCaster(AuraType auratype, uint64 caster) const } bool Unit::HasVisibleAuraType(AuraType auraType) const -{ +{ AuraEffectList const& mAuraList = GetAuraEffectsByType(auraType); for (AuraEffectList::const_iterator i = mAuraList.begin(); i != mAuraList.end(); ++i) if( (*i)->GetBase()->CanBeSentToClient() ) @@ -5012,7 +5005,7 @@ bool Unit::HasVisibleAuraType(AuraType auraType) const } bool Unit::HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const -{ +{ AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) if (miscvalue == (*i)->GetMiscValue()) @@ -5021,7 +5014,7 @@ bool Unit::HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const } bool Unit::HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const -{ +{ AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) if ((*i)->IsAffectedOnSpell(affectedSpell)) @@ -5030,7 +5023,7 @@ bool Unit::HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const* affecte } bool Unit::HasAuraTypeWithValue(AuraType auratype, int32 value) const -{ +{ AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) if (value == (*i)->GetAmount()) @@ -5039,7 +5032,7 @@ bool Unit::HasAuraTypeWithValue(AuraType auratype, int32 value) const } bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid) -{ +{ if (!(m_interruptMask & flag)) return false; for (AuraApplicationList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); ++iter) @@ -5051,7 +5044,7 @@ bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid) } bool Unit::HasNegativeAuraWithAttribute(uint32 flag, uint64 guid) -{ +{ for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter) { Aura const* aura = iter->second->GetBase(); @@ -5062,7 +5055,7 @@ bool Unit::HasNegativeAuraWithAttribute(uint32 flag, uint64 guid) } bool Unit::HasAuraWithMechanic(uint32 mechanicMask) const -{ +{ for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter) { SpellInfo const* spellInfo = iter->second->GetBase()->GetSpellInfo(); @@ -5079,7 +5072,7 @@ bool Unit::HasAuraWithMechanic(uint32 mechanicMask) const } AuraEffect* Unit::IsScriptOverriden(SpellInfo const* spell, int32 script) const -{ +{ AuraEffectList const& auras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i) { @@ -5091,7 +5084,7 @@ AuraEffect* Unit::IsScriptOverriden(SpellInfo const* spell, int32 script) const } uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, uint8 mode) -{ +{ static const AuraType diseaseAuraTypes[] = { SPELL_AURA_PERIODIC_DAMAGE, // Frost Fever and Blood Plague @@ -5137,7 +5130,7 @@ uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, uint8 mode) } uint32 Unit::GetDoTsByCaster(uint64 casterGUID) const -{ +{ static const AuraType diseaseAuraTypes[] = { SPELL_AURA_PERIODIC_DAMAGE, @@ -5160,7 +5153,7 @@ uint32 Unit::GetDoTsByCaster(uint64 casterGUID) const } int32 Unit::GetTotalAuraModifierAreaExclusive(AuraType auratype) const -{ +{ int32 modifier = 0; int32 areaModifier = 0; @@ -5180,7 +5173,7 @@ int32 Unit::GetTotalAuraModifierAreaExclusive(AuraType auratype) const } int32 Unit::GetTotalAuraModifier(AuraType auratype) const -{ +{ AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); if (mTotalAuraList.empty()) return 0; @@ -5194,7 +5187,7 @@ int32 Unit::GetTotalAuraModifier(AuraType auratype) const } float Unit::GetTotalAuraMultiplier(AuraType auratype) const -{ +{ float multiplier = 1.0f; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5205,7 +5198,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auratype) const } int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5219,7 +5212,7 @@ int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) } int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5231,7 +5224,7 @@ int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const } int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5244,7 +5237,7 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) } float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const -{ +{ float multiplier = 1.0f; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5256,7 +5249,7 @@ float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask } int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask, const AuraEffect* except) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5270,7 +5263,7 @@ int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_ } int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5284,7 +5277,7 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_ } int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5296,7 +5289,7 @@ int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) } float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const -{ +{ float multiplier = 1.0f; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5308,7 +5301,7 @@ float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_valu } int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5322,7 +5315,7 @@ int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_ } int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5336,7 +5329,7 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_ } int32 Unit::GetTotalAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5348,7 +5341,7 @@ int32 Unit::GetTotalAuraModifierByAffectMask(AuraType auratype, SpellInfo const* } float Unit::GetTotalAuraMultiplierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const -{ +{ float multiplier = 1.0f; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5360,7 +5353,7 @@ float Unit::GetTotalAuraMultiplierByAffectMask(AuraType auratype, SpellInfo cons } int32 Unit::GetMaxPositiveAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5374,7 +5367,7 @@ int32 Unit::GetMaxPositiveAuraModifierByAffectMask(AuraType auratype, SpellInfo } int32 Unit::GetMaxNegativeAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const -{ +{ int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); @@ -5388,17 +5381,17 @@ int32 Unit::GetMaxNegativeAuraModifierByAffectMask(AuraType auratype, SpellInfo } void Unit::_RegisterDynObject(DynamicObject* dynObj) -{ +{ m_dynObj.push_back(dynObj); } void Unit::_UnregisterDynObject(DynamicObject* dynObj) -{ +{ m_dynObj.remove(dynObj); } DynamicObject* Unit::GetDynObject(uint32 spellId) -{ +{ if (m_dynObj.empty()) return NULL; for (DynObjectList::const_iterator i = m_dynObj.begin(); i != m_dynObj.end();++i) @@ -5411,7 +5404,7 @@ DynamicObject* Unit::GetDynObject(uint32 spellId) } void Unit::RemoveDynObject(uint32 spellId) -{ +{ if (m_dynObj.empty()) return; for (DynObjectList::iterator i = m_dynObj.begin(); i != m_dynObj.end();) @@ -5428,13 +5421,13 @@ void Unit::RemoveDynObject(uint32 spellId) } void Unit::RemoveAllDynObjects() -{ +{ while (!m_dynObj.empty()) m_dynObj.front()->Remove(); } GameObject* Unit::GetGameObject(uint32 spellId) const -{ +{ for (GameObjectList::const_iterator itr = m_gameObj.begin(); itr != m_gameObj.end(); ++itr) if (GameObject* go = ObjectAccessor::GetGameObject(*this, *itr)) if (go->GetSpellId() == spellId) @@ -5444,7 +5437,7 @@ GameObject* Unit::GetGameObject(uint32 spellId) const } void Unit::AddGameObject(GameObject* gameObj) -{ +{ if (!gameObj || gameObj->GetOwnerGUID() != 0) return; @@ -5462,7 +5455,7 @@ void Unit::AddGameObject(GameObject* gameObj) } void Unit::RemoveGameObject(GameObject* gameObj, bool del) -{ +{ if (!gameObj || gameObj->GetOwnerGUID() != GetGUID()) return; @@ -5502,7 +5495,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del) } void Unit::RemoveGameObject(uint32 spellid, bool del) -{ +{ if (m_gameObj.empty()) return; @@ -5528,7 +5521,7 @@ void Unit::RemoveGameObject(uint32 spellid, bool del) } void Unit::RemoveAllGameObjects() -{ +{ while(!m_gameObj.empty()) { GameObject* go = ObjectAccessor::GetGameObject(*this, *m_gameObj.begin()); @@ -5543,7 +5536,7 @@ void Unit::RemoveAllGameObjects() } void Unit::SendSpellNonMeleeReflectLog(SpellNonMeleeDamage* log, Unit* attacker) -{ +{ // Xinef: function for players only, placed in unit because of cosmetics if (GetTypeId() != TYPEID_PLAYER) return; @@ -5567,7 +5560,7 @@ void Unit::SendSpellNonMeleeReflectLog(SpellNonMeleeDamage* log, Unit* attacker) } void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log) -{ +{ WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+4+1+4+4+1+1+4+4+1)); // we guess size data.append(log->target->GetPackGUID()); data.append(log->attacker->GetPackGUID()); @@ -5587,7 +5580,7 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log) } void Unit::SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit) -{ +{ SpellNonMeleeDamage log(this, target, SpellID, damageSchoolMask); log.damage = Damage - AbsorbedDamage - Resist - Blocked; log.absorb = AbsorbedDamage; @@ -5601,7 +5594,7 @@ void Unit::SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damag } void Unit::ProcDamageAndSpell(Unit* victim, uint32 procAttacker, uint32 procVictim, uint32 procExtra, uint32 amount, WeaponAttackType attType, SpellInfo const* procSpell, SpellInfo const* procAura) -{ +{ // Not much to do if no flags are set. if (procAttacker) ProcDamageAndSpellFor(false, victim, procAttacker, procExtra, attType, procSpell, amount, procAura); @@ -5612,7 +5605,7 @@ void Unit::ProcDamageAndSpell(Unit* victim, uint32 procAttacker, uint32 procVict } void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo) -{ +{ AuraEffect const* aura = pInfo->auraEff; WorldPacket data(SMSG_PERIODICAURALOG, 30); @@ -5658,7 +5651,7 @@ void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo) } void Unit::SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo) -{ +{ WorldPacket data(SMSG_SPELLLOGMISS, (4+8+1+4+8+1)); data << uint32(spellID); data << uint64(GetGUID()); @@ -5672,7 +5665,7 @@ void Unit::SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo) } void Unit::SendSpellDamageResist(Unit* target, uint32 spellId) -{ +{ WorldPacket data(SMSG_PROCRESIST, 8+8+4+1); data << uint64(GetGUID()); data << uint64(target->GetGUID()); @@ -5682,7 +5675,7 @@ void Unit::SendSpellDamageResist(Unit* target, uint32 spellId) } void Unit::SendSpellDamageImmune(Unit* target, uint32 spellId) -{ +{ WorldPacket data(SMSG_SPELLORDAMAGE_IMMUNE, 8+8+4+1); data << uint64(GetGUID()); data << uint64(target->GetGUID()); @@ -5692,7 +5685,7 @@ void Unit::SendSpellDamageImmune(Unit* target, uint32 spellId) } void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo) -{ +{ #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_UNITS, "WORLD: Sending SMSG_ATTACKERSTATEUPDATE"); #endif @@ -5758,7 +5751,7 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo) } void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType*/, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) -{ +{ CalcDamageInfo dmgInfo; dmgInfo.HitInfo = HitInfo; dmgInfo.attacker = this; @@ -5774,7 +5767,7 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType //victim may be NULL bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) -{ +{ SpellInfo const* dummySpell = triggeredByAura->GetSpellInfo(); uint32 effIndex = triggeredByAura->GetEffIndex(); int32 triggerAmount = triggeredByAura->GetAmount(); @@ -6966,7 +6959,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere { if (!victim) return false; - + Unit* beaconTarget = triggeredByAura->GetBase()->GetCaster(); if (!beaconTarget || beaconTarget == this || !beaconTarget->GetAura(53563, victim->GetGUID())) return false; @@ -6979,7 +6972,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere victim->CastCustomSpell(beaconTarget, triggered_spell_id, &basepoints0, NULL, NULL, true, 0, triggeredByAura, victim->GetGUID()); return true; } - + return false; } // Judgements of the Wise @@ -7603,7 +7596,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // do not reduce damage-spells have correct basepoints damage /= 2; int32 dmg = damage; - + // Cast CastCustomSpell(victim, spell, &dmg, 0, 0, true, castItem, triggeredByAura); } while (roll_chance_i(33)); @@ -7662,7 +7655,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere //Glyph of Unholy Blight if (AuraEffect* glyph=GetAuraEffect(63332, 0)) AddPct(basepoints0, glyph->GetAmount()); - + basepoints0 = basepoints0 / (unholyBlight->GetMaxDuration() / unholyBlight->Effects[0].Amplitude); victim->CastDelayedSpellWithPeriodicAmount(this, triggered_spell_id, SPELL_AURA_PERIODIC_DAMAGE, basepoints0); return true; @@ -7899,7 +7892,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Used in case when access to whole aura is needed // All procs should be handled like this... bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, SpellInfo const* /*procSpell*/, uint32 /*procFlag*/, uint32 procEx, uint32 /*cooldown*/, bool * handled) -{ +{ SpellInfo const* dummySpell = triggeredByAura->GetSpellInfo(); switch (dummySpell->SpellFamilyName) @@ -8076,7 +8069,7 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp } bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlags, uint32 procEx, uint32 cooldown) -{ +{ // Get triggered aura spell info SpellInfo const* auraSpellInfo = triggeredByAura->GetSpellInfo(); @@ -8706,7 +8699,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg return true; } } - + // Custom basepoints/target for exist spell // dummy basepoints or other customs @@ -8986,7 +8979,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg } bool Unit::HandleOverrideClassScriptAuraProc(Unit* victim, uint32 /*damage*/, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 cooldown) -{ +{ int32 scriptId = triggeredByAura->GetMiscValue(); if (!victim || !victim->IsAlive()) @@ -9091,7 +9084,7 @@ bool Unit::HandleOverrideClassScriptAuraProc(Unit* victim, uint32 /*damage*/, Au void Unit::setPowerType(Powers new_powertype) -{ +{ SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype); if (GetTypeId() == TYPEID_PLAYER) @@ -9146,7 +9139,7 @@ void Unit::setPowerType(Powers new_powertype) } FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const -{ +{ FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction()); if (!entry) { @@ -9168,7 +9161,7 @@ FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const } void Unit::setFaction(uint32 faction) -{ +{ SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); if (GetTypeId() == TYPEID_UNIT) ToCreature()->UpdateMoveInLineOfSightState(); @@ -9176,7 +9169,7 @@ void Unit::setFaction(uint32 faction) // function based on function Unit::UnitReaction from 13850 client ReputationRank Unit::GetReactionTo(Unit const* target) const -{ +{ // always friendly to self if (this == target) return REP_FRIENDLY; @@ -9189,7 +9182,7 @@ ReputationRank Unit::GetReactionTo(Unit const* target) const Player const* targetPlayerOwner = target->GetAffectingPlayer(); // check forced reputation to support SPELL_AURA_FORCE_REACTION - if (selfPlayerOwner) + if (selfPlayerOwner) { if (FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry()) if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry)) @@ -9261,7 +9254,7 @@ ReputationRank Unit::GetReactionTo(Unit const* target) const } ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTemplateEntry, Unit const* target) const -{ +{ // always neutral when no template entry found if (!factionTemplateEntry) return REP_NEUTRAL; @@ -9313,17 +9306,17 @@ ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTem } bool Unit::IsHostileTo(Unit const* unit) const -{ +{ return GetReactionTo(unit) <= REP_HOSTILE; } bool Unit::IsFriendlyTo(Unit const* unit) const -{ +{ return GetReactionTo(unit) >= REP_FRIENDLY; } bool Unit::IsHostileToPlayers() const -{ +{ FactionTemplateEntry const* my_faction = GetFactionTemplateEntry(); if (!my_faction || !my_faction->faction) return false; @@ -9336,7 +9329,7 @@ bool Unit::IsHostileToPlayers() const } bool Unit::IsNeutralToAll() const -{ +{ FactionTemplateEntry const* my_faction = GetFactionTemplateEntry(); if (!my_faction || !my_faction->faction) return true; @@ -9349,7 +9342,7 @@ bool Unit::IsNeutralToAll() const } bool Unit::Attack(Unit* victim, bool meleeAttack) -{ +{ if (!victim || victim == this) return false; @@ -9458,13 +9451,13 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) for (Unit::ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) if (Unit* pet = *itr) if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT) - pet->ToCreature()->AI()->OwnerAttacked(victim); + pet->ToCreature()->AI()->OwnerAttacked(victim); return true; } bool Unit::AttackStop() -{ +{ if (!m_attacking) return false; @@ -9498,7 +9491,7 @@ bool Unit::AttackStop() } void Unit::CombatStop(bool includingCast) -{ +{ if (includingCast && IsNonMeleeSpellCast(false)) InterruptNonMeleeSpells(false); @@ -9514,7 +9507,7 @@ void Unit::CombatStop(bool includingCast) } void Unit::CombatStopWithPets(bool includingCast) -{ +{ CombatStop(includingCast); for (ControlSet::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) @@ -9522,7 +9515,7 @@ void Unit::CombatStopWithPets(bool includingCast) } bool Unit::isAttackingPlayer() const -{ +{ if (HasUnitState(UNIT_STATE_ATTACK_PLAYER)) return true; @@ -9541,7 +9534,7 @@ bool Unit::isAttackingPlayer() const } void Unit::RemoveAllAttackers() -{ +{ while (!m_attackers.empty()) { AttackerSet::iterator iter = m_attackers.begin(); @@ -9554,7 +9547,7 @@ void Unit::RemoveAllAttackers() } void Unit::ModifyAuraState(AuraStateType flag, bool apply) -{ +{ if (apply) { if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1))) @@ -9594,7 +9587,7 @@ void Unit::ModifyAuraState(AuraStateType flag, bool apply) } uint32 Unit::BuildAuraStateUpdateForTarget(Unit* target) const -{ +{ uint32 auraStates = GetUInt32Value(UNIT_FIELD_AURASTATE) &~(PER_CASTER_AURA_STATE_MASK); for (AuraStateAurasMap::const_iterator itr = m_auraStateAuras.begin(); itr != m_auraStateAuras.end(); ++itr) if ((1<<(itr->first-1)) & PER_CASTER_AURA_STATE_MASK) @@ -9605,7 +9598,7 @@ uint32 Unit::BuildAuraStateUpdateForTarget(Unit* target) const } bool Unit::HasAuraState(AuraStateType flag, SpellInfo const* spellProto, Unit const* Caster) const -{ +{ if (Caster) { if (spellProto) @@ -9631,7 +9624,7 @@ bool Unit::HasAuraState(AuraStateType flag, SpellInfo const* spellProto, Unit co } void Unit::SetOwnerGUID(uint64 owner) -{ +{ if (GetOwnerGUID() == owner) return; @@ -9658,7 +9651,7 @@ void Unit::SetOwnerGUID(uint64 owner) } Unit* Unit::GetOwner() const -{ +{ if (uint64 ownerGUID = GetOwnerGUID()) return ObjectAccessor::GetUnit(*this, ownerGUID); @@ -9666,7 +9659,7 @@ Unit* Unit::GetOwner() const } Unit* Unit::GetCharmer() const -{ +{ if (uint64 charmerGUID = GetCharmerGUID()) return ObjectAccessor::GetUnit(*this, charmerGUID); @@ -9674,7 +9667,7 @@ Unit* Unit::GetCharmer() const } Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const -{ +{ uint64 guid = GetCharmerOrOwnerGUID(); if (IS_PLAYER_GUID(guid)) return ObjectAccessor::GetPlayer(*this, guid); @@ -9683,7 +9676,7 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const } Player* Unit::GetAffectingPlayer() const -{ +{ if (!GetCharmerOrOwnerGUID()) return const_cast<Unit*>(this)->ToPlayer(); @@ -9709,7 +9702,7 @@ Minion *Unit::GetFirstMinion() const } Guardian* Unit::GetGuardianPet() const -{ +{ if (uint64 pet_guid = GetPetGUID()) { if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid)) @@ -9724,7 +9717,7 @@ Guardian* Unit::GetGuardianPet() const } Unit* Unit::GetCharm() const -{ +{ if (uint64 charm_guid = GetCharmGUID()) { if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) @@ -9738,7 +9731,7 @@ Unit* Unit::GetCharm() const } void Unit::SetMinion(Minion *minion, bool apply) -{ +{ #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_UNITS, "SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply); #endif @@ -9906,7 +9899,7 @@ void Unit::SetMinion(Minion *minion, bool apply) } void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry) -{ +{ for (Unit::ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();) { Unit* unit = *itr; @@ -9918,7 +9911,7 @@ void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry) } void Unit::RemoveAllMinionsByEntry(uint32 entry) -{ +{ for (Unit::ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();) { Unit* unit = *itr; @@ -9931,7 +9924,7 @@ void Unit::RemoveAllMinionsByEntry(uint32 entry) } void Unit::SetCharm(Unit* charm, bool apply) -{ +{ if (apply) { if (GetTypeId() == TYPEID_PLAYER) @@ -10010,10 +10003,10 @@ int32 Unit::DealHeal(Unit* healer, Unit* victim, uint32 addhealth) if (addhealth) gain = victim->ModifyHealth(int32(addhealth)); - + // Hook for OnHeal Event sScriptMgr->OnHeal(healer, victim, (uint32&)gain); - + Unit* unit = healer; if (healer && healer->GetTypeId() == TYPEID_UNIT && healer->ToCreature()->IsTotem()) @@ -10064,7 +10057,7 @@ bool RedirectSpellEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) } Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) -{ +{ // Patch 1.2 notes: Spell Reflection no longer reflects abilities if (spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR1_CANT_BE_REDIRECTED) || spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)) return victim; @@ -10094,7 +10087,7 @@ Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) magnet->m_Events.AddEvent(new KillMagnetEvent(*magnet), queueTime); } - + return magnet; } } @@ -10102,7 +10095,7 @@ Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) } Unit* Unit::GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) -{ +{ AuraEffectList const& hitTriggerAuras = victim->GetAuraEffectsByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER); for (AuraEffectList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i) { @@ -10120,7 +10113,7 @@ Unit* Unit::GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo) } Unit* Unit::GetFirstControlled() const -{ +{ // Sequence: charmed, pet, other guardians Unit* unit = GetCharm(); if (!unit) @@ -10131,7 +10124,7 @@ Unit* Unit::GetFirstControlled() const } void Unit::RemoveAllControlled() -{ +{ // possessed pet and vehicle if (GetTypeId() == TYPEID_PLAYER) ToPlayer()->StopCastingCharm(); @@ -10156,7 +10149,7 @@ void Unit::RemoveAllControlled() } Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) -{ +{ Player* player = NULL; if (GetTypeId() == TYPEID_PLAYER) player = ToPlayer(); @@ -10211,7 +10204,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) // only called in Player::SetSeer // so move it to Player? void Unit::AddPlayerToVision(Player* player) -{ +{ if (m_sharedVision.empty()) { setActive(true); @@ -10223,7 +10216,7 @@ void Unit::AddPlayerToVision(Player* player) // only called in Player::SetSeer void Unit::RemovePlayerFromVision(Player* player) -{ +{ m_sharedVision.erase(player); player->m_isInSharedVisionOf.erase(this); if (m_sharedVision.empty()) @@ -10234,12 +10227,12 @@ void Unit::RemovePlayerFromVision(Player* player) } void Unit::RemoveBindSightAuras() -{ +{ RemoveAurasByType(SPELL_AURA_BIND_SIGHT); } void Unit::RemoveCharmAuras() -{ +{ RemoveAurasByType(SPELL_AURA_MOD_CHARM); RemoveAurasByType(SPELL_AURA_MOD_POSSESS_PET); RemoveAurasByType(SPELL_AURA_MOD_POSSESS); @@ -10247,7 +10240,7 @@ void Unit::RemoveCharmAuras() } void Unit::UnsummonAllTotems() -{ +{ for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i) { if (!m_SummonSlot[i]) @@ -10260,7 +10253,7 @@ void Unit::UnsummonAllTotems() } void Unit::SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 OverHeal, uint32 Absorb, bool critical) -{ +{ // we guess size WorldPacket data(SMSG_SPELLHEALLOG, (8+8+4+4+4+4+1+1)); data.append(victim->GetPackGUID()); @@ -10275,20 +10268,20 @@ void Unit::SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 } int32 Unit::HealBySpell(Unit* victim, SpellInfo const* spellInfo, uint32 addHealth, bool critical) -{ +{ uint32 absorb = 0; // calculate heal absorb and reduce healing CalcHealAbsorb(victim, spellInfo, addHealth, absorb); - + sScriptMgr->ModifyHealRecieved(this, victim, addHealth); - + int32 gain = Unit::DealHeal(this, victim, addHealth); SendHealSpellLog(victim, spellInfo->Id, addHealth, uint32(addHealth - gain), absorb, critical); return gain; } void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellID, uint32 damage, Powers powerType) -{ +{ WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); data.append(victim->GetPackGUID()); data.append(GetPackGUID()); @@ -10299,7 +10292,7 @@ void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellID, uint32 damage, Pow } void Unit::EnergizeBySpell(Unit* victim, uint32 spellID, uint32 damage, Powers powerType) -{ +{ SendEnergizeSpellLog(victim, spellID, damage, powerType); // needs to be called after sending spell log victim->ModifyPower(powerType, damage); @@ -10309,7 +10302,7 @@ void Unit::EnergizeBySpell(Unit* victim, uint32 spellID, uint32 damage, Powers p } float Unit::SpellPctDamageModsDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) -{ +{ if (!spellProto || !victim || damagetype == DIRECT_DAMAGE) return 1.0f; @@ -10625,7 +10618,7 @@ float Unit::SpellPctDamageModsDone(Unit* victim, SpellInfo const* spellProto, Da } uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, float TotalMod, uint32 stack) -{ +{ if (!spellProto || !victim || damagetype == DIRECT_DAMAGE) return pdamage; @@ -10653,7 +10646,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin float ApCoeffMod = 1.0f; int32 DoneTotal = 0; float DoneTotalMod = TotalMod ? TotalMod : SpellPctDamageModsDone(victim, spellProto, damagetype); - + // Config : RATE_CREATURE_X_SPELLDAMAGE & Do Not Modify Pet/Guardian/Mind Controled Damage if (GetTypeId() == TYPEID_UNIT && (!ToCreature()->IsPet() || !ToCreature()->IsGuardian() || !ToCreature()->IsControlledByPlayer())) DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank); @@ -10758,7 +10751,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod); } - + float tmpDamage = (float(pdamage) + DoneTotal) * DoneTotalMod; // apply spellmod to Done damage (flat and pct) if (Player* modOwner = GetSpellModOwner()) @@ -10768,7 +10761,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin } uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) -{ +{ if (!spellProto || damagetype == DIRECT_DAMAGE) return pdamage; @@ -10898,7 +10891,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui } int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) -{ +{ int32 DoneAdvertisedBenefit = 0; AuraEffectList const& mDamageDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE); @@ -10937,7 +10930,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) } int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask, bool isDoT) -{ +{ int32 TakenAdvertisedBenefit = 0; AuraEffectList const& mDamageTaken = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_TAKEN); @@ -10956,7 +10949,7 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask, bool isDoT) } float Unit::SpellDoneCritChance(Unit const* /*victim*/, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType, bool skipEffectCheck) const -{ +{ // Mobs can't crit with spells. if (GetTypeId() == TYPEID_UNIT && !GetSpellModOwner()) return -100.0f; @@ -11025,7 +11018,7 @@ float Unit::SpellDoneCritChance(Unit const* /*victim*/, SpellInfo const* spellPr } float Unit::SpellTakenCritChance(Unit const* caster, SpellInfo const* spellProto, SpellSchoolMask schoolMask, float doneChance, WeaponAttackType attackType, bool skipEffectCheck) const -{ +{ // not critting spell if (spellProto->HasAttribute(SPELL_ATTR2_CANT_CRIT)) return 0.0f; @@ -11290,7 +11283,7 @@ uint32 Unit::SpellCriticalHealingBonus(Unit const* caster, SpellInfo const* spel uint32 creatureTypeMask = victim->GetCreatureTypeMask(); crit_bonus = int32(crit_bonus * caster->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask)); } - + // adds additional damage to critBonus (from talents) // xinef: used for death knight death coil if (Player* modOwner = caster->GetSpellModOwner()) @@ -11307,7 +11300,7 @@ uint32 Unit::SpellCriticalHealingBonus(Unit const* caster, SpellInfo const* spel } float Unit::SpellPctHealingModsDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) -{ +{ // For totems get healing bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && IsTotem()) if (Unit* owner = GetOwner()) @@ -11386,7 +11379,7 @@ float Unit::SpellPctHealingModsDone(Unit* victim, SpellInfo const* spellProto, D // T9 HEALING 4P, empowered renew instant heal if (spellProto->Id == 63544) if (AuraEffect *aurEff = GetAuraEffect(67202, EFFECT_0)) - AddPct(DoneTotalMod, aurEff->GetAmount()); + AddPct(DoneTotalMod, aurEff->GetAmount()); break; } @@ -11394,7 +11387,7 @@ float Unit::SpellPctHealingModsDone(Unit* victim, SpellInfo const* spellProto, D } uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, float TotalMod, uint32 stack) -{ +{ // For totems get healing bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && IsTotem()) if (Unit* owner = GetOwner()) @@ -11503,7 +11496,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui } uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) -{ +{ float TakenTotalMod = 1.0f; // Healing taken percent @@ -11630,7 +11623,7 @@ uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, u } int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) -{ +{ int32 AdvertisedBenefit = 0; AuraEffectList const& mHealingDone = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE); @@ -11663,7 +11656,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) } int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) -{ +{ int32 AdvertisedBenefit = 0; AuraEffectList const& mDamageTaken = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING); @@ -11675,7 +11668,7 @@ int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) } bool Unit::IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const -{ +{ // If m_immuneToDamage type contain magic, IMMUNE damage. SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE]; for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr) @@ -11686,7 +11679,7 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const } bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const -{ +{ if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) return false; @@ -11701,7 +11694,7 @@ bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const } bool Unit::IsImmunedToSchool(SpellSchoolMask meleeSchoolMask) const -{ +{ // If m_immuneToSchool type contain this school type, IMMUNE damage. SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) @@ -11712,7 +11705,7 @@ bool Unit::IsImmunedToSchool(SpellSchoolMask meleeSchoolMask) const } bool Unit::IsImmunedToSchool(SpellInfo const* spellInfo) const -{ +{ if (spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) return false; @@ -11730,12 +11723,12 @@ bool Unit::IsImmunedToSchool(SpellInfo const* spellInfo) const } bool Unit::IsImmunedToDamageOrSchool(SpellSchoolMask meleeSchoolMask) const -{ +{ return IsImmunedToDamage(meleeSchoolMask) || IsImmunedToSchool(meleeSchoolMask); } bool Unit::IsImmunedToDamageOrSchool(SpellInfo const* spellInfo) const -{ +{ return IsImmunedToDamage(spellInfo) || IsImmunedToSchool(spellInfo); } @@ -11787,7 +11780,7 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) // Ignore effects with mechanic, they are supposed to be checked separately if (!spellInfo->Effects[i].IsEffect()) continue; - + // Xinef: if target is immune to one effect, and the spell has transform aura - it is immune to whole spell if (IsImmunedToSpellEffect(spellInfo, i)) { @@ -11868,7 +11861,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons } uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto) -{ +{ if (!victim || pdamage == 0) return 0; @@ -12068,7 +12061,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType } uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto) -{ +{ if (pdamage == 0) return 0; @@ -12199,7 +12192,7 @@ class spellIdImmunityPredicate }; void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType) -{ +{ if (apply) { // xinef: immunities with spellId 0 are intended to be applied only once (script purposes mosty) @@ -12226,7 +12219,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, } void Unit::ApplySpellDispelImmunity(const SpellInfo* spellProto, DispelType type, bool apply) -{ +{ ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply); if (apply && spellProto->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)) @@ -12250,7 +12243,7 @@ void Unit::ApplySpellDispelImmunity(const SpellInfo* spellProto, DispelType type } float Unit::GetWeaponProcChance() const -{ +{ // normalized proc chance for weapon attack speed // (odd formula...) if (isAttackReady(BASE_ATTACK)) @@ -12261,7 +12254,7 @@ float Unit::GetWeaponProcChance() const } float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellInfo* spellProto) const -{ +{ // proc per minute chance calculation if (PPM <= 0) return 0.0f; @@ -12275,7 +12268,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellInfo* spe } void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) -{ +{ if (mount) SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); @@ -12332,7 +12325,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) } void Unit::Dismount() -{ +{ if (!IsMounted()) return; @@ -12387,8 +12380,8 @@ void Unit::Dismount() } void Unit::SetInCombatWith(Unit* enemy, uint32 duration) -{ - +{ + // Xinef: Dont allow to start combat with triggers if (enemy->GetTypeId() == TYPEID_UNIT && enemy->ToCreature()->IsTrigger()) return; @@ -12414,7 +12407,7 @@ void Unit::SetInCombatWith(Unit* enemy, uint32 duration) } void Unit::CombatStart(Unit* target, bool initialAggro) -{ +{ // Xinef: Dont allow to start combat with triggers if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsTrigger()) @@ -12457,7 +12450,7 @@ void Unit::CombatStart(Unit* target, bool initialAggro) } void Unit::CombatStartOnCast(Unit* target, bool initialAggro, uint32 duration) -{ +{ // Xinef: Dont allow to start combat with triggers if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsTrigger()) return; @@ -12484,7 +12477,7 @@ void Unit::CombatStartOnCast(Unit* target, bool initialAggro, uint32 duration) } void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration) -{ +{ // only alive units can be in combat if (!IsAlive()) return; @@ -12553,7 +12546,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration) } void Unit::ClearInCombat() -{ +{ m_CombatTimer = 0; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); @@ -12588,7 +12581,7 @@ void Unit::ClearInPetCombat() } bool Unit::isTargetableForAttack(bool checkFakeDeath, Unit const* byWho) const -{ +{ if (!IsAlive()) return false; @@ -12605,13 +12598,13 @@ bool Unit::isTargetableForAttack(bool checkFakeDeath, Unit const* byWho) const } bool Unit::IsValidAttackTarget(Unit const* target) const -{ +{ return _IsValidAttackTarget(target, NULL); } // function based on function Unit::CanAttack from 13850 client bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, WorldObject const* obj) const -{ +{ ASSERT(target); // can't attack self @@ -12725,13 +12718,13 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo } bool Unit::IsValidAssistTarget(Unit const* target) const -{ +{ return _IsValidAssistTarget(target, NULL); } // function based on function Unit::CanAssist from 13850 client bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) const -{ +{ ASSERT(target); // can assist to self @@ -12822,7 +12815,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co } int32 Unit::ModifyHealth(int32 dVal) -{ +{ int32 gain = 0; if (dVal == 0) @@ -12854,7 +12847,7 @@ int32 Unit::ModifyHealth(int32 dVal) } int32 Unit::GetHealthGain(int32 dVal) -{ +{ int32 gain = 0; if (dVal == 0) @@ -12880,7 +12873,7 @@ int32 Unit::GetHealthGain(int32 dVal) // returns negative amount on power reduction int32 Unit::ModifyPower(Powers power, int32 dVal) -{ +{ if (dVal == 0) return 0; @@ -12913,7 +12906,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) // returns negative amount on power reduction int32 Unit::ModifyPowerPct(Powers power, float pct, bool apply) -{ +{ float amount = (float)GetMaxPower(power); ApplyPercentModFloatVar(amount, pct, apply); @@ -12921,7 +12914,7 @@ int32 Unit::ModifyPowerPct(Powers power, float pct, bool apply) } bool Unit::IsAlwaysVisibleFor(WorldObject const* seer) const -{ +{ if (WorldObject::IsAlwaysVisibleFor(seer)) return true; @@ -12940,7 +12933,7 @@ bool Unit::IsAlwaysVisibleFor(WorldObject const* seer) const } bool Unit::IsAlwaysDetectableFor(WorldObject const* seer) const -{ +{ if (WorldObject::IsAlwaysDetectableFor(seer)) return true; @@ -12958,7 +12951,7 @@ bool Unit::IsAlwaysDetectableFor(WorldObject const* seer) const } void Unit::SetVisible(bool x) -{ +{ if (!x) m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_GAMEMASTER); else @@ -12976,7 +12969,7 @@ void Unit::SetModelVisible(bool on) } void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) -{ +{ int32 main_speed_mod = 0; float stack_bonus = 1.0f; float non_stack_bonus = 1.0f; @@ -13112,7 +13105,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) int32 slow = GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); if (slow) AddPct(speed, slow); - + if (float minSpeedMod = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED)) { float base_speed = (GetTypeId() == TYPEID_UNIT ? ToCreature()->GetCreatureTemplate()->speed_run : 1.0f); @@ -13125,12 +13118,12 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) } float Unit::GetSpeed(UnitMoveType mtype) const -{ +{ return m_speed_rate[mtype]*(IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]); } void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) -{ +{ if (rate < 0) rate = 0.0f; @@ -13197,7 +13190,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) Unit* pet = ToPlayer()->GetPet(); if (!pet) pet = GetCharm(); - + // xinef: do not affect vehicles and possesed pets if (pet && (pet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) || pet->IsVehicle())) pet = NULL; @@ -13252,7 +13245,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) } void Unit::setDeathState(DeathState s, bool despawn) -{ +{ // death state needs to be updated before RemoveAllAurasOnDeath() calls HandleChannelDeathItem(..) so that // it can be used to check creation of death items (such as soul shards). @@ -13313,7 +13306,7 @@ void Unit::setDeathState(DeathState s, bool despawn) ######## ######## ########################################*/ bool Unit::CanHaveThreatList() const -{ +{ // only creatures can have threat list if (GetTypeId() != TYPEID_UNIT) return false; @@ -13340,7 +13333,7 @@ bool Unit::CanHaveThreatList() const //====================================================================== float Unit::ApplyTotalThreatModifier(float fThreat, SpellSchoolMask schoolMask) -{ +{ if (!HasAuraType(SPELL_AURA_MOD_THREAT) || fThreat < 0) return fThreat; @@ -13352,7 +13345,7 @@ float Unit::ApplyTotalThreatModifier(float fThreat, SpellSchoolMask schoolMask) //====================================================================== void Unit::AddThreat(Unit* victim, float fThreat, SpellSchoolMask schoolMask, SpellInfo const* threatSpell) -{ +{ // Only mobs can manage threat lists if (CanHaveThreatList()) m_ThreatManager.addThreat(victim, fThreat, schoolMask, threatSpell); @@ -13361,7 +13354,7 @@ void Unit::AddThreat(Unit* victim, float fThreat, SpellSchoolMask schoolMask, Sp //====================================================================== void Unit::DeleteThreatList() -{ +{ if (CanHaveThreatList() && !m_ThreatManager.isThreatListEmpty()) SendClearThreatListOpcode(); m_ThreatManager.clearReferences(); @@ -13370,7 +13363,7 @@ void Unit::DeleteThreatList() //====================================================================== void Unit::TauntApply(Unit* taunter) -{ +{ ASSERT(GetTypeId() == TYPEID_UNIT); if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && taunter->ToPlayer()->IsGameMaster())) @@ -13398,7 +13391,7 @@ void Unit::TauntApply(Unit* taunter) //====================================================================== void Unit::TauntFadeOut(Unit* taunter) -{ +{ ASSERT(GetTypeId() == TYPEID_UNIT); if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && taunter->ToPlayer()->IsGameMaster())) @@ -13436,7 +13429,7 @@ void Unit::TauntFadeOut(Unit* taunter) //====================================================================== Unit* Creature::SelectVictim() -{ +{ // function provides main threat functionality // next-victim-selection algorithm and evade mode are called // threat list sorting etc. @@ -13548,7 +13541,7 @@ Unit* Creature::SelectVictim() //====================================================================== float Unit::ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index, float value) const -{ +{ if (Player* modOwner = GetSpellModOwner()) { modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_ALL_EFFECTS, value); @@ -13570,12 +13563,12 @@ float Unit::ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index // function uses real base points (typically value - 1) int32 Unit::CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints) const -{ +{ return spellProto->Effects[effect_index].CalcValue(this, basePoints, target); } int32 Unit::CalcSpellDuration(SpellInfo const* spellProto) -{ +{ uint8 comboPoints = m_movedByPlayer ? m_movedByPlayer->ToPlayer()->GetComboPoints() : 0; int32 minduration = spellProto->GetDuration(); @@ -13592,7 +13585,7 @@ int32 Unit::CalcSpellDuration(SpellInfo const* spellProto) } int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask) -{ +{ // don't mod permanent auras duration if (duration < 0) return duration; @@ -13727,7 +13720,7 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32 & castTime, Spell* } DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) -{ +{ for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) { if (i->DRGroup != group) @@ -13753,7 +13746,7 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) } void Unit::IncrDiminishing(DiminishingGroup group) -{ +{ // Checking for existing in the table for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) { @@ -13767,7 +13760,7 @@ void Unit::IncrDiminishing(DiminishingGroup group) } float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, Unit* caster, DiminishingLevels Level, int32 limitduration) -{ +{ // xinef: dont apply diminish to self casts if (duration == -1 || group == DIMINISHING_NONE) return 1.0f; @@ -13828,7 +13821,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, } void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply) -{ +{ // Checking for existing in the table for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) { @@ -13849,7 +13842,7 @@ void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply) } float Unit::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const -{ +{ if (!spellInfo->RangeEntry) return 0; if (spellInfo->RangeEntry->maxRangeFriend == spellInfo->RangeEntry->maxRangeHostile) @@ -13860,7 +13853,7 @@ float Unit::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spell } float Unit::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const -{ +{ if (!spellInfo->RangeEntry) return 0; if (spellInfo->RangeEntry->minRangeFriend == spellInfo->RangeEntry->minRangeHostile) @@ -13870,7 +13863,7 @@ float Unit::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spell uint32 Unit::GetCreatureType() const -{ +{ if (GetTypeId() == TYPEID_PLAYER) { ShapeshiftForm form = GetShapeshiftForm(); @@ -13891,7 +13884,7 @@ uint32 Unit::GetCreatureType() const #######################################*/ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply) -{ +{ if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { sLog->outError("ERROR in HandleStatModifier(): non-existing UnitMods or wrong UnitModifierType!"); @@ -13956,7 +13949,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f } float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const -{ +{ if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { sLog->outError("attempt to access non-existing modifier value from UnitMods!"); @@ -13970,7 +13963,7 @@ float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) co } float Unit::GetTotalStatValue(Stats stat, float additionalValue) const -{ +{ UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat); if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) @@ -13986,7 +13979,7 @@ float Unit::GetTotalStatValue(Stats stat, float additionalValue) const } float Unit::GetTotalAuraModValue(UnitMods unitMod) const -{ +{ if (unitMod >= UNIT_MOD_END) { sLog->outError("attempt to access non-existing UnitMods in GetTotalAuraModValue()!"); @@ -14005,7 +13998,7 @@ float Unit::GetTotalAuraModValue(UnitMods unitMod) const } void Unit::ApplyStatPercentBuffMod(Stats stat, float val, bool apply) -{ +{ if (val == -100.0f) // prevent set var to zero val = -99.99f; float var = GetStat(stat)*val/100.0f; @@ -14013,7 +14006,7 @@ void Unit::ApplyStatPercentBuffMod(Stats stat, float val, bool apply) } SpellSchools Unit::GetSpellSchoolByAuraGroup(UnitMods unitMod) const -{ +{ SpellSchools school = SPELL_SCHOOL_NORMAL; switch (unitMod) @@ -14033,7 +14026,7 @@ SpellSchools Unit::GetSpellSchoolByAuraGroup(UnitMods unitMod) const } Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const -{ +{ Stats stat = STAT_STRENGTH; switch (unitMod) @@ -14052,7 +14045,7 @@ Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const } Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const -{ +{ switch (unitMod) { case UNIT_MOD_RAGE: return POWER_RAGE; @@ -14067,13 +14060,13 @@ Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const } float Unit::GetTotalAttackPowerValue(WeaponAttackType attType, Unit *victim) const -{ +{ if (attType == RANGED_ATTACK) { int32 ap = GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS); if( victim ) ap += victim->GetTotalAuraModifier(SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS); - + if (ap < 0) return 0.0f; return ap * (1.0f + GetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER)); @@ -14083,7 +14076,7 @@ float Unit::GetTotalAttackPowerValue(WeaponAttackType attType, Unit *victim) con int32 ap = GetInt32Value(UNIT_FIELD_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS); if( victim ) ap += victim->GetTotalAuraModifier(SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS); - + if (ap < 0) return 0.0f; return ap * (1.0f + GetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER)); @@ -14091,7 +14084,7 @@ float Unit::GetTotalAttackPowerValue(WeaponAttackType attType, Unit *victim) con } float Unit::GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange type) const -{ +{ if (attType == OFF_ATTACK && !haveOffhandWeapon()) return 0.0f; @@ -14099,7 +14092,7 @@ float Unit::GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange typ } void Unit::SetLevel(uint8 lvl, bool showLevelChange) -{ +{ SetUInt32Value(UNIT_FIELD_LEVEL, lvl); // Xinef: unmark field bit update @@ -14116,7 +14109,7 @@ void Unit::SetLevel(uint8 lvl, bool showLevelChange) } void Unit::SetHealth(uint32 val) -{ +{ if (getDeathState() == JUST_DIED) val = 0; else if (GetTypeId() == TYPEID_PLAYER && getDeathState() == DEAD) @@ -14158,7 +14151,7 @@ void Unit::SetHealth(uint32 val) } void Unit::SetMaxHealth(uint32 val) -{ +{ if (!val) val = 1; @@ -14196,7 +14189,7 @@ void Unit::SetMaxHealth(uint32 val) } void Unit::SetPower(Powers power, uint32 val) -{ +{ if (GetPower(power) == val) return; @@ -14238,7 +14231,7 @@ void Unit::SetPower(Powers power, uint32 val) } void Unit::SetMaxPower(Powers power, uint32 val) -{ +{ uint32 cur_power = GetPower(power); SetStatInt32Value(UNIT_FIELD_MAXPOWER1 + power, val); @@ -14267,7 +14260,7 @@ void Unit::SetMaxPower(Powers power, uint32 val) } uint32 Unit::GetCreatePowers(Powers power) const -{ +{ // Only hunter pets have POWER_FOCUS and POWER_HAPPINESS switch (power) { @@ -14287,7 +14280,7 @@ uint32 Unit::GetCreatePowers(Powers power) const } void Unit::AddToWorld() -{ +{ if (!IsInWorld()) { WorldObject::AddToWorld(); @@ -14295,7 +14288,7 @@ void Unit::AddToWorld() } void Unit::RemoveFromWorld() -{ +{ // cleanup ASSERT(GetGUID()); @@ -14341,7 +14334,7 @@ void Unit::RemoveFromWorld() } void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup) -{ +{ if (IsDuringRemoveFromWorld()) return; @@ -14370,7 +14363,7 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup) } void Unit::CleanupsBeforeDelete(bool finalCleanup) -{ +{ if (GetTransport()) { GetTransport()->RemovePassenger(this); @@ -14383,7 +14376,7 @@ void Unit::CleanupsBeforeDelete(bool finalCleanup) } void Unit::UpdateCharmAI() -{ +{ if (GetTypeId() == TYPEID_PLAYER) return; @@ -14410,7 +14403,7 @@ void Unit::UpdateCharmAI() } CharmInfo* Unit::InitCharmInfo() -{ +{ if (!m_charmInfo) m_charmInfo = new CharmInfo(this); @@ -14418,7 +14411,7 @@ CharmInfo* Unit::InitCharmInfo() } void Unit::DeleteCharmInfo() -{ +{ if (!m_charmInfo) return; @@ -14682,7 +14675,7 @@ void CharmInfo::SetSpellAutocast(SpellInfo const* spellInfo, bool state) } bool Unit::isFrozen() const -{ +{ return HasAuraState(AURA_STATE_FROZEN); } @@ -14878,7 +14871,7 @@ uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missC } void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellInfo const* procSpell, uint32 damage, SpellInfo const* procAura) -{ +{ // Player is loaded now - do not allow passive spell casts to proc if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetSession()->PlayerLoading()) return; @@ -15070,7 +15063,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u uint32 cooldown = 0; if (prepare && i->spellProcEvent && i->spellProcEvent->cooldown) cooldown = i->spellProcEvent->cooldown; - + // Xinef: set cooldown for actual proc eventInfo.SetProcCooldown(cooldown); @@ -15190,7 +15183,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u // Skip melee hits or instant cast spells // xinef: check channeled spells which are affected by haste also if (procSpell && (procSpell->SpellFamilyName || GetTypeId() != TYPEID_PLAYER) && - (procSpell->CalcCastTime() > 0 /*|| + (procSpell->CalcCastTime() > 0 /*|| (procSpell->IsChanneled() && procSpell->GetDuration() > 0 && (HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, procSpell) || procSpell->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION)))*/)) takeCharges = true; break; @@ -15285,7 +15278,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u } void Unit::GetProcAurasTriggeredOnEvent(std::list<AuraApplication*>& aurasTriggeringProc, std::list<AuraApplication*>* procAuras, ProcEventInfo eventInfo) -{ +{ // use provided list of auras which can proc if (procAuras) { @@ -15315,13 +15308,13 @@ void Unit::GetProcAurasTriggeredOnEvent(std::list<AuraApplication*>& aurasTrigge } void Unit::TriggerAurasProcOnEvent(CalcDamageInfo& damageInfo) -{ +{ DamageInfo dmgInfo = DamageInfo(damageInfo); TriggerAurasProcOnEvent(NULL, NULL, damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, 0, 0, damageInfo.procEx, NULL, &dmgInfo, NULL); } void Unit::TriggerAurasProcOnEvent(std::list<AuraApplication*>* myProcAuras, std::list<AuraApplication*>* targetProcAuras, Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo) -{ +{ // prepare data for self trigger ProcEventInfo myProcEventInfo = ProcEventInfo(this, actionTarget, actionTarget, typeMaskActor, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo, NULL); std::list<AuraApplication*> myAurasTriggeringProc; @@ -15340,7 +15333,7 @@ void Unit::TriggerAurasProcOnEvent(std::list<AuraApplication*>* myProcAuras, std } void Unit::TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, std::list<AuraApplication*>& aurasTriggeringProc) -{ +{ for (std::list<AuraApplication*>::iterator itr = aurasTriggeringProc.begin(); itr != aurasTriggeringProc.end(); ++itr) { if (!(*itr)->GetRemoveMode()) @@ -15349,12 +15342,12 @@ void Unit::TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, std::list<AuraAppli } SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const -{ +{ return SPELL_SCHOOL_MASK_NORMAL; } Player* Unit::GetSpellModOwner() const -{ +{ if (Player* player = const_cast<Unit*>(this)->ToPlayer()) return player; @@ -15367,7 +15360,7 @@ Player* Unit::GetSpellModOwner() const ///----------Pet responses methods----------------- void Unit::SendPetActionFeedback(uint8 msg) -{ +{ Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; @@ -15378,7 +15371,7 @@ void Unit::SendPetActionFeedback(uint8 msg) } void Unit::SendPetTalk(uint32 pettalk) -{ +{ Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; @@ -15390,7 +15383,7 @@ void Unit::SendPetTalk(uint32 pettalk) } void Unit::SendPetAIReaction(uint64 guid) -{ +{ Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; @@ -15404,13 +15397,13 @@ void Unit::SendPetAIReaction(uint64 guid) ///----------End of Pet responses methods---------- void Unit::StopMoving() -{ +{ ClearUnitState(UNIT_STATE_MOVING); // not need send any packets if not in world or not moving if (!IsInWorld()) return; - + if (movespline->Finalized()) return; @@ -15419,7 +15412,7 @@ void Unit::StopMoving() } void Unit::StopMovingOnCurrentPos() // pussywizard -{ +{ ClearUnitState(UNIT_STATE_MOVING); // not need send any packets if not in world @@ -15434,14 +15427,14 @@ void Unit::StopMovingOnCurrentPos() // pussywizard } void Unit::SendMovementFlagUpdate(bool self /* = false */) -{ +{ WorldPacket data; BuildHeartBeatMsg(&data); SendMessageToSet(&data, self); } bool Unit::IsSitState() const -{ +{ uint8 s = getStandState(); return s == UNIT_STAND_STATE_SIT_CHAIR || s == UNIT_STAND_STATE_SIT_LOW_CHAIR || @@ -15450,13 +15443,13 @@ bool Unit::IsSitState() const } bool Unit::IsStandState() const -{ +{ uint8 s = getStandState(); return !IsSitState() && s != UNIT_STAND_STATE_SLEEP && s != UNIT_STAND_STATE_KNEEL; } void Unit::SetStandState(uint8 state) -{ +{ SetByteValue(UNIT_FIELD_BYTES_1, 0, state); if (IsStandState()) @@ -15471,7 +15464,7 @@ void Unit::SetStandState(uint8 state) } bool Unit::IsPolymorphed() const -{ +{ uint32 transformId = getTransForm(); if (!transformId) return false; @@ -15484,7 +15477,7 @@ bool Unit::IsPolymorphed() const } void Unit::SetDisplayId(uint32 modelId) -{ +{ SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId); // Set Gender by modelId if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId)) @@ -15492,7 +15485,7 @@ void Unit::SetDisplayId(uint32 modelId) } void Unit::RestoreDisplayId() -{ +{ AuraEffect* handledAura = NULL; AuraEffect* handledAuraForced = NULL; // try to receive model from transform auras @@ -15541,7 +15534,7 @@ void Unit::RestoreDisplayId() } void Unit::ClearComboPointHolders() -{ +{ while (!m_ComboPointHolders.empty()) { uint32 lowguid = *m_ComboPointHolders.begin(); @@ -15555,7 +15548,7 @@ void Unit::ClearComboPointHolders() } void Unit::ClearAllReactives() -{ +{ for (uint8 i = 0; i < MAX_REACTIVE; ++i) m_reactiveTimer[i] = 0; @@ -15568,7 +15561,7 @@ void Unit::ClearAllReactives() } void Unit::UpdateReactives(uint32 p_time) -{ +{ for (uint8 i = 0; i < MAX_REACTIVE; ++i) { ReactiveType reactive = ReactiveType(i); @@ -15606,7 +15599,7 @@ void Unit::UpdateReactives(uint32 p_time) } Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const -{ +{ std::list<Unit*> targets; Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist); Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(this, targets, u_check); @@ -15676,7 +15669,7 @@ Unit* Unit::SelectNearbyNoTotemTarget(Unit* exclude, float dist) const } void Unit::ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply) -{ +{ float remainingTimePct = std::max((float)m_attackTimer[att], 0.0f) / (GetAttackTime(att) * m_modAttackSpeedPct[att]); if (val > 0) { @@ -15692,7 +15685,7 @@ void Unit::ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply } void Unit::ApplyCastTimePercentMod(float val, bool apply) -{ +{ if (val > 0) ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED, val, !apply); else @@ -15700,7 +15693,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply) } uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const -{ +{ // Not apply this to creature casted spells with casttime == 0 if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !IsPet()) return 3500; @@ -15791,7 +15784,7 @@ uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectTyp } void Unit::UpdateAuraForGroup(uint8 slot) -{ +{ if (slot >= MAX_AURAS) // slot not found, return return; if (Player* player = ToPlayer()) @@ -15818,7 +15811,7 @@ void Unit::UpdateAuraForGroup(uint8 slot) } float Unit::CalculateDefaultCoefficient(SpellInfo const *spellInfo, DamageEffectType damagetype) const -{ +{ // Damage over Time spells bonus calculation float DotFactor = 1.0f; if (damagetype == DOT) @@ -15841,7 +15834,7 @@ float Unit::CalculateDefaultCoefficient(SpellInfo const *spellInfo, DamageEffect } float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) -{ +{ if (!normalized || GetTypeId() != TYPEID_PLAYER) return float(GetAttackTime(attType)) / 1000.0f; @@ -15866,12 +15859,12 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) } bool Unit::IsUnderLastManaUseEffect() const -{ +{ return getMSTimeDiff(m_lastManaUse, World::GetGameTimeMS()) < 5000; } void Unit::SetContestedPvP(Player* attackedPlayer) -{ +{ Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); if (!player || (attackedPlayer && (attackedPlayer == player || (player->duel && player->duel->opponent == attackedPlayer)))) @@ -15894,7 +15887,7 @@ void Unit::SetContestedPvP(Player* attackedPlayer) } void Unit::AddPetAura(PetAura const* petSpell) -{ +{ if (GetTypeId() != TYPEID_PLAYER) return; @@ -15906,7 +15899,7 @@ void Unit::AddPetAura(PetAura const* petSpell) } void Unit::RemovePetAura(PetAura const* petSpell) -{ +{ if (GetTypeId() != TYPEID_PLAYER) return; @@ -15918,7 +15911,7 @@ void Unit::RemovePetAura(PetAura const* petSpell) } void Unit::CastPetAura(PetAura const* aura) -{ +{ uint32 auraId = aura->GetAura(GetEntry()); if (!auraId) return; @@ -15933,7 +15926,7 @@ void Unit::CastPetAura(PetAura const* aura) } bool Unit::IsPetAura(Aura const* aura) -{ +{ Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) @@ -15949,7 +15942,7 @@ bool Unit::IsPetAura(Aura const* aura) } Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id) -{ +{ if (GetTypeId() != TYPEID_PLAYER) return NULL; @@ -15969,7 +15962,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id) } Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id) -{ +{ if (GetTypeId() != TYPEID_PLAYER) return NULL; @@ -15989,7 +15982,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id) } bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id) -{ +{ pet->SetCreatorGUID(GetGUID()); pet->setFaction(getFaction()); pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); @@ -16011,7 +16004,7 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id) } bool Unit::IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, SpellInfo const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const* & spellProcEvent, ProcEventInfo const& eventInfo) -{ +{ SpellInfo const* spellProto = aura->GetSpellInfo(); // let the aura be handled by new proc system if it has new entry @@ -16145,7 +16138,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, SpellInfo const } bool Unit::HandleAuraRaidProcFromChargeWithValue(AuraEffect* triggeredByAura) -{ +{ // aura can be deleted at casts SpellInfo const* spellProto = triggeredByAura->GetSpellInfo(); int32 heal = triggeredByAura->GetAmount(); @@ -16237,7 +16230,7 @@ bool Unit::HandleAuraRaidProcFromChargeWithValue(AuraEffect* triggeredByAura) } bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura) -{ +{ // aura can be deleted at casts SpellInfo const* spellProto = triggeredByAura->GetSpellInfo(); @@ -16427,7 +16420,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp // Xinef: aura_spirit_of_redemption is triggered by 27827 shapeshift if (victim->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || victim->HasAura(27827)) { - /*sLog->outMisc("Player (%u) died with spirit of redemption. Killer (Entry: %u, Name: %s), Map: %u, x: %f, y: %f, z: %f", + /*sLog->outMisc("Player (%u) died with spirit of redemption. Killer (Entry: %u, Name: %s), Map: %u, x: %f, y: %f, z: %f", victim->GetGUIDLow(), killer ? killer->GetEntry() : 1, killer ? killer->GetName().c_str() : "", victim->GetMapId(), victim->GetPositionX(), victim->GetPositionY(), victim->GetPositionZ()); @@ -16440,14 +16433,14 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp uint32 ressSpellId = victim->GetUInt32Value(PLAYER_SELF_RES_SPELL); if (!ressSpellId) ressSpellId = victim->ToPlayer()->GetResurrectionSpellId(); - + //Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers) victim->RemoveAllAurasOnDeath(); - + // Stop attacks victim->CombatStop(); victim->getHostileRefManager().deleteReferences(); - + // restore for use at real death victim->SetUInt32Value(PLAYER_SELF_RES_SPELL,ressSpellId); @@ -16601,7 +16594,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp } void Unit::SetControlled(bool apply, UnitState state) -{ +{ if (apply) { if (HasUnitState(state)) @@ -16695,7 +16688,7 @@ void Unit::SetControlled(bool apply, UnitState state) } void Unit::SetStunned(bool apply) -{ +{ if (apply) { SetTarget(0); @@ -16756,7 +16749,7 @@ void Unit::SetStunned(bool apply) } void Unit::SetRooted(bool apply) -{ +{ if (apply) { if (m_rootTimes > 0) // blizzard internal check? @@ -16807,7 +16800,7 @@ void Unit::SetRooted(bool apply) } void Unit::DisableRotate(bool apply) -{ +{ if (GetTypeId() != TYPEID_UNIT) return; @@ -16818,7 +16811,7 @@ void Unit::DisableRotate(bool apply) } void Unit::SetFeared(bool apply) -{ +{ if (apply) { SetTarget(0); @@ -16857,7 +16850,7 @@ void Unit::SetFeared(bool apply) } void Unit::SetConfused(bool apply) -{ +{ if (apply) { SetTarget(0); @@ -16889,7 +16882,7 @@ void Unit::SetConfused(bool apply) } bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp) -{ +{ if (!charmer) return false; @@ -17016,7 +17009,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au // Xinef: convert charm npcs dont have pet bar so initialize them as defensive helpers if (type == CHARM_TYPE_CONVERT && GetTypeId() == TYPEID_UNIT) ToCreature()->SetReactState(REACT_DEFENSIVE); - } + } } if (playerCharmer) @@ -17082,7 +17075,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au } void Unit::RemoveCharmedBy(Unit* charmer) -{ +{ if (!IsCharmed()) return; @@ -17221,7 +17214,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) } void Unit::RestoreFaction() -{ +{ if (GetTypeId() == TYPEID_PLAYER) ToPlayer()->setFactionForRace(getRace()); else @@ -17241,7 +17234,7 @@ void Unit::RestoreFaction() } bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry) -{ +{ VehicleEntry const* vehInfo = sVehicleStore.LookupEntry(id); if (!vehInfo) return false; @@ -17253,7 +17246,7 @@ bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry) } void Unit::RemoveVehicleKit() -{ +{ if (!m_vehicleKit) return; @@ -17268,12 +17261,12 @@ void Unit::RemoveVehicleKit() } Unit* Unit::GetVehicleBase() const -{ +{ return m_vehicle ? m_vehicle->GetBase() : NULL; } Creature* Unit::GetVehicleCreatureBase() const -{ +{ if (Unit* veh = GetVehicleBase()) if (Creature* c = veh->ToCreature()) return c; @@ -17282,7 +17275,7 @@ Creature* Unit::GetVehicleCreatureBase() const } uint64 Unit::GetTransGUID() const -{ +{ if (GetVehicle()) return GetVehicleBase()->GetGUID(); if (GetTransport()) @@ -17292,14 +17285,14 @@ uint64 Unit::GetTransGUID() const } TransportBase* Unit::GetDirectTransport() const -{ +{ if (Vehicle* veh = GetVehicle()) return veh; return GetTransport(); } bool Unit::IsInPartyWith(Unit const* unit) const -{ +{ if (this == unit) return true; @@ -17322,7 +17315,7 @@ bool Unit::IsInPartyWith(Unit const* unit) const } bool Unit::IsInRaidWith(Unit const* unit) const -{ +{ if (this == unit) return true; @@ -17345,7 +17338,7 @@ bool Unit::IsInRaidWith(Unit const* unit) const void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap) -{ +{ Unit* owner = GetCharmerOrOwnerOrSelf(); Group* group = NULL; if (owner->GetTypeId() == TYPEID_PLAYER) @@ -17389,7 +17382,7 @@ void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap) } Aura* Unit::AddAura(uint32 spellId, Unit* target) -{ +{ if (!target) return NULL; @@ -17404,7 +17397,7 @@ Aura* Unit::AddAura(uint32 spellId, Unit* target) } Aura* Unit::AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target) -{ +{ if (!spellInfo) return NULL; @@ -17428,7 +17421,7 @@ Aura* Unit::AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target) } void Unit::SetAuraStack(uint32 spellId, Unit* target, uint32 stack) -{ +{ Aura* aura = target->GetAura(spellId, GetGUID()); if (!aura) aura = AddAura(spellId, target); @@ -17437,7 +17430,7 @@ void Unit::SetAuraStack(uint32 spellId, Unit* target, uint32 stack) } void Unit::SendPlaySpellVisual(uint32 id) -{ +{ WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4); data << uint64(GetGUID()); data << uint32(id); // SpellVisualKit.dbc index @@ -17445,7 +17438,7 @@ void Unit::SendPlaySpellVisual(uint32 id) } void Unit::SendPlaySpellImpact(uint64 guid, uint32 id) -{ +{ WorldPacket data(SMSG_PLAY_SPELL_IMPACT, 8 + 4); data << uint64(guid); // target data << uint32(id); // SpellVisualKit.dbc index @@ -17514,7 +17507,7 @@ void Unit::ApplyResilience(Unit const* victim, float* crit, int32* damage, bool // Melee based spells can be miss, parry or dodge on this step // Crit or block - determined on damage calculation phase! (and can be both in some time) float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const -{ +{ //calculate miss chance float missChance = victim->GetUnitMissChance(attType); @@ -17555,7 +17548,7 @@ float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, i } void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) -{ +{ if (newPhaseMask == GetPhaseMask()) return; @@ -17618,7 +17611,7 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) } void Unit::UpdateObjectVisibility(bool forced, bool /*fromUpdate*/) -{ +{ if (!forced) AddToNotify(NOTIFY_VISIBILITY_CHANGED); else @@ -17636,7 +17629,7 @@ void Unit::UpdateObjectVisibility(bool forced, bool /*fromUpdate*/) } void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) -{ +{ Player* player = ToPlayer(); if (!player) { @@ -17673,7 +17666,7 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) } float Unit::GetCombatRatingReduction(CombatRating cr) const -{ +{ if (Player const* player = ToPlayer()) return player->GetRatingBonusValue(cr); // Player's pet get resilience from owner @@ -17685,13 +17678,13 @@ float Unit::GetCombatRatingReduction(CombatRating cr) const } uint32 Unit::GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const -{ +{ float percent = std::min(GetCombatRatingReduction(cr) * rate, cap); return CalculatePct(damage, percent); } uint32 Unit::GetModelForForm(ShapeshiftForm form) const -{ +{ if (GetTypeId() == TYPEID_PLAYER) { switch (form) @@ -17891,7 +17884,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form) const } uint32 Unit::GetModelForTotem(PlayerTotemType totemType) -{ +{ switch (getRace()) { case RACE_ORC: @@ -17994,7 +17987,7 @@ Unit* Unit::GetRedirectThreatTarget() const } void Unit::JumpTo(float speedXY, float speedZ, bool forward) -{ +{ float angle = forward ? 0 : M_PI; if (GetTypeId() == TYPEID_UNIT) GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ); @@ -18016,7 +18009,7 @@ void Unit::JumpTo(float speedXY, float speedZ, bool forward) } void Unit::JumpTo(WorldObject* obj, float speedZ) -{ +{ float x, y, z; obj->GetContactPoint(this, x, y, z); float speedXY = GetExactDist2d(x, y) * 10.0f / speedZ; @@ -18024,7 +18017,7 @@ void Unit::JumpTo(WorldObject* obj, float speedZ) } bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) -{ +{ bool result = false; uint32 spellClickEntry = GetVehicleKit() ? GetVehicleKit()->GetCreatureEntry() : GetEntry(); SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(spellClickEntry); @@ -18101,17 +18094,17 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) } void Unit::EnterVehicle(Unit* base, int8 seatId) -{ +{ CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId+1, base, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE); } void Unit::EnterVehicleUnattackable(Unit *base, int8 seatId) -{ +{ CastCustomSpell(67830, SPELLVALUE_BASE_POINT0, seatId+1, base, true); } void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp) -{ +{ // Must be called only from aura handler if (!IsAlive() || GetVehicleKit() == vehicle || vehicle->GetBase()->IsOnVehicle(this)) return; @@ -18175,7 +18168,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a } void Unit::ChangeSeat(int8 seatId, bool next) -{ +{ if (!m_vehicle) return; @@ -18194,7 +18187,7 @@ void Unit::ChangeSeat(int8 seatId, bool next) } void Unit::ExitVehicle(Position const* /*exitPosition*/) -{ +{ //! This function can be called at upper level code to initialize an exit from the passenger's side. if (!m_vehicle) return; @@ -18222,7 +18215,7 @@ bool VehicleDespawnEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) } void Unit::_ExitVehicle(Position const* exitPosition) -{ +{ if (!m_vehicle) return; @@ -18296,7 +18289,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) } // xinef: move fall, should we support all creatures that exited vehicle in air? Currently Quest Drag and Drop only, Air Assault quest - if (GetTypeId() == TYPEID_UNIT && !CanFly() && + if (GetTypeId() == TYPEID_UNIT && !CanFly() && (vehicle->GetVehicleInfo()->m_ID == 113 || vehicle->GetVehicleInfo()->m_ID == 8 || vehicle->GetVehicleInfo()->m_ID == 290 || vehicle->GetVehicleInfo()->m_ID == 298)) GetMotionMaster()->MoveFall(); //GetMotionMaster()->MoveFall(); // Enable this once passenger positions are calculater properly (see above) @@ -18340,7 +18333,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) } void Unit::BuildMovementPacket(ByteBuffer *data) const -{ +{ if (GetTypeId() == TYPEID_UNIT && GetHoverHeight() >= 2.0f && !HasUnitMovementFlag(MOVEMENTFLAG_FALLING) && !movespline->isFalling()) // pussywizard: add disable gravity to hover (artifically, not to spoil speed and other things) *data << uint32(GetUnitMovementFlags() | MOVEMENTFLAG_DISABLE_GRAVITY); // movement flags else @@ -18395,12 +18388,12 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const } bool Unit::IsFalling() const -{ +{ return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR) || movespline->isFalling(); } void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/, bool vehicleTeleport /*= false*/, bool withPet /*= false*/, bool removeTransport /*= false*/) -{ +{ DisableSpline(); if (GetTypeId() == TYPEID_PLAYER) ToPlayer()->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | (removeTransport ? 0 : TELE_TO_NOT_LEAVE_TRANSPORT) | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0) | (vehicleTeleport ? TELE_TO_NOT_LEAVE_VEHICLE : 0) | (withPet ? TELE_TO_WITH_PET : 0)); @@ -18415,7 +18408,7 @@ void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool cas } void Unit::SendTeleportPacket(Position& pos) -{ +{ Position oldPos = { GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation() }; if (GetTypeId() == TYPEID_UNIT) Relocate(&pos); @@ -18431,7 +18424,7 @@ void Unit::SendTeleportPacket(Position& pos) } bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool teleport) -{ +{ if (!Trinity::IsValidMapCoord(x, y, z, orientation)) return false; @@ -18464,7 +18457,7 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel //! Only server-side orientation update, does not broadcast to client void Unit::UpdateOrientation(float orientation) -{ +{ SetOrientation(orientation); if (IsVehicle()) GetVehicleKit()->RelocatePassengers(); @@ -18472,14 +18465,14 @@ void Unit::UpdateOrientation(float orientation) //! Only server-side height update, does not broadcast to client void Unit::UpdateHeight(float newZ) -{ +{ Relocate(GetPositionX(), GetPositionY(), newZ); if (IsVehicle()) GetVehicleKit()->RelocatePassengers(); } void Unit::SendThreatListUpdate() -{ +{ if (!getThreatManager().isThreatListEmpty()) { uint32 count = getThreatManager().getThreatList().size(); @@ -18499,7 +18492,7 @@ void Unit::SendThreatListUpdate() } void Unit::SendChangeCurrentVictimOpcode(HostileReference* pHostileReference) -{ +{ if (!getThreatManager().isThreatListEmpty()) { uint32 count = getThreatManager().getThreatList().size(); @@ -18522,7 +18515,7 @@ void Unit::SendChangeCurrentVictimOpcode(HostileReference* pHostileReference) } void Unit::SendClearThreatListOpcode() -{ +{ #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_UNITS, "WORLD: Send SMSG_THREAT_CLEAR Message"); #endif @@ -18532,7 +18525,7 @@ void Unit::SendClearThreatListOpcode() } void Unit::SendRemoveFromThreatListOpcode(HostileReference* pHostileReference) -{ +{ #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_UNITS, "WORLD: Send SMSG_THREAT_REMOVE Message"); #endif @@ -18543,7 +18536,7 @@ void Unit::SendRemoveFromThreatListOpcode(HostileReference* pHostileReference) } void Unit::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker) -{ +{ float addRage; float rageconversion = ((0.0091107836f * getLevel() * getLevel()) + 3.225598133f * getLevel()) + 4.2652911f; @@ -18574,7 +18567,7 @@ void Unit::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker) } void Unit::StopAttackFaction(uint32 faction_id) -{ +{ if (Unit* victim = GetVictim()) { if (victim->GetFactionTemplateEntry()->faction == faction_id) @@ -18608,7 +18601,7 @@ void Unit::StopAttackFaction(uint32 faction_id) } void Unit::OutDebugInfo() const -{ +{ sLog->outError("Unit::OutDebugInfo"); sLog->outString("GUID " UI64FMTD ", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName().c_str()); sLog->outString("OwnerGUID " UI64FMTD ", MinionGUID " UI64FMTD ", CharmerGUID " UI64FMTD ", CharmedGUID " UI64FMTD , GetOwnerGUID(), GetMinionGUID(), GetCharmerGUID(), GetCharmGUID()); @@ -18654,7 +18647,7 @@ class AuraMunchingQueue : public BasicEvent if (_owner.IsInWorld() && _owner.FindMap()) if (Unit* target = ObjectAccessor::GetUnit(_owner, _targetGUID)) _owner.CastCustomSpell(_spellId, SPELLVALUE_BASE_POINT0, _basePoints, target, TriggerCastFlags(TRIGGERED_FULL_MASK&~TRIGGERED_NO_PERIODIC_RESET), NULL, NULL, _owner.GetGUID()); - + return true; } @@ -18666,7 +18659,7 @@ class AuraMunchingQueue : public BasicEvent }; void Unit::CastDelayedSpellWithPeriodicAmount(Unit* caster, uint32 spellId, AuraType auraType, int32 addAmount, uint8 effectIndex) -{ +{ for (AuraEffectList::iterator i = m_modAuras[auraType].begin(); i != m_modAuras[auraType].end(); ++i) { AuraEffect* aurEff = *i; @@ -18692,7 +18685,7 @@ void Unit::SendClearTarget() } uint32 Unit::GetResistance(SpellSchoolMask mask) const -{ +{ int32 resist = -1; for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) if (mask & (1 << i) && (resist < 0 || resist > int32(GetResistance(SpellSchools(i))))) @@ -18726,7 +18719,7 @@ void CharmInfo::SaveStayPosition(bool atCurrentPos) { //! At this point a new spline destination is enabled because of Unit::StopMoving() G3D::Vector3 stayPos = G3D::Vector3(); - + if (atCurrentPos) { float z = INVALID_HEIGHT; @@ -18795,7 +18788,7 @@ bool CharmInfo::IsReturning() } void Unit::PetSpellFail(const SpellInfo* spellInfo, Unit* target, uint32 result) -{ +{ CharmInfo* charmInfo = GetCharmInfo(); if (!charmInfo || GetTypeId() != TYPEID_UNIT) return; @@ -18812,7 +18805,7 @@ void Unit::PetSpellFail(const SpellInfo* spellInfo, Unit* target, uint32 result) charmInfo->SetIsCommandAttack(!ToCreature()->HasReactState(REACT_PASSIVE)); charmInfo->SetIsReturning(false); charmInfo->SetIsFollowing(false); - + GetMotionMaster()->MoveFollow(target, PET_FOLLOW_DIST, rand_norm()*2*M_PI); } else if (owner->IsValidAttackTarget(target)) @@ -18822,7 +18815,7 @@ void Unit::PetSpellFail(const SpellInfo* spellInfo, Unit* target, uint32 result) charmInfo->SetIsCommandAttack(!ToCreature()->HasReactState(REACT_PASSIVE)); charmInfo->SetIsReturning(false); charmInfo->SetIsFollowing(false); - + if (!ToCreature()->HasReactState(REACT_PASSIVE)) ToCreature()->AI()->AttackStart(target); else @@ -18865,7 +18858,7 @@ bool ConflagrateAuraStateDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_tim } uint32 Unit::GetZoneId(bool forceRecalc) const -{ +{ // xinef: optimization, zone calculated every few yards if (!forceRecalc && GetExactDistSq(&m_last_zone_position) < 4.0f*4.0f) return m_last_zone_id; @@ -18878,7 +18871,7 @@ uint32 Unit::GetZoneId(bool forceRecalc) const } uint32 Unit::GetAreaId(bool forceRecalc) const -{ +{ // xinef: optimization, area calculated every few yards if (!forceRecalc && GetExactDistSq(&m_last_area_position) < 4.0f*4.0f) return m_last_area_id; @@ -18891,7 +18884,7 @@ uint32 Unit::GetAreaId(bool forceRecalc) const } void Unit::GetZoneAndAreaId(uint32& zoneid, uint32& areaid, bool forceRecalc) const -{ +{ // xinef: optimization, zone and area calculated every few yards if (!forceRecalc && GetExactDistSq(&m_last_area_position) < 4.0f*4.0f && GetExactDistSq(&m_last_zone_position) < 4.0f*4.0f) { @@ -18908,7 +18901,7 @@ void Unit::GetZoneAndAreaId(uint32& zoneid, uint32& areaid, bool forceRecalc) co } bool Unit::IsOutdoors() const -{ +{ // xinef: optimization, outdoor status calculated every few yards if (GetExactDistSq(&m_last_outdoors_position) < 4.0f*4.0f) return m_last_outdoors_status; @@ -18921,7 +18914,7 @@ bool Unit::IsOutdoors() const } void Unit::ExecuteDelayedUnitRelocationEvent() -{ +{ this->RemoveFromNotify(NOTIFY_VISIBILITY_CHANGED); if (!this->IsInWorld() || this->IsDuringRemoveFromWorld()) return; @@ -18982,7 +18975,7 @@ void Unit::ExecuteDelayedUnitRelocationEvent() float mindistsq = DynamicVisibilityMgr::GetReqMoveDistSq(active->FindMap()->GetEntry()->map_type); if (distsq < mindistsq) return; - + active->m_last_notify_position.Relocate(active->GetPositionX(), active->GetPositionY(), active->GetPositionZ()); } @@ -19015,7 +19008,7 @@ void Unit::ExecuteDelayedUnitRelocationEvent() } void Unit::ExecuteDelayedUnitAINotifyEvent() -{ +{ this->RemoveFromNotify(NOTIFY_AI_RELOCATION); if (!this->IsInWorld() || this->IsDuringRemoveFromWorld()) return; @@ -19026,13 +19019,13 @@ void Unit::ExecuteDelayedUnitAINotifyEvent() } void Unit::SetInFront(WorldObject const* target) -{ +{ if (!HasUnitState(UNIT_STATE_CANNOT_TURN)) SetOrientation(GetAngle(target)); } void Unit::SetFacingTo(float ori) -{ +{ Movement::MoveSplineInit init(this); init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZ(), false); if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && GetTransGUID()) @@ -19042,7 +19035,7 @@ void Unit::SetFacingTo(float ori) } void Unit::SetFacingToObject(WorldObject* object) -{ +{ // never face when already moving if (!IsStopped()) return; @@ -19055,7 +19048,7 @@ void Unit::SetFacingToObject(WorldObject* object) } bool Unit::SetWalk(bool enable) -{ +{ if (enable == IsWalking()) return false; @@ -19069,7 +19062,7 @@ bool Unit::SetWalk(bool enable) } bool Unit::SetDisableGravity(bool disable, bool /*packetOnly = false*/) -{ +{ if (disable == IsLevitating()) return false; @@ -19092,7 +19085,7 @@ bool Unit::SetDisableGravity(bool disable, bool /*packetOnly = false*/) } bool Unit::SetSwim(bool enable) -{ +{ if (enable == HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING)) return false; @@ -19105,7 +19098,7 @@ bool Unit::SetSwim(bool enable) } bool Unit::SetCanFly(bool enable, bool /*packetOnly = false */) -{ +{ if (enable == HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY)) return false; @@ -19128,7 +19121,7 @@ bool Unit::SetCanFly(bool enable, bool /*packetOnly = false */) } bool Unit::SetWaterWalking(bool enable, bool /*packetOnly = false*/) -{ +{ if (enable == HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING)) return false; @@ -19141,7 +19134,7 @@ bool Unit::SetWaterWalking(bool enable, bool /*packetOnly = false*/) } void Unit::SendMovementWaterWalking(Player* sendTo) -{ +{ if (!movespline->Initialized()) return; WorldPacket data(SMSG_SPLINE_MOVE_WATER_WALK, 9); @@ -19150,7 +19143,7 @@ void Unit::SendMovementWaterWalking(Player* sendTo) } bool Unit::SetFeatherFall(bool enable, bool /*packetOnly = false*/) -{ +{ if (enable == HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW)) return false; @@ -19163,7 +19156,7 @@ bool Unit::SetFeatherFall(bool enable, bool /*packetOnly = false*/) } void Unit::SendMovementFeatherFall(Player* sendTo) -{ +{ if (!movespline->Initialized()) return; WorldPacket data(SMSG_SPLINE_MOVE_FEATHER_FALL, 9); @@ -19172,7 +19165,7 @@ void Unit::SendMovementFeatherFall(Player* sendTo) } bool Unit::SetHover(bool enable, bool /*packetOnly = false*/) -{ +{ if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER)) return false; @@ -19190,7 +19183,7 @@ bool Unit::SetHover(bool enable, bool /*packetOnly = false*/) } void Unit::SendMovementHover(Player* sendTo) -{ +{ if (!movespline->Initialized()) return; WorldPacket data(SMSG_SPLINE_MOVE_SET_HOVER, 9); @@ -19199,7 +19192,7 @@ void Unit::SendMovementHover(Player* sendTo) } void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) const -{ +{ if (!target) return; @@ -19379,7 +19372,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) } void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown) -{ +{ data.Initialize(SMSG_SPELL_COOLDOWN, 8 + 1 + 4 + 4); data << uint64(GetGUID()); data << uint8(flags); @@ -19388,7 +19381,7 @@ void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, u } void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns) -{ +{ data.Initialize(SMSG_SPELL_COOLDOWN, 8 + 1 + (4 + 4) * cooldowns.size()); data << uint64(GetGUID()); data << uint8(flags); diff --git a/src/game/Events/GameEventMgr.cpp b/src/game/Events/GameEventMgr.cpp index 5092fa32c7..096825803b 100644 --- a/src/game/Events/GameEventMgr.cpp +++ b/src/game/Events/GameEventMgr.cpp @@ -1096,6 +1096,7 @@ uint32 GameEventMgr::Update() // return the next e nextEventDelay = 0; for (std::set<uint16>::iterator itr = deactivate.begin(); itr != deactivate.end(); ++itr) StopEvent(*itr); + #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDetail("Next game event check in %u seconds.", nextEventDelay + 1); #endif diff --git a/src/game/Handlers/AddonHandler.cpp b/src/game/Handlers/AddonHandler.cpp index 452609d1b3..d1b30c027a 100644 --- a/src/game/Handlers/AddonHandler.cpp +++ b/src/game/Handlers/AddonHandler.cpp @@ -121,8 +121,8 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) uint32 count = 0; *Target << uint32(count); - //if (AddOnPacked.rpos() != AddOnPacked.size()) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + if (AddOnPacked.rpos() != AddOnPacked.size()) sLog->outDebug(LOG_FILTER_NETWORKIO, "packet under read!"); #endif } diff --git a/src/game/Handlers/DuelHandler.cpp b/src/game/Handlers/DuelHandler.cpp index 4dbdf494bc..5ceb57a4bf 100644 --- a/src/game/Handlers/DuelHandler.cpp +++ b/src/game/Handlers/DuelHandler.cpp @@ -32,8 +32,6 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_DUEL_ACCEPTED"); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName().c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName().c_str()); #endif diff --git a/src/game/Handlers/MiscHandler.cpp b/src/game/Handlers/MiscHandler.cpp index 2e2c84c484..bf15832c50 100644 --- a/src/game/Handlers/MiscHandler.cpp +++ b/src/game/Handlers/MiscHandler.cpp @@ -414,7 +414,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) if (uint64 lguid = GetPlayer()->GetLootGUID()) DoLootRelease(lguid); - bool instantLogout = ((GetSecurity() >= 0 && uint32(GetSecurity()) >= sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT)) + bool instantLogout = ((GetSecurity() >= 0 && uint32(GetSecurity()) >= sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT)) || (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && !GetPlayer()->IsInCombat())) || GetPlayer()->IsInFlight(); /// TODO: Possibly add RBAC permission to log out in combat @@ -537,7 +537,8 @@ void WorldSession::HandleSetSelectionOpcode(WorldPacket & recv_data) void WorldSession::HandleStandStateChangeOpcode(WorldPacket & recv_data) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - // sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_STANDSTATECHANGE"); -- too many spam in log at lags/debug stop + // too many spam in log at lags/debug stop + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_STANDSTATECHANGE"); #endif uint32 animstate; recv_data >> animstate; @@ -1656,7 +1657,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data) } if (!groupGuy->IsAlive() || groupGuy->IsInCombat() || groupGuy->GetVictim() || groupGuy->m_mover != groupGuy || groupGuy->IsNonMeleeSpellCast(true) || (!groupGuy->GetMotionMaster()->empty() && groupGuy->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE) - || !groupGuy->movespline->Finalized() || !groupGuy->GetMap()->ToInstanceMap() || !groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript() || groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript()->IsEncounterInProgress() + || !groupGuy->movespline->Finalized() || !groupGuy->GetMap()->ToInstanceMap() || !groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript() || groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript()->IsEncounterInProgress() || !groupGuy->Satisfy(sObjectMgr->GetAccessRequirement(groupGuy->GetMap()->GetId(), Difficulty(mode)), groupGuy->GetMap()->GetId(), false)) { _player->SendRaidDifficulty(group != NULL); diff --git a/src/game/Movement/MotionMaster.cpp b/src/game/Movement/MotionMaster.cpp index 0685370184..9b17749f51 100644 --- a/src/game/Movement/MotionMaster.cpp +++ b/src/game/Movement/MotionMaster.cpp @@ -374,26 +374,16 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate void MotionMaster::MoveSplinePath(Movement::PointsArray* path) { - //uint32 id; - //float x, y, z; - // Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) return; if (_owner->GetTypeId() == TYPEID_PLAYER) { -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - //sLog->outStaticDebug("Player (GUID: %u) targeted point (Id: %u X: %f Y: %f Z: %f)", _owner->GetGUIDLow(), id, x, y, z); -#endif Mutate(new EscortMovementGenerator<Player>(path), MOTION_SLOT_ACTIVE); } else { -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - /*sLog->outStaticDebug("Creature (Entry: %u GUID: %u) targeted point (ID: %u X: %f Y: %f Z: %f)", - _owner->GetEntry(), _owner->GetGUIDLow(), id, x, y, z);*/ -#endif Mutate(new EscortMovementGenerator<Creature>(path), MOTION_SLOT_ACTIVE); } } diff --git a/src/game/Warden/WardenMac.cpp b/src/game/Warden/WardenMac.cpp index e2c97f6d6d..251e5525bf 100644 --- a/src/game/Warden/WardenMac.cpp +++ b/src/game/Warden/WardenMac.cpp @@ -48,17 +48,9 @@ void WardenMac::Init(WorldSession *pClient, BigNumber *K) _outputCrypto.Init(_outputKey); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Server side warden for client %u initializing...", pClient->GetAccountId()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "C->S Key: %s", ByteArrayToHexStr(_inputKey, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "S->C Key: %s", ByteArrayToHexStr(_outputKey, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, " Seed: %s", ByteArrayToHexStr(_seed, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Loading Module..."); #endif @@ -66,8 +58,6 @@ void WardenMac::Init(WorldSession *pClient, BigNumber *K) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Module Key: %s", ByteArrayToHexStr(_module->Key, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Module ID: %s", ByteArrayToHexStr(_module->Id, 16).c_str()); #endif RequestModule(); diff --git a/src/game/Warden/WardenWin.cpp b/src/game/Warden/WardenWin.cpp index 0d8037e939..df50484437 100644 --- a/src/game/Warden/WardenWin.cpp +++ b/src/game/Warden/WardenWin.cpp @@ -55,17 +55,9 @@ void WardenWin::Init(WorldSession* session, BigNumber *k) _outputCrypto.Init(_outputKey); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Server side warden for client %u initializing...", session->GetAccountId()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "C->S Key: %s", ByteArrayToHexStr(_inputKey, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "S->C Key: %s", ByteArrayToHexStr(_outputKey, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, " Seed: %s", ByteArrayToHexStr(_seed, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Loading Module..."); #endif @@ -73,8 +65,6 @@ void WardenWin::Init(WorldSession* session, BigNumber *k) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Module Key: %s", ByteArrayToHexStr(_module->Key, 16).c_str()); -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Module ID: %s", ByteArrayToHexStr(_module->Id, 16).c_str()); #endif RequestModule(); @@ -401,14 +391,8 @@ void WardenWin::HandleData(ByteBuffer &buff) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "ServerTicks %u", ticksNow); // Now -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "RequestTicks %u", _serverTicks); // At request -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Ticks %u", newClientTicks); // At response -#endif -#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_WARDEN, "Ticks diff %u", ourTicks - newClientTicks); #endif } |
