mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[11000] Minor code style changes for readability in aggro related unit functions
Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
e9fc7d05b2
commit
d38539f12a
2 changed files with 28 additions and 21 deletions
|
|
@ -8501,6 +8501,7 @@ void Unit::SetDeathState(DeathState s)
|
||||||
######## AGGRO SYSTEM ########
|
######## AGGRO SYSTEM ########
|
||||||
######## ########
|
######## ########
|
||||||
########################################*/
|
########################################*/
|
||||||
|
|
||||||
bool Unit::CanHaveThreatList() const
|
bool Unit::CanHaveThreatList() const
|
||||||
{
|
{
|
||||||
// only creatures can have threat list
|
// only creatures can have threat list
|
||||||
|
|
@ -8552,7 +8553,7 @@ float Unit::ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask)
|
||||||
void Unit::AddThreat(Unit* pVictim, float threat /*= 0.0f*/, bool crit /*= false*/, SpellSchoolMask schoolMask /*= SPELL_SCHOOL_MASK_NONE*/, SpellEntry const *threatSpell /*= NULL*/)
|
void Unit::AddThreat(Unit* pVictim, float threat /*= 0.0f*/, bool crit /*= false*/, SpellSchoolMask schoolMask /*= SPELL_SCHOOL_MASK_NONE*/, SpellEntry const *threatSpell /*= NULL*/)
|
||||||
{
|
{
|
||||||
// Only mobs can manage threat lists
|
// Only mobs can manage threat lists
|
||||||
if(CanHaveThreatList())
|
if (CanHaveThreatList())
|
||||||
m_ThreatManager.addThreat(pVictim, threat, crit, schoolMask, threatSpell);
|
m_ThreatManager.addThreat(pVictim, threat, crit, schoolMask, threatSpell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8560,8 +8561,9 @@ void Unit::AddThreat(Unit* pVictim, float threat /*= 0.0f*/, bool crit /*= false
|
||||||
|
|
||||||
void Unit::DeleteThreatList()
|
void Unit::DeleteThreatList()
|
||||||
{
|
{
|
||||||
if(CanHaveThreatList() && !m_ThreatManager.isThreatListEmpty())
|
if (CanHaveThreatList() && !m_ThreatManager.isThreatListEmpty())
|
||||||
SendThreatClear();
|
SendThreatClear();
|
||||||
|
|
||||||
m_ThreatManager.clearReferences();
|
m_ThreatManager.clearReferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8569,19 +8571,21 @@ void Unit::DeleteThreatList()
|
||||||
|
|
||||||
void Unit::TauntApply(Unit* taunter)
|
void Unit::TauntApply(Unit* taunter)
|
||||||
{
|
{
|
||||||
MANGOS_ASSERT(GetTypeId()== TYPEID_UNIT);
|
MANGOS_ASSERT(GetTypeId() == TYPEID_UNIT);
|
||||||
|
|
||||||
if(!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster()))
|
if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!CanHaveThreatList())
|
if (!CanHaveThreatList())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Unit *target = getVictim();
|
Unit *target = getVictim();
|
||||||
if(target && target == taunter)
|
|
||||||
|
if (target && target == taunter)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetInFront(taunter);
|
SetInFront(taunter);
|
||||||
|
|
||||||
if (((Creature*)this)->AI())
|
if (((Creature*)this)->AI())
|
||||||
((Creature*)this)->AI()->AttackStart(taunter);
|
((Creature*)this)->AI()->AttackStart(taunter);
|
||||||
|
|
||||||
|
|
@ -8592,21 +8596,22 @@ void Unit::TauntApply(Unit* taunter)
|
||||||
|
|
||||||
void Unit::TauntFadeOut(Unit *taunter)
|
void Unit::TauntFadeOut(Unit *taunter)
|
||||||
{
|
{
|
||||||
MANGOS_ASSERT(GetTypeId()== TYPEID_UNIT);
|
MANGOS_ASSERT(GetTypeId() == TYPEID_UNIT);
|
||||||
|
|
||||||
if(!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster()))
|
if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!CanHaveThreatList())
|
if (!CanHaveThreatList())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Unit *target = getVictim();
|
Unit *target = getVictim();
|
||||||
if(!target || target != taunter)
|
|
||||||
|
if (!target || target != taunter)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_ThreatManager.isThreatListEmpty())
|
if (m_ThreatManager.isThreatListEmpty())
|
||||||
{
|
{
|
||||||
if(((Creature*)this)->AI())
|
if (((Creature*)this)->AI())
|
||||||
((Creature*)this)->AI()->EnterEvadeMode();
|
((Creature*)this)->AI()->EnterEvadeMode();
|
||||||
|
|
||||||
if (InstanceData* mapInstance = GetInstanceData())
|
if (InstanceData* mapInstance = GetInstanceData())
|
||||||
|
|
@ -8621,6 +8626,7 @@ void Unit::TauntFadeOut(Unit *taunter)
|
||||||
if (target && target != taunter)
|
if (target && target != taunter)
|
||||||
{
|
{
|
||||||
SetInFront(target);
|
SetInFront(target);
|
||||||
|
|
||||||
if (((Creature*)this)->AI())
|
if (((Creature*)this)->AI())
|
||||||
((Creature*)this)->AI()->AttackStart(target);
|
((Creature*)this)->AI()->AttackStart(target);
|
||||||
}
|
}
|
||||||
|
|
@ -8634,10 +8640,11 @@ bool Unit::SelectHostileTarget()
|
||||||
//next-victim-selection algorithm and evade mode are called
|
//next-victim-selection algorithm and evade mode are called
|
||||||
//threat list sorting etc.
|
//threat list sorting etc.
|
||||||
|
|
||||||
MANGOS_ASSERT(GetTypeId()== TYPEID_UNIT);
|
MANGOS_ASSERT(GetTypeId() == TYPEID_UNIT);
|
||||||
|
|
||||||
if (!this->isAlive())
|
if (!this->isAlive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//This function only useful once AI has been initialized
|
//This function only useful once AI has been initialized
|
||||||
if (!((Creature*)this)->AI())
|
if (!((Creature*)this)->AI())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -8646,12 +8653,12 @@ bool Unit::SelectHostileTarget()
|
||||||
|
|
||||||
// First checking if we have some taunt on us
|
// First checking if we have some taunt on us
|
||||||
const AuraList& tauntAuras = GetAurasByType(SPELL_AURA_MOD_TAUNT);
|
const AuraList& tauntAuras = GetAurasByType(SPELL_AURA_MOD_TAUNT);
|
||||||
if ( !tauntAuras.empty() )
|
if (!tauntAuras.empty())
|
||||||
{
|
{
|
||||||
Unit* caster;
|
Unit* caster;
|
||||||
|
|
||||||
// The last taunt aura caster is alive an we are happy to attack him
|
// The last taunt aura caster is alive an we are happy to attack him
|
||||||
if ( (caster = tauntAuras.back()->GetCaster()) && caster->isAlive() )
|
if ((caster = tauntAuras.back()->GetCaster()) && caster->isAlive())
|
||||||
return true;
|
return true;
|
||||||
else if (tauntAuras.size() > 1)
|
else if (tauntAuras.size() > 1)
|
||||||
{
|
{
|
||||||
|
|
@ -8663,8 +8670,8 @@ bool Unit::SelectHostileTarget()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
--aura;
|
--aura;
|
||||||
if ( (caster = (*aura)->GetCaster()) &&
|
if ((caster = (*aura)->GetCaster()) && caster->IsInMap(this) &&
|
||||||
caster->IsInMap(this) && caster->isTargetableForAttack() && caster->isInAccessablePlaceFor((Creature*)this) )
|
caster->isTargetableForAttack() && caster->isInAccessablePlaceFor((Creature*)this))
|
||||||
{
|
{
|
||||||
target = caster;
|
target = caster;
|
||||||
break;
|
break;
|
||||||
|
|
@ -8673,8 +8680,8 @@ bool Unit::SelectHostileTarget()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !target && !m_ThreatManager.isThreatListEmpty() )
|
// No taunt aura or taunt aura caster is dead, standard target selection
|
||||||
// No taunt aura or taunt aura caster is dead standart target selection
|
if (!target && !m_ThreatManager.isThreatListEmpty())
|
||||||
target = m_ThreatManager.getHostileTarget();
|
target = m_ThreatManager.getHostileTarget();
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
|
|
@ -8688,7 +8695,7 @@ bool Unit::SelectHostileTarget()
|
||||||
}
|
}
|
||||||
|
|
||||||
// no target but something prevent go to evade mode
|
// no target but something prevent go to evade mode
|
||||||
if( !isInCombat() || HasAuraType(SPELL_AURA_MOD_TAUNT) )
|
if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_TAUNT))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// last case when creature don't must go to evade mode:
|
// last case when creature don't must go to evade mode:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10999"
|
#define REVISION_NR "11000"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue