mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[7667] Add to CreatureAI field pointing to creature itself. Use it instead diff. fields in subclases.
Also send pointer to AI constructors ans mark constructors as explicit. This changes allow move now some generic often used AI code to CreatureAI helper functions.
This commit is contained in:
parent
721e005b84
commit
69fb9736cc
18 changed files with 379 additions and 382 deletions
|
|
@ -45,15 +45,15 @@ ReactorAI::AttackStart(Unit *p)
|
|||
if(!p)
|
||||
return;
|
||||
|
||||
if(i_creature.Attack(p,true))
|
||||
if(m_creature->Attack(p,true))
|
||||
{
|
||||
DEBUG_LOG("Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId());
|
||||
i_creature.SetInCombatWith(p);
|
||||
p->SetInCombatWith(&i_creature);
|
||||
m_creature->SetInCombatWith(p);
|
||||
p->SetInCombatWith(m_creature);
|
||||
|
||||
i_creature.AddThreat(p, 0.0f);
|
||||
m_creature->AddThreat(p, 0.0f);
|
||||
i_victimGuid = p->GetGUID();
|
||||
i_creature.GetMotionMaster()->MoveChase(p);
|
||||
m_creature->GetMotionMaster()->MoveChase(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,17 +67,17 @@ void
|
|||
ReactorAI::UpdateAI(const uint32 /*time_diff*/)
|
||||
{
|
||||
// update i_victimGuid if i_creature.getVictim() !=0 and changed
|
||||
if(!i_creature.SelectHostilTarget() || !i_creature.getVictim())
|
||||
if(!m_creature->SelectHostilTarget() || !m_creature->getVictim())
|
||||
return;
|
||||
|
||||
i_victimGuid = i_creature.getVictim()->GetGUID();
|
||||
i_victimGuid = m_creature->getVictim()->GetGUID();
|
||||
|
||||
if( i_creature.isAttackReady() )
|
||||
if( m_creature->isAttackReady() )
|
||||
{
|
||||
if( i_creature.IsWithinDistInMap(i_creature.getVictim(), ATTACK_DISTANCE))
|
||||
if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
|
||||
{
|
||||
i_creature.AttackerStateUpdate(i_creature.getVictim());
|
||||
i_creature.resetAttackTimer();
|
||||
m_creature->AttackerStateUpdate(m_creature->getVictim());
|
||||
m_creature->resetAttackTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,43 +85,43 @@ ReactorAI::UpdateAI(const uint32 /*time_diff*/)
|
|||
void
|
||||
ReactorAI::EnterEvadeMode()
|
||||
{
|
||||
if( !i_creature.isAlive() )
|
||||
if( !m_creature->isAlive() )
|
||||
{
|
||||
DEBUG_LOG("Creature stoped attacking cuz his dead [guid=%u]", i_creature.GetGUIDLow());
|
||||
i_creature.GetMotionMaster()->MovementExpired();
|
||||
i_creature.GetMotionMaster()->MoveIdle();
|
||||
DEBUG_LOG("Creature stoped attacking cuz his dead [guid=%u]", m_creature->GetGUIDLow());
|
||||
m_creature->GetMotionMaster()->MovementExpired();
|
||||
m_creature->GetMotionMaster()->MoveIdle();
|
||||
i_victimGuid = 0;
|
||||
i_creature.CombatStop();
|
||||
i_creature.DeleteThreatList();
|
||||
m_creature->CombatStop();
|
||||
m_creature->DeleteThreatList();
|
||||
return;
|
||||
}
|
||||
|
||||
Unit* victim = ObjectAccessor::GetUnit(i_creature, i_victimGuid );
|
||||
Unit* victim = ObjectAccessor::GetUnit(*m_creature, i_victimGuid );
|
||||
|
||||
if( !victim )
|
||||
{
|
||||
DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", i_creature.GetGUIDLow());
|
||||
DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", m_creature->GetGUIDLow());
|
||||
}
|
||||
else if( victim->HasStealthAura() )
|
||||
{
|
||||
DEBUG_LOG("Creature stopped attacking cuz his victim is stealth [guid=%u]", i_creature.GetGUIDLow());
|
||||
DEBUG_LOG("Creature stopped attacking cuz his victim is stealth [guid=%u]", m_creature->GetGUIDLow());
|
||||
}
|
||||
else if( victim->isInFlight() )
|
||||
{
|
||||
DEBUG_LOG("Creature stopped attacking cuz his victim is fly away [guid=%u]", i_creature.GetGUIDLow());
|
||||
DEBUG_LOG("Creature stopped attacking cuz his victim is fly away [guid=%u]", m_creature->GetGUIDLow());
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG("Creature stopped attacking due to target %s [guid=%u]", victim->isAlive() ? "out run him" : "is dead", i_creature.GetGUIDLow());
|
||||
DEBUG_LOG("Creature stopped attacking due to target %s [guid=%u]", victim->isAlive() ? "out run him" : "is dead", m_creature->GetGUIDLow());
|
||||
}
|
||||
|
||||
i_creature.RemoveAllAuras();
|
||||
i_creature.DeleteThreatList();
|
||||
m_creature->RemoveAllAuras();
|
||||
m_creature->DeleteThreatList();
|
||||
i_victimGuid = 0;
|
||||
i_creature.CombatStop();
|
||||
i_creature.SetLootRecipient(NULL);
|
||||
m_creature->CombatStop();
|
||||
m_creature->SetLootRecipient(NULL);
|
||||
|
||||
// Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
|
||||
if( i_creature.GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE )
|
||||
i_creature.GetMotionMaster()->MoveTargetedHome();
|
||||
if( m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE )
|
||||
m_creature->GetMotionMaster()->MoveTargetedHome();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue