aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-11-20 19:11:28 -0800
committermaximius <none@none>2009-11-20 19:11:28 -0800
commit654519d1a685e3b666c3be4eb74bbecd747bf735 (patch)
tree6426d9dacd803508dd2761d715b1bf62b38aea6f /src/game/Unit.cpp
parent5b54c76ac339769978e869c8326720f99bd36b3e (diff)
*Some cleanup (mostly whitespace changes)
--HG-- branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp1596
1 files changed, 783 insertions, 813 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index bc6d714bf6c..01c6202456d 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -102,8 +102,8 @@ Unit::Unit()
m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION);
- m_attackTimer[BASE_ATTACK] = 0;
- m_attackTimer[OFF_ATTACK] = 0;
+ m_attackTimer[BASE_ATTACK] = 0;
+ m_attackTimer[OFF_ATTACK] = 0;
m_attackTimer[RANGED_ATTACK] = 0;
m_modAttackSpeedPct[BASE_ATTACK] = 1.0f;
m_modAttackSpeedPct[OFF_ATTACK] = 1.0f;
@@ -116,7 +116,7 @@ Unit::Unit()
m_form = FORM_NONE;
m_deathState = ALIVE;
- for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
+ for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
m_currentSpells[i] = NULL;
m_addDmgOnce = 0;
@@ -189,7 +189,7 @@ Unit::Unit()
Unit::~Unit()
{
// set current spells as deletable
- for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
+ for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
{
if (m_currentSpells[i])
{
@@ -202,8 +202,10 @@ Unit::~Unit()
RemoveAllDynObjects();
_DeleteAuras();
- if(m_charmInfo) delete m_charmInfo;
- if(m_vehicleKit) delete m_vehicleKit;
+ if (m_charmInfo)
+ delete m_charmInfo;
+ if (m_vehicleKit)
+ delete m_vehicleKit;
assert(!m_attacking);
assert(m_attackers.empty());
@@ -211,9 +213,9 @@ Unit::~Unit()
assert(m_Controlled.empty());
}
-void Unit::Update( uint32 p_time )
+void Unit::Update(uint32 p_time)
{
- /*if(p_time > m_AurasCheck)
+ /*if (p_time > m_AurasCheck)
{
m_AurasCheck = 2000;
_UpdateAura();
@@ -225,8 +227,8 @@ void Unit::Update( uint32 p_time )
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
#pragma omp critical(UpdateThreadSafety)
{
- m_Events.Update( p_time );
- _UpdateSpells( p_time );
+ m_Events.Update(p_time);
+ _UpdateSpells(p_time);
}
// If this is set during update SetCantProc(false) call is missing somewhere in the code
@@ -242,10 +244,10 @@ void Unit::Update( uint32 p_time )
// Check UNIT_STAT_MELEE_ATTACKING or UNIT_STAT_CHASE (without UNIT_STAT_FOLLOW in this case) so pets can reach far away
// targets without stopping half way there and running off.
// These flags are reset after target dies or another command is given.
- if( m_HostilRefManager.isEmpty())
+ if (m_HostilRefManager.isEmpty())
{
// m_CombatTimer set at aura start and it will be freeze until aura removing
- if ( m_CombatTimer <= p_time )
+ if (m_CombatTimer <= p_time)
ClearInCombat();
else
m_CombatTimer -= p_time;
@@ -253,7 +255,7 @@ void Unit::Update( uint32 p_time )
}
//not implemented before 3.0.2
- //if(!hasUnitState(UNIT_STAT_CASTING))
+ //if (!hasUnitState(UNIT_STAT_CASTING))
{
if (uint32 base_att = getAttackTimer(BASE_ATTACK))
setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time));
@@ -275,7 +277,7 @@ void Unit::Update( uint32 p_time )
bool Unit::haveOffhandWeapon() const
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK,true);
else
return m_canDualWield;
@@ -284,7 +286,7 @@ bool Unit::haveOffhandWeapon() const
void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player)
{
float x, y, z;
- if(GetMotionMaster()->GetDestination(x, y, z))
+ if (GetMotionMaster()->GetDestination(x, y, z))
SendMonsterMoveWithSpeed(x, y, z, 0, player);
}
@@ -292,7 +294,7 @@ void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTim
{
if (!transitTime)
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
Traveller<Player> traveller(*(Player*)this);
transitTime = traveller.GetTotalTrevelTimeTo(x,y,z);
@@ -309,7 +311,7 @@ void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTim
void Unit::SendMonsterStop()
{
- WorldPacket data( SMSG_MONSTER_MOVE, (17 + GetPackGUID().size()) );
+ WorldPacket data(SMSG_MONSTER_MOVE, (17 + GetPackGUID().size()));
data.append(GetPackGUID());
data << uint8(0); // new in 3.1
data << GetPositionX() << GetPositionY() << GetPositionZ();
@@ -335,10 +337,10 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 T
data << uint32(1); // 1 single waypoint
data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B
- if(player)
+ if (player)
player->GetSession()->SendPacket(&data);
else
- SendMessageToSet( &data, true );
+ SendMessageToSet(&data, true);
addUnitState(UNIT_STAT_MOVE);
}
@@ -355,7 +357,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M
data << uint8(0);
data << MoveFlags;
- if(MoveFlags & MOVEFLAG_JUMP)
+ if (MoveFlags & MOVEFLAG_JUMP)
{
data << time;
data << speedZ;
@@ -367,17 +369,17 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M
data << uint32(1); // 1 single waypoint
data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B
- if(player)
+ if (player)
player->GetSession()->SendPacket(&data);
else
- SendMessageToSet( &data, true );
+ SendMessageToSet(&data, true);
}
/*void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player)
{
float moveTime = Time;
- WorldPacket data( SMSG_MONSTER_MOVE, (41 + GetPackGUID().size()) );
+ WorldPacket data(SMSG_MONSTER_MOVE, (41 + GetPackGUID().size()));
data.append(GetPackGUID());
data << uint8(0); // new in 3.1
data << GetPositionX() << GetPositionY() << GetPositionZ();
@@ -389,7 +391,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M
case 0: // normal packet
break;
case 1: // stop packet (raw pos?)
- SendMessageToSet( &data, true );
+ SendMessageToSet(&data, true);
return;
case 2: // facing spot, not used currently
data << float(0);
@@ -406,17 +408,17 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M
data << uint32(MovementFlags);
- if(MovementFlags & MONSTER_MOVE_WALK)
+ if (MovementFlags & MONSTER_MOVE_WALK)
moveTime *= 1.05f;
data << uint32(moveTime); // Time in between points
data << uint32(1); // 1 single waypoint
data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B
- if(player)
+ if (player)
player->GetSession()->SendPacket(&data);
else
- SendMessageToSet( &data, true );
+ SendMessageToSet(&data, true);
}*/
void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end)
@@ -436,7 +438,7 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end)
data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight())? (MOVEFLAG_FLY|MOVEFLAG_WALK) : MOVEFLAG_WALK);
data << uint32( traveltime );
data << uint32( pathSize );
- data.append( (char*)path.GetNodes(start), pathSize * 4 * 3 );
+ data.append((char*)path.GetNodes(start), pathSize * 4 * 3);
SendMessageToSet(&data, true);
//MONSTER_MOVE_SPLINE_FLY
addUnitState(UNIT_STAT_MOVE);
@@ -456,7 +458,7 @@ void Unit::SendMonsterMoveTransport(Unit *vehicleOwner)
data << uint8(4);
data << GetTransOffsetO();
data << uint32(MOVEFLAG_ENTER_TRANSPORT);
- data << uint32(0); // move time
+ data << uint32(0);// move time
data << uint32(0);//GetTransOffsetX();
data << uint32(0);//GetTransOffsetY();
data << uint32(0);//GetTransOffsetZ();
@@ -498,20 +500,21 @@ bool Unit::IsWithinMeleeRange(const Unit *obj, float dist) const
return distsq < maxdist * maxdist;
}
-void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const
+void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const
{
float combat_reach = GetCombatReach();
if(combat_reach < 0.1) // sometimes bugged for players
{
//sLog.outError("Unit %u (Type: %u) has invalid combat_reach %f",GetGUIDLow(),GetTypeId(),combat_reach);
- // if(GetTypeId() == TYPEID_UNIT)
- // sLog.outError("Creature entry %u has invalid combat_reach", ((Creature*)this)->GetEntry());
+ //if (GetTypeId() == TYPEID_UNIT)
+ // sLog.outError("Creature entry %u has invalid combat_reach", ((Creature*)this)->GetEntry());
combat_reach = DEFAULT_COMBAT_REACH;
}
uint32 attacker_number = getAttackers().size();
- if(attacker_number > 0) --attacker_number;
+ if (attacker_number > 0)
+ --attacker_number;
GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm()
- , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach * 0.3 : 0));
+ , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * float(attacker_number) / combat_reach * 0.3 : 0));
}
void Unit::RemoveMovementImpairingAuras()
@@ -519,9 +522,9 @@ void Unit::RemoveMovementImpairingAuras()
RemoveAurasWithMechanic((1<<MECHANIC_SNARE)|(1<<MECHANIC_ROOT));
return;
- for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); )
+ for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();)
{
- if(spellmgr.GetSpellCustomAttr(iter->second->GetId()) & SPELL_ATTR_CU_MOVEMENT_IMPAIR)
+ if (spellmgr.GetSpellCustomAttr(iter->second->GetId()) & SPELL_ATTR_CU_MOVEMENT_IMPAIR)
RemoveAura(iter);
else
++iter;
@@ -530,11 +533,11 @@ void Unit::RemoveMovementImpairingAuras()
void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
{
- if(!(m_interruptMask & flag))
+ if (!(m_interruptMask & flag))
return;
// interrupt auras
- for (AuraList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); )
+ for (AuraList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end();)
{
Aura * aur = *iter;
++iter;
@@ -548,8 +551,8 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
}
// interrupt channeled spell
- if(Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
- if(spell->getState() == SPELL_STATE_CASTING
+ if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
+ if (spell->getState() == SPELL_STATE_CASTING
&& (spell->m_spellInfo->ChannelInterruptFlags & flag)
&& spell->m_spellInfo->Id != except)
InterruptNonMeleeSpells(false);
@@ -580,7 +583,7 @@ void Unit::RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemo
{
if (!except || iter->second->GetId() != except)
{
- if(GetAllSpellMechanicMask(iter->second->GetSpellProto()) & mechanic_mask)
+ if (GetAllSpellMechanicMask(iter->second->GetSpellProto()) & mechanic_mask)
{
RemoveAura(iter, removemode);
continue;
@@ -596,18 +599,19 @@ void Unit::UpdateInterruptMask()
for (AuraList::const_iterator i = m_interruptableAuras.begin(); i != m_interruptableAuras.end(); ++i)
m_interruptMask |= (*i)->GetSpellProto()->AuraInterruptFlags;
- if(Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
- if(spell->getState() == SPELL_STATE_CASTING)
+ if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
+ if (spell->getState() == SPELL_STATE_CASTING)
m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags;
}
bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const
{
- if(!HasAuraType(auraType)) return false;
+ if (!HasAuraType(auraType))
+ return false;
AuraEffectList const &auras = GetAurasByType(auraType);
for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
- if(SpellEntry const *iterSpellProto = (*itr)->GetSpellProto())
- if(iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags)
+ if (SpellEntry const *iterSpellProto = (*itr)->GetSpellProto())
+ if (iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags)
return true;
return false;
}
@@ -624,7 +628,7 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
//You don't lose health from damage taken from another player while in a sanctuary
//You still see it in the combat log though
- if(pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer())
+ if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer())
{
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
if (area && area->IsSanctuary()) //sanctuary
@@ -638,13 +642,13 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
uint32 originalDamage = damage;
//Script Event damage Deal
- //if( GetTypeId()== TYPEID_UNIT && ((Creature *)this)->AI())
+ //if (GetTypeId() == TYPEID_UNIT && ((Creature *)this)->AI())
// ((Creature *)this)->AI()->DamageDeal(pVictim, damage);
//Script Event damage taken
- //if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled )
+ //if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled)
// ((Creature *)pVictim)->AI()->DamageTaken(this, damage);
- if(absorb && originalDamage > damage)
+ if (absorb && originalDamage > damage)
absorb += (originalDamage - damage);
}
@@ -666,7 +670,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
}
- if(pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled)
+ if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled)
((Creature*)pVictim)->AI()->DamageTaken(this, damage);
if (damagetype != NODAMAGE)
@@ -675,31 +679,31 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TAKE_DAMAGE, spellProto ? spellProto->Id : 0);
}
- if(!damage)
+ if (!damage)
{
// Rage from absorbed damage
- if(cleanDamage && cleanDamage->absorbed_damage && pVictim->getPowerType() == POWER_RAGE)
+ if (cleanDamage && cleanDamage->absorbed_damage && pVictim->getPowerType() == POWER_RAGE)
pVictim->RewardRage(cleanDamage->absorbed_damage, 0, false);
return 0;
}
// no xp,health if type 8 /critters/
- if(pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER)
+ if (pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER)
{
// allow loot only if has loot_id in creature_template
- if(damage >= pVictim->GetHealth())
+ if (damage >= pVictim->GetHealth())
{
pVictim->setDeathState(JUST_DIED);
pVictim->SetHealth(0);
CreatureInfo const* cInfo = ((Creature*)pVictim)->GetCreatureInfo();
- if(cInfo && cInfo->lootid)
+ if (cInfo && cInfo->lootid)
pVictim->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
// some critters required for quests (need normal entry instead possible heroic in any cases)
- if(GetTypeId() == TYPEID_PLAYER)
- if(CreatureInfo const* normalInfo = objmgr.GetCreatureTemplate(pVictim->GetEntry()))
+ if (GetTypeId() == TYPEID_PLAYER)
+ if (CreatureInfo const* normalInfo = objmgr.GetCreatureTemplate(pVictim->GetEntry()))
((Player*)this)->KilledMonster(normalInfo,pVictim->GetGUID());
}
else
@@ -715,17 +719,17 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
// duel ends when player has 1 or less hp
bool duel_hasEnded = false;
- if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1))
+ if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1))
{
// prevent kill only if killed in duel and killed by opponent or opponent controlled creature
- if(((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetGUID() == GetOwnerGUID())
+ if (((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetGUID() == GetOwnerGUID())
damage = health-1;
duel_hasEnded = true;
}
// Rage from Damage made (only from direct weapon damage)
- if(cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && getPowerType() == POWER_RAGE)
+ if (cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && getPowerType() == POWER_RAGE)
{
uint32 weaponSpeedHitFactor;
uint32 rage_damage = damage + cleanDamage->absorbed_damage;
@@ -734,7 +738,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
{
case BASE_ATTACK:
{
- if(cleanDamage->hitOutCome == MELEE_HIT_CRIT)
+ if (cleanDamage->hitOutCome == MELEE_HIT_CRIT)
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 7);
else
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f);
@@ -745,7 +749,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
case OFF_ATTACK:
{
- if(cleanDamage->hitOutCome == MELEE_HIT_CRIT)
+ if (cleanDamage->hitOutCome == MELEE_HIT_CRIT)
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f);
else
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f);
@@ -779,13 +783,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (pVictim->GetTypeId() == TYPEID_PLAYER)
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, damage);
- else if(!pVictim->IsControlledByPlayer())
+ else if (!pVictim->IsControlledByPlayer())
{
//!pVictim->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER)
- if(!((Creature*)pVictim)->hasLootRecipient())
+ if (!((Creature*)pVictim)->hasLootRecipient())
((Creature*)pVictim)->SetLootRecipient(this);
- if(IsControlledByPlayer())
+ if (IsControlledByPlayer())
((Creature*)pVictim)->LowerPlayerDamageReq(health < damage ? health : damage);
}
@@ -821,7 +825,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
pVictim->ModifyHealth(- (int32)damage);
- if(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
+ if (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE)
{
//TODO: This is from procflag, I do not know which spell needs this
//Maim?
@@ -830,7 +834,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
if (pVictim->GetTypeId() != TYPEID_PLAYER)
{
- if(spellProto && IsDamageToThreatSpell(spellProto))
+ if (spellProto && IsDamageToThreatSpell(spellProto))
pVictim->AddThreat(this, damage*2, damageSchoolMask, spellProto);
else
pVictim->AddThreat(this, damage, damageSchoolMask, spellProto);
@@ -846,13 +850,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
// Rage from damage received
- if(this != pVictim && pVictim->getPowerType() == POWER_RAGE)
+ if (this != pVictim && pVictim->getPowerType() == POWER_RAGE)
{
uint32 rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0);
pVictim->RewardRage(rage_damage, 0, false);
}
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
// random durability for items (HIT DONE)
if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE)))
@@ -864,29 +868,29 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (damagetype != NODAMAGE && damage)// && pVictim->GetTypeId() == TYPEID_PLAYER)
{
- if(pVictim != this && pVictim->GetTypeId() == TYPEID_PLAYER) // does not support creature push_back
+ if (pVictim != this && pVictim->GetTypeId() == TYPEID_PLAYER) // does not support creature push_back
{
- if(damagetype != DOT)
+ if (damagetype != DOT)
{
- if(Spell* spell = pVictim->m_currentSpells[CURRENT_GENERIC_SPELL])
+ if (Spell* spell = pVictim->m_currentSpells[CURRENT_GENERIC_SPELL])
{
- if(spell->getState() == SPELL_STATE_PREPARING)
+ if (spell->getState() == SPELL_STATE_PREPARING)
{
uint32 interruptFlags = spell->m_spellInfo->InterruptFlags;
- if(interruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG)
+ if (interruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG)
pVictim->InterruptNonMeleeSpells(false);
- else if(interruptFlags & SPELL_INTERRUPT_FLAG_PUSH_BACK)
+ else if (interruptFlags & SPELL_INTERRUPT_FLAG_PUSH_BACK)
spell->Delayed();
}
}
}
- if(Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL])
+ if (Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL])
{
- if(spell->getState() == SPELL_STATE_CASTING)
+ if (spell->getState() == SPELL_STATE_CASTING)
{
uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags;
- if( channelInterruptFlags & CHANNEL_FLAG_DELAY )
+ if (channelInterruptFlags & CHANNEL_FLAG_DELAY)
spell->DelayedChannel();
}
}
@@ -894,7 +898,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
// last damage from duel opponent
- if(duel_hasEnded)
+ if (duel_hasEnded)
{
assert(pVictim->GetTypeId() == TYPEID_PLAYER);
Player *he = (Player*)pVictim;
@@ -927,7 +931,7 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
- if(!spellInfo)
+ if (!spellInfo)
{
sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -938,30 +942,30 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte
void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster)
{
- if(!spellInfo)
+ if (!spellInfo)
{
sLog.outError("CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
}
- if (!originalCaster && GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem() && IsControlledByPlayer())
+ if (!originalCaster && GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem() && IsControlledByPlayer())
if (Unit * owner = GetOwner())
originalCaster=owner->GetGUID();
SpellCastTargets targets;
uint32 targetMask = spellInfo->Targets;
- //if(targetMask & (TARGET_FLAG_UNIT|TARGET_FLAG_UNK2))
+ //if (targetMask & (TARGET_FLAG_UNIT|TARGET_FLAG_UNK2))
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if(SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET)
+ if (SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET)
{
/*SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
- if(srange && GetSpellMaxRange(srange) == 0.0f)
+ if (srange && GetSpellMaxRange(srange) == 0.0f)
{
Victim = this;
break;
}
- else */if(!Victim)
+ else */if (!Victim)
{
sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have unit target", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -972,9 +976,9 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I
}
targets.setUnitTarget(Victim);
- if(targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION))
+ if (targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION))
{
- if(!Victim)
+ if (!Victim)
{
sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have destination", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -985,7 +989,7 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I
if (castItem)
DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id);
- if(!originalCaster && triggeredByAura)
+ if (!originalCaster && triggeredByAura)
originalCaster = triggeredByAura->GetCasterGUID();
Spell *spell = new Spell(this, spellInfo, triggered, originalCaster );
@@ -997,9 +1001,12 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I
void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster)
{
CustomSpellValues values;
- if(bp0) values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0);
- if(bp1) values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1);
- if(bp2) values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2);
+ if (bp0)
+ values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0);
+ if (bp1)
+ values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1);
+ if (bp2)
+ values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2);
CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster);
}
@@ -1013,7 +1020,7 @@ void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit*
void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
- if(!spellInfo)
+ if (!spellInfo)
{
sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -1025,9 +1032,9 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit*
//check unit target
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if(SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET)
+ if (SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET)
{
- if(!Victim)
+ if (!Victim)
{
sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have unit target", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -1039,9 +1046,9 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit*
targets.setUnitTarget(Victim);
//check destination
- if(targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION))
+ if (targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION))
{
- if(!Victim)
+ if (!Victim)
{
sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have destination", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -1049,12 +1056,12 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit*
targets.setDst(Victim);
}
- if(!originalCaster && triggeredByAura)
+ if (!originalCaster && triggeredByAura)
originalCaster = triggeredByAura->GetCasterGUID();
Spell *spell = new Spell(this, spellInfo, triggered, originalCaster );
- if(castItem)
+ if (castItem)
{
DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id);
spell->m_CastItem = castItem;
@@ -1071,7 +1078,7 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered,
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
- if(!spellInfo)
+ if (!spellInfo)
{
sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -1080,14 +1087,14 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered,
if (castItem)
DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id);
- if(!originalCaster && triggeredByAura)
+ if (!originalCaster && triggeredByAura)
originalCaster = triggeredByAura->GetCasterGUID();
Spell *spell = new Spell(this, spellInfo, triggered, originalCaster );
SpellCastTargets targets;
targets.setDst(x, y, z, GetOrientation());
- if(OriginalVictim)
+ if (OriginalVictim)
targets.setUnitTarget(OriginalVictim);
spell->m_CastItem = castItem;
spell->prepare(&targets, triggeredByAura);
@@ -1096,18 +1103,18 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered,
// used for scripting
void Unit::CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster)
{
- if(!go)
+ if (!go)
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
- if(!spellInfo)
+ if (!spellInfo)
{
sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
}
- if(!(spellInfo->Targets & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK)))
+ if (!(spellInfo->Targets & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK)))
{
sLog.outError("CastSpell: spell id %i by caster: %s %u) is not gameobject spell", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry()));
return;
@@ -1116,7 +1123,7 @@ void Unit::CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castI
if (castItem)
DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id);
- if(!originalCaster && triggeredByAura)
+ if (!originalCaster && triggeredByAura)
originalCaster = triggeredByAura->GetCasterGUID();
Spell *spell = new Spell(this, spellInfo, triggered, originalCaster );
@@ -1145,14 +1152,14 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
if (damage < 0)
return;
- if(spellInfo->AttributesEx4 & SPELL_ATTR_EX4_FIXED_DAMAGE)
+ if (spellInfo->AttributesEx4 & SPELL_ATTR_EX4_FIXED_DAMAGE)
{
damageInfo->damage = damage;
return;
}
Unit *pVictim = damageInfo->target;
- if(!pVictim || !pVictim->isAlive())
+ if (!pVictim || !pVictim->isAlive())
return;
SpellSchoolMask damageSchoolMask = SpellSchoolMask(damageInfo->schoolMask);
@@ -1181,13 +1188,13 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
// Calculate crit bonus
uint32 crit_bonus = damage;
// Apply crit_damage bonus for melee spells
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
damage += crit_bonus;
// Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE
int32 critPctDamageMod = 0;
- if(attackType == RANGED_ATTACK)
+ if (attackType == RANGED_ATTACK)
critPctDamageMod += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE);
else
{
@@ -1238,7 +1245,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
damage = CalcArmorReducedDamage(pVictim, damage, spellInfo, attackType);
// Calculate absorb resist
- if(damage > 0)
+ if (damage > 0)
{
CalcAbsorbResist(pVictim, damageSchoolMask, SPELL_DIRECT_DAMAGE, damage, &damageInfo->absorb, &damageInfo->resist, spellInfo);
damage-= damageInfo->absorb + damageInfo->resist;
@@ -1255,7 +1262,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
Unit *pVictim = damageInfo->target;
- if(!pVictim)
+ if (!pVictim)
return;
if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())
@@ -1270,10 +1277,10 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
//You don't lose health from damage taken from another player while in a sanctuary
//You still see it in the combat log though
- if(pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer())
+ if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer())
{
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
- if(area && area->IsSanctuary()) // sanctuary
+ if (area && area->IsSanctuary()) // sanctuary
return;
}
@@ -1330,7 +1337,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
}
// Physical Immune check
- if(damageInfo->target->IsImmunedToDamage(SpellSchoolMask(damageInfo->damageSchoolMask)))
+ if (damageInfo->target->IsImmunedToDamage(SpellSchoolMask(damageInfo->damageSchoolMask)))
{
damageInfo->HitInfo |= HITINFO_NORMALSWING;
damageInfo->TargetState = VICTIMSTATE_IS_IMMUNE;
@@ -1350,10 +1357,12 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
damageInfo->hitOutCome = RollMeleeOutcomeAgainst(damageInfo->target, damageInfo->attackType);
// Disable parry or dodge for ranged attack
- if(damageInfo->attackType == RANGED_ATTACK)
+ if (damageInfo->attackType == RANGED_ATTACK)
{
- if (damageInfo->hitOutCome == MELEE_HIT_PARRY) damageInfo->hitOutCome = MELEE_HIT_NORMAL;
- if (damageInfo->hitOutCome == MELEE_HIT_DODGE) damageInfo->hitOutCome = MELEE_HIT_MISS;
+ if (damageInfo->hitOutCome == MELEE_HIT_PARRY)
+ damageInfo->hitOutCome = MELEE_HIT_NORMAL;
+ else if (damageInfo->hitOutCome == MELEE_HIT_DODGE)
+ damageInfo->hitOutCome = MELEE_HIT_MISS;
}
switch (damageInfo->hitOutCome)
@@ -1475,7 +1484,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
}
// Calculate absorb resist
- if(int32(damageInfo->damage) > 0)
+ if (int32(damageInfo->damage) > 0)
{
damageInfo->procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE;
// Calculate absorb & resists
@@ -1499,7 +1508,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
return;
Unit *pVictim = damageInfo->target;
- if(!pVictim)
+ if (!pVictim)
return;
if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())
@@ -1520,7 +1529,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS)
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD);
- if(damageInfo->TargetState == VICTIMSTATE_PARRY)
+ if (damageInfo->TargetState == VICTIMSTATE_PARRY)
{
// Get attack timers
float offtime = float(pVictim->getAttackTimer(OFF_ATTACK));
@@ -1530,11 +1539,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
{
float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20f;
float percent60 = 3.0f * percent20;
- if(offtime > percent20 && offtime <= percent60)
- {
+ if (offtime > percent20 && offtime <= percent60)
pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20));
- }
- else if(offtime > percent60)
+ else if (offtime > percent60)
{
offtime -= 2.0f * percent20;
pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime));
@@ -1544,11 +1551,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
{
float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20;
float percent60 = 3.0f * percent20;
- if(basetime > percent20 && basetime <= percent60)
- {
+ if (basetime > percent20 && basetime <= percent60)
pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20));
- }
- else if(basetime > percent60)
+ else if (basetime > percent60)
{
basetime -= 2.0f * percent20;
pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime));
@@ -1561,7 +1566,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
DealDamage(pVictim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), NULL, durabilityLoss);
// If this is a creature and it attacks from behind it has a probability to daze it's victim
- if( (damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) &&
+ if ((damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) &&
GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->IsControlledByPlayer() && !pVictim->HasInArc(M_PI, this)
&& (pVictim->GetTypeId() == TYPEID_PLAYER || !((Creature*)pVictim)->isWorldBoss()))
{
@@ -1570,7 +1575,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
float Probability = 20.0f;
//there is a newbie protection, at level 10 just 7% base chance; assuming linear function
- if( pVictim->getLevel() < 30 )
+ if (pVictim->getLevel() < 30)
Probability = 0.65f*pVictim->getLevel()+0.5f;
uint32 VictimDefense=pVictim->GetDefenseSkillValue();
@@ -1578,14 +1583,14 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
Probability *= AttackerMeleeSkill/(float)VictimDefense;
- if(Probability > 40.0f)
+ if (Probability > 40.0f)
Probability = 40.0f;
- if(roll_chance_f(Probability))
+ if (roll_chance_f(Probability))
CastSpell(pVictim, 1604, true);
}
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
((Player *)this)->CastItemCombatSpell(pVictim, damageInfo->attackType, damageInfo->procVictim, damageInfo->procEx);
// Do effect if any damage done to target
@@ -1648,14 +1653,14 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt
// Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura
armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL);
- if(spellInfo)
- if(Player *modOwner = GetSpellModOwner())
+ if (spellInfo)
+ if (Player *modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor);
AuraEffectList const& ResIgnoreAurasAb = GetAurasByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST);
for (AuraEffectList::const_iterator j = ResIgnoreAurasAb.begin(); j != ResIgnoreAurasAb.end(); ++j)
{
- if( (*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL
+ if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL
&& (*j)->isAffectedOnSpell(spellInfo))
armor= int32(float(armor) * (float(100-(*j)->GetAmount())/100.0f));
}
@@ -1663,19 +1668,19 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt
AuraEffectList const& ResIgnoreAuras = GetAurasByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j)
{
- if( (*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
+ if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
armor= int32(float(armor) * (float(100-(*j)->GetAmount())/100.0f));
}
- if ( GetTypeId() == TYPEID_PLAYER )
+ if (GetTypeId() == TYPEID_PLAYER)
{
AuraEffectList const& ResIgnoreAuras = GetAurasByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT);
for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr)
{
// item neutral spell
- if((*itr)->GetSpellProto()->EquippedItemClass == -1)
+ if ((*itr)->GetSpellProto()->EquippedItemClass == -1)
{
- armor= int32(float(armor) * (float(100-(*itr)->GetAmount())/100.0f));
+ armor = int32(float(armor) * (float(100-(*itr)->GetAmount())/100.0f));
continue;
}
@@ -1684,7 +1689,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt
{
Item *weapon = ((Player *)this)->GetWeaponForAttack(WeaponAttackType(i));
- if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
+ if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
{
armor= int32(float(armor) * (float(100-(*itr)->GetAmount())/100.0f));
break;
@@ -1733,11 +1738,11 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt
void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, SpellEntry const *spellInfo)
{
- if(!pVictim || !pVictim->isAlive() || !damage)
+ if (!pVictim || !pVictim->isAlive() || !damage)
return;
// Magic damage, check for resists
- if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL)==0)
+ if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
{
// Get base victim resistance for school
float tmpvalue2 = (float)pVictim->GetResistance(GetFirstSchoolInMask(schoolMask));
@@ -1753,7 +1758,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
uint32 faq[4] = {24,6,4,6};
uint8 m = 0;
float Binom = 0.0f;
- for (uint8 i = 0; i < 4; i++)
+ for (uint8 i = 0; i < 4; ++i)
{
Binom += 2400 *( powf(tmpvalue2, i) * powf( (1-tmpvalue2), (4-i)))/faq[i];
if (ran > Binom )
@@ -1765,13 +1770,13 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
*resist += uint32(damage - 1);
else
*resist += uint32(damage * m / 4);
- if(*resist > damage)
+ if (*resist > damage)
*resist = damage;
AuraEffectList const& ResIgnoreAurasAb = GetAurasByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST);
for (AuraEffectList::const_iterator j = ResIgnoreAurasAb.begin(); j != ResIgnoreAurasAb.end(); ++j)
{
- if( (*j)->GetMiscValue() & schoolMask
+ if ((*j)->GetMiscValue() & schoolMask
&& (*j)->isAffectedOnSpell(spellInfo))
*resist= int32(float(*resist) * (float(100-(*j)->GetAmount())/100.0f));
}
@@ -1779,7 +1784,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
AuraEffectList const& ResIgnoreAuras = GetAurasByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j)
{
- if( (*j)->GetMiscValue() & schoolMask)
+ if ((*j)->GetMiscValue() & schoolMask)
*resist= int32(float(*resist) * (float(100-(*j)->GetAmount())/100.0f));
}
}
@@ -1951,7 +1956,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
switch(spellProto->Id)
{
case 51271: // Unbreakable Armor
- if(Unit *caster = (*i)->GetCaster())
+ if (Unit *caster = (*i)->GetCaster())
{
uint32 absorbed = uint32( currentAbsorb * caster->GetArmor() * 0.01f );
@@ -1975,7 +1980,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
RemainingDamage -= RemainingDamage * currentAbsorb / 100;
continue;
case 50461: // Anti-Magic Zone
- if(Unit *caster = (*i)->GetCaster())
+ if (Unit *caster = (*i)->GetCaster())
{
int32 absorbed = RemainingDamage * currentAbsorb / 100;
int32 canabsorb = caster->GetHealth();
@@ -2011,11 +2016,9 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
for (TriggeredSpellInfoVct::const_iterator itr = triggeredSpells.begin(); itr != triggeredSpells.end(); ++itr)
{
- if(itr->spell)
- {
+ if (itr->spell)
itr->source->CastCustomSpell(itr->spell, SPELLVALUE_BASE_POINT0, itr->amount, itr->target, true, NULL, itr->auraEff);
- }
- else if(itr->amount > 0)
+ else if (itr->amount > 0)
{
uint32 damage = (uint32)itr->amount;
itr->source->DealDamageMods(itr->target, damage, NULL);
@@ -2026,7 +2029,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
// Remove all expired absorb auras
if (existExpired)
{
- for (AuraEffectList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end(); )
+ for (AuraEffectList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end();)
{
Aura *aura=(*i)->GetParentAura();
AuraEffect *auraeff =(*i);
@@ -2048,7 +2051,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
next = i; ++next;
// check damage school mask
- if(((*i)->GetMiscValue() & schoolMask)==0)
+ if (((*i)->GetMiscValue() & schoolMask)==0)
continue;
int32 currentAbsorb;
@@ -2058,7 +2061,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
currentAbsorb = RemainingDamage;
float manaMultiplier = (*i)->GetSpellProto()->EffectMultipleValue[(*i)->GetEffIndex()];
- if(Player *modOwner = pVictim->GetSpellModOwner())
+ if (Player *modOwner = pVictim->GetSpellModOwner())
modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier);
int32 maxAbsorb = int32(pVictim->GetPower(POWER_MANA) / manaMultiplier);
@@ -2066,7 +2069,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
currentAbsorb = maxAbsorb;
(*i)->SetAmount((*i)->GetAmount()-currentAbsorb);
- if((*i)->GetAmount() <= 0)
+ if ((*i)->GetAmount() <= 0)
{
pVictim->RemoveAura((*i)->GetParentAura(), AURA_REMOVE_BY_ENEMY_SPELL);
next = vManaShield.begin();
@@ -2079,7 +2082,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
}
// only split damage if not damaging yourself
- if(pVictim != this)
+ if (pVictim != this)
{
AuraEffectList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT);
for (AuraEffectList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next)
@@ -2087,12 +2090,12 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
next = i; ++next;
// check damage school mask
- if(((*i)->GetMiscValue() & schoolMask)==0)
+ if (((*i)->GetMiscValue() & schoolMask) == 0)
continue;
// Damage can be splitted only if aura has an alive caster
Unit *caster = (*i)->GetCaster();
- if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
+ if (!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
continue;
int32 currentAbsorb;
@@ -2119,12 +2122,12 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
next = i; ++next;
// check damage school mask
- if(((*i)->GetMiscValue() & schoolMask)==0)
+ if (((*i)->GetMiscValue() & schoolMask)==0)
continue;
// Damage can be splitted only if aura has an alive caster
Unit *caster = (*i)->GetCaster();
- if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
+ if (!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive())
continue;
uint32 splitted = uint32(RemainingDamage * (*i)->GetAmount() / 100.0f);
@@ -2206,9 +2209,9 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
int32 new_dmg = (int32)*absorb * aurEff->GetAmount() / 100;
int32 max_dmg = (int32)pVictim->GetMaxHealth() * 5 / 100;
// Do not apply more auras if more than 5% hp
- if(current_dmg + new_dmg > max_dmg)
+ if (current_dmg + new_dmg > max_dmg)
new_dmg = max_dmg - current_dmg;
- if(new_dmg > 0)
+ if (new_dmg > 0)
pVictim->CastCustomSpell(pVictim, 44413, &new_dmg, NULL, NULL, true);
}
}
@@ -2216,7 +2219,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra )
{
- if(hasUnitState(UNIT_STAT_CANNOT_AUTOATTACK) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) )
+ if (hasUnitState(UNIT_STAT_CANNOT_AUTOATTACK) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) )
return;
if (!pVictim->isAlive())
@@ -2260,7 +2263,7 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex
GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
// if damage pVictim call AI reaction
- //if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
+ //if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->AI())
// ((Creature*)pVictim)->AI()->AttackedBy(this);
}
@@ -2289,7 +2292,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackT
MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const
{
- if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())
+ if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())
return MELEE_HIT_EVADE;
int32 attackerMaxSkillValueForLevel = GetMaxSkillValueForLevel(pVictim);
@@ -2316,7 +2319,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
}
// always crit against a sitting target (except 0 crit chance)
- if( pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState() )
+ if (pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState() )
{
DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT (sitting victim)");
return MELEE_HIT_CRIT;
@@ -2366,24 +2369,24 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
else
parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25;
- if(pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) )
+ if (pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) )
{
int32 tmp2 = int32(parry_chance);
- if ( (tmp2 > 0) // check if unit _can_ parry
- && ((tmp2 -= skillBonus) > 0)
- && (roll < (sum += tmp2)))
+ if (tmp2 > 0 // check if unit _can_ parry
+ && (tmp2 -= skillBonus) > 0
+ && roll < (sum += tmp2))
{
DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum);
return MELEE_HIT_PARRY;
}
}
- if(pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) )
+ if (pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) )
{
tmp = block_chance;
- if ( (tmp > 0) // check if unit _can_ block
- && ((tmp -= skillBonus) > 0)
- && (roll < (sum += tmp)))
+ if (tmp > 0 // check if unit _can_ block
+ && (tmp -= skillBonus) > 0
+ && roll < (sum += tmp))
{
DEBUG_LOG ("RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum-tmp, sum);
return MELEE_HIT_BLOCK;
@@ -2397,17 +2400,17 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
if (tmp > 0 && roll < (sum += tmp))
{
DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum);
- if(GetTypeId() == TYPEID_UNIT && (((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT))
+ if (GetTypeId() == TYPEID_UNIT && (((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT))
DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT DISABLED)");
else
return MELEE_HIT_CRIT;
}
// Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon)
- if( attType != RANGED_ATTACK &&
+ if (attType != RANGED_ATTACK &&
(GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet()) &&
pVictim->GetTypeId() != TYPEID_PLAYER && !((Creature*)pVictim)->isPet() &&
- getLevel() < pVictim->getLevelForTarget(this) )
+ getLevel() < pVictim->getLevelForTarget(this))
{
// cap possible value (with bonuses > max skill)
int32 skill = attackerWeaponSkill;
@@ -2436,7 +2439,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
tmp = tmp > tmpmax ? tmpmax : tmp;
// tmp = mob's level * 5 - player's current defense skill
tmp = attackerMaxSkillValueForLevel - tmp;
- if(tmp >= 15)
+ if (tmp >= 15)
{
// add 2% chance per lacking skill point, min. is 15%
tmp = tmp * 200 - 1500;
@@ -2487,7 +2490,7 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add
std::swap(min_damage,max_damage);
}
- if(max_damage == 0.0f)
+ if (max_damage == 0.0f)
max_damage = 5.0f;
return urand((uint32)min_damage, (uint32)max_damage);
@@ -2495,15 +2498,15 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add
float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const
{
- if(spellProto->spellLevel <= 0)
+ if (spellProto->spellLevel <= 0)
return 1.0f;
float LvlPenalty = 0.0f;
- if(spellProto->spellLevel < 20)
+ if (spellProto->spellLevel < 20)
LvlPenalty = 20.0f - spellProto->spellLevel * 3.75f;
float LvlFactor = (float(spellProto->spellLevel) + 6.0f) / float(getLevel());
- if(LvlFactor > 1.0f)
+ if (LvlFactor > 1.0f)
LvlFactor = 1.0f;
return (100.0f - LvlPenalty) * LvlFactor / 100.0f;
@@ -2521,7 +2524,7 @@ void Unit::SendMeleeAttackStart(Unit* pVictim)
void Unit::SendMeleeAttackStop(Unit* victim)
{
- if(!victim)
+ if (!victim)
return;
WorldPacket data( SMSG_ATTACKSTOP, (4+16) ); // we guess size
@@ -2531,7 +2534,7 @@ void Unit::SendMeleeAttackStop(Unit* victim)
SendMessageToSet(&data, true);
sLog.outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"),victim->GetGUIDLow());
- /*if(victim->GetTypeId() == TYPEID_UNIT)
+ /*if (victim->GetTypeId() == TYPEID_UNIT)
((Creature*)victim)->AI().EnterEvadeMode(this);*/
}
@@ -2552,7 +2555,7 @@ bool Unit::isSpellBlocked(Unit *pVictim, SpellEntry const * /*spellProto*/, Weap
*/
// Check creatures flags_extra for disable block
- if(pVictim->GetTypeId()==TYPEID_UNIT &&
+ if (pVictim->GetTypeId() == TYPEID_UNIT &&
((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK )
return false;
@@ -2581,19 +2584,19 @@ bool Unit::isBlockCritical()
// PvP - PvE melee chances
int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7;
int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim);
- if(leveldif < 3)
+ if (leveldif < 3)
HitChance = 95 - leveldif;
else
HitChance = 93 - (leveldif - 2) * lchance;
// Hit chance depends from victim auras
- if(attType == RANGED_ATTACK)
+ if (attType == RANGED_ATTACK)
HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE);
else
HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
- if(Player *modOwner = GetSpellModOwner())
+ if (Player *modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, HitChance);
// Miss = 100 - hit
@@ -2618,12 +2621,12 @@ bool Unit::isBlockCritical()
int32 Unit::GetMechanicResistChance(const SpellEntry *spell)
{
- if(!spell)
+ if (!spell)
return 0;
int32 resist_mech = 0;
for (uint8 eff = 0; eff < MAX_SPELL_EFFECTS; ++eff)
{
- if(spell->Effect[eff] == 0)
+ if (spell->Effect[eff] == 0)
break;
int32 effect_mech = GetEffectMechanic(spell, eff);
if (effect_mech)
@@ -2722,22 +2725,22 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
canBlock = false;
}
// Check creatures flags_extra for disable parry
- if(pVictim->GetTypeId()==TYPEID_UNIT)
+ if (pVictim->GetTypeId() == TYPEID_UNIT)
{
uint32 flagEx = ((Creature*)pVictim)->GetCreatureInfo()->flags_extra;
- if( flagEx & CREATURE_FLAG_EXTRA_NO_PARRY )
+ if (flagEx & CREATURE_FLAG_EXTRA_NO_PARRY)
canParry = false;
// Check creatures flags_extra for disable block
- if( flagEx & CREATURE_FLAG_EXTRA_NO_BLOCK )
+ if (flagEx & CREATURE_FLAG_EXTRA_NO_BLOCK)
canBlock = false;
}
// Ignore combat result aura
- AuraEffectList const& ignore = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT);
+ AuraEffectList const &ignore = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT);
for (AuraEffectList::const_iterator i = ignore.begin(); i != ignore.end(); ++i)
{
if (!(*i)->isAffectedOnSpell(spell))
continue;
- switch((*i)->GetMiscValue())
+ switch ((*i)->GetMiscValue())
{
case MELEE_HIT_DODGE: canDodge = false; break;
case MELEE_HIT_BLOCK: canBlock = false; break;
@@ -2753,8 +2756,8 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
// Roll dodge
int32 dodgeChance = int32(pVictim->GetUnitDodgeChance()*100.0f) - skillDiff * 4;
// Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE
- dodgeChance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100;
- dodgeChance = int32 (float (dodgeChance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE));
+ dodgeChance += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100;
+ dodgeChance = int32(float(dodgeChance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE));
// Reduce dodge chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
dodgeChance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f);
@@ -2763,8 +2766,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (dodgeChance < 0)
dodgeChance = 0;
- tmp += dodgeChance;
- if (roll < tmp)
+ if (roll < (tmp += dodgeChance))
return SPELL_MISS_DODGE;
}
@@ -2788,7 +2790,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (canBlock)
{
int32 blockChance = int32(pVictim->GetUnitBlockChance()*100.0f) - skillDiff * 4;
- if ( blockChance < 0 )
+ if (blockChance < 0)
blockChance = 0;
tmp += blockChance;
@@ -2813,13 +2815,13 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
// Base hit chance from attacker and victim levels
int32 modHitChance;
- if(leveldif < 3)
+ if (leveldif < 3)
modHitChance = 96 - leveldif;
else
modHitChance = 94 - (leveldif - 2) * lchance;
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
- if(Player *modOwner = GetSpellModOwner())
+ if (Player *modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance);
// Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras
modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask);
@@ -2840,8 +2842,10 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (pVictim->GetTypeId() == TYPEID_PLAYER)
HitChance -= int32(((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_SPELL)*100.0f);
- if (HitChance < 100) HitChance = 100;
- if (HitChance > 10000) HitChance = 10000;
+ if (HitChance < 100)
+ HitChance = 100;
+ else if (HitChance > 10000)
+ HitChance = 10000;
int32 tmp = 10000 - HitChance;
@@ -2884,7 +2888,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool CanReflect)
{
// Return evade for units in evade mode
- if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode() && this != pVictim)
+ if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode() && this != pVictim)
return SPELL_MISS_EVADE;
// Check for immune
@@ -3218,7 +3222,7 @@ void Unit::_UpdateSpells( uint32 time )
// update auras
// m_AurasUpdateIterator can be updated in inderect called code at aura remove to skip next planned to update but removed auras
- for (m_AurasUpdateIterator = m_Auras.begin(); m_AurasUpdateIterator != m_Auras.end(); )
+ for (m_AurasUpdateIterator = m_Auras.begin(); m_AurasUpdateIterator != m_Auras.end();)
{
Aura* i_aura = m_AurasUpdateIterator->second;
++m_AurasUpdateIterator; // need shift to next for allow update if need into aura update
@@ -3226,7 +3230,7 @@ void Unit::_UpdateSpells( uint32 time )
}
// remove expired auras
- for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); )
+ for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
{
if(i->second->IsExpired())
RemoveAura(i, AURA_REMOVE_BY_EXPIRE);
@@ -3239,7 +3243,7 @@ void Unit::_UpdateSpells( uint32 time )
if(!m_gameObj.empty())
{
GameObjectList::iterator itr;
- for (itr = m_gameObj.begin(); itr != m_gameObj.end(); )
+ for (itr = m_gameObj.begin(); itr != m_gameObj.end();)
{
if( !(*itr)->isSpawned() )
{
@@ -3742,7 +3746,7 @@ bool Unit::AddAura(Aura *Aur, bool handleEffects)
if (Aur->IsSingleTarget())
{
// caster pointer can be deleted in time aura remove, find it by guid at each iteration
- for (; ; )
+ for (;;)
{
Unit* caster = Aur->GetCaster();
assert(caster);
@@ -3885,9 +3889,9 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur)
void Unit::RemoveAura(uint32 spellId, uint64 caster, AuraRemoveMode removeMode)
{
- for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId); )
+ for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);)
{
- if (!caster || iter->second->GetCasterGUID()==caster)
+ if (!caster || iter->second->GetCasterGUID() == caster)
{
RemoveAura(iter, removeMode);
return;
@@ -4028,7 +4032,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId)
{
- for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId); )
+ for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);)
{
if (!castItem || iter->second->GetCastItemGUID()==castItem->GetGUID())
{
@@ -4042,7 +4046,7 @@ void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId)
void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except, bool negative, bool positive)
{
- for (AuraEffectList::const_iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); )
+ for (AuraEffectList::const_iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
{
Aura * aur = (*iter)->GetParentAura();
++iter;
@@ -4060,16 +4064,16 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except
void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase)
{
// single target auras from other casters
- for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); )
+ for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();)
{
if (iter->second->GetCasterGUID()!=GetGUID() && IsSingleTargetSpell(iter->second->GetSpellProto()))
{
- if(!newPhase)
+ if (!newPhase)
RemoveAura(iter);
else
{
Unit* caster = iter->second->GetCaster();
- if(!caster || !caster->InSamePhase(newPhase))
+ if (!caster || !caster->InSamePhase(newPhase))
RemoveAura(iter);
else
++iter;
@@ -4081,7 +4085,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase)
// single target auras at other targets
AuraList& scAuras = GetSingleCastAuras();
- for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); )
+ for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();)
{
Aura * aura=*iter;
++iter;
@@ -4136,7 +4140,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
{
bool canBreak = false;
// Get mask of all aurastates from remaining auras
- for (AuraStateAurasMap::iterator itr = m_auraStateAuras.lower_bound(auraState); itr != m_auraStateAuras.upper_bound(auraState) && !(auraStateFound && canBreak); )
+ for (AuraStateAurasMap::iterator itr = m_auraStateAuras.lower_bound(auraState); itr != m_auraStateAuras.upper_bound(auraState) && !(auraStateFound && canBreak);)
{
if (itr->second == Aur)
{
@@ -4154,7 +4158,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
}
// Remove totem at next update if totem looses its aura
- if (Aur->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem()&& ((TempSummon*)this)->GetSummonerGUID()==Aur->GetCasterGUID())
+ if (Aur->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem()&& ((TempSummon*)this)->GetSummonerGUID()==Aur->GetCasterGUID())
{
if (((Totem*)this)->GetSpell()==Aur->GetId() && ((Totem*)this)->GetTotemType()==TOTEM_PASSIVE)
((Totem*)this)->setDeathState(JUST_DIED);
@@ -4278,7 +4282,7 @@ bool Unit::HasAura(Aura * aur) const
// no need to find aura
if (!aur || aur->IsRemoved())
return false;
- for (AuraMap::const_iterator iter = m_Auras.lower_bound(aur->GetId()); iter != m_Auras.upper_bound(aur->GetId()); )
+ for (AuraMap::const_iterator iter = m_Auras.lower_bound(aur->GetId()); iter != m_Auras.upper_bound(aur->GetId());)
{
if (aur == iter->second)
return true;
@@ -4359,7 +4363,7 @@ uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, bool remove)
uint32 diseases=0;
for (AuraType const* itr = &diseaseAuraTypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr)
{
- for (AuraEffectList::iterator i = m_modAuras[*itr].begin(); i != m_modAuras[*itr].end(); )
+ for (AuraEffectList::iterator i = m_modAuras[*itr].begin(); i != m_modAuras[*itr].end();)
{
// Get auras with disease dispel type by caster
if ((*i)->GetSpellProto()->Dispel == DISPEL_DISEASE
@@ -4412,7 +4416,7 @@ void Unit::RemoveDynObject(uint32 spellid)
{
if(m_dynObjGUIDs.empty())
return;
- for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end(); )
+ for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
{
DynamicObject* dynObj = GetMap()->GetDynamicObject(*i);
if(!dynObj) // may happen if a dynobj is removed when grid unload
@@ -4442,7 +4446,7 @@ void Unit::RemoveAllDynObjects()
DynamicObject * Unit::GetDynObject(uint32 spellId)
{
- for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end(); )
+ for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
{
DynamicObject* dynObj = GetMap()->GetDynamicObject(*i);
if(!dynObj)
@@ -4549,7 +4553,7 @@ void Unit::RemoveGameObject(uint32 spellid, bool del)
void Unit::RemoveAllGameObjects()
{
// remove references to unit
- for (GameObjectList::iterator i = m_gameObj.begin(); i != m_gameObj.end(); )
+ for (GameObjectList::iterator i = m_gameObj.begin(); i != m_gameObj.end();)
{
(*i)->SetOwnerGUID(0);
(*i)->SetRespawnTime(0);
@@ -8230,41 +8234,41 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
}
// faction base cases
- FactionTemplateEntry const*tester_faction = tester->getFactionTemplateEntry();
- FactionTemplateEntry const*target_faction = target->getFactionTemplateEntry();
- if(!tester_faction || !target_faction)
+ FactionTemplateEntry const *tester_faction = tester->getFactionTemplateEntry();
+ FactionTemplateEntry const *target_faction = target->getFactionTemplateEntry();
+ if (!tester_faction || !target_faction)
return false;
- if(target->isAttackingPlayer() && tester->IsContestedGuard())
+ if (target->isAttackingPlayer() && tester->IsContestedGuard())
return false;
// PvC forced reaction and reputation case
- if(tester->GetTypeId() == TYPEID_PLAYER)
+ if (tester->GetTypeId() == TYPEID_PLAYER)
{
// forced reaction
- if(target_faction->faction)
+ if (target_faction->faction)
{
- if(ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
+ if (ReputationRank const *force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
return *force >= REP_FRIENDLY;
// if faction have reputation then friendly state for tester at 100% dependent from at_war state
- if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
- if(FactionState const* factionState = ((Player*)tester)->GetReputationMgr().GetState(raw_target_faction))
+ if (FactionEntry const *raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
+ if (FactionState const *factionState = ((Player*)tester)->GetReputationMgr().GetState(raw_target_faction))
return !(factionState->Flags & FACTION_FLAG_AT_WAR);
}
}
// CvP forced reaction and reputation case
- else if(target->GetTypeId() == TYPEID_PLAYER)
+ else if (target->GetTypeId() == TYPEID_PLAYER)
{
// forced reaction
- if(tester_faction->faction)
+ if (tester_faction->faction)
{
- if(ReputationRank const* force =((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
+ if (ReputationRank const *force =((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
return *force >= REP_FRIENDLY;
// apply reputation state
- if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
- if(raw_tester_faction->reputationListID >=0 )
+ if (FactionEntry const *raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
+ if (raw_tester_faction->reputationListID >= 0)
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
}
}
@@ -8275,12 +8279,12 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
bool Unit::IsHostileToPlayers() const
{
- FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
- if(!my_faction || !my_faction->faction)
+ FactionTemplateEntry const *my_faction = getFactionTemplateEntry();
+ if (!my_faction || !my_faction->faction)
return false;
- FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
- if(raw_faction && raw_faction->reputationListID >=0 )
+ FactionEntry const *raw_faction = sFactionStore.LookupEntry(my_faction->faction);
+ if (raw_faction && raw_faction->reputationListID >= 0)
return false;
return my_faction->IsHostileToPlayers();
@@ -8288,12 +8292,12 @@ bool Unit::IsHostileToPlayers() const
bool Unit::IsNeutralToAll() const
{
- FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
- if(!my_faction || !my_faction->faction)
+ FactionTemplateEntry const *my_faction = getFactionTemplateEntry();
+ if (!my_faction || !my_faction->faction)
return true;
- FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
- if(raw_faction && raw_faction->reputationListID >=0 )
+ FactionEntry const *raw_faction = sFactionStore.LookupEntry(my_faction->faction);
+ if (raw_faction && raw_faction->reputationListID >= 0)
return false;
return my_faction->IsNeutralToAll();
@@ -8333,16 +8337,16 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
if (m_attacking == victim)
{
// switch to melee attack from ranged/magic
- if(meleeAttack)
+ if (meleeAttack)
{
- if(!hasUnitState(UNIT_STAT_MELEE_ATTACKING))
+ if (!hasUnitState(UNIT_STAT_MELEE_ATTACKING))
{
addUnitState(UNIT_STAT_MELEE_ATTACKING);
SendMeleeAttackStart(victim);
return true;
}
}
- else if(hasUnitState(UNIT_STAT_MELEE_ATTACKING))
+ else if (hasUnitState(UNIT_STAT_MELEE_ATTACKING))
{
clearUnitState(UNIT_STAT_MELEE_ATTACKING);
SendMeleeAttackStop(victim);
@@ -8353,11 +8357,11 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
//switch target
InterruptSpell(CURRENT_MELEE_SPELL);
- if(!meleeAttack)
+ if (!meleeAttack)
clearUnitState(UNIT_STAT_MELEE_ATTACKING);
}
- if(m_attacking)
+ if (m_attacking)
m_attacking->_removeAttacker(this);
m_attacking = victim;
@@ -8366,18 +8370,18 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
//Set our target
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
- if(meleeAttack)
+ if (meleeAttack)
addUnitState(UNIT_STAT_MELEE_ATTACKING);
// set position before any AI calls/assistance
- //if(GetTypeId()==TYPEID_UNIT)
+ //if(GetTypeId() == TYPEID_UNIT)
// ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
- if(GetTypeId()==TYPEID_UNIT)
+ if (GetTypeId() == TYPEID_UNIT)
{
// should not let player enter combat by right clicking target
SetInCombatWith(victim);
- if(victim->GetTypeId() == TYPEID_PLAYER)
+ if (victim->GetTypeId() == TYPEID_PLAYER)
victim->SetInCombatWith(this);
AddThreat(victim, 0.0f);
@@ -8393,7 +8397,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
if(haveOffhandWeapon())
resetAttackTimer(OFF_ATTACK);
- if(meleeAttack)
+ if (meleeAttack)
SendMeleeAttackStart(victim);
return true;
@@ -8417,7 +8421,7 @@ bool Unit::AttackStop()
InterruptSpell(CURRENT_MELEE_SPELL);
// reset only at real combat stop
- if(GetTypeId()==TYPEID_UNIT )
+ if (GetTypeId() == TYPEID_UNIT)
{
((Creature*)this)->SetNoCallAssistance(false);
((Creature*)this)->SetNoSearchAssistance(false);
@@ -8435,7 +8439,7 @@ void Unit::CombatStop(bool includingCast)
AttackStop();
RemoveAllAttackers();
- if( GetTypeId() == TYPEID_PLAYER )
+ if (GetTypeId() == TYPEID_PLAYER)
((Player*)this)->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel
ClearInCombat();
}
@@ -8450,17 +8454,17 @@ void Unit::CombatStopWithPets(bool includingCast)
bool Unit::isAttackingPlayer() const
{
- if(hasUnitState(UNIT_STAT_ATTACK_PLAYER))
+ if (hasUnitState(UNIT_STAT_ATTACK_PLAYER))
return true;
for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
- if((*itr)->isAttackingPlayer())
+ if ((*itr)->isAttackingPlayer())
return true;
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
- if(m_SummonSlot[i])
- if(Creature *summon = GetMap()->GetCreature(m_SummonSlot[i]))
- if(summon->isAttackingPlayer())
+ if (m_SummonSlot[i])
+ if (Creature *summon = GetMap()->GetCreature(m_SummonSlot[i]))
+ if (summon->isAttackingPlayer())
return true;
return false;
@@ -8471,7 +8475,7 @@ void Unit::RemoveAllAttackers()
while (!m_attackers.empty())
{
AttackerSet::iterator iter = m_attackers.begin();
- if(!(*iter)->AttackStop())
+ if (!(*iter)->AttackStop())
{
sLog.outError("WORLD: Unit has an attacker that isn't attacking it!");
m_attackers.erase(iter);
@@ -8486,12 +8490,12 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)))
{
SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1));
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
PlayerSpellMap const& sp_list = ((Player*)this)->GetSpellMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
{
- if(itr->second->state == PLAYERSPELL_REMOVED) continue;
+ if (itr->second->state == PLAYERSPELL_REMOVED) continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (!spellInfo || !IsPassiveSpell(itr->first)) continue;
if (spellInfo->CasterAuraState == flag)
@@ -8503,7 +8507,7 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
Pet *pet = ((Pet*)this);
for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
{
- if(itr->second.state == PLAYERSPELL_REMOVED) continue;
+ if (itr->second.state == PLAYERSPELL_REMOVED) continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (!spellInfo || !IsPassiveSpell(itr->first)) continue;
if (spellInfo->CasterAuraState == flag)
@@ -8521,13 +8525,11 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
if (flag != AURA_STATE_ENRAGE) // enrage aura state triggering continues auras
{
Unit::AuraMap& tAuras = GetAuras();
- for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end(); )
+ for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
{
SpellEntry const* spellProto = (*itr).second->GetSpellProto();
if (spellProto->CasterAuraState == flag)
- {
RemoveAura(itr);
- }
else
++itr;
}
@@ -8540,13 +8542,10 @@ 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)
- {
if (itr->second->GetCasterGUID() == target->GetGUID())
auraStates |= (1<<(itr->first-1));
- }
- }
+
return auraStates;
}
@@ -8554,11 +8553,11 @@ bool Unit::HasAuraState(AuraState flag, SpellEntry const *spellProto, Unit const
{
if (Caster)
{
- if(spellProto)
+ if (spellProto)
{
AuraEffectList const& stateAuras = Caster->GetAurasByType(SPELL_AURA_ABILITY_IGNORE_AURASTATE);
for (AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j)
- if((*j)->isAffectedOnSpell(spellProto))
+ if ((*j)->isAffectedOnSpell(spellProto))
return true;
}
// Check per caster aura state
@@ -8577,7 +8576,7 @@ bool Unit::HasAuraState(AuraState flag, SpellEntry const *spellProto, Unit const
Unit *Unit::GetOwner(bool inWorld) const
{
- if(uint64 ownerid = GetOwnerGUID())
+ if (uint64 ownerid = GetOwnerGUID())
{
if (inWorld)
return ObjectAccessor::GetUnit(*this, ownerid);
@@ -8588,7 +8587,7 @@ Unit *Unit::GetOwner(bool inWorld) const
Unit *Unit::GetCharmer() const
{
- if(uint64 charmerid = GetCharmerGUID())
+ if (uint64 charmerid = GetCharmerGUID())
return ObjectAccessor::GetUnit(*this, charmerid);
return NULL;
}
@@ -8596,7 +8595,7 @@ Unit *Unit::GetCharmer() const
Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const
{
uint64 guid = GetCharmerOrOwnerGUID();
- if(IS_PLAYER_GUID(guid))
+ if (IS_PLAYER_GUID(guid))
return ObjectAccessor::GetPlayer(*this, guid);
return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL;
@@ -8604,10 +8603,10 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const
Minion *Unit::GetFirstMinion() const
{
- if(uint64 pet_guid = GetMinionGUID())
+ if (uint64 pet_guid = GetMinionGUID())
{
- if(Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid))
- if(pet->HasUnitTypeMask(UNIT_MASK_MINION))
+ if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid))
+ if (pet->HasUnitTypeMask(UNIT_MASK_MINION))
return (Minion*)pet;
sLog.outError("Unit::GetFirstMinion: Minion %u not exist.",GUID_LOPART(pet_guid));
@@ -8619,10 +8618,10 @@ Minion *Unit::GetFirstMinion() const
Guardian* Unit::GetGuardianPet() const
{
- if(uint64 pet_guid = GetPetGUID())
+ if (uint64 pet_guid = GetPetGUID())
{
- if(Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid))
- if(pet->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
+ if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid))
+ if (pet->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
return (Guardian*)pet;
sLog.outCrash("Unit::GetGuardianPet: Guardian " I64FMT " not exist.", pet_guid);
@@ -8634,9 +8633,9 @@ Guardian* Unit::GetGuardianPet() const
Unit* Unit::GetCharm() const
{
- if(uint64 charm_guid = GetCharmGUID())
+ if (uint64 charm_guid = GetCharmGUID())
{
- if(Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid))
+ if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid))
return pet;
sLog.outError("Unit::GetCharm: Charmed creature %u not exist.",GUID_LOPART(charm_guid));
@@ -8650,9 +8649,9 @@ void Unit::SetMinion(Minion *minion, bool apply)
{
sLog.outDebug("SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply);
- if(apply)
+ if (apply)
{
- if(!minion->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()))
+ if (!minion->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()))
{
sLog.outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
return;
@@ -8660,21 +8659,21 @@ void Unit::SetMinion(Minion *minion, bool apply)
m_Controlled.insert(minion);
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
minion->m_ControlledByPlayer = true;
minion->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
}
// Can only have one pet. If a new one is summoned, dismiss the old one.
- if(minion->IsGuardianPet())
+ if (minion->IsGuardianPet())
{
- if(Guardian* oldPet = GetGuardianPet())
+ if (Guardian* oldPet = GetGuardianPet())
{
- if(oldPet != minion && (oldPet->isPet() || minion->isPet() || oldPet->GetEntry() != minion->GetEntry()))
+ if (oldPet != minion && (oldPet->isPet() || minion->isPet() || oldPet->GetEntry() != minion->GetEntry()))
{
// remove existing minion pet
- if(oldPet->isPet())
+ if (oldPet->isPet())
((Pet*)oldPet)->Remove(PET_SAVE_AS_CURRENT);
else
oldPet->UnSummon();
@@ -8689,9 +8688,9 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
}
- if(minion->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
+ if (minion->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
{
- if(AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
+ if (AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
{
}
}
@@ -8702,29 +8701,25 @@ void Unit::SetMinion(Minion *minion, bool apply)
minion->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
// FIXME: hack, speed must be set only at follow
- if(GetTypeId() == TYPEID_PLAYER && minion->isPet())
+ if (GetTypeId() == TYPEID_PLAYER && minion->isPet())
for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
minion->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
// Ghoul pets have energy instead of mana (is anywhere better place for this code?)
if (minion->IsPetGhoul())
- {
minion->setPowerType(POWER_ENERGY);
- }
if (GetTypeId() == TYPEID_PLAYER)
{
// Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again
SpellEntry const *spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
if (spellInfo && (spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE))
- {
((Player*)this)->AddSpellAndCategoryCooldowns(spellInfo, 0, NULL ,true);
- }
}
}
else
{
- if(minion->GetOwnerGUID() != GetGUID())
+ if (minion->GetOwnerGUID() != GetGUID())
{
sLog.outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
return;
@@ -8732,8 +8727,8 @@ void Unit::SetMinion(Minion *minion, bool apply)
m_Controlled.erase(minion);
- if(minion->IsGuardianPet())
- if(GetPetGUID() == minion->GetGUID())
+ if (minion->IsGuardianPet())
+ if (GetPetGUID() == minion->GetGUID())
SetPetGUID(0);
if (GetTypeId() == TYPEID_PLAYER)
@@ -8741,25 +8736,23 @@ void Unit::SetMinion(Minion *minion, bool apply)
SpellEntry const *spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL));
// Remove infinity cooldown
if (spellInfo && (spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE))
- {
((Player*)this)->SendCooldownEvent(spellInfo);
- }
}
//if(minion->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
{
- if(RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
+ if (RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
{
//Check if there is another minion
for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
{
// do not use this check, creature do not have charm guid
//if(GetCharmGUID() == (*itr)->GetGUID())
- if(GetGUID() == (*itr)->GetCharmerGUID())
+ if (GetGUID() == (*itr)->GetCharmerGUID())
continue;
//assert((*itr)->GetOwnerGUID() == GetGUID());
- if((*itr)->GetOwnerGUID() != GetGUID())
+ if ((*itr)->GetOwnerGUID() != GetGUID())
{
OutDebugInfo();
(*itr)->OutDebugInfo();
@@ -8767,15 +8760,15 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
assert((*itr)->GetTypeId() == TYPEID_UNIT);
- if(!(*itr)->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
+ if (!(*itr)->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
continue;
- if(AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
+ if (AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
{
//show another pet bar if there is no charm bar
- if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
+ if (GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
{
- if((*itr)->isPet())
+ if ((*itr)->isPet())
((Player*)this)->PetSpellInitialize();
else
((Player*)this)->CharmSpellInitialize();
@@ -8792,11 +8785,11 @@ void Unit::SetMinion(Minion *minion, bool apply)
void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry)
{
- for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); )
+ for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();)
{
Unit *unit = *itr;
++itr;
- if(unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
+ if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
&& ((Creature*)unit)->isSummon()) // minion, actually
Minions.push_back((Creature*)unit);
}
@@ -8804,11 +8797,11 @@ void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry)
void Unit::RemoveAllMinionsByEntry(uint32 entry)
{
- for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); )
+ for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();)
{
Unit *unit = *itr;
++itr;
- if(unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
+ if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
&& ((Creature*)unit)->isSummon()) // minion, actually
((TempSummon*)unit)->UnSummon();
// i think this is safe because i have never heard that a despawned minion will trigger a same minion
@@ -8817,11 +8810,11 @@ void Unit::RemoveAllMinionsByEntry(uint32 entry)
void Unit::SetCharm(Unit* charm, bool apply)
{
- if(apply)
+ if (apply)
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
- if(!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID()))
+ if (!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID()))
sLog.outCrash("Player %s is trying to charm unit %u, but it already has a charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID());
charm->m_ControlledByPlayer = true;
@@ -8834,10 +8827,10 @@ void Unit::SetCharm(Unit* charm, bool apply)
// PvP, FFAPvP
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1));
- if(!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
+ if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
sLog.outCrash("Unit %u is being charmed, but it already has a charmer %u", charm->GetEntry(), charm->GetCharmerGUID());
- if(charm->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
+ if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
{
charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
charm->SendMovementFlagUpdate();
@@ -8847,16 +8840,16 @@ void Unit::SetCharm(Unit* charm, bool apply)
}
else
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
- if(!RemoveUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID()))
+ if (!RemoveUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID()))
sLog.outCrash("Player %s is trying to uncharm unit %u, but it has another charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID());
}
- if(!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
+ if (!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
sLog.outCrash("Unit %u is being uncharmed, but it has another charmer %u", charm->GetEntry(), charm->GetCharmerGUID());
- if(charm->GetTypeId() == TYPEID_PLAYER)
+ if (charm->GetTypeId() == TYPEID_PLAYER)
{
charm->m_ControlledByPlayer = true;
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
@@ -8875,7 +8868,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
}
- if(charm->GetTypeId() == TYPEID_PLAYER
+ if (charm->GetTypeId() == TYPEID_PLAYER
|| !((Creature*)charm)->HasUnitTypeMask(UNIT_MASK_MINION)
|| charm->GetOwnerGUID() != GetGUID())
m_Controlled.erase(charm);
@@ -8888,7 +8881,7 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellPro
Unit* unit = this;
- if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem())
+ if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem())
unit = GetOwner();
if (unit->GetTypeId() == TYPEID_PLAYER)
@@ -8974,7 +8967,7 @@ void Unit::RemoveAllControlled()
{
Unit *target = *m_Controlled.begin();
m_Controlled.erase(m_Controlled.begin());
- if(target->GetCharmerGUID() == GetGUID())
+ if (target->GetCharmerGUID() == GetGUID())
target->RemoveCharmAuras();
else if (target->GetOwnerGUID() == GetGUID() && target->isSummon())
((TempSummon*)target)->UnSummon();
@@ -8992,7 +8985,7 @@ void Unit::RemoveAllControlled()
Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
{
Player* player = NULL;
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
player = (Player*)this;
// Should we enable this also for charmed units?
else if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
@@ -9005,7 +8998,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
if (!pGroup)
{
// We are pet now, return owner
- if(player!=this)
+ if (player!=this)
return IsWithinDistInMap(player, radius) ? player : NULL;
Unit * pet = GetGuardianPet();
//No pet, no group, nothing to return
@@ -9020,20 +9013,17 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
nearMembers.reserve(pGroup->GetMembersCount()*2);
for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- Player* Target = itr->getSource();
-
- // IsHostileTo check duel and controlled by enemy
- if( Target && Target !=this && Target->isAlive() && IsWithinDistInMap(Target, radius) &&
- !IsHostileTo(Target) )
- nearMembers.push_back(Target);
+ if (Player *Target = itr->getSource())
+ {
+ // IsHostileTo check duel and controlled by enemy
+ if (Target !=this && Target->isAlive() && IsWithinDistInMap(Target, radius) && !IsHostileTo(Target))
+ nearMembers.push_back(Target);
// Push player's pet to vector
- Unit * pet = Target->GetGuardianPet();
- if (pet && pet !=this && pet->isAlive() && IsWithinDistInMap(pet, radius) &&
- !IsHostileTo(pet) )
- nearMembers.push_back(pet);
- }
+ if (Unit *pet = Target->GetGuardianPet())
+ if (pet != this && pet->isAlive() && IsWithinDistInMap(pet, radius) && !IsHostileTo(pet))
+ nearMembers.push_back(pet);
+ }
if (nearMembers.empty())
return NULL;
@@ -9045,10 +9035,10 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
/*
Player * Unit::GetMoverSource() const
{
- if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->m_mover == this)
+ if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->m_mover == this)
return (Player*)this;
- if(Unit *charmer = GetCharmer())
- if(charmer->GetTypeId() == TYPEID_PLAYER && ((Player*)charmer)->m_mover == this)
+ if (Unit *charmer = GetCharmer())
+ if (charmer->GetTypeId() == TYPEID_PLAYER && ((Player*)charmer)->m_mover == this)
return (Player*)charmer;
return NULL;
}
@@ -9057,7 +9047,7 @@ Player * Unit::GetMoverSource() const
//only called in Player::SetSeer
void Unit::AddPlayerToVision(Player* plr)
{
- if(m_sharedVision.empty())
+ if (m_sharedVision.empty())
{
setActive(true);
SetWorldObject(true);
@@ -9069,7 +9059,7 @@ void Unit::AddPlayerToVision(Player* plr)
void Unit::RemovePlayerFromVision(Player* plr)
{
m_sharedVision.remove(plr);
- if(m_sharedVision.empty())
+ if (m_sharedVision.empty())
{
setActive(false);
SetWorldObject(false);
@@ -9091,14 +9081,14 @@ void Unit::RemoveCharmAuras()
void Unit::UnsummonAllTotems()
{
- for (int8 i = 0; i < MAX_SUMMON_SLOT; ++i)
+ for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
{
- if(!m_SummonSlot[i])
+ if (!m_SummonSlot[i])
continue;
- Creature *OldTotem = GetMap()->GetCreature(m_SummonSlot[i]);
- if(OldTotem && OldTotem->isSummon())
- ((TempSummon*)OldTotem)->UnSummon();
+ if (Creature *OldTotem = GetMap()->GetCreature(m_SummonSlot[i]))
+ if (OldTotem->isSummon())
+ ((TempSummon*)OldTotem)->UnSummon();
}
}
@@ -9136,15 +9126,13 @@ void Unit::EnergizeBySpell(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers
uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack)
{
- if(!spellProto || !pVictim || damagetype==DIRECT_DAMAGE )
+ if (!spellProto || !pVictim || damagetype == DIRECT_DAMAGE)
return pdamage;
// For totems get damage bonus from owner
- if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem())
- {
- if(Unit* owner = GetOwner())
+ if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem())
+ if (Unit *owner = GetOwner())
return owner->SpellDamageBonus(pVictim, spellProto, pdamage, damagetype);
- }
// Taken/Done total percent damage auras
float DoneTotalMod = 1.0f;
@@ -9158,9 +9146,9 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet())
DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank);
- AuraEffectList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
+ AuraEffectList const &mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
- if(((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto)) &&
+ if (((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto)) &&
(*i)->GetSpellProto()->EquippedItemClass == -1 && // -1 == any item class (not wand)
(*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0) // 0 == any inventory type (not wand)
DoneTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
@@ -9168,21 +9156,19 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
uint32 creatureTypeMask = pVictim->GetCreatureTypeMask();
// Add flat bonus from spell damage versus
DoneTotal += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS, creatureTypeMask);
- AuraEffectList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
+ AuraEffectList const &mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
- if(creatureTypeMask & uint32((*i)->GetMiscValue()))
+ if (creatureTypeMask & uint32((*i)->GetMiscValue()))
DoneTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
// done scripted mod (take it from owner)
- Unit *owner = GetOwner();
- if (!owner)
- owner = this;
- AuraEffectList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
+ Unit *owner = GetOwner() ? GetOwner() : this;
+ AuraEffectList const &mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
{
if (!(*i)->isAffectedOnSpell(spellProto))
continue;
- switch((*i)->GetMiscValue())
+ switch ((*i)->GetMiscValue())
{
case 4920: // Molten Fury
case 4919:
@@ -9190,7 +9176,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
case 6926:
case 6928:
{
- if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
+ if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
DoneTotalMod *= (100.0f+(*i)->GetAmount())/100.0f;
break;
}
@@ -9204,10 +9190,10 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
int32 stepPercent = CalculateSpellDamage((*i)->GetSpellProto(), 0, (*i)->GetSpellProto()->EffectBasePoints[0], this);
// count affliction effects and calc additional damage in percentage
int32 modPercent = 0;
- AuraMap const& victimAuras = pVictim->GetAuras();
+ AuraMap const &victimAuras = pVictim->GetAuras();
for (AuraMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr)
{
- SpellEntry const* m_spell = itr->second->GetSpellProto();
+ SpellEntry const *m_spell = itr->second->GetSpellProto();
if (m_spell->SpellFamilyName != SPELLFAMILY_WARLOCK || !(m_spell->SpellFamilyFlags[1] & 0x0004071B || m_spell->SpellFamilyFlags[0] & 0x8044C402))
continue;
modPercent += stepPercent * itr->second->GetStackAmount();
@@ -9250,7 +9236,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// Merciless Combat
if ((*i)->GetSpellProto()->SpellIconID == 2656)
{
- if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
+ if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
DoneTotalMod *= (100.0f+(*i)->GetAmount())/100.0f;
}
// Tundra Stalker
@@ -9313,7 +9299,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// Torment the weak
if (spellProto->SpellFamilyFlags[0]&0x20200021 || spellProto->SpellFamilyFlags[1]& 0x9000)
- if(pVictim->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED))
+ if (pVictim->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED))
{
AuraEffectList const& mDumyAuras = GetAurasByType(SPELL_AURA_DUMMY);
for (AuraEffectList::const_iterator i = mDumyAuras.begin(); i != mDumyAuras.end(); ++i)
@@ -9338,26 +9324,26 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
case SPELLFAMILY_PALADIN:
// Judgement of Vengeance/Judgement of Corruption
- if((spellProto->SpellFamilyFlags[1] & 0x400000) && spellProto->SpellIconID==2292)
+ if ((spellProto->SpellFamilyFlags[1] & 0x400000) && spellProto->SpellIconID==2292)
{
// Get stack of Holy Vengeance/Blood Corruption on the target added by caster
uint32 stacks = 0;
Unit::AuraEffectList const& auras = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr)
- if(((*itr)->GetId() == 31803 || (*itr)->GetId() == 53742) && (*itr)->GetCasterGUID()==GetGUID())
+ if (((*itr)->GetId() == 31803 || (*itr)->GetId() == 53742) && (*itr)->GetCasterGUID()==GetGUID())
{
stacks = (*itr)->GetParentAura()->GetStackAmount();
break;
}
// + 10% for each application of Holy Vengeance/Blood Corruption on the target
- if(stacks)
- DoneTotalMod *= (10.0f + (float)stacks) / 10.0f;
+ if (stacks)
+ DoneTotalMod *= (10.0f + float(stacks)) / 10.0f;
}
break;
case SPELLFAMILY_WARLOCK:
//Fire and Brimstone
- if(spellProto->SpellFamilyFlags[1] & 0x00020040)
- if(pVictim->HasAuraState(AURA_STATE_CONFLAGRATE))
+ if (spellProto->SpellFamilyFlags[1] & 0x00020040)
+ if (pVictim->HasAuraState(AURA_STATE_CONFLAGRATE))
{
AuraEffectList const& mDumyAuras = GetAurasByType(SPELL_AURA_DUMMY);
for (AuraEffectList::const_iterator i = mDumyAuras.begin(); i != mDumyAuras.end(); ++i)
@@ -9388,7 +9374,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// ..taken
AuraEffectList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN);
for (AuraEffectList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i)
- if( (*i)->GetMiscValue() & GetSpellSchoolMask(spellProto) )
+ if ((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto) )
TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
// .. taken pct: dummy auras
@@ -9404,14 +9390,14 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
}
// Ebon Plague
if (AuraEffect *dummy = pVictim->GetDummyAura(SPELLFAMILY_DEATHKNIGHT, 1933, 1))
- if(dummy->GetMiscValue() & GetSpellSchoolMask(spellProto))
+ if (dummy->GetMiscValue() & GetSpellSchoolMask(spellProto))
TakenTotalMod *= (dummy->GetAmount()+100.0f)/100.0f;
}
// From caster spells
AuraEffectList const& mOwnerTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER);
for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i)
- if( (*i)->GetCasterGUID() == GetGUID() && (*i)->isAffectedOnSpell(spellProto))
+ if ((*i)->GetCasterGUID() == GetGUID() && (*i)->isAffectedOnSpell(spellProto))
TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
// Mod damage from spell mechanic
@@ -9419,7 +9405,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
{
AuraEffectList const& mDamageDoneMechanic = pVictim->GetAurasByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT);
for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i)
- if(mechanicMask & uint32(1<<((*i)->GetMiscValue())))
+ if (mechanicMask & uint32(1<<((*i)->GetMiscValue())))
TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
}
@@ -9433,7 +9419,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// Check for table values
float coeff = 0;
- SpellBonusEntry const* bonus = spellmgr.GetSpellBonusData(spellProto->Id);
+ SpellBonusEntry const *bonus = spellmgr.GetSpellBonusData(spellProto->Id);
if (bonus)
{
if (damagetype == DOT)
@@ -9454,64 +9440,66 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
// Default calculation
if (DoneAdvertisedBenefit || TakenAdvertisedBenefit)
{
- if(!bonus || coeff < 0)
- {
- // Damage Done from spell damage bonus
- int32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto);
- // Damage over Time spells bonus calculation
- float DotFactor = 1.0f;
- if(damagetype == DOT)
+ if (!bonus || coeff < 0)
{
- int32 DotDuration = GetSpellDuration(spellProto);
- // 200% limit
- if(DotDuration > 0)
+ // Damage Done from spell damage bonus
+ int32 CastingTime = IsChanneledSpell(spellProto) ? GetSpellDuration(spellProto) : GetSpellCastTime(spellProto);
+ // Damage over Time spells bonus calculation
+ float DotFactor = 1.0f;
+ if (damagetype == DOT)
{
- if(DotDuration > 30000) DotDuration = 30000;
- if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f;
- int x = 0;
- for (uint8 j = 0; j < MAX_SPELL_EFFECTS; j++)
- {
- if( spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && (
- spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE ||
- spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) )
+ int32 DotDuration = GetSpellDuration(spellProto);
+ // 200% limit
+ if (DotDuration > 0)
+ {
+ if (DotDuration > 30000)
+ DotDuration = 30000;
+ if (!IsChanneledSpell(spellProto))
+ DotFactor = DotDuration / 15000.0f;
+ uint8 x = 0;
+ for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
- x = j;
- break;
+ if (spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && (
+ spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE ||
+ spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH))
+ {
+ x = j;
+ break;
+ }
+ }
+ int32 DotTicks = 6;
+ if (spellProto->EffectAmplitude[x] != 0)
+ DotTicks = DotDuration / spellProto->EffectAmplitude[x];
+ if (DotTicks)
+ {
+ DoneAdvertisedBenefit /= DotTicks;
+ TakenAdvertisedBenefit /= DotTicks;
}
- }
- int32 DotTicks = 6;
- if(spellProto->EffectAmplitude[x] != 0)
- DotTicks = DotDuration / spellProto->EffectAmplitude[x];
- if(DotTicks)
- {
- DoneAdvertisedBenefit /= DotTicks;
- TakenAdvertisedBenefit /= DotTicks;
}
}
- }
- // Distribute Damage over multiple effects, reduce by AoE
- CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime );
+ // Distribute Damage over multiple effects, reduce by AoE
+ CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime );
- // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
- for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
- {
- if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ||
- spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH )
+ // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
+ for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
- CastingTime /= 2;
- break;
+ if (spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ||
+ spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH)
+ {
+ CastingTime /= 2;
+ break;
+ }
}
- }
- if(spellProto->SchoolMask != SPELL_SCHOOL_MASK_NORMAL)
- coeff = (CastingTime / 3500.0f) * DotFactor;
- else
- coeff = DotFactor;
+ if (spellProto->SchoolMask != SPELL_SCHOOL_MASK_NORMAL)
+ coeff = (CastingTime / 3500.0f) * DotFactor;
+ else
+ coeff = DotFactor;
}
float coeff2 = CalculateLevelPenalty(spellProto) * stack;
- if(spellProto->SpellFamilyName) //TODO: fix this
+ if (spellProto->SpellFamilyName) //TODO: fix this
TakenTotal+= TakenAdvertisedBenefit * coeff * coeff2;
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
{
coeff *= 100.0f;
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_SPELL_BONUS_DAMAGE, coeff);
@@ -9537,7 +9525,7 @@ int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask)
// ..done
AuraEffectList const& mDamageDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE);
for (AuraEffectList::const_iterator i = mDamageDone.begin(); i != mDamageDone.end(); ++i)
- if(((*i)->GetMiscValue() & schoolMask) != 0 &&
+ if (((*i)->GetMiscValue() & schoolMask) != 0 &&
(*i)->GetSpellProto()->EquippedItemClass == -1 &&
// -1 == any item class (not wand then)
(*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0 )
@@ -9553,7 +9541,7 @@ int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask)
AuraEffectList const& mDamageDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT);
for (AuraEffectList::const_iterator i = mDamageDoneOfStatPercent.begin(); i != mDamageDoneOfStatPercent.end(); ++i)
{
- if((*i)->GetMiscValue() & schoolMask)
+ if ((*i)->GetMiscValue() & schoolMask)
{
// stat used stored in miscValueB for this aura
Stats usedStat = Stats((*i)->GetMiscBValue());
@@ -9578,13 +9566,13 @@ int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVic
// ..done (for creature type by mask) in taken
AuraEffectList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);
for (AuraEffectList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i)
- if(creatureTypeMask & uint32((*i)->GetMiscValue()))
+ if (creatureTypeMask & uint32((*i)->GetMiscValue()))
TakenAdvertisedBenefit += (*i)->GetAmount();
// ..taken
AuraEffectList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN);
for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
- if(((*i)->GetMiscValue() & schoolMask) != 0)
+ if (((*i)->GetMiscValue() & schoolMask) != 0)
TakenAdvertisedBenefit += (*i)->GetAmount();
return TakenAdvertisedBenefit;
@@ -9593,7 +9581,7 @@ int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVic
bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) const
{
// not critting spell
- if((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT))
+ if ((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT))
return false;
float crit_chance = 0.0f;
@@ -9723,23 +9711,17 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
// Rend and Tear - bonus crit chance for bleeding targets of Ferocious Bite
if (spellProto->SpellFamilyFlags[0] & 0x00800000 && pVictim->HasAuraState(AURA_STATE_BLEEDING, spellProto, this))
{
- if (AuraEffect const* rendAndTear = GetDummyAura(SPELLFAMILY_DRUID, 2859, 1))
- {
+ if (AuraEffect const *rendAndTear = GetDummyAura(SPELLFAMILY_DRUID, 2859, 1))
crit_chance += rendAndTear->GetAmount();
- }
break;
}
break;
case SPELLFAMILY_PALADIN:
- // Judgement of Command proc always crits on stunned target
- if(spellProto->SpellFamilyName == SPELLFAMILY_PALADIN)
- {
- if(spellProto->SpellFamilyFlags[0] & 0x0000000000800000LL && spellProto->SpellIconID == 561)
- {
- if(pVictim->hasUnitState(UNIT_STAT_STUNNED))
- return true;
- }
- }
+ // Judgement of Command proc always crits on stunned target
+ if (spellProto->SpellFamilyName == SPELLFAMILY_PALADIN)
+ if (spellProto->SpellFamilyFlags[0] & 0x0000000000800000LL && spellProto->SpellIconID == 561)
+ if (pVictim->hasUnitState(UNIT_STAT_STUNNED))
+ return true;
}
}
case SPELL_DAMAGE_CLASS_RANGED:
@@ -9756,7 +9738,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
}
// percent done
// only players use intelligence for critical chance computations
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance);
crit_chance = crit_chance > 0.0f ? crit_chance : 0.0f;
@@ -9782,16 +9764,16 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const *spellProto, uint32 damag
}
// adds additional damage to crit_bonus (from talents)
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
- if(pVictim)
+ if (pVictim)
{
uint32 creatureTypeMask = pVictim->GetCreatureTypeMask();
crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask));
}
- if(crit_bonus > 0)
+ if (crit_bonus > 0)
damage += crit_bonus;
return damage;
@@ -9813,13 +9795,13 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama
break;
}
- if(pVictim)
+ if (pVictim)
{
uint32 creatureTypeMask = pVictim->GetCreatureTypeMask();
crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask));
}
- if(crit_bonus > 0)
+ if (crit_bonus > 0)
damage += crit_bonus;
damage = int32(float(damage) * GetTotalAuraMultiplier(SPELL_AURA_MOD_CRITICAL_HEALING_AMOUNT));
@@ -9830,8 +9812,8 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama
uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack)
{
// For totems get healing bonus from owner (statue isn't totem in fact)
- if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem())
- if(Unit* owner = GetOwner())
+ if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem())
+ if (Unit* owner = GetOwner())
return owner->SpellHealingBonus(pVictim, spellProto, healamount, damagetype, stack);
// Healing Done
@@ -9847,9 +9829,8 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
DoneTotalMod *= (100.0f + (*i)->GetAmount()) / 100.0f;
// done scripted mod (take it from owner)
- Unit *owner = GetOwner();
- if (!owner) owner = this;
- AuraEffectList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
+ Unit *owner = GetOwner() ? GetOwner() : this;
+ AuraEffectList const &mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
{
if (!(*i)->isAffectedOnSpell(spellProto))
@@ -9963,9 +9944,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
}
// Earthliving - 0.45% of normal hot coeff
else if (spellProto->SpellFamilyName==SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags[1] & 0x80000)
- {
factorMod *= 0.45f;
- }
// Already set to scripted? so not uses healing bonus coefficient
// No heal coeff for SPELL_DAMAGE_CLASS_NONE class spells by default
else if (scripted || spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE)
@@ -9984,14 +9963,14 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
int32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto);
// Damage over Time spells bonus calculation
float DotFactor = 1.0f;
- if(damagetype == DOT)
+ if (damagetype == DOT)
{
int32 DotDuration = GetSpellDuration(spellProto);
// 200% limit
- if(DotDuration > 0)
+ if (DotDuration > 0)
{
- if(DotDuration > 30000) DotDuration = 30000;
- if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f;
+ if (DotDuration > 30000) DotDuration = 30000;
+ if (!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f;
uint32 x = 0;
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; j++)
{
@@ -10004,9 +9983,9 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
}
}
int32 DotTicks = 6;
- if(spellProto->EffectAmplitude[x] != 0)
+ if (spellProto->EffectAmplitude[x] != 0)
DotTicks = DotDuration / spellProto->EffectAmplitude[x];
- if(DotTicks)
+ if (DotTicks)
{
DoneAdvertisedBenefit = DoneAdvertisedBenefit * int32(stack) / DotTicks;
TakenAdvertisedBenefit = TakenAdvertisedBenefit * int32(stack) / DotTicks;
@@ -10018,7 +9997,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
// 50% for damage and healing spells for leech spells from damage bonus and 0% from healing
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
- if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ||
+ if (spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ||
spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH )
{
CastingTime /= 2;
@@ -10031,7 +10010,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
factorMod *= CalculateLevelPenalty(spellProto)* stack;
TakenTotal += TakenAdvertisedBenefit * coeff * factorMod;
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
{
coeff *= 100.0f;
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_SPELL_BONUS_DAMAGE, coeff);
@@ -10043,7 +10022,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
// use float as more appropriate for negative values and percent applying
float heal = (int32(healamount) + DoneTotal) * DoneTotalMod;
// apply spellmod to Done amount
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal);
// Nourish cast
@@ -10078,7 +10057,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
{
// Healing over time taken percent
float minval_hot = pVictim->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HOT_PCT);
- if(minval_hot)
+ if (minval_hot)
TakenTotalMod *= (100.0f + minval_hot) / 100.0f;
float maxval_hot = pVictim->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HOT_PCT);
@@ -10102,7 +10081,7 @@ int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask)
AuraEffectList const& mHealingDone = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE);
for (AuraEffectList::const_iterator i = mHealingDone.begin(); i != mHealingDone.end(); ++i)
- if(((*i)->GetMiscValue() & schoolMask) != 0)
+ if (((*i)->GetMiscValue() & schoolMask) != 0)
AdvertisedBenefit += (*i)->GetAmount();
// Healing bonus of spirit, intellect and strength
@@ -10134,7 +10113,7 @@ int32 Unit::SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVi
int32 AdvertisedBenefit = 0;
AuraEffectList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_HEALING);
for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
- if(((*i)->GetMiscValue() & schoolMask) != 0)
+ if (((*i)->GetMiscValue() & schoolMask) != 0)
AdvertisedBenefit += (*i)->GetAmount();
return AdvertisedBenefit;
}
@@ -10144,13 +10123,13 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask)
//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)
- if(itr->type & shoolMask)
+ if (itr->type & shoolMask)
return true;
//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)
- if(itr->type & shoolMask)
+ if (itr->type & shoolMask)
return true;
return false;
@@ -10159,19 +10138,19 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask)
bool Unit::IsImmunedToDamage(SpellEntry const* spellInfo)
{
uint32 shoolMask = GetSpellSchoolMask(spellInfo);
- if(spellInfo->Id != 42292 && spellInfo->Id !=59752)
+ if (spellInfo->Id != 42292 && spellInfo->Id !=59752)
{
//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)
- if(itr->type & shoolMask &&!IsDispelableBySpell(spellInfo, itr->spellId))
+ if (itr->type & shoolMask &&!IsDispelableBySpell(spellInfo, itr->spellId))
return true;
}
//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)
- if(itr->type & shoolMask)
+ if (itr->type & shoolMask)
return true;
return false;
@@ -10185,30 +10164,30 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo)
// Single spell immunity.
SpellImmuneList const& idList = m_spellImmune[IMMUNITY_ID];
for (SpellImmuneList::const_iterator itr = idList.begin(); itr != idList.end(); ++itr)
- if(itr->type == spellInfo->Id)
+ if (itr->type == spellInfo->Id)
return true;
- if(spellInfo->Dispel)
+ if (spellInfo->Dispel)
{
SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL];
for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr)
- if(itr->type == spellInfo->Dispel)
+ if (itr->type == spellInfo->Dispel)
return true;
}
- if(spellInfo->Mechanic)
+ if (spellInfo->Mechanic)
{
SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
- if(itr->type == spellInfo->Mechanic)
+ if (itr->type == spellInfo->Mechanic)
return true;
}
- if(spellInfo->Id != 42292 && spellInfo->Id !=59752)
+ if (spellInfo->Id != 42292 && spellInfo->Id !=59752)
{
SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr)
- if((itr->type & GetSpellSchoolMask(spellInfo))
+ if ((itr->type & GetSpellSchoolMask(spellInfo))
&& !(IsPositiveSpell(itr->spellId) && IsPositiveSpell(spellInfo->Id))
&& !IsDispelableBySpell(spellInfo, itr->spellId))
return true;
@@ -10225,22 +10204,22 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con
uint32 effect = spellInfo->Effect[index];
SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT];
for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr)
- if(itr->type == effect)
+ if (itr->type == effect)
return true;
- if(uint32 mechanic = spellInfo->EffectMechanic[index])
+ if (uint32 mechanic = spellInfo->EffectMechanic[index])
{
SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
- if(itr->type == spellInfo->EffectMechanic[index])
+ if (itr->type == spellInfo->EffectMechanic[index])
return true;
}
- if(uint32 aura = spellInfo->EffectApplyAuraName[index])
+ if (uint32 aura = spellInfo->EffectApplyAuraName[index])
{
SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE];
for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr)
- if(itr->type == aura)
+ if (itr->type == aura)
return true;
// Check for immune to application of harmful magical effects
AuraEffectList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL);
@@ -10256,21 +10235,21 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con
bool Unit::IsDamageToThreatSpell(SpellEntry const * spellInfo) const
{
- if(!spellInfo)
+ if (!spellInfo)
return false;
switch(spellInfo->SpellFamilyName)
{
case SPELLFAMILY_WARLOCK:
- if(spellInfo->SpellFamilyFlags[0] == 0x100) // Searing Pain
+ if (spellInfo->SpellFamilyFlags[0] == 0x100) // Searing Pain
return true;
break;
case SPELLFAMILY_SHAMAN:
- if(spellInfo->SpellFamilyFlags[0] == SPELLFAMILYFLAG_SHAMAN_FROST_SHOCK)
+ if (spellInfo->SpellFamilyFlags[0] == SPELLFAMILYFLAG_SHAMAN_FROST_SHOCK)
return true;
break;
case SPELLFAMILY_DEATHKNIGHT:
- if(spellInfo->SpellFamilyFlags[1] == 0x20000000) // Rune Strike
+ if (spellInfo->SpellFamilyFlags[1] == 0x20000000) // Rune Strike
return true;
break;
}
@@ -10295,7 +10274,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
// ..done (for creature type by mask) in taken
AuraEffectList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);
for (AuraEffectList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i)
- if(creatureTypeMask & uint32((*i)->GetMiscValue()))
+ if (creatureTypeMask & uint32((*i)->GetMiscValue()))
DoneFlatBenefit += (*i)->GetAmount();
// ..done
@@ -10310,7 +10289,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
// ..done (base at attack power and creature type)
AuraEffectList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS);
for (AuraEffectList::const_iterator i = mCreatureAttackPower.begin(); i != mCreatureAttackPower.end(); ++i)
- if(creatureTypeMask & uint32((*i)->GetMiscValue()))
+ if (creatureTypeMask & uint32((*i)->GetMiscValue()))
APbonus += (*i)->GetAmount();
}
else
@@ -10320,24 +10299,21 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
// ..done (base at attack power and creature type)
AuraEffectList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS);
for (AuraEffectList::const_iterator i = mCreatureAttackPower.begin(); i != mCreatureAttackPower.end(); ++i)
- if(creatureTypeMask & uint32((*i)->GetMiscValue()))
+ if (creatureTypeMask & uint32((*i)->GetMiscValue()))
APbonus += (*i)->GetAmount();
}
if (APbonus != 0) // Can be negative
{
bool normalized = false;
- if(spellProto)
- {
+ if (spellProto)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- {
if (spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
{
normalized = true;
break;
}
- }
- }
+
// This is not a typo - Impurity has SPELLFAMILY_DRUID
if (AuraEffect const * aurEff = GetDummyAura(SPELLFAMILY_DRUID, 1986, 0))
APbonus *= (100.0f + aurEff->GetAmount()) / 100.0f;
@@ -10348,10 +10324,10 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
// ..taken
AuraEffectList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN);
for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i)
- if((*i)->GetMiscValue() & GetMeleeDamageSchoolMask())
+ if ((*i)->GetMiscValue() & GetMeleeDamageSchoolMask())
TakenFlatBenefit += (*i)->GetAmount();
- if(attType!=RANGED_ATTACK)
+ if (attType!=RANGED_ATTACK)
TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN);
else
TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN);
@@ -10376,7 +10352,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
AuraEffectList const &mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i)
- if(creatureTypeMask & uint32((*i)->GetMiscValue()))
+ if (creatureTypeMask & uint32((*i)->GetMiscValue()))
DoneTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
// done scripted mod (take it from owner)
@@ -10421,7 +10397,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
// ..taken
AuraEffectList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN);
for (AuraEffectList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i)
- if((*i)->GetMiscValue() & GetMeleeDamageSchoolMask())
+ if ((*i)->GetMiscValue() & GetMeleeDamageSchoolMask())
TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f;
// .. taken pct (special attacks)
@@ -10451,9 +10427,9 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
{
//Cheat Death
case 2109:
- if((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
+ if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
{
- if(pVictim->GetTypeId() != TYPEID_PLAYER)
+ if (pVictim->GetTypeId() != TYPEID_PLAYER)
continue;
float mod = ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f);
if (mod < (*i)->GetAmount())
@@ -10476,10 +10452,10 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
switch((*i)->GetMiscValue())
{
case 6427: case 6428: // Dirty Deeds
- if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
+ if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
{
AuraEffect* eff0 = (*i)->GetParentAura()->GetPartAura(0);
- if(!eff0 || (*i)->GetEffIndex()!=1)
+ if (!eff0 || (*i)->GetEffIndex()!=1)
{
sLog.outError("Spell structure of DD (%u) changed.",(*i)->GetId());
continue;
@@ -10492,7 +10468,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att
}
}
- if(attType != RANGED_ATTACK)
+ if (attType != RANGED_ATTACK)
{
AuraEffectList const& mModMeleeDamageTakenPercent = pVictim->GetAurasByType(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT);
for (AuraEffectList::const_iterator i = mModMeleeDamageTakenPercent.begin(); i != mModMeleeDamageTakenPercent.end(); ++i)
@@ -10525,7 +10501,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next)
{
next = itr; ++next;
- if(itr->type == type)
+ if (itr->type == type)
{
m_spellImmune[op].erase(itr);
next = m_spellImmune[op].begin();
@@ -10540,7 +10516,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
{
for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr)
{
- if(itr->spellId == spellId)
+ if (itr->spellId == spellId)
{
m_spellImmune[op].erase(itr);
break;
@@ -10560,10 +10536,10 @@ void Unit::ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType ty
uint32 dispelMask = GetDispellMask(type);
// Dispel all existing auras vs current dispel type
AuraMap& auras = GetAuras();
- for (AuraMap::iterator itr = auras.begin(); itr != auras.end(); )
+ for (AuraMap::iterator itr = auras.begin(); itr != auras.end();)
{
SpellEntry const* spell = itr->second->GetSpellProto();
- if( (1<<spell->Dispel) & dispelMask )
+ if ((1<<spell->Dispel) & dispelMask )
{
// Dispel aura
RemoveAura(itr);
@@ -10578,7 +10554,7 @@ float Unit::GetWeaponProcChance() const
{
// normalized proc chance for weapon attack speed
// (odd formula...)
- if(isAttackReady(BASE_ATTACK))
+ if (isAttackReady(BASE_ATTACK))
return (GetAttackTime(BASE_ATTACK) * 1.8f / 1000.0f);
else if (haveOffhandWeapon() && isAttackReady(OFF_ATTACK))
return (GetAttackTime(OFF_ATTACK) * 1.6f / 1000.0f);
@@ -10591,7 +10567,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellEntry * s
if (PPM <= 0) return 0.0f;
// Apply chance modifer aura
if (spellProto)
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_PROC_PER_MINUTE,PPM);
return uint32((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
@@ -10601,20 +10577,20 @@ void Unit::Mount(uint32 mount)
{
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT);
- if(mount)
+ if (mount)
SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount);
SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT );
// unsummon pet
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
Pet* pet = ((Player*)this)->GetPet();
- if(pet)
+ if (pet)
{
BattleGround *bg = ((Player *)this)->GetBattleGround();
// don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface
- if(bg && bg->isArena())
+ if (bg && bg->isArena())
pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
else
((Player*)this)->UnsummonPetTemporaryIfAny();
@@ -10625,7 +10601,7 @@ void Unit::Mount(uint32 mount)
void Unit::Unmount()
{
- if(!IsMounted())
+ if (!IsMounted())
return;
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_MOUNTED);
@@ -10636,11 +10612,11 @@ void Unit::Unmount()
// only resummon old pet if the player is already added to a map
// this prevents adding a pet to a not created map which would otherwise cause a crash
// (it could probably happen when logging in after a previous crash)
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
- if(Pet *pPet = ((Player*)this)->GetPet())
+ if (Pet *pPet = ((Player*)this)->GetPet())
{
- if(pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->hasUnitState(UNIT_STAT_STUNNED))
+ if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->hasUnitState(UNIT_STAT_STUNNED))
pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
}
else
@@ -10651,17 +10627,17 @@ void Unit::Unmount()
void Unit::SetInCombatWith(Unit* enemy)
{
Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf();
- if(eOwner->IsPvP())
+ if (eOwner->IsPvP())
{
SetInCombatState(true,enemy);
return;
}
//check for duel
- if(eOwner->GetTypeId() == TYPEID_PLAYER && ((Player*)eOwner)->duel)
+ if (eOwner->GetTypeId() == TYPEID_PLAYER && ((Player*)eOwner)->duel)
{
Unit const* myOwner = GetCharmerOrOwnerOrSelf();
- if(((Player const*)eOwner)->duel->opponent == myOwner)
+ if (((Player const*)eOwner)->duel->opponent == myOwner)
{
SetInCombatState(true,enemy);
return;
@@ -10674,10 +10650,10 @@ void Unit::CombatStart(Unit* target, bool initialAggro)
{
if (initialAggro)
{
- if(!target->IsStandState()/* && !target->hasUnitState(UNIT_STAT_STUNNED)*/)
+ if (!target->IsStandState()/* && !target->hasUnitState(UNIT_STAT_STUNNED)*/)
target->SetStandState(UNIT_STAND_STATE_STAND);
- if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
+ if (!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
&& !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled)
{
((Creature*)target)->AI()->AttackStart(this);
@@ -10687,11 +10663,11 @@ void Unit::CombatStart(Unit* target, bool initialAggro)
target->SetInCombatWith(this);
}
Unit *who = target->GetCharmerOrOwnerOrSelf();
- if(who->GetTypeId() == TYPEID_PLAYER)
+ if (who->GetTypeId() == TYPEID_PLAYER)
SetContestedPvP((Player*)who);
Player *me = GetCharmerOrOwnerPlayerOrPlayerItself();
- if(me && who->IsPvP()
+ if (me && who->IsPvP()
&& (who->GetTypeId() != TYPEID_PLAYER
|| !me->duel || me->duel->opponent != who))
{
@@ -10717,7 +10693,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
if (GetTypeId() != TYPEID_PLAYER)
{
// Set home position at place of engaging combat for escorted creatures
- if(( IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) ||
+ if (( IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) ||
GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE ||
GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
@@ -10783,30 +10759,30 @@ bool Unit::canAttack(Unit const* target, bool force) const
{
assert(target);
- if(force)
+ if (force)
{
- if(IsFriendlyTo(target))
+ if (IsFriendlyTo(target))
return false;
}
- else if(!IsHostileTo(target))
+ else if (!IsHostileTo(target))
return false;
//if(m_Vehicle && m_Vehicle == target->m_Vehicle)
// return true;
- if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED))
+ if (!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED))
return false;
// shaman totem quests: spell 8898, shaman can detect elementals but elementals cannot see shaman
- if(m_invisibilityMask || target->m_invisibilityMask)
- if(!canDetectInvisibilityOf(target) && !target->canDetectInvisibilityOf(this))
+ if (m_invisibilityMask || target->m_invisibilityMask)
+ if (!canDetectInvisibilityOf(target) && !target->canDetectInvisibilityOf(this))
return false;
- if(target->GetVisibility() == VISIBILITY_GROUP_STEALTH && !canDetectStealthOf(target, GetDistance(target)))
+ if (target->GetVisibility() == VISIBILITY_GROUP_STEALTH && !canDetectStealthOf(target, GetDistance(target)))
return false;
- if(m_vehicle)
- if(IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target))
+ if (m_vehicle)
+ if (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target))
return false;
return true;
@@ -10814,14 +10790,14 @@ bool Unit::canAttack(Unit const* target, bool force) const
bool Unit::isAttackableByAOE() const
{
- if(!isAlive())
+ if (!isAlive())
return false;
- if(HasFlag(UNIT_FIELD_FLAGS,
+ if (HasFlag(UNIT_FIELD_FLAGS,
UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_OOC_NOT_ATTACKABLE))
return false;
- if(GetTypeId() == TYPEID_PLAYER && ((Player *)this)->isGameMaster())
+ if (GetTypeId() == TYPEID_PLAYER && ((Player *)this)->isGameMaster())
return false;
return !hasUnitState(UNIT_STAT_UNATTACKABLE);
@@ -10831,13 +10807,13 @@ int32 Unit::ModifyHealth(int32 dVal)
{
int32 gain = 0;
- if(dVal==0)
+ if (dVal==0)
return 0;
int32 curHealth = (int32)GetHealth();
int32 val = dVal + curHealth;
- if(val <= 0)
+ if (val <= 0)
{
SetHealth(0);
return -curHealth;
@@ -10845,12 +10821,12 @@ int32 Unit::ModifyHealth(int32 dVal)
int32 maxHealth = (int32)GetMaxHealth();
- if(val < maxHealth)
+ if (val < maxHealth)
{
SetHealth(val);
gain = val - curHealth;
}
- else if(curHealth != maxHealth)
+ else if (curHealth != maxHealth)
{
SetHealth(maxHealth);
gain = maxHealth - curHealth;
@@ -10863,27 +10839,23 @@ int32 Unit::GetHealthGain(int32 dVal)
{
int32 gain = 0;
- if(dVal==0)
+ if (dVal==0)
return 0;
int32 curHealth = (int32)GetHealth();
int32 val = dVal + curHealth;
- if(val <= 0)
+ if (val <= 0)
{
return -curHealth;
}
int32 maxHealth = (int32)GetMaxHealth();
- if(val < maxHealth)
- {
+ if (val < maxHealth)
gain = dVal;
- }
- else if(curHealth != maxHealth)
- {
+ else if (curHealth != maxHealth)
gain = maxHealth - curHealth;
- }
return gain;
}
@@ -10892,13 +10864,13 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
{
int32 gain = 0;
- if(dVal==0)
+ if (dVal==0)
return 0;
int32 curPower = (int32)GetPower(power);
int32 val = dVal + curPower;
- if(val <= 0)
+ if (val <= 0)
{
SetPower(power,0);
return -curPower;
@@ -10906,12 +10878,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
int32 maxPower = (int32)GetMaxPower(power);
- if(val < maxPower)
+ if (val < maxPower)
{
SetPower(power,val);
gain = val - curPower;
}
- else if(curPower != maxPower)
+ else if (curPower != maxPower)
{
SetPower(power,maxPower);
gain = maxPower - curPower;
@@ -10922,7 +10894,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, bool is3dDistance) const
{
- if(!u || !IsInMap(u))
+ if (!u || !IsInMap(u))
return false;
return u->canSeeOrDetect(this, detect, inVisibleList, is3dDistance);
@@ -10935,30 +10907,30 @@ bool Unit::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool i
bool Unit::canDetectInvisibilityOf(Unit const* u) const
{
- if(m_invisibilityMask & u->m_invisibilityMask) // same group
+ if (m_invisibilityMask & u->m_invisibilityMask) // same group
return true;
AuraEffectList const& auras = u->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark
for (AuraEffectList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter)
- if((*iter)->GetCasterGUID()==GetGUID())
+ if ((*iter)->GetCasterGUID()==GetGUID())
return true;
- if(uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask))
+ if (uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask))
{
for (uint32 i = 0; i < 10; ++i)
{
- if(((1 << i) & mask)==0)
+ if (((1 << i) & mask)==0)
continue;
// find invisibility level
uint32 invLevel = 0;
Unit::AuraEffectList const& iAuras = u->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY);
for (Unit::AuraEffectList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr)
- if(((*itr)->GetMiscValue())==i && invLevel < (*itr)->GetAmount())
+ if (((*itr)->GetMiscValue())==i && invLevel < (*itr)->GetAmount())
invLevel = (*itr)->GetAmount();
// find invisibility detect level
uint32 detectLevel = 0;
- if(i==6 && GetTypeId() == TYPEID_PLAYER) // special drunk detection case
+ if (i==6 && GetTypeId() == TYPEID_PLAYER) // special drunk detection case
{
detectLevel = ((Player*)this)->GetDrunkValue();
}
@@ -10966,11 +10938,11 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
{
Unit::AuraEffectList const& dAuras = GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
for (Unit::AuraEffectList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr)
- if(((*itr)->GetMiscValue())==i && detectLevel < (*itr)->GetAmount())
+ if (((*itr)->GetMiscValue())==i && detectLevel < (*itr)->GetAmount())
detectLevel = (*itr)->GetAmount();
}
- if(invLevel <= detectLevel)
+ if (invLevel <= detectLevel)
return true;
}
}
@@ -10980,18 +10952,18 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
bool Unit::canDetectStealthOf(Unit const* target, float distance) const
{
- if(hasUnitState(UNIT_STAT_STUNNED))
+ if (hasUnitState(UNIT_STAT_STUNNED))
return false;
- if(distance < 0.24f) //collision
+ if (distance < 0.24f) //collision
return true;
- if(!HasInArc(M_PI, target)) //behind
+ if (!HasInArc(M_PI, target)) //behind
return false;
- if(HasAuraType(SPELL_AURA_DETECT_STEALTH))
+ if (HasAuraType(SPELL_AURA_DETECT_STEALTH))
return true;
- AuraEffectList const& auras = target->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark
+ AuraEffectList const &auras = target->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark
for (AuraEffectList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter)
- if((*iter)->GetCasterGUID()==GetGUID())
+ if ((*iter)->GetCasterGUID() == GetGUID())
return true;
//Visible distance based on stealth value (stealth rank 4 300MOD, 10.5 - 3 = 7.5)
@@ -11012,7 +10984,7 @@ void Unit::SetVisibility(UnitVisibility x)
SetToNotify();
- if(x == VISIBILITY_GROUP_STEALTH)
+ if (x == VISIBILITY_GROUP_STEALTH)
DestroyForNearbyPlayers();
}
@@ -11054,7 +11026,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
}
case MOVE_FLIGHT:
{
- if (GetTypeId()==TYPEID_UNIT && IsControlledByPlayer()) // not sure if good for pet
+ if (GetTypeId() == TYPEID_UNIT && IsControlledByPlayer()) // not sure if good for pet
{
main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED);
stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS);
@@ -11104,7 +11076,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
// Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need
// TODO: possible affect only on MOVE_RUN
- if(int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED))
+ if (int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED))
{
// Use speed from aura
float max_speed = normalization / (IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]);
@@ -11143,7 +11115,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
propagateSpeedChange();
WorldPacket data;
- if(!forced)
+ if (!forced)
{
switch(mtype)
{
@@ -11193,14 +11165,14 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
}
else
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
// register forced speed changes for WorldSession::HandleForceSpeedChangeAck
// and do it only for real sent packets and use run for run/mounted as client expected
++((Player*)this)->m_forced_speed_changes[mtype];
- if(!isInCombat())
- if(Pet* pet = ((Player*)this)->GetPet())
+ if (!isInCombat())
+ if (Pet* pet = ((Player*)this)->GetPet())
pet->SetSpeed(mtype, m_speed_rate[mtype], forced);
}
@@ -11248,7 +11220,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
void Unit::SetHover(bool on)
{
- if(on)
+ if (on)
CastSpell(this, 11010, true);
else
RemoveAurasDueToSpell(11010);
@@ -11281,7 +11253,8 @@ void Unit::setDeathState(DeathState s)
ClearDiminishings();
GetMotionMaster()->Clear(false);
GetMotionMaster()->MoveIdle();
- if(m_vehicleKit) m_vehicleKit->Die();
+ if (m_vehicleKit)
+ m_vehicleKit->Die();
StopMoving();
//without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
//do not why since in IncreaseMaxHealth currenthealth is checked
@@ -11363,7 +11336,7 @@ void Unit::DeleteThreatList()
void Unit::TauntApply(Unit* taunter)
{
- assert(GetTypeId()== TYPEID_UNIT);
+ assert(GetTypeId() == TYPEID_UNIT);
if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster()))
return;
@@ -11389,7 +11362,7 @@ void Unit::TauntApply(Unit* taunter)
void Unit::TauntFadeOut(Unit *taunter)
{
- assert(GetTypeId()== TYPEID_UNIT);
+ assert(GetTypeId() == TYPEID_UNIT);
if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster()))
return;
@@ -11406,7 +11379,7 @@ void Unit::TauntFadeOut(Unit *taunter)
if (m_ThreatManager.isThreatListEmpty())
{
- if(((Creature*)this)->IsAIEnabled)
+ if (((Creature*)this)->IsAIEnabled)
((Creature*)this)->AI()->EnterEvadeMode();
return;
}
@@ -11565,13 +11538,13 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
int32 value = basePoints + randvalue;
//random damage
- //if(comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/)
+ //if (comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/)
if (m_movedPlayer)
if (uint8 comboPoints = m_movedPlayer->GetComboPoints())
if (float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index])
value += int32(comboDamage * comboPoints);
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
{
modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_ALL_EFFECTS, value);
switch (effect_index)
@@ -11588,7 +11561,7 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
}
}
- if(!basePointsPerLevel && (spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel) &&
+ if (!basePointsPerLevel && (spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel) &&
spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE &&
spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK &&
spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_SPEED_ALWAYS &&
@@ -11778,7 +11751,7 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un
Unit const* target = targetOwner ? targetOwner : this;
Unit const* source = casterOwner ? casterOwner : caster;
- if(target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER)
+ if (target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER)
duration = limitduration;
}
@@ -11875,10 +11848,10 @@ bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const
uint32 Unit::GetCreatureType() const
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(m_form);
- if(ssEntry && ssEntry->creatureType > 0)
+ if (ssEntry && ssEntry->creatureType > 0)
return ssEntry->creatureType;
else
return CREATURE_TYPE_HUMANOID;
@@ -11911,7 +11884,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f
break;
case BASE_PCT:
case TOTAL_PCT:
- if(amount <= -100.0f) //small hack-fix for -100% modifiers
+ if (amount <= -100.0f) //small hack-fix for -100% modifiers
amount = -200.0f;
val = (100.0f + amount) / 100.0f;
@@ -11967,13 +11940,13 @@ 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)
+ if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END)
{
sLog.outError("trial to access non existed modifier value from UnitMods!");
return 0.0f;
}
- if(modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f)
+ if (modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f)
return 0.0f;
return m_auraModifiersGroup[unitMod][modifierType];
@@ -11983,7 +11956,7 @@ float Unit::GetTotalStatValue(Stats stat) const
{
UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat);
- if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f)
+ if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f)
return 0.0f;
// value = ((base_value * base_pct) + total_value) * total_pct
@@ -11997,13 +11970,13 @@ float Unit::GetTotalStatValue(Stats stat) const
float Unit::GetTotalAuraModValue(UnitMods unitMod) const
{
- if(unitMod >= UNIT_MOD_END)
+ if (unitMod >= UNIT_MOD_END)
{
sLog.outError("trial to access non existed UnitMods in GetTotalAuraModValue()!");
return 0.0f;
}
- if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f)
+ if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f)
return 0.0f;
float value = m_auraModifiersGroup[unitMod][BASE_VALUE];
@@ -12112,7 +12085,7 @@ void Unit::SetHealth(uint32 val)
else
{
uint32 maxHealth = GetMaxHealth();
- if(maxHealth < val)
+ if (maxHealth < val)
val = maxHealth;
}
@@ -12130,7 +12103,7 @@ void Unit::SetHealth(uint32 val)
if (pet->isControlled())
{
Unit *owner = GetOwner();
- if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
+ if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP);
}
}
@@ -12153,10 +12126,10 @@ void Unit::SetMaxHealth(uint32 val)
else if (((Creature*)this)->isPet())
{
Pet *pet = ((Pet*)this);
- if(pet->isControlled())
+ if (pet->isControlled())
{
Unit *owner = GetOwner();
- if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
+ if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP);
}
}
@@ -12374,7 +12347,8 @@ void Unit::UpdateCharmAI()
{
if (!isCharmed())
{
- if(i_AI) delete i_AI;
+ if (i_AI)
+ delete i_AI;
i_AI = i_disabledAI;
i_disabledAI = NULL;
}
@@ -12459,7 +12433,7 @@ void CharmInfo::InitEmptyActionBar(bool withAttack)
void CharmInfo::InitPossessCreateSpells()
{
InitEmptyActionBar();
- if(m_unit->GetTypeId() == TYPEID_UNIT)
+ if (m_unit->GetTypeId() == TYPEID_UNIT)
{
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{
@@ -12588,7 +12562,7 @@ void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply)
return;
for (uint32 x = 0; x < MAX_SPELL_CHARM; ++x)
- if(spellid == m_charmspells[x].GetAction())
+ if (spellid == m_charmspells[x].GetAction())
m_charmspells[x].SetType(apply ? ACT_ENABLED : ACT_DISABLED);
}
@@ -12843,7 +12817,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit * pTarget, uint32 procFlag,
// Defensive procs are active on absorbs (so absorption effects are not a hindrance)
bool active = (damage > 0) || ((procExtra & PROC_EX_ABSORB) && isVictim);
- if(!IsTriggeredAtSpellProcEvent(pTarget, triggerData.aura, procSpell, procFlag, procExtra, attType, isVictim, active, triggerData.spellProcEvent))
+ if (!IsTriggeredAtSpellProcEvent(pTarget, triggerData.aura, procSpell, procFlag, procExtra, attType, isVictim, active, triggerData.spellProcEvent))
continue;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
@@ -13057,7 +13031,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit * pTarget, uint32 procFlag,
}
}
// Remove charge (aura can be removed by triggers)
- if(useCharges && takeCharges)
+ if (useCharges && takeCharges)
i->aura->DropAuraCharge();
if (spellInfo->AttributesEx3 & SPELL_ATTR_EX3_DISABLE_PROC)
@@ -13076,12 +13050,12 @@ SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const
Player* Unit::GetSpellModOwner() const
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
return (Player*)this;
- if(((Creature*)this)->isPet() || ((Creature*)this)->isTotem())
+ if (((Creature*)this)->isPet() || ((Creature*)this)->isTotem())
{
Unit* owner = GetOwner();
- if(owner && owner->GetTypeId() == TYPEID_PLAYER)
+ if (owner && owner->GetTypeId() == TYPEID_PLAYER)
return (Player*)owner;
}
return NULL;
@@ -13090,11 +13064,11 @@ Player* Unit::GetSpellModOwner() const
///----------Pet responses methods-----------------
void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg)
{
- if(msg == SPELL_CAST_OK)
+ if (msg == SPELL_CAST_OK)
return;
Unit *owner = GetCharmerOrOwner();
- if(!owner || owner->GetTypeId() != TYPEID_PLAYER)
+ if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1);
@@ -13109,7 +13083,7 @@ void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg)
void Unit::SendPetActionFeedback (uint8 msg)
{
Unit* owner = GetOwner();
- if(!owner || owner->GetTypeId() != TYPEID_PLAYER)
+ if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
WorldPacket data(SMSG_PET_ACTION_FEEDBACK, 1);
@@ -13120,7 +13094,7 @@ void Unit::SendPetActionFeedback (uint8 msg)
void Unit::SendPetTalk (uint32 pettalk)
{
Unit* owner = GetOwner();
- if(!owner || owner->GetTypeId() != TYPEID_PLAYER)
+ if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4);
@@ -13132,7 +13106,7 @@ void Unit::SendPetTalk (uint32 pettalk)
void Unit::SendPetAIReaction(uint64 guid)
{
Unit* owner = GetOwner();
- if(!owner || owner->GetTypeId() != TYPEID_PLAYER)
+ if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
WorldPacket data(SMSG_AI_REACTION, 8 + 4);
@@ -13191,7 +13165,7 @@ void Unit::SetStandState(uint8 state)
if (IsStandState())
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_SEATED);
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
WorldPacket data(SMSG_STANDSTATE_UPDATE, 1);
data << (uint8)state;
@@ -13208,13 +13182,13 @@ void Unit::SetDisplayId(uint32 modelId)
{
SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
- if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
+ if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
{
Pet *pet = ((Pet*)this);
- if(!pet->isControlled())
+ if (!pet->isControlled())
return;
Unit *owner = GetOwner();
- if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
+ if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
}
}
@@ -13226,7 +13200,7 @@ void Unit::ClearComboPointHolders()
uint32 lowguid = *m_ComboPointHolders.begin();
Player* plr = objmgr.GetPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER));
- if(plr && plr->GetComboTarget()==GetGUID()) // recheck for safe
+ if (plr && plr->GetComboTarget()==GetGUID()) // recheck for safe
plr->ClearComboPoints(); // remove also guid from m_ComboPointHolders;
else
m_ComboPointHolders.erase(lowguid); // or remove manually
@@ -13242,7 +13216,7 @@ void Unit::ClearAllReactives()
ModifyAuraState(AURA_STATE_DEFENSE, false);
if (getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY))
ModifyAuraState(AURA_STATE_HUNTER_PARRY, false);
- if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
+ if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
((Player*)this)->ClearComboPoints();
}
@@ -13252,7 +13226,7 @@ void Unit::UpdateReactives( uint32 p_time )
{
ReactiveType reactive = ReactiveType(i);
- if(!m_reactiveTimer[reactive])
+ if (!m_reactiveTimer[reactive])
continue;
if ( m_reactiveTimer[reactive] <= p_time)
@@ -13270,7 +13244,7 @@ void Unit::UpdateReactives( uint32 p_time )
ModifyAuraState(AURA_STATE_HUNTER_PARRY, false);
break;
case REACTIVE_OVERPOWER:
- if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
+ if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
((Player*)this)->ClearComboPoints();
break;
default:
@@ -13292,13 +13266,13 @@ Unit* Unit::SelectNearbyTarget(float dist) const
VisitNearbyObject(dist, searcher);
// remove current target
- if(getVictim())
+ if (getVictim())
targets.remove(getVictim());
// remove not LoS targets
- for (std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); )
+ for (std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end();)
{
- if(!IsWithinLOSInMap(*tIter))
+ if (!IsWithinLOSInMap(*tIter))
{
std::list<Unit *>::iterator tIter2 = tIter;
++tIter;
@@ -13309,7 +13283,7 @@ Unit* Unit::SelectNearbyTarget(float dist) const
}
// no appropriate targets
- if(targets.empty())
+ if (targets.empty())
return NULL;
// select random
@@ -13334,7 +13308,7 @@ bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag)
void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply )
{
float remainingTimePct = (float)m_attackTimer[att] / (GetAttackTime(att) * m_modAttackSpeedPct[att]);
- if(val > 0)
+ if (val > 0)
{
ApplyPercentModFloatVar(m_modAttackSpeedPct[att], val, !apply);
ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val,!apply);
@@ -13349,7 +13323,7 @@ void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply
void Unit::ApplyCastTimePercentMod(float val, bool apply )
{
- if(val > 0)
+ if (val > 0)
ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,val,!apply);
else
ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,-val,apply);
@@ -13358,13 +13332,13 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply )
uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime )
{
// Not apply this to creature casted spells with casttime==0
- if(CastingTime==0 && GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet())
+ if (CastingTime==0 && GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet())
return 3500;
if (CastingTime > 7000) CastingTime = 7000;
if (CastingTime < 1500) CastingTime = 1500;
- if(damagetype == DOT && !IsChanneledSpell(spellProto))
+ if (damagetype == DOT && !IsChanneledSpell(spellProto))
CastingTime = 3500;
int32 overTime = 0;
@@ -13402,7 +13376,7 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT
break;
}
- if(IsAreaEffectTarget[spellProto->EffectImplicitTargetA[i]] || IsAreaEffectTarget[spellProto->EffectImplicitTargetB[i]])
+ if (IsAreaEffectTarget[spellProto->EffectImplicitTargetA[i]] || IsAreaEffectTarget[spellProto->EffectImplicitTargetB[i]])
AreaEffect = true;
}
@@ -13447,24 +13421,24 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT
void Unit::UpdateAuraForGroup(uint8 slot)
{
- if(slot >= MAX_AURAS) // slot not found, return
+ if (slot >= MAX_AURAS) // slot not found, return
return;
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
Player* player = (Player*)this;
- if(player->GetGroup())
+ if (player->GetGroup())
{
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS);
player->SetAuraUpdateMaskForRaid(slot);
}
}
- else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
+ else if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
{
Pet *pet = ((Pet*)this);
- if(pet->isControlled())
+ if (pet->isControlled())
{
Unit *owner = GetOwner();
- if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
+ if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
{
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS);
pet->SetAuraUpdateMaskForRaid(slot);
@@ -13522,18 +13496,18 @@ void Unit::SetContestedPvP(Player *attackedPlayer)
{
Player* player = GetCharmerOrOwnerPlayerOrPlayerItself();
- if(!player || attackedPlayer && (attackedPlayer == player || player->duel && player->duel->opponent == attackedPlayer))
+ if (!player || attackedPlayer && (attackedPlayer == player || player->duel && player->duel->opponent == attackedPlayer))
return;
player->SetContestedPvPTimer(30000);
- if(!player->hasUnitState(UNIT_STAT_ATTACK_PLAYER))
+ if (!player->hasUnitState(UNIT_STAT_ATTACK_PLAYER))
{
player->addUnitState(UNIT_STAT_ATTACK_PLAYER);
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP);
// call MoveInLineOfSight for nearby contested guards
player->SetVisibility(GetVisibility());
}
- if(!hasUnitState(UNIT_STAT_ATTACK_PLAYER))
+ if (!hasUnitState(UNIT_STAT_ATTACK_PLAYER))
{
addUnitState(UNIT_STAT_ATTACK_PLAYER);
// call MoveInLineOfSight for nearby contested guards
@@ -13543,32 +13517,32 @@ void Unit::SetContestedPvP(Player *attackedPlayer)
void Unit::AddPetAura(PetAura const* petSpell)
{
- if(GetTypeId() != TYPEID_PLAYER)
+ if (GetTypeId() != TYPEID_PLAYER)
return;
m_petAuras.insert(petSpell);
- if(Pet* pet = ((Player*)this)->GetPet())
+ if (Pet* pet = ((Player*)this)->GetPet())
pet->CastPetAura(petSpell);
}
void Unit::RemovePetAura(PetAura const* petSpell)
{
- if(GetTypeId() != TYPEID_PLAYER)
+ if (GetTypeId() != TYPEID_PLAYER)
return;
m_petAuras.erase(petSpell);
- if(Pet* pet = ((Player*)this)->GetPet())
+ if (Pet* pet = ((Player*)this)->GetPet())
pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
}
Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
{
- if(GetTypeId() != TYPEID_PLAYER)
+ if (GetTypeId() != TYPEID_PLAYER)
return NULL;
Pet* pet = new Pet((Player*)this, HUNTER_PET);
- if(!pet->CreateBaseAtCreature(creatureTarget))
+ if (!pet->CreateBaseAtCreature(creatureTarget))
{
delete pet;
return NULL;
@@ -13578,12 +13552,12 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
pet->setFaction(getFaction());
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
uint8 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel();
- if(!pet->InitStatsForLevel(level))
+ if (!pet->InitStatsForLevel(level))
{
sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry());
delete pet;
@@ -13665,7 +13639,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co
{
// Check if player is wearing shield
Item *item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
- if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
+ if (!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
return false;
}
}
@@ -13689,7 +13663,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co
}
}
// Apply chance modifer aura
- if(Player* modOwner = GetSpellModOwner())
+ if (Player* modOwner = GetSpellModOwner())
{
modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance);
}
@@ -13719,7 +13693,7 @@ bool Unit::HandleAuraRaidProcFromChargeWithValue(AuraEffect *triggeredByAura)
else
radius = GetSpellMaxRangeForTarget(triggeredByAura->GetCaster(), sSpellRangeStore.LookupEntry(spellProto->rangeIndex));
- if(Player *caster = (Player*)triggeredByAura->GetCaster())
+ if (Player *caster = (Player*)triggeredByAura->GetCaster())
{
caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius, NULL);
@@ -13778,7 +13752,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura)
triggeredByAura->GetParentAura()->SetAuraCharges(1); // will removed at next charges decrease
// next target selection
- if(jumps > 0 && IS_PLAYER_GUID(caster_guid))
+ if (jumps > 0 && IS_PLAYER_GUID(caster_guid))
{
float radius;
if (spellProto->EffectRadiusIndex[effIdx])
@@ -13786,7 +13760,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura)
else
radius = GetSpellMaxRangeForTarget(triggeredByAura->GetCaster() ,sSpellRangeStore.LookupEntry(spellProto->rangeIndex));
- if(Player* caster = ((Player*)triggeredByAura->GetCaster()))
+ if (Player* caster = ((Player*)triggeredByAura->GetCaster()))
{
caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL);
@@ -13808,7 +13782,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura)
void Unit::SetToNotify()
{
// it is called somewhere when obj is not in world (crash when log in instance)
- if(m_NotifyListPos < 0)
+ if (m_NotifyListPos < 0)
GetMap()->AddUnitToNotify(this);
}
@@ -13835,20 +13809,20 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
Player *player = GetCharmerOrOwnerPlayerOrPlayerItself();
bool bRewardIsAllowed = true;
- if(pVictim->GetTypeId() == TYPEID_UNIT)
+ if (pVictim->GetTypeId() == TYPEID_UNIT)
{
bRewardIsAllowed = ((Creature*)pVictim)->IsDamageEnoughForLootingAndReward();
- if(!bRewardIsAllowed)
+ if (!bRewardIsAllowed)
((Creature*)pVictim)->SetLootRecipient(NULL);
}
- if(bRewardIsAllowed && pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient())
+ if (bRewardIsAllowed && pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient())
player = ((Creature*)pVictim)->GetLootRecipient();
// Reward player, his pets, and group/raid members
// call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop)
- if(bRewardIsAllowed && player && player!=pVictim)
+ if (bRewardIsAllowed && player && player!=pVictim)
{
- if(player->RewardPlayerAndGroupAtKill(pVictim))
+ if (player->RewardPlayerAndGroupAtKill(pVictim))
player->ProcDamageAndSpell(pVictim, PROC_FLAG_KILL, PROC_FLAG_KILLED, PROC_EX_NONE, 0);
else
player->ProcDamageAndSpell(pVictim, PROC_FLAG_NONE, PROC_FLAG_KILLED, PROC_EX_NONE, 0);
@@ -13859,16 +13833,16 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
// if talent known but not triggered (check priest class for speedup check)
bool SpiritOfRedemption = false;
- if(pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->getClass() == CLASS_PRIEST)
+ if (pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->getClass() == CLASS_PRIEST)
{
AuraEffectList const& vDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY);
for (AuraEffectList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr)
{
- if((*itr)->GetSpellProto()->SpellIconID==1654)
+ if ((*itr)->GetSpellProto()->SpellIconID==1654)
{
// save value before aura remove
uint32 ressSpellId = pVictim->GetUInt32Value(PLAYER_SELF_RES_SPELL);
- if(!ressSpellId)
+ if (!ressSpellId)
ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId();
//Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers)
pVictim->RemoveAllAurasOnDeath();
@@ -13940,17 +13914,17 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
cVictim->AI()->JustDied(this);
// Dungeon specific stuff, only applies to players killing creatures
- if(cVictim->GetInstanceId())
+ if (cVictim->GetInstanceId())
{
Map *m = cVictim->GetMap();
Player *creditedPlayer = GetCharmerOrOwnerPlayerOrPlayerItself();
// TODO: do instance binding anyway if the charmer/owner is offline
- if(m->IsDungeon() && creditedPlayer)
+ if (m->IsDungeon() && creditedPlayer)
{
- if(m->IsRaid() || m->IsHeroic())
+ if (m->IsRaid() || m->IsHeroic())
{
- if(cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
+ if (cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer);
}
else
@@ -13958,8 +13932,8 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
// the reset time is set but not added to the scheduler
// until the players leave the instance
time_t resettime = cVictim->GetRespawnTimeEx() + 2 * HOUR;
- if(InstanceSave *save = sInstanceSaveManager.GetInstanceSave(cVictim->GetInstanceId()))
- if(save->GetResetTime() < resettime) save->SetResetTime(resettime);
+ if (InstanceSave *save = sInstanceSaveManager.GetInstanceSave(cVictim->GetInstanceId()))
+ if (save->GetResetTime() < resettime) save->SetResetTime(resettime);
}
}
}
@@ -13967,20 +13941,20 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
// outdoor pvp things, do these after setting the death state, else the player activity notify won't work... doh...
// handle player kill only if not suicide (spirit of redemption for example)
- if(player && this != pVictim)
- if(OutdoorPvP * pvp = player->GetOutdoorPvP())
+ if (player && this != pVictim)
+ if (OutdoorPvP * pvp = player->GetOutdoorPvP())
pvp->HandleKill(player, pVictim);
- //if(pVictim->GetTypeId() == TYPEID_PLAYER)
- // if(OutdoorPvP * pvp = ((Player*)pVictim)->GetOutdoorPvP())
+ //if (pVictim->GetTypeId() == TYPEID_PLAYER)
+ // if (OutdoorPvP * pvp = ((Player*)pVictim)->GetOutdoorPvP())
// pvp->HandlePlayerActivityChanged((Player*)pVictim);
// battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill)
- if(player && player->InBattleGround())
+ if (player && player->InBattleGround())
{
- if(BattleGround *bg = player->GetBattleGround())
+ if (BattleGround *bg = player->GetBattleGround())
{
- if(pVictim->GetTypeId() == TYPEID_PLAYER)
+ if (pVictim->GetTypeId() == TYPEID_PLAYER)
bg->HandleKillPlayer((Player*)pVictim, player);
else
bg->HandleKillUnit((Creature*)pVictim, player);
@@ -13992,16 +13966,16 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
{
if (GetTypeId() == TYPEID_UNIT)
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, GetEntry());
- else if(GetTypeId() == TYPEID_PLAYER && pVictim != this)
+ else if (GetTypeId() == TYPEID_PLAYER && pVictim != this)
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, ((Player*)this)->GetTeam());
}
}
void Unit::SetControlled(bool apply, UnitState state)
{
- if(apply)
+ if (apply)
{
- if(hasUnitState(state))
+ if (hasUnitState(state))
return;
addUnitState(state);
@@ -14012,15 +13986,15 @@ void Unit::SetControlled(bool apply, UnitState state)
SetStunned(true);
break;
case UNIT_STAT_ROOT:
- if(!hasUnitState(UNIT_STAT_STUNNED))
+ if (!hasUnitState(UNIT_STAT_STUNNED))
SetRooted(true);
break;
case UNIT_STAT_CONFUSED:
- if(!hasUnitState(UNIT_STAT_STUNNED))
+ if (!hasUnitState(UNIT_STAT_STUNNED))
SetConfused(true);
break;
case UNIT_STAT_FLEEING:
- if(!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED))
+ if (!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED))
SetFeared(true);
break;
default:
@@ -14031,29 +14005,29 @@ void Unit::SetControlled(bool apply, UnitState state)
{
switch(state)
{
- case UNIT_STAT_STUNNED: if(HasAuraType(SPELL_AURA_MOD_STUN)) return;
+ case UNIT_STAT_STUNNED: if (HasAuraType(SPELL_AURA_MOD_STUN)) return;
else SetStunned(false); break;
- case UNIT_STAT_ROOT: if(HasAuraType(SPELL_AURA_MOD_ROOT) || GetVehicle()) return;
+ case UNIT_STAT_ROOT: if (HasAuraType(SPELL_AURA_MOD_ROOT) || GetVehicle()) return;
else SetRooted(false); break;
- case UNIT_STAT_CONFUSED:if(HasAuraType(SPELL_AURA_MOD_CONFUSE)) return;
+ case UNIT_STAT_CONFUSED:if (HasAuraType(SPELL_AURA_MOD_CONFUSE)) return;
else SetConfused(false); break;
- case UNIT_STAT_FLEEING: if(HasAuraType(SPELL_AURA_MOD_FEAR)) return;
+ case UNIT_STAT_FLEEING: if (HasAuraType(SPELL_AURA_MOD_FEAR)) return;
else SetFeared(false); break;
default: return;
}
clearUnitState(state);
- if(hasUnitState(UNIT_STAT_STUNNED))
+ if (hasUnitState(UNIT_STAT_STUNNED))
SetStunned(true);
else
{
- if(hasUnitState(UNIT_STAT_ROOT))
+ if (hasUnitState(UNIT_STAT_ROOT))
SetRooted(true);
- if(hasUnitState(UNIT_STAT_CONFUSED))
+ if (hasUnitState(UNIT_STAT_CONFUSED))
SetConfused(true);
- else if(hasUnitState(UNIT_STAT_FLEEING))
+ else if (hasUnitState(UNIT_STAT_FLEEING))
SetFeared(true);
}
}
@@ -14061,7 +14035,7 @@ void Unit::SetControlled(bool apply, UnitState state)
void Unit::SetStunned(bool apply)
{
- if(apply)
+ if (apply)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
@@ -14069,7 +14043,7 @@ void Unit::SetStunned(bool apply)
AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
// Creature specific
- if(GetTypeId() != TYPEID_PLAYER)
+ if (GetTypeId() != TYPEID_PLAYER)
((Creature*)this)->StopMoving();
else
SetStandState(UNIT_STAND_STATE_STAND);
@@ -14081,15 +14055,15 @@ void Unit::SetStunned(bool apply)
}
else
{
- if(isAlive() && getVictim())
+ if (isAlive() && getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
// don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface)
Unit *pOwner = GetOwner();
- if(!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !((Player *)pOwner)->IsMounted()))
+ if (!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !((Player *)pOwner)->IsMounted()))
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
- if(!hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
+ if (!hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
{
WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4);
data.append(GetPackGUID());
@@ -14103,7 +14077,7 @@ void Unit::SetStunned(bool apply)
void Unit::SetRooted(bool apply)
{
- if(apply)
+ if (apply)
{
AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
@@ -14112,12 +14086,12 @@ void Unit::SetRooted(bool apply)
data << (uint32)2;
SendMessageToSet(&data,true);
- if(GetTypeId() != TYPEID_PLAYER)
+ if (GetTypeId() != TYPEID_PLAYER)
((Creature *)this)->StopMoving();
}
else
{
- if(!hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
+ if (!hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
{
WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
data.append(GetPackGUID());
@@ -14131,25 +14105,25 @@ void Unit::SetRooted(bool apply)
void Unit::SetFeared(bool apply)
{
- if(apply)
+ if (apply)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0);
Unit *caster = NULL;
Unit::AuraEffectList const& fearAuras = GetAurasByType(SPELL_AURA_MOD_FEAR);
- if(!fearAuras.empty())
+ if (!fearAuras.empty())
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
- if(!caster)
+ if (!caster)
caster = getAttackerForHelper();
GetMotionMaster()->MoveFleeing(caster, fearAuras.empty() ? sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY) : 0); // caster==NULL processed in MoveFleeing
}
else
{
- if(isAlive())
+ if (isAlive())
{
- if(GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE)
+ if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE)
GetMotionMaster()->MovementExpired();
- if(getVictim())
+ if (getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
}
}
@@ -14160,29 +14134,29 @@ void Unit::SetFeared(bool apply)
void Unit::SetConfused(bool apply)
{
- if(apply)
+ if (apply)
{
SetUInt64Value(UNIT_FIELD_TARGET, 0);
GetMotionMaster()->MoveConfused();
}
else
{
- if(isAlive())
+ if (isAlive())
{
- if(GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
+ if (GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
GetMotionMaster()->MovementExpired();
- if(getVictim())
+ if (getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
}
}
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
((Player*)this)->SetClientControl(this, !apply);
}
bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
{
- if(!charmer)
+ if (!charmer)
return false;
assert(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER);
@@ -14190,23 +14164,23 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
sLog.outDebug("SetCharmedBy: charmer %u, charmed %u, type %u.", charmer->GetEntry(), GetEntry(), (uint32)type);
- if(this == charmer)
+ if (this == charmer)
{
sLog.outCrash("Unit::SetCharmedBy: Unit %u is trying to charm itself!", GetEntry());
return false;
}
- //if(hasUnitState(UNIT_STAT_UNATTACKABLE))
+ //if (hasUnitState(UNIT_STAT_UNATTACKABLE))
// return false;
- if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport())
+ if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport())
{
sLog.outCrash("Unit::SetCharmedBy: Player on transport is trying to charm %u", GetEntry());
return false;
}
// Already charmed
- if(GetCharmerGUID())
+ if (GetCharmerGUID())
{
sLog.outCrash("Unit::SetCharmedBy: %u has already been charmed but %u is trying to charm it!", GetEntry(), charmer->GetEntry());
return false;
@@ -14217,21 +14191,21 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
DeleteThreatList();
// Charmer stop charming
- if(charmer->GetTypeId() == TYPEID_PLAYER)
+ if (charmer->GetTypeId() == TYPEID_PLAYER)
{
((Player*)charmer)->StopCastingCharm();
((Player*)charmer)->StopCastingBindSight();
}
// Charmed stop charming
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
((Player*)this)->StopCastingCharm();
((Player*)this)->StopCastingBindSight();
}
// StopCastingCharm may remove a possessed pet?
- if(!IsInWorld())
+ if (!IsInWorld())
{
sLog.outCrash("Unit::SetCharmedBy: %u is not in world but %u is trying to charm it!", GetEntry(), charmer->GetEntry());
return false;
@@ -14241,29 +14215,29 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
setFaction(charmer->getFaction());
charmer->SetCharm(this, true);
- if(GetTypeId() == TYPEID_UNIT)
+ if (GetTypeId() == TYPEID_UNIT)
{
((Creature*)this)->AI()->OnCharmed(true);
GetMotionMaster()->MoveIdle();
}
else
{
- if(((Player*)this)->isAFK())
+ if (((Player*)this)->isAFK())
((Player*)this)->ToggleAFK();
((Player*)this)->SetClientControl(this, 0);
}
// Pets already have a properly initialized CharmInfo, don't overwrite it.
- if(type != CHARM_TYPE_VEHICLE && !GetCharmInfo())
+ if (type != CHARM_TYPE_VEHICLE && !GetCharmInfo())
{
CharmInfo *charmInfo = InitCharmInfo();
- if(type == CHARM_TYPE_POSSESS)
+ if (type == CHARM_TYPE_POSSESS)
charmInfo->InitPossessCreateSpells();
else
charmInfo->InitCharmCreateSpells();
}
- if(charmer->GetTypeId() == TYPEID_PLAYER)
+ if (charmer->GetTypeId() == TYPEID_PLAYER)
{
switch(type)
{
@@ -14282,16 +14256,16 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
((Player*)charmer)->PossessSpellInitialize();
break;
case CHARM_TYPE_CHARM:
- if(GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
+ if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
{
CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo();
- if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
+ if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
{
//to prevent client crash
SetByteValue(UNIT_FIELD_BYTES_0, 1, (uint8)CLASS_MAGE);
//just to enable stat window
- if(GetCharmInfo())
+ if (GetCharmInfo())
GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
//if charmed two demons the same session, the 2nd gets the 1st one's name
@@ -14310,12 +14284,12 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
void Unit::RemoveCharmedBy(Unit *charmer)
{
- if(!isCharmed())
+ if (!isCharmed())
return;
- if(!charmer)
+ if (!charmer)
charmer = GetCharmer();
- if(charmer != GetCharmer()) // one aura overrides another?
+ if (charmer != GetCharmer()) // one aura overrides another?
{
// sLog.outCrash("Unit::RemoveCharmedBy: this: " UI64FMTD " true charmer: " UI64FMTD " false charmer: " UI64FMTD,
// GetGUID(), GetCharmerGUID(), charmer->GetGUID());
@@ -14324,9 +14298,9 @@ void Unit::RemoveCharmedBy(Unit *charmer)
}
CharmType type;
- if(hasUnitState(UNIT_STAT_POSSESSED))
+ if (hasUnitState(UNIT_STAT_POSSESSED))
type = CHARM_TYPE_POSSESS;
- else if(charmer->IsOnVehicle(this))
+ else if (charmer->IsOnVehicle(this))
type = CHARM_TYPE_VEHICLE;
else
type = CHARM_TYPE_CHARM;
@@ -14338,23 +14312,21 @@ void Unit::RemoveCharmedBy(Unit *charmer)
RestoreFaction();
GetMotionMaster()->InitDefault();
- if(type == CHARM_TYPE_POSSESS)
+ if (type == CHARM_TYPE_POSSESS)
{
clearUnitState(UNIT_STAT_POSSESSED);
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
}
- if(GetTypeId() == TYPEID_UNIT)
+ if (GetTypeId() == TYPEID_UNIT)
{
((Creature*)this)->AI()->OnCharmed(false);
- if(isAlive() && charmer && !IsFriendlyTo(charmer))
+ if (isAlive() && charmer && !IsFriendlyTo(charmer))
((Creature*)this)->AddThreat(charmer, 10000.0f);
- /*if(isAlive() && ((Creature*)this)->IsAIEnabled)
+ /*if (isAlive() && ((Creature*)this)->IsAIEnabled)
{
- if(charmer && !IsFriendlyTo(charmer))
- {
+ if (charmer && !IsFriendlyTo(charmer))
((Creature*)this)->AI()->AttackStart(charmer);
- }
else
((Creature*)this)->AI()->EnterEvadeMode();
}*/
@@ -14363,7 +14335,7 @@ void Unit::RemoveCharmedBy(Unit *charmer)
((Player*)this)->SetClientControl(this, 1);
// If charmer still exists
- if(!charmer)
+ if (!charmer)
return;
assert(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER);
@@ -14371,7 +14343,7 @@ void Unit::RemoveCharmedBy(Unit *charmer)
charmer->SetCharm(this, false);
- if(charmer->GetTypeId() == TYPEID_PLAYER)
+ if (charmer->GetTypeId() == TYPEID_PLAYER)
{
switch(type)
{
@@ -14385,13 +14357,13 @@ void Unit::RemoveCharmedBy(Unit *charmer)
charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
break;
case CHARM_TYPE_CHARM:
- if(GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
+ if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
{
CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo();
- if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
+ if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
{
SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class));
- if(GetCharmInfo())
+ if (GetCharmInfo())
GetCharmInfo()->SetPetNumber(0, true);
else
sLog.outError("Aura::HandleModCharm: target="UI64FMTD" with typeid=%d has a charm aura but no charm info!", GetGUID(), GetTypeId());
@@ -14426,7 +14398,7 @@ void Unit::RestoreFaction()
}
}
- if(CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo()) // normal creature
+ if (CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo()) // normal creature
{
FactionTemplateEntry const *faction = getFactionTemplateEntry();
setFaction((faction && faction->friendlyMask & 0x004) ? cinfo->faction_H : cinfo->faction_A);
@@ -14437,7 +14409,7 @@ void Unit::RestoreFaction()
bool Unit::CreateVehicleKit(uint32 id)
{
VehicleEntry const *vehInfo = sVehicleStore.LookupEntry(id);
- if(!vehInfo)
+ if (!vehInfo)
return false;
m_vehicleKit = new Vehicle(this, vehInfo);
@@ -14569,7 +14541,7 @@ void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap)
if (owner->GetTypeId() == TYPEID_PLAYER)
pGroup = ((Player*)owner)->GetGroup();
- if(pGroup)
+ if (pGroup)
{
uint8 subgroup = ((Player*)owner)->GetSubGroup();
@@ -14591,10 +14563,10 @@ void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap)
}
else
{
- if(owner->isAlive() && (owner == this || IsInMap(owner)))
+ if (owner->isAlive() && (owner == this || IsInMap(owner)))
TagUnitMap.push_back(owner);
- if(Guardian* pet = owner->GetGuardianPet())
- if(pet->isAlive() && (pet == this || IsInMap(pet)))
+ if (Guardian* pet = owner->GetGuardianPet())
+ if (pet->isAlive() && (pet == this || IsInMap(pet)))
TagUnitMap.push_back(pet);
}
}
@@ -14632,11 +14604,11 @@ void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply)
void Unit::AddAura(uint32 spellId, Unit *target)
{
- if(!target || !target->isAlive())
+ if (!target || !target->isAlive())
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
- if(!spellInfo)
+ if (!spellInfo)
return;
if (target->IsImmunedToSpell(spellInfo))
@@ -14647,13 +14619,13 @@ void Unit::AddAura(uint32 spellId, Unit *target)
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if(spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || IsAreaAuraEffect(spellInfo->Effect[i]))
+ if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || IsAreaAuraEffect(spellInfo->Effect[i]))
{
// Area auras applied as linked should have target as source (otherwise they'll be removed after first aura update)
if (spellInfo->Effect[i] != SPELL_EFFECT_APPLY_AURA)
source = target;
- if(target->IsImmunedToSpellEffect(spellInfo, i))
+ if (target->IsImmunedToSpellEffect(spellInfo, i))
continue;
eff_mask|=1<<i;
}
@@ -14670,12 +14642,12 @@ void Unit::AddAura(uint32 spellId, Unit *target)
void Unit::SetAuraStack(uint32 spellId, Unit *target, uint32 stack)
{
Aura *aur = target->GetAura(spellId, GetGUID());
- if(!aur)
+ if (!aur)
{
AddAura(spellId, target);
aur = target->GetAura(spellId, GetGUID());
}
- if(aur && stack)
+ if (aur && stack)
aur->SetStackAmount(stack);
}
@@ -14690,16 +14662,16 @@ Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, WorldOb
Aura *aur = GetAura(spellInfo->Id, caster->GetGUID());
// without this it may crash when shaman refresh totem? source is NULL
- if(aur && aur->GetSourceGUID() != source->GetGUID())
+ if (aur && aur->GetSourceGUID() != source->GetGUID())
{
RemoveAura(aur);
aur = NULL;
}
- if(aur)
+ if (aur)
{
- if(AuraEffect *aurEffect = CreateAuraEffect(aur, effIndex, basePoints))
- if(!aur->SetPartAura(aurEffect, effIndex))
+ if (AuraEffect *aurEffect = CreateAuraEffect(aur, effIndex, basePoints))
+ if (!aur->SetPartAura(aurEffect, effIndex))
delete aurEffect;
}
else
@@ -14713,7 +14685,7 @@ Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, WorldOb
else
aur = new Aura(spellInfo, 1<<effIndex, this, source, caster, NULL, NULL);
- if(!AddAura(aur))
+ if (!AddAura(aur))
return NULL;
}
return aur;
@@ -14729,7 +14701,7 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType,
// PvP - PvE melee chances
/*int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7;
int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim);
- if(leveldif < 3)
+ if (leveldif < 3)
HitChance = 95 - leveldif;
else
HitChance = 93 - (leveldif - 2) * lchance;*/
@@ -14739,20 +14711,20 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType,
HitChance = 76.0f;
// Hit chance depends from victim auras
- if(attType == RANGED_ATTACK)
+ if (attType == RANGED_ATTACK)
HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE);
else
HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
- if(spellId)
+ if (spellId)
{
- if(Player *modOwner = GetSpellModOwner())
+ if (Player *modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, HitChance);
}
// Miss = 100 - hit
- float miss_chance= 100.0f - HitChance;
+ float miss_chance = 100.0f - HitChance;
// Bonuses from attacker aura and ratings
if (attType == RANGED_ATTACK)
@@ -14763,7 +14735,7 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType,
// bonus from skills is 0.04%
//miss_chance -= skillDiff * 0.04f;
int32 diff = -skillDiff;
- if(pVictim->GetTypeId() == TYPEID_PLAYER)
+ if (pVictim->GetTypeId() == TYPEID_PLAYER)
miss_chance += diff > 0 ? diff * 0.04 : diff * 0.02;
else
miss_chance += diff > 10 ? 2 + (diff - 10) * 0.4 : diff * 0.1;
@@ -14778,40 +14750,40 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType,
void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
{
- if(newPhaseMask==GetPhaseMask())
+ if (newPhaseMask == GetPhaseMask())
return;
- if(IsInWorld())
+ if (IsInWorld())
RemoveNotOwnSingleTargetAuras(newPhaseMask); // we can lost access to caster or target
WorldObject::SetPhaseMask(newPhaseMask,update);
- if(!IsInWorld())
+ if (!IsInWorld())
return;
for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
- if((*itr)->GetTypeId() == TYPEID_UNIT)
+ if ((*itr)->GetTypeId() == TYPEID_UNIT)
(*itr)->SetPhaseMask(newPhaseMask,true);
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
- if(m_SummonSlot[i])
- if(Creature *summon = GetMap()->GetCreature(m_SummonSlot[i]))
+ if (m_SummonSlot[i])
+ if (Creature *summon = GetMap()->GetCreature(m_SummonSlot[i]))
summon->SetPhaseMask(newPhaseMask,true);
}
void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
{
Player *player = NULL;
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
player = (Player*)this;
else
{
player = dynamic_cast<Player*>(GetCharmer());
- if(player && player->m_mover != this)
+ if (player && player->m_mover != this)
player = NULL;
}
- if(!player)
+ if (!player)
{
GetMotionMaster()->MoveKnockbackFrom(x, y, speedXY, speedZ);
}
@@ -14835,10 +14807,8 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
void Unit::JumpTo(float speedXY, float speedZ, bool forward)
{
float angle = forward ? 0 : M_PI;
- if(GetTypeId() == TYPEID_UNIT)
- {
+ if (GetTypeId() == TYPEID_UNIT)
GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ);
- }
else
{
float vcos = cos(angle+GetOrientation());
@@ -14866,14 +14836,14 @@ void Unit::JumpTo(WorldObject *obj, float speedZ)
void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
{
- if(!isAlive() || GetVehicleKit() == vehicle)
+ if (!isAlive() || GetVehicleKit() == vehicle)
return;
- if(m_vehicle)
+ if (m_vehicle)
{
- if(m_vehicle == vehicle)
+ if (m_vehicle == vehicle)
{
- if(seatId >= 0)
+ if (seatId >= 0)
{
sLog.outDebug("EnterVehicle: %u leave vehicle %u seat %d and enter %d.", GetEntry(), m_vehicle->GetBase()->GetEntry(), GetTransSeat(), seatId);
ChangeSeat(seatId);
@@ -14887,7 +14857,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
}
}
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
((Player*)this)->StopCastingCharm();
((Player*)this)->StopCastingBindSight();
@@ -14897,7 +14867,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
assert(!m_vehicle);
m_vehicle = vehicle;
- if(!m_vehicle->AddPassenger(this, seatId))
+ if (!m_vehicle->AddPassenger(this, seatId))
{
m_vehicle = NULL;
return;
@@ -14907,7 +14877,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
//movementInfo is set in AddPassenger
//packets are sent in AddPassenger
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
//((Player*)this)->SetClientControl(vehicle, 1);
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
@@ -14917,40 +14887,40 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
void Unit::ChangeSeat(int8 seatId, bool next)
{
- if(!m_vehicle)
+ if (!m_vehicle)
return;
- if(seatId < 0)
+ if (seatId < 0)
{
seatId = m_vehicle->GetNextEmptySeat(GetTransSeat(), next);
- if(seatId < 0)
+ if (seatId < 0)
return;
}
- else if(seatId == GetTransSeat() || !m_vehicle->HasEmptySeat(seatId))
+ else if (seatId == GetTransSeat() || !m_vehicle->HasEmptySeat(seatId))
return;
m_vehicle->RemovePassenger(this);
- if(!m_vehicle->AddPassenger(this, seatId))
+ if (!m_vehicle->AddPassenger(this, seatId))
assert(false);
}
void Unit::ExitVehicle()
{
- if(!m_vehicle)
+ if (!m_vehicle)
return;
Unit *vehicleBase = m_vehicle->GetBase();
const AuraEffectList &modAuras = vehicleBase->GetAurasByType(SPELL_AURA_CONTROL_VEHICLE);
for (AuraEffectList::const_iterator itr = modAuras.begin(); itr != modAuras.end(); ++itr)
{
- if((*itr)->GetParentAura()->GetSourceGUID() == GetGUID())
+ if ((*itr)->GetParentAura()->GetSourceGUID() == GetGUID())
{
vehicleBase->RemoveAura((*itr)->GetParentAura());
break; // there should be no case that a vehicle has two auras for one source
}
}
- if(!m_vehicle)
+ if (!m_vehicle)
return;
//sLog.outError("exit vehicle");
@@ -14974,7 +14944,7 @@ void Unit::ExitVehicle()
Relocate(vehicle->GetBase());
//Send leave vehicle, not correct
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
{
//((Player*)this)->SetClientControl(this, 1);
((Player*)this)->SendTeleportAckMsg();
@@ -14984,8 +14954,8 @@ void Unit::ExitVehicle()
BuildHeartBeatMsg(&data);
SendMessageToSet(&data, false);
- if(vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
- if(((Minion*)vehicle->GetBase())->GetOwner() == this)
+ if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
+ if (((Minion*)vehicle->GetBase())->GetOwner() == this)
vehicle->Dismiss();
}
@@ -15037,14 +15007,14 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
}
// 0x02200000
- if((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING))
+ if ((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING))
|| (m_movementInfo.unk1 & 0x20))
*data << (float)m_movementInfo.s_pitch;
*data << (uint32)m_movementInfo.fallTime;
// 0x00001000
- if(GetUnitMovementFlags() & MOVEMENTFLAG_JUMPING)
+ if (GetUnitMovementFlags() & MOVEMENTFLAG_JUMPING)
{
*data << (float)m_movementInfo.j_zspeed;
*data << (float)m_movementInfo.j_sinAngle;
@@ -15053,10 +15023,10 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
}
// 0x04000000
- if(GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE)
+ if (GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE)
*data << (float)m_movementInfo.u_unk1;
- /*if(GetTypeId() == TYPEID_PLAYER)
+ /*if (GetTypeId() == TYPEID_PLAYER)
{
sLog.outString("Send MovementInfo:");
OutMovementInfo();
@@ -15066,19 +15036,19 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const
void Unit::OutMovementInfo() const
{
sLog.outString("MovementInfo for %u: Flag %u, Unk1 %u, Time %u, Pos %f %f %f %f, Fall %u", GetEntry(), m_movementInfo.flags, (uint32)m_movementInfo.unk1, m_movementInfo.time, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), m_movementInfo.fallTime);
- if(m_movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
+ if (m_movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
sLog.outString("Transport: GUID " UI64FMTD ", Pos %f %f %f %f, Time %u, Seat %d", m_movementInfo.t_guid, m_movementInfo.t_x, m_movementInfo.t_y, m_movementInfo.t_z, m_movementInfo.t_o, m_movementInfo.t_time, (int32)m_movementInfo.t_seat);
- if((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20))
+ if ((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20))
sLog.outString("Pitch: %f", m_movementInfo.s_pitch);
- if(m_movementInfo.flags & MOVEMENTFLAG_JUMPING)
+ if (m_movementInfo.flags & MOVEMENTFLAG_JUMPING)
sLog.outString("Jump: speedz %f, sin %f, cos %f, speedxy %f", m_movementInfo.j_zspeed, m_movementInfo.j_sinAngle, m_movementInfo.j_cosAngle, m_movementInfo.j_xyspeed);
- if(m_movementInfo.flags & MOVEMENTFLAG_SPLINE)
+ if (m_movementInfo.flags & MOVEMENTFLAG_SPLINE)
sLog.outString("Spline: %f", m_movementInfo.u_unk1);
}
void Unit::SetFlying(bool apply)
{
- if(apply)
+ if (apply)
{
SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02);
AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE + MOVEMENTFLAG_FLYING);
@@ -15092,7 +15062,7 @@ void Unit::SetFlying(bool apply)
void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool casting /*= false*/ )
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_PLAYER)
((Player*)this)->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0));
else
{
@@ -15188,7 +15158,7 @@ void Unit::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker
if (getLevel() > 70)
rageconversion += 13.27f*(getLevel()-70);
- if(attacker)
+ if (attacker)
{
addRage = ((damage/rageconversion*7.5 + weaponSpeedHitFactor)/2);
@@ -15200,7 +15170,7 @@ void Unit::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker
addRage = damage/rageconversion*2.5;
// Berserker Rage effect
- if(HasAura(18499))
+ if (HasAura(18499))
addRage *= 2.0;
}
@@ -15231,16 +15201,16 @@ void Unit::OutDebugInfo() const
sLog.outStringInLine("%u, ", itr->first);
sLog.outString();
- if(IsVehicle())
+ if (IsVehicle())
{
sLog.outStringInLine("Passenger List: ");
for (SeatMap::iterator itr = GetVehicleKit()->m_Seats.begin(); itr != GetVehicleKit()->m_Seats.end(); ++itr)
- if(Unit *passenger = itr->second.passenger)
+ if (Unit *passenger = itr->second.passenger)
sLog.outStringInLine(UI64FMTD", ", passenger->GetGUID());
sLog.outString();
}
- if(GetVehicle())
+ if (GetVehicle())
sLog.outString("On vehicle %u.", GetVehicleBase()->GetEntry());
}