*Update creature AI functions.
--HG-- branch : trunk
This commit is contained in:
@@ -12,10 +12,11 @@
|
|||||||
#include "GridNotifiersImpl.h"
|
#include "GridNotifiersImpl.h"
|
||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
#include "TemporarySummon.h"
|
|
||||||
#include "sc_creature.h"
|
#include "sc_creature.h"
|
||||||
#include "sc_gossip.h"
|
#include "sc_gossip.h"
|
||||||
#include "sc_instance.h"
|
#include "sc_instance.h"
|
||||||
|
#include "AggressorAI.h"
|
||||||
|
#include "NullCreatureAI.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
#include "Spell.h"
|
#include "Spell.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "TemporarySummon.h"
|
||||||
|
|
||||||
// Spell summary for ScriptedAI::SelectSpell
|
// Spell summary for ScriptedAI::SelectSpell
|
||||||
struct TSpellSummary {
|
struct TSpellSummary {
|
||||||
@@ -56,6 +57,9 @@ void SummonList::DespawnAll()
|
|||||||
{
|
{
|
||||||
erase(begin());
|
erase(begin());
|
||||||
summon->SetVisibility(VISIBILITY_OFF);
|
summon->SetVisibility(VISIBILITY_OFF);
|
||||||
|
if(summon->HasSummonMask(SUMMON_MASK_SUMMON) && !summon->isPet())
|
||||||
|
((TempSummon*)summon)->UnSummon();
|
||||||
|
else
|
||||||
summon->setDeathState(JUST_DIED);
|
summon->setDeathState(JUST_DIED);
|
||||||
summon->RemoveCorpse();
|
summon->RemoveCorpse();
|
||||||
}
|
}
|
||||||
@@ -109,26 +113,6 @@ void ScriptedAI::UpdateAI(const uint32 diff)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptedAI::EnterEvadeMode()
|
|
||||||
{
|
|
||||||
//m_creature->InterruptNonMeleeSpells(true);
|
|
||||||
m_creature->RemoveAllAuras();
|
|
||||||
m_creature->DeleteThreatList();
|
|
||||||
m_creature->CombatStop();
|
|
||||||
m_creature->LoadCreaturesAddon();
|
|
||||||
m_creature->SetLootRecipient(NULL);
|
|
||||||
|
|
||||||
if(m_creature->isAlive())
|
|
||||||
m_creature->GetMotionMaster()->MoveTargetedHome();
|
|
||||||
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptedAI::JustRespawned()
|
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle)
|
void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle)
|
||||||
{
|
{
|
||||||
if (!victim)
|
if (!victim)
|
||||||
|
|||||||
@@ -58,9 +58,6 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
|||||||
void AttackStart(Unit *);
|
void AttackStart(Unit *);
|
||||||
void AttackStart(Unit *, bool melee);
|
void AttackStart(Unit *, bool melee);
|
||||||
|
|
||||||
//Called at stoping attack by any attacker
|
|
||||||
void EnterEvadeMode();
|
|
||||||
|
|
||||||
// Called at any Damage from any attacker (before damage apply)
|
// Called at any Damage from any attacker (before damage apply)
|
||||||
void DamageTaken(Unit *done_by, uint32 &damage) {}
|
void DamageTaken(Unit *done_by, uint32 &damage) {}
|
||||||
|
|
||||||
@@ -85,9 +82,6 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
|||||||
// Called when spell hits a target
|
// Called when spell hits a target
|
||||||
void SpellHitTarget(Unit* target, const SpellEntry*) {}
|
void SpellHitTarget(Unit* target, const SpellEntry*) {}
|
||||||
|
|
||||||
// Called when creature is spawned or respawned (for reseting variables)
|
|
||||||
void JustRespawned();
|
|
||||||
|
|
||||||
//Called at waypoint reached or PointMovement end
|
//Called at waypoint reached or PointMovement end
|
||||||
void MovementInform(uint32 type, uint32 id){}
|
void MovementInform(uint32 type, uint32 id){}
|
||||||
|
|
||||||
@@ -204,20 +198,6 @@ struct TRINITY_DLL_DECL Scripted_NoMovementAI : public ScriptedAI
|
|||||||
void AttackStart(Unit *);
|
void AttackStart(Unit *);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TRINITY_DLL_DECL NullCreatureAI : public ScriptedAI
|
|
||||||
{
|
|
||||||
NullCreatureAI(Creature* c) : ScriptedAI(c) {}
|
|
||||||
~NullCreatureAI() {}
|
|
||||||
|
|
||||||
void Reset() {}
|
|
||||||
void EnterCombat(Unit*) {}
|
|
||||||
void MoveInLineOfSight(Unit *) {}
|
|
||||||
void AttackStart(Unit *) {}
|
|
||||||
void EnterEvadeMode() {}
|
|
||||||
|
|
||||||
void UpdateAI(const uint32) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TRINITY_DLL_DECL BossAI : public ScriptedAI
|
struct TRINITY_DLL_DECL BossAI : public ScriptedAI
|
||||||
{
|
{
|
||||||
BossAI(Creature *c, uint32 id) : ScriptedAI(c), bossId(id)
|
BossAI(Creature *c, uint32 id) : ScriptedAI(c), bossId(id)
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ EndScriptData */
|
|||||||
|
|
||||||
struct TRINITY_DLL_DECL molten_flameAI : public NullCreatureAI
|
struct TRINITY_DLL_DECL molten_flameAI : public NullCreatureAI
|
||||||
{
|
{
|
||||||
molten_flameAI(Creature *c) : NullCreatureAI(c)
|
molten_flameAI(Creature *c) : NullCreatureAI(c) {}
|
||||||
|
|
||||||
|
void InitializeAI()
|
||||||
{
|
{
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
me->GetNearPoint(me, x, y, z, 1, 50, M_PI*2*rand_norm());
|
me->GetNearPoint(me, x, y, z, 1, 50, M_PI*2*rand_norm());
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class TRINITY_DLL_DECL AggressorAI : public CreatureAI
|
|||||||
|
|
||||||
typedef std::vector<uint32> SpellVct;
|
typedef std::vector<uint32> SpellVct;
|
||||||
|
|
||||||
class TRINITY_DLL_DECL SpellAI : public CreatureAI
|
class TRINITY_DLL_SPEC SpellAI : public CreatureAI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SpellAI(Creature *c) : CreatureAI(c) {}
|
explicit SpellAI(Creature *c) : CreatureAI(c) {}
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ void CreatureAI::EnterEvadeMode()
|
|||||||
|
|
||||||
if(me->isAlive())
|
if(me->isAlive())
|
||||||
me->GetMotionMaster()->MoveTargetedHome();
|
me->GetMotionMaster()->MoveTargetedHome();
|
||||||
|
|
||||||
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SelectTargetHelper(const Unit * me, const Unit * target, const bool &playerOnly, const float &dist, const int32 &aura)
|
inline bool SelectTargetHelper(const Unit * me, const Unit * target, const bool &playerOnly, const float &dist, const int32 &aura)
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
|
|||||||
//virtual void AttackedBy(Unit* attacker);
|
//virtual void AttackedBy(Unit* attacker);
|
||||||
|
|
||||||
// Called when creature is spawned or respawned (for reseting variables)
|
// Called when creature is spawned or respawned (for reseting variables)
|
||||||
virtual void JustRespawned() {}
|
virtual void JustRespawned() { Reset(); }
|
||||||
|
|
||||||
// Called at waypoint reached or point movement finished
|
// Called at waypoint reached or point movement finished
|
||||||
virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
|
virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
|
||||||
|
|||||||
@@ -28,35 +28,41 @@ class TRINITY_DLL_DECL PassiveAI : public CreatureAI
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PassiveAI(Creature *c) : CreatureAI(c) {}
|
explicit PassiveAI(Creature *c) : CreatureAI(c) {}
|
||||||
~PassiveAI() {}
|
|
||||||
|
|
||||||
void MoveInLineOfSight(Unit *) {}
|
void MoveInLineOfSight(Unit *) {}
|
||||||
void AttackStart(Unit *) {}
|
void AttackStart(Unit *) {}
|
||||||
|
|
||||||
void UpdateAI(const uint32);
|
void UpdateAI(const uint32);
|
||||||
|
|
||||||
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
|
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TRINITY_DLL_DECL PossessedAI : public PassiveAI
|
class TRINITY_DLL_DECL PossessedAI : public CreatureAI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PossessedAI(Creature *c) : PassiveAI(c) {}
|
explicit PossessedAI(Creature *c) : CreatureAI(c) {}
|
||||||
|
|
||||||
|
void MoveInLineOfSight(Unit *) {}
|
||||||
void AttackStart(Unit *target);
|
void AttackStart(Unit *target);
|
||||||
void UpdateAI(const uint32);
|
void UpdateAI(const uint32);
|
||||||
void EnterEvadeMode() {}
|
void EnterEvadeMode() {}
|
||||||
|
|
||||||
void JustDied(Unit*);
|
void JustDied(Unit*);
|
||||||
void KilledUnit(Unit* victim);
|
void KilledUnit(Unit* victim);
|
||||||
|
|
||||||
|
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TRINITY_DLL_DECL NullCreatureAI : public PassiveAI
|
class TRINITY_DLL_DECL NullCreatureAI : public CreatureAI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit NullCreatureAI(Creature *c) : PassiveAI(c) {}
|
explicit NullCreatureAI(Creature *c) : CreatureAI(c) {}
|
||||||
|
|
||||||
|
void MoveInLineOfSight(Unit *) {}
|
||||||
|
void AttackStart(Unit *) {}
|
||||||
void UpdateAI(const uint32) {}
|
void UpdateAI(const uint32) {}
|
||||||
void EnterEvadeMode() {}
|
void EnterEvadeMode() {}
|
||||||
|
|
||||||
|
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TRINITY_DLL_DECL CritterAI : public PassiveAI
|
class TRINITY_DLL_DECL CritterAI : public PassiveAI
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "Creature.h"
|
#include "Creature.h"
|
||||||
|
|
||||||
class TempSummon : public Creature
|
class TRINITY_DLL_SPEC TempSummon : public Creature
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TempSummon(SummonPropertiesEntry const *properties, Unit *owner);
|
explicit TempSummon(SummonPropertiesEntry const *properties, Unit *owner);
|
||||||
|
|||||||
Reference in New Issue
Block a user