Implemented NPC special ability 40 'NPC_CHASE_DISTANCE'

Param 0: Sets max distance you need to be away from an npc for it to chase you.
Param 1: Sets min distance you need to be from npc for it to chase you.
Usage: Ideally used with ranged attack npcs / casters who you DO NOT WANT
to chase you unless you get too close or too far or out of sight.
This commit is contained in:
KayenEQ
2014-08-23 03:21:36 -04:00
parent 16d47a2c47
commit 85df09b3f2
5 changed files with 42 additions and 3 deletions
+26 -1
View File
@@ -873,7 +873,30 @@ bool Mob::CombatRange(Mob* other)
if (size_mod > 10000)
size_mod = size_mod / 7;
if (DistNoRoot(*other) <= size_mod)
float _DistNoRoot = DistNoRoot(*other);
if (GetSpecialAbility(NPC_CHASE_DISTANCE)){
float max_dist = static_cast<float>(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 0));
float min_dist = static_cast<float>(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 1));
if (max_dist == 1)
max_dist = 250.0f; //Default it to 250 if you forget to put a value
max_dist = max_dist * max_dist;
if (!min_dist)
min_dist = size_mod; //Default to melee range
else
min_dist = min_dist * min_dist;
if (CheckLastLosState() && (_DistNoRoot >= min_dist && _DistNoRoot <= max_dist))
SetPseudoRoot(true);
else
SetPseudoRoot(false);
}
if (_DistNoRoot <= size_mod)
{
return true;
}
@@ -887,6 +910,8 @@ bool Mob::CheckLosFN(Mob* other) {
if(other)
Result = CheckLosFN(other->GetX(), other->GetY(), other->GetZ(), other->GetSize());
SetLastLosState(Result);
return Result;
}