diff options
author | megamage <none@none> | 2009-08-15 14:30:14 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-15 14:30:14 -0500 |
commit | e03b7cd4d75e040336fa18f20e24d5797111728e (patch) | |
tree | e6dddcd7c4be0fac426d560a48ce9d8b05bb97a0 | |
parent | bc7f37fe1cd29c4315b38d2c844e227e97e6b900 (diff) |
*Change react state of guardian back to aggressive. Instead check threat radius in canstartattack to prevent them attack too far target.
--HG--
branch : trunk
-rw-r--r-- | src/game/Creature.cpp | 26 | ||||
-rw-r--r-- | src/game/Creature.h | 2 | ||||
-rw-r--r-- | src/game/TemporarySummon.cpp | 2 | ||||
-rw-r--r-- | src/game/ThreatManager.cpp | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 5 |
5 files changed, 17 insertions, 20 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 19eae315e9c..07652fe8eb6 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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 diff --git a/src/game/Creature.h b/src/game/Creature.h index cec6a123579..fdab5157bd4 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -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; diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 40c6d79c919..434750c8744 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -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) diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index 60c46c2307d..5db2a99440d 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -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 { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index da55ce24576..567a3628c9c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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) { |