diff options
author | megamage <none@none> | 2009-08-26 16:54:59 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-26 16:54:59 -0500 |
commit | a35991c8365575226394f90071dc97894e94f21c (patch) | |
tree | 450f5f2eec929dacc5c09f1e13c9eaa7a75a81ba | |
parent | dad2c55287d4a9c35cbfa1ad4e8d3e8e8255f588 (diff) |
*Add function CanAIAttack
--HG--
branch : trunk
-rw-r--r-- | src/game/CombatAI.cpp | 17 | ||||
-rw-r--r-- | src/game/CombatAI.h | 1 | ||||
-rw-r--r-- | src/game/Creature.cpp | 3 | ||||
-rw-r--r-- | src/game/Creature.h | 2 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 2 | ||||
-rw-r--r-- | src/game/UnitAI.h | 1 |
6 files changed, 21 insertions, 5 deletions
diff --git a/src/game/CombatAI.cpp b/src/game/CombatAI.cpp index 37ef8186e2b..b18e6dd7532 100644 --- a/src/game/CombatAI.cpp +++ b/src/game/CombatAI.cpp @@ -223,6 +223,15 @@ TurretAI::TurretAI(Creature *c) : CreatureAI(c) me->m_SightDistance = me->m_CombatDistance; } +bool TurretAI::CanAIAttack(const Unit *who) const +{ + // TODO: use one function to replace it + if(!me->IsWithinCombatRange(me->getVictim(), me->m_CombatDistance) + || m_minRange && me->IsWithinCombatRange(me->getVictim(), m_minRange)) + return false; + return true; +} + void TurretAI::AttackStart(Unit *who) { if(who) @@ -234,7 +243,9 @@ void TurretAI::UpdateAI(const uint32 diff) if(!UpdateVictim()) return; - if(m_minRange && me->IsWithinCombatRange(me->getVictim(), m_minRange) || !DoSpellAttackIfReady(me->m_spells[0])) - if(HostilReference *ref = me->getThreatManager().getCurrentVictim()) - ref->removeReference(); + DoSpellAttackIfReady(me->m_spells[0]); + + //if(!DoSpellAttackIfReady(me->m_spells[0])) + //if(HostilReference *ref = me->getThreatManager().getCurrentVictim()) + //ref->removeReference(); } diff --git a/src/game/CombatAI.h b/src/game/CombatAI.h index 96f46d73b5b..5ded95601ae 100644 --- a/src/game/CombatAI.h +++ b/src/game/CombatAI.h @@ -81,6 +81,7 @@ struct TRINITY_DLL_SPEC TurretAI : public CreatureAI { public: explicit TurretAI(Creature *c); + bool CanAIAttack(const Unit *who) const; void AttackStart(Unit *who); void UpdateAI(const uint32 diff); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 3d11c4a0941..330c93429b6 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -2185,6 +2185,9 @@ bool Creature::canCreatureAttack(Unit const *pVictim, bool force) const if(!pVictim->isInAccessiblePlaceFor(this)) return false; + if(!AI()->CanAIAttack(pVictim)) + return false; + if(sMapStore.LookupEntry(GetMapId())->IsDungeon()) return true; diff --git a/src/game/Creature.h b/src/game/Creature.h index cd726c567fb..6035d3da6aa 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -535,7 +535,7 @@ class TRINITY_DLL_SPEC Creature : public Unit void Motion_Initialize(); void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); - CreatureAI* AI() { return (CreatureAI*)i_AI; } + CreatureAI * AI() const { return (CreatureAI*)i_AI; } uint32 GetShieldBlockValue() const //dunno mob block value { diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index f1bef6c6808..2acad8f7ede 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1033,9 +1033,9 @@ uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const case 28511: // Eye of Acherus case 33114: // Flame Leviathan Seat (model 24914 chair) case 33167: // Salvaged Demolisher Mechanic Seat - case 33218: // Pyrite Safety Container return cinfo->DisplayID_A[0]; case 33143: // Overload Control Device + case 33218: // Pyrite Safety Container return cinfo->DisplayID_H[0]; default: return cinfo->GetRandomValidModelId(); diff --git a/src/game/UnitAI.h b/src/game/UnitAI.h index 3458eda9b36..ba6704d897f 100644 --- a/src/game/UnitAI.h +++ b/src/game/UnitAI.h @@ -45,6 +45,7 @@ class TRINITY_DLL_SPEC UnitAI Unit * const me; public: explicit UnitAI(Unit *u) : me(u) {} + virtual bool CanAIAttack(const Unit *who) const { return true; } virtual void AttackStart(Unit *); virtual void UpdateAI(const uint32 diff) = 0; |