*Add function CanAIAttack
--HG-- branch : trunk
This commit is contained in:
+14
-3
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user