Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[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!
  • Loading branch information...
commit 649b48823c4c4c983075ca6981309eb2f7ab39b9 1 parent 07989b7
sixsixnine authored Schmoozerd committed
View
10 src/game/ThreatManager.cpp
@@ -252,7 +252,15 @@ HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat)
void ThreatContainer::modifyThreatPercent(Unit *pVictim, int32 pPercent)
{
if(HostileReference* ref = getReferenceByTarget(pVictim))
- ref->addThreatPercent(pPercent);
+ {
+ if(pPercent < -100)
+ {
+ ref->removeReference();
+ delete ref;
+ }
+ else
+ ref->addThreatPercent(pPercent);
+ }
}
//============================================================
View
26 src/game/Unit.cpp
@@ -8666,6 +8666,32 @@ bool Unit::SelectHostileTarget()
SetInFront(target);
if (oldTarget != 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;
}
View
2  src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "11917"
+ #define REVISION_NR "11918"
#endif // __REVISION_NR_H__
Please sign in to comment.
Something went wrong with that request. Please try again.