mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11918] Let creatures evade when the enemy is unreachable
This commit is not great, but will be improved hopefully soon. However it seems that it doesn't really cause problems, it is just not as good as it should be!
This commit is contained in:
parent
68b701f5d1
commit
d0bdf7611a
3 changed files with 36 additions and 2 deletions
|
|
@ -252,7 +252,15 @@ HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat)
|
||||||
void ThreatContainer::modifyThreatPercent(Unit *pVictim, int32 pPercent)
|
void ThreatContainer::modifyThreatPercent(Unit *pVictim, int32 pPercent)
|
||||||
{
|
{
|
||||||
if(HostileReference* ref = getReferenceByTarget(pVictim))
|
if(HostileReference* ref = getReferenceByTarget(pVictim))
|
||||||
ref->addThreatPercent(pPercent);
|
{
|
||||||
|
if(pPercent < -100)
|
||||||
|
{
|
||||||
|
ref->removeReference();
|
||||||
|
delete ref;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ref->addThreatPercent(pPercent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
|
||||||
|
|
@ -8666,6 +8666,32 @@ bool Unit::SelectHostileTarget()
|
||||||
SetInFront(target);
|
SetInFront(target);
|
||||||
if (oldTarget != target)
|
if (oldTarget != target)
|
||||||
((Creature*)this)->AI()->AttackStart(target);
|
((Creature*)this)->AI()->AttackStart(target);
|
||||||
|
|
||||||
|
// check if currently selected target is reachable
|
||||||
|
// NOTE: path alrteady generated from AttackStart()
|
||||||
|
if(!GetMotionMaster()->operator->()->IsReachable())
|
||||||
|
{
|
||||||
|
// remove all taunts
|
||||||
|
RemoveSpellsCausingAura(SPELL_AURA_MOD_TAUNT);
|
||||||
|
|
||||||
|
if(m_ThreatManager.getThreatList().size() < 2)
|
||||||
|
{
|
||||||
|
// only one target in list, we have to evade after timer
|
||||||
|
// TODO: make timer - inside Creature class
|
||||||
|
((Creature*)this)->AI()->EnterEvadeMode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// remove unreachable target from our threat list
|
||||||
|
// next iteration we will select next possible target
|
||||||
|
m_HostileRefManager.deleteReference(target);
|
||||||
|
m_ThreatManager.modifyThreatPercent(target, -101);
|
||||||
|
|
||||||
|
_removeAttacker(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11917"
|
#define REVISION_NR "11918"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue