mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 13:37:00 +00:00
[11460] Use ObjectGuids in last missing cases in AI classes.
This commit is contained in:
parent
44f2c26389
commit
b4f2e3d1a0
13 changed files with 38 additions and 34 deletions
|
|
@ -37,7 +37,7 @@ AggressorAI::Permissible(const Creature *creature)
|
||||||
return PERMIT_BASE_NO;
|
return PERMIT_BASE_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK)
|
AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ void AggressorAI::EnterEvadeMode()
|
||||||
if (!m_creature->isAlive())
|
if (!m_creature->isAlive())
|
||||||
{
|
{
|
||||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow());
|
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow());
|
||||||
i_victimGuid = 0;
|
i_victimGuid.Clear();
|
||||||
m_creature->CombatStop(true);
|
m_creature->CombatStop(true);
|
||||||
m_creature->DeleteThreatList();
|
m_creature->DeleteThreatList();
|
||||||
return;
|
return;
|
||||||
|
|
@ -114,7 +114,7 @@ void AggressorAI::EnterEvadeMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_creature->DeleteThreatList();
|
m_creature->DeleteThreatList();
|
||||||
i_victimGuid = 0;
|
i_victimGuid.Clear();
|
||||||
m_creature->CombatStop(true);
|
m_creature->CombatStop(true);
|
||||||
m_creature->SetLootRecipient(NULL);
|
m_creature->SetLootRecipient(NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +126,7 @@ AggressorAI::UpdateAI(const uint32 /*diff*/)
|
||||||
if(!m_creature->SelectHostileTarget() || !m_creature->getVictim())
|
if(!m_creature->SelectHostileTarget() || !m_creature->getVictim())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i_victimGuid = m_creature->getVictim()->GetGUID();
|
i_victimGuid = m_creature->getVictim()->GetObjectGuid();
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
DoMeleeAttackIfReady();
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +146,7 @@ AggressorAI::AttackStart(Unit *u)
|
||||||
|
|
||||||
if(m_creature->Attack(u,true))
|
if(m_creature->Attack(u,true))
|
||||||
{
|
{
|
||||||
i_victimGuid = u->GetGUID();
|
i_victimGuid = u->GetObjectGuid();
|
||||||
|
|
||||||
m_creature->AddThreat(u);
|
m_creature->AddThreat(u);
|
||||||
m_creature->SetInCombatWith(u);
|
m_creature->SetInCombatWith(u);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "CreatureAI.h"
|
#include "CreatureAI.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
#include "ObjectGuid.h"
|
||||||
|
|
||||||
class Creature;
|
class Creature;
|
||||||
|
|
||||||
|
|
@ -45,8 +46,9 @@ class MANGOS_DLL_DECL AggressorAI : public CreatureAI
|
||||||
static int Permissible(const Creature *);
|
static int Permissible(const Creature *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64 i_victimGuid;
|
ObjectGuid i_victimGuid;
|
||||||
AggressorState i_state;
|
AggressorState i_state;
|
||||||
TimeTracker i_tracker;
|
TimeTracker i_tracker;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry *pSpell,
|
||||||
return CAST_FAIL_OTHER;
|
return CAST_FAIL_OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, uint64 uiOriginalCasterGUID)
|
CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, ObjectGuid uiOriginalCasterGUID)
|
||||||
{
|
{
|
||||||
Unit* pCaster = m_creature;
|
Unit* pCaster = m_creature;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "Policies/Singleton.h"
|
#include "Policies/Singleton.h"
|
||||||
#include "Dynamic/ObjectRegistry.h"
|
#include "Dynamic/ObjectRegistry.h"
|
||||||
#include "Dynamic/FactoryHolder.h"
|
#include "Dynamic/FactoryHolder.h"
|
||||||
|
#include "ObjectGuid.h"
|
||||||
|
|
||||||
class WorldObject;
|
class WorldObject;
|
||||||
class GameObject;
|
class GameObject;
|
||||||
|
|
@ -156,7 +157,7 @@ class MANGOS_DLL_SPEC CreatureAI
|
||||||
|
|
||||||
///== Helper functions =============================
|
///== Helper functions =============================
|
||||||
bool DoMeleeAttackIfReady();
|
bool DoMeleeAttackIfReady();
|
||||||
CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, uint64 uiOriginalCasterGUID = 0);
|
CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, ObjectGuid uiOriginalCasterGUID = ObjectGuid());
|
||||||
|
|
||||||
///== Fields =======================================
|
///== Fields =======================================
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,9 +189,9 @@ FleeingMovementGenerator<T>::_setMoveData(T &owner)
|
||||||
{
|
{
|
||||||
float cur_dist_xyz = owner.GetDistance(i_caster_x, i_caster_y, i_caster_z);
|
float cur_dist_xyz = owner.GetDistance(i_caster_x, i_caster_y, i_caster_z);
|
||||||
|
|
||||||
if(i_to_distance_from_caster > 0.0f)
|
if (i_to_distance_from_caster > 0.0f)
|
||||||
{
|
{
|
||||||
if((i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz < i_to_distance_from_caster) ||
|
if ((i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz < i_to_distance_from_caster) ||
|
||||||
// if we reach lower distance
|
// if we reach lower distance
|
||||||
(i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz > i_last_distance_from_caster) ||
|
(i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz > i_last_distance_from_caster) ||
|
||||||
// if we can't be close
|
// if we can't be close
|
||||||
|
|
@ -217,12 +217,10 @@ FleeingMovementGenerator<T>::_setMoveData(T &owner)
|
||||||
float cur_dist;
|
float cur_dist;
|
||||||
float angle_to_caster;
|
float angle_to_caster;
|
||||||
|
|
||||||
Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID);
|
if (Unit* fright = owner.GetMap()->GetUnit(i_frightGuid))
|
||||||
|
|
||||||
if(fright)
|
|
||||||
{
|
{
|
||||||
cur_dist = fright->GetDistance(&owner);
|
cur_dist = fright->GetDistance(&owner);
|
||||||
if(cur_dist < cur_dist_xyz)
|
if (cur_dist < cur_dist_xyz)
|
||||||
{
|
{
|
||||||
i_caster_x = fright->GetPositionX();
|
i_caster_x = fright->GetPositionX();
|
||||||
i_caster_y = fright->GetPositionY();
|
i_caster_y = fright->GetPositionY();
|
||||||
|
|
@ -286,7 +284,7 @@ FleeingMovementGenerator<T>::Initialize(T &owner)
|
||||||
|
|
||||||
_Init(owner);
|
_Init(owner);
|
||||||
|
|
||||||
if(Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
|
if (Unit * fright = owner.GetMap()->GetUnit(i_frightGuid))
|
||||||
{
|
{
|
||||||
i_caster_x = fright->GetPositionX();
|
i_caster_x = fright->GetPositionX();
|
||||||
i_caster_y = fright->GetPositionY();
|
i_caster_y = fright->GetPositionY();
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,14 @@
|
||||||
#include "MovementGenerator.h"
|
#include "MovementGenerator.h"
|
||||||
#include "DestinationHolder.h"
|
#include "DestinationHolder.h"
|
||||||
#include "Traveller.h"
|
#include "Traveller.h"
|
||||||
|
#include "ObjectGuid.h"
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class MANGOS_DLL_SPEC FleeingMovementGenerator
|
class MANGOS_DLL_SPEC FleeingMovementGenerator
|
||||||
: public MovementGeneratorMedium< T, FleeingMovementGenerator<T> >
|
: public MovementGeneratorMedium< T, FleeingMovementGenerator<T> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FleeingMovementGenerator(uint64 fright) : i_frightGUID(fright), i_nextCheckTime(0) {}
|
FleeingMovementGenerator(ObjectGuid fright) : i_frightGuid(fright), i_nextCheckTime(0) {}
|
||||||
|
|
||||||
void Initialize(T &);
|
void Initialize(T &);
|
||||||
void Finalize(T &);
|
void Finalize(T &);
|
||||||
|
|
@ -54,7 +55,7 @@ class MANGOS_DLL_SPEC FleeingMovementGenerator
|
||||||
float i_last_distance_from_caster;
|
float i_last_distance_from_caster;
|
||||||
float i_to_distance_from_caster;
|
float i_to_distance_from_caster;
|
||||||
float i_cur_angle;
|
float i_cur_angle;
|
||||||
uint64 i_frightGUID;
|
ObjectGuid i_frightGuid;
|
||||||
TimeTracker i_nextCheckTime;
|
TimeTracker i_nextCheckTime;
|
||||||
|
|
||||||
DestinationHolder< Traveller<T> > i_destinationHolder;
|
DestinationHolder< Traveller<T> > i_destinationHolder;
|
||||||
|
|
@ -64,7 +65,7 @@ class MANGOS_DLL_SPEC TimedFleeingMovementGenerator
|
||||||
: public FleeingMovementGenerator<Creature>
|
: public FleeingMovementGenerator<Creature>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimedFleeingMovementGenerator(uint64 fright, uint32 time) :
|
TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) :
|
||||||
FleeingMovementGenerator<Creature>(fright),
|
FleeingMovementGenerator<Creature>(fright),
|
||||||
i_totalFleeTime(time) {}
|
i_totalFleeTime(time) {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -345,13 +345,13 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
|
||||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str());
|
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str());
|
||||||
|
|
||||||
if (m_owner->GetTypeId() == TYPEID_PLAYER)
|
if (m_owner->GetTypeId() == TYPEID_PLAYER)
|
||||||
Mutate(new FleeingMovementGenerator<Player>(enemy->GetGUID()));
|
Mutate(new FleeingMovementGenerator<Player>(enemy->GetObjectGuid()));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (time)
|
if (time)
|
||||||
Mutate(new TimedFleeingMovementGenerator(enemy->GetGUID(), time));
|
Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time));
|
||||||
else
|
else
|
||||||
Mutate(new FleeingMovementGenerator<Creature>(enemy->GetGUID()));
|
Mutate(new FleeingMovementGenerator<Creature>(enemy->GetObjectGuid()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
bool spellUsed = false;
|
bool spellUsed = false;
|
||||||
for (AllySet::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)
|
for (AllySet::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)
|
||||||
{
|
{
|
||||||
Unit* Target = ObjectAccessor::GetUnit(*m_creature,*tar);
|
Unit* Target = m_creature->GetMap()->GetUnit(*tar);
|
||||||
|
|
||||||
//only buff targets that are in combat, unless the spell can only be cast while out of combat
|
//only buff targets that are in combat, unless the spell can only be cast while out of combat
|
||||||
if (!Target)
|
if (!Target)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ ReactorAI::AttackStart(Unit *p)
|
||||||
if(m_creature->Attack(p,true))
|
if(m_creature->Attack(p,true))
|
||||||
{
|
{
|
||||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId());
|
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId());
|
||||||
i_victimGuid = p->GetGUID();
|
i_victimGuid = p->GetObjectGuid();
|
||||||
m_creature->AddThreat(p);
|
m_creature->AddThreat(p);
|
||||||
|
|
||||||
m_creature->SetInCombatWith(p);
|
m_creature->SetInCombatWith(p);
|
||||||
|
|
@ -71,7 +71,7 @@ ReactorAI::UpdateAI(const uint32 /*time_diff*/)
|
||||||
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
|
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i_victimGuid = m_creature->getVictim()->GetGUID();
|
i_victimGuid = m_creature->getVictim()->GetObjectGuid();
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
DoMeleeAttackIfReady();
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +84,7 @@ ReactorAI::EnterEvadeMode()
|
||||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow());
|
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow());
|
||||||
m_creature->GetMotionMaster()->MovementExpired();
|
m_creature->GetMotionMaster()->MovementExpired();
|
||||||
m_creature->GetMotionMaster()->MoveIdle();
|
m_creature->GetMotionMaster()->MoveIdle();
|
||||||
i_victimGuid = 0;
|
i_victimGuid.Clear();
|
||||||
m_creature->CombatStop(true);
|
m_creature->CombatStop(true);
|
||||||
m_creature->DeleteThreatList();
|
m_creature->DeleteThreatList();
|
||||||
return;
|
return;
|
||||||
|
|
@ -111,7 +111,7 @@ ReactorAI::EnterEvadeMode()
|
||||||
|
|
||||||
m_creature->RemoveAllAuras();
|
m_creature->RemoveAllAuras();
|
||||||
m_creature->DeleteThreatList();
|
m_creature->DeleteThreatList();
|
||||||
i_victimGuid = 0;
|
i_victimGuid.Clear();
|
||||||
m_creature->CombatStop(true);
|
m_creature->CombatStop(true);
|
||||||
m_creature->SetLootRecipient(NULL);
|
m_creature->SetLootRecipient(NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#define MANGOS_REACTORAI_H
|
#define MANGOS_REACTORAI_H
|
||||||
|
|
||||||
#include "CreatureAI.h"
|
#include "CreatureAI.h"
|
||||||
|
#include "ObjectGuid.h"
|
||||||
|
|
||||||
class Unit;
|
class Unit;
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ class MANGOS_DLL_DECL ReactorAI : public CreatureAI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit ReactorAI(Creature *c) : CreatureAI(c), i_victimGuid(0) {}
|
explicit ReactorAI(Creature *c) : CreatureAI(c) {}
|
||||||
|
|
||||||
void MoveInLineOfSight(Unit *);
|
void MoveInLineOfSight(Unit *);
|
||||||
void AttackStart(Unit *);
|
void AttackStart(Unit *);
|
||||||
|
|
@ -38,6 +39,6 @@ class MANGOS_DLL_DECL ReactorAI : public CreatureAI
|
||||||
static int Permissible(const Creature *);
|
static int Permissible(const Creature *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64 i_victimGuid;
|
ObjectGuid i_victimGuid;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ TotemAI::Permissible(const Creature *creature)
|
||||||
return PERMIT_BASE_NO;
|
return PERMIT_BASE_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
TotemAI::TotemAI(Creature *c) : CreatureAI(c), i_victimGuid(0)
|
TotemAI::TotemAI(Creature *c) : CreatureAI(c)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/)
|
||||||
// SPELLMOD_RANGE not applied in this place just because nonexistent range mods for attacking totems
|
// SPELLMOD_RANGE not applied in this place just because nonexistent range mods for attacking totems
|
||||||
|
|
||||||
// pointer to appropriate target if found any
|
// pointer to appropriate target if found any
|
||||||
Unit* victim = i_victimGuid ? m_creature->GetMap()->GetUnit(i_victimGuid) : NULL;
|
Unit* victim = m_creature->GetMap()->GetUnit(i_victimGuid);
|
||||||
|
|
||||||
// Search victim if no, not attackable, or out of range, or friendly (possible in case duel end)
|
// Search victim if no, not attackable, or out of range, or friendly (possible in case duel end)
|
||||||
if( !victim ||
|
if( !victim ||
|
||||||
|
|
@ -88,14 +88,14 @@ TotemAI::UpdateAI(const uint32 /*diff*/)
|
||||||
if (victim)
|
if (victim)
|
||||||
{
|
{
|
||||||
// remember
|
// remember
|
||||||
i_victimGuid = victim->GetGUID();
|
i_victimGuid = victim->GetObjectGuid();
|
||||||
|
|
||||||
// attack
|
// attack
|
||||||
m_creature->SetInFront(victim); // client change orientation by self
|
m_creature->SetInFront(victim); // client change orientation by self
|
||||||
m_creature->CastSpell(victim, getTotem().GetSpell(), false);
|
m_creature->CastSpell(victim, getTotem().GetSpell(), false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
i_victimGuid = 0;
|
i_victimGuid.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#define MANGOS_TOTEMAI_H
|
#define MANGOS_TOTEMAI_H
|
||||||
|
|
||||||
#include "CreatureAI.h"
|
#include "CreatureAI.h"
|
||||||
|
#include "ObjectGuid.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
|
||||||
class Creature;
|
class Creature;
|
||||||
|
|
@ -42,6 +43,6 @@ class MANGOS_DLL_DECL TotemAI : public CreatureAI
|
||||||
Totem& getTotem();
|
Totem& getTotem();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64 i_victimGuid;
|
ObjectGuid i_victimGuid;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11459"
|
#define REVISION_NR "11460"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue