*Change react state of guardian back to aggressive. Instead check threat radius in canstartattack to prevent them attack too far target.
--HG-- branch : trunk
This commit is contained in:
+13
-13
@@ -1704,7 +1704,7 @@ bool Creature::IsWithinSightDist(Unit const* u) const
|
||||
|
||||
bool Creature::canStartAttack(Unit const* who, bool force) const
|
||||
{
|
||||
if(isCivilian() || !who->isInAccessiblePlaceFor(this))
|
||||
if(isCivilian())
|
||||
return false;
|
||||
|
||||
if(!canFly() && (GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE))
|
||||
@@ -1716,7 +1716,7 @@ bool Creature::canStartAttack(Unit const* who, bool force) const
|
||||
if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who))))
|
||||
return false;
|
||||
|
||||
if(!canAttack(who, force))
|
||||
if(!canCreatureAttack(who, force))
|
||||
return false;
|
||||
|
||||
return IsWithinLOSInMap(who);
|
||||
@@ -2180,29 +2180,29 @@ void Creature::SaveRespawnTime()
|
||||
objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),time(NULL)+m_respawnDelay+m_deathTimer/IN_MILISECONDS);
|
||||
}
|
||||
|
||||
bool Creature::IsOutOfThreatArea(Unit* pVictim) const
|
||||
// this should not be called by petAI or
|
||||
bool Creature::canCreatureAttack(Unit const *pVictim, bool force) const
|
||||
{
|
||||
if(!pVictim)
|
||||
return true;
|
||||
|
||||
if(!pVictim->IsInMap(this))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if(!canAttack(pVictim))
|
||||
return true;
|
||||
if(!canAttack(pVictim, force))
|
||||
return false;
|
||||
|
||||
if(!pVictim->isInAccessiblePlaceFor(this))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if(sMapStore.LookupEntry(GetMapId())->IsDungeon())
|
||||
return false;
|
||||
return true;
|
||||
|
||||
float AttackDist = GetAttackDistance(pVictim);
|
||||
uint32 ThreatRadius = sWorld.getConfig(CONFIG_THREAT_RADIUS);
|
||||
|
||||
//Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and out of combat every update tick.
|
||||
return !pVictim->IsWithinDist3d(mHome_X,mHome_Y,mHome_Z,
|
||||
ThreatRadius > AttackDist ? ThreatRadius : AttackDist);
|
||||
if(Unit *unit = GetCharmerOrOwner())
|
||||
return pVictim->IsWithinDist(unit, ThreatRadius > AttackDist ? ThreatRadius : AttackDist);
|
||||
else
|
||||
return pVictim->IsWithinDist3d(mHome_X, mHome_Y, mHome_Z, ThreatRadius > AttackDist ? ThreatRadius : AttackDist);
|
||||
}
|
||||
|
||||
CreatureDataAddon const* Creature::GetCreatureAddon() const
|
||||
|
||||
+1
-1
@@ -527,7 +527,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
bool isCanTrainingOf(Player* player, bool msg) const;
|
||||
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
|
||||
bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
|
||||
bool IsOutOfThreatArea(Unit* pVictim) const;
|
||||
bool canCreatureAttack(Unit const *pVictim, bool force = true) const;
|
||||
bool IsImmunedToSpell(SpellEntry const* spellInfo);
|
||||
// redefine Unit::IsImmunedToSpell
|
||||
bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
|
||||
|
||||
@@ -325,7 +325,7 @@ void Guardian::InitStats(uint32 duration)
|
||||
if(m_owner->GetTypeId() == TYPEID_PLAYER && HasSummonMask(SUMMON_MASK_CONTROLABLE_GUARDIAN))
|
||||
m_charmInfo->InitCharmCreateSpells();
|
||||
|
||||
SetReactState(REACT_DEFENSIVE);
|
||||
SetReactState(REACT_AGGRESSIVE);
|
||||
}
|
||||
|
||||
Puppet::Puppet(SummonPropertiesEntry const *properties, Unit *owner) : Minion(properties, owner)
|
||||
|
||||
@@ -306,7 +306,7 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe
|
||||
}
|
||||
}
|
||||
|
||||
if(!pAttacker->IsOutOfThreatArea(target)) // skip non attackable currently targets
|
||||
if(pAttacker->canCreatureAttack(target)) // skip non attackable currently targets
|
||||
{
|
||||
if(pCurrentVictim) // select 1.3/1.1 better target in comparison current target
|
||||
{
|
||||
|
||||
+1
-4
@@ -11187,11 +11187,8 @@ Unit* Creature::SelectVictim()
|
||||
|
||||
// search nearby enemy before enter evade mode
|
||||
if(HasReactState(REACT_AGGRESSIVE))
|
||||
{
|
||||
target = SelectNearestTarget();
|
||||
if(target && !IsOutOfThreatArea(target))
|
||||
if(target = SelectNearestTarget())
|
||||
return target;
|
||||
}
|
||||
|
||||
if(m_invisibilityMask)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user