2009-02-04 12:04:12 +01:00
|
|
|
/* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
|
2008-10-14 11:57:03 -05:00
|
|
|
*
|
|
|
|
|
* Thanks to the original authors: ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
|
|
|
|
|
*
|
2008-10-02 16:23:55 -05:00
|
|
|
* This program is free software licensed under GPL version 2
|
|
|
|
|
* Please see the included DOCS/LICENSE.TXT for more information */
|
|
|
|
|
|
|
|
|
|
#ifndef SC_CREATURE_H
|
|
|
|
|
#define SC_CREATURE_H
|
|
|
|
|
|
|
|
|
|
#include "Creature.h"
|
2009-05-10 16:07:49 -05:00
|
|
|
#include "CreatureAI.h"
|
|
|
|
|
#include "CreatureAIImpl.h"
|
2009-05-17 16:37:03 -05:00
|
|
|
#include "InstanceData.h"
|
2009-01-17 17:46:28 -06:00
|
|
|
|
2009-05-10 22:48:22 -05:00
|
|
|
class ScriptedInstance;
|
|
|
|
|
|
2009-04-22 23:03:49 -05:00
|
|
|
class SummonList : private std::list<uint64>
|
2008-11-03 10:16:06 -06:00
|
|
|
{
|
2009-05-10 16:07:49 -05:00
|
|
|
public:
|
|
|
|
|
explicit SummonList(Creature* creature) : m_creature(creature) {}
|
|
|
|
|
void Summon(Creature *summon) { push_back(summon->GetGUID()); }
|
|
|
|
|
void Despawn(Creature *summon) { remove(summon->GetGUID()); }
|
|
|
|
|
void DespawnEntry(uint32 entry);
|
|
|
|
|
void DespawnAll();
|
|
|
|
|
void DoAction(uint32 entry, uint32 info);
|
2009-05-13 10:54:11 -05:00
|
|
|
void DoZoneInCombat(uint32 entry = 0);
|
2009-05-10 16:07:49 -05:00
|
|
|
private:
|
|
|
|
|
Creature *m_creature;
|
2008-11-03 10:16:06 -06:00
|
|
|
};
|
|
|
|
|
|
2009-03-22 23:11:55 +01:00
|
|
|
struct PointMovement
|
|
|
|
|
{
|
|
|
|
|
uint32 m_uiCreatureEntry;
|
|
|
|
|
uint32 m_uiPointId;
|
|
|
|
|
float m_fX;
|
|
|
|
|
float m_fY;
|
|
|
|
|
float m_fZ;
|
|
|
|
|
uint32 m_uiWaitTime;
|
|
|
|
|
};
|
|
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-04-29 00:15:18 -05:00
|
|
|
explicit ScriptedAI(Creature* creature);
|
2008-10-02 16:23:55 -05:00
|
|
|
~ScriptedAI() {}
|
|
|
|
|
|
|
|
|
|
//*************
|
|
|
|
|
//CreatureAI Functions
|
|
|
|
|
//*************
|
|
|
|
|
|
2009-05-17 16:37:03 -05:00
|
|
|
void AttackStartNoMove(Unit *target);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
// Called at any Damage from any attacker (before damage apply)
|
|
|
|
|
void DamageTaken(Unit *done_by, uint32 &damage) {}
|
|
|
|
|
|
|
|
|
|
//Called at World update tick
|
|
|
|
|
void UpdateAI(const uint32);
|
|
|
|
|
|
|
|
|
|
//Called at creature death
|
|
|
|
|
void JustDied(Unit*){}
|
|
|
|
|
|
|
|
|
|
//Called at creature killing another unit
|
|
|
|
|
void KilledUnit(Unit*){}
|
|
|
|
|
|
|
|
|
|
// Called when the creature summon successfully other creature
|
|
|
|
|
void JustSummoned(Creature* ) {}
|
|
|
|
|
|
|
|
|
|
// Called when a summoned creature is despawned
|
|
|
|
|
void SummonedCreatureDespawn(Creature* /*unit*/) {}
|
|
|
|
|
|
|
|
|
|
// Called when hit by a spell
|
2008-10-18 11:50:02 -05:00
|
|
|
void SpellHit(Unit* caster, const SpellEntry*) {}
|
|
|
|
|
|
|
|
|
|
// Called when spell hits a target
|
|
|
|
|
void SpellHitTarget(Unit* target, const SpellEntry*) {}
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Called at waypoint reached or PointMovement end
|
2009-05-09 10:50:41 -05:00
|
|
|
void MovementInform(uint32 type, uint32 id){}
|
2008-10-02 16:23:55 -05:00
|
|
|
|
2008-11-05 20:51:05 -06:00
|
|
|
// Called when AI is temporarily replaced or put back when possess is applied or removed
|
|
|
|
|
void OnPossess(bool apply) {}
|
|
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
//*************
|
|
|
|
|
// Variables
|
|
|
|
|
//*************
|
|
|
|
|
|
|
|
|
|
//Pointer to creature we are manipulating
|
|
|
|
|
Creature* m_creature;
|
|
|
|
|
|
2008-10-05 12:10:02 -05:00
|
|
|
//For fleeing
|
|
|
|
|
bool IsFleeing;
|
|
|
|
|
|
2009-04-29 00:15:18 -05:00
|
|
|
bool HeroicMode;
|
|
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
//*************
|
|
|
|
|
//Pure virtual functions
|
|
|
|
|
//*************
|
|
|
|
|
|
|
|
|
|
//Called at creature reset either by death or evade
|
2009-04-13 17:53:09 -05:00
|
|
|
void Reset() {}
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Called at creature aggro either by MoveInLOS or Attack Start
|
2009-04-27 23:09:27 -05:00
|
|
|
void EnterCombat(Unit*) {}
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//*************
|
|
|
|
|
//AI Helper Functions
|
|
|
|
|
//*************
|
|
|
|
|
|
2008-10-25 11:40:10 -05:00
|
|
|
//Start movement toward victim
|
|
|
|
|
void DoStartMovement(Unit* victim, float distance = 0, float angle = 0);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
2008-10-25 11:40:10 -05:00
|
|
|
//Start no movement on victim
|
|
|
|
|
void DoStartNoMovement(Unit* victim);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Stop attack of current victim
|
|
|
|
|
void DoStopAttack();
|
|
|
|
|
|
|
|
|
|
//Cast spell by spell info
|
|
|
|
|
void DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered = false);
|
|
|
|
|
|
|
|
|
|
//Creature say
|
2008-12-27 21:27:41 +01:00
|
|
|
void DoSay(const char* text, uint32 language, Unit* target, bool SayEmote = false);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Creature Yell
|
|
|
|
|
void DoYell(const char* text, uint32 language, Unit* target);
|
|
|
|
|
|
|
|
|
|
//Creature Text emote, optional bool for boss emote text
|
|
|
|
|
void DoTextEmote(const char* text, Unit* target, bool IsBossEmote = false);
|
|
|
|
|
|
|
|
|
|
//Creature whisper, optional bool for boss whisper
|
|
|
|
|
void DoWhisper(const char* text, Unit* reciever, bool IsBossWhisper = false);
|
|
|
|
|
|
|
|
|
|
//Plays a sound to all nearby players
|
|
|
|
|
void DoPlaySoundToSet(Unit* unit, uint32 sound);
|
|
|
|
|
|
|
|
|
|
//Drops all threat to 0%. Does not remove players from the threat list
|
|
|
|
|
void DoResetThreat();
|
|
|
|
|
|
2009-01-09 12:06:08 -06:00
|
|
|
float DoGetThreat(Unit *u);
|
|
|
|
|
void DoModifyThreatPercent(Unit *pUnit, int32 pct);
|
|
|
|
|
|
2009-02-23 13:14:04 -06:00
|
|
|
void DoTeleportTo(float x, float y, float z, uint32 time = 0);
|
2009-05-13 10:54:11 -05:00
|
|
|
void DoTeleportTo(const float pos[4]);
|
2009-02-23 13:14:04 -06:00
|
|
|
|
2009-03-31 18:12:49 -06:00
|
|
|
void DoAction(const int32 param) {}
|
|
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
//Teleports a player without dropping threat (only teleports to same map)
|
|
|
|
|
void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o);
|
2008-11-18 19:40:06 -06:00
|
|
|
void DoTeleportAll(float x, float y, float z, float o);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Returns friendly unit with the most amount of hp missing from max hp
|
|
|
|
|
Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff = 1);
|
|
|
|
|
|
|
|
|
|
//Returns a list of friendly CC'd units within range
|
|
|
|
|
std::list<Creature*> DoFindFriendlyCC(float range);
|
|
|
|
|
|
|
|
|
|
//Returns a list of all friendly units missing a specific buff within range
|
|
|
|
|
std::list<Creature*> DoFindFriendlyMissingBuff(float range, uint32 spellid);
|
|
|
|
|
|
|
|
|
|
//Spawns a creature relative to m_creature
|
|
|
|
|
Creature* DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime);
|
2009-05-13 10:54:11 -05:00
|
|
|
Creature *DoSummon(uint32 entry, const float pos[4], uint32 despawntime = 30000, TempSummonType type = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
|
|
|
|
Creature *DoSummon(uint32 entry, WorldObject *obj, float radius = 5.0f, uint32 despawntime = 30000, TempSummonType type = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Selects a unit from the creature's current aggro list
|
|
|
|
|
Unit* SelectUnit(SelectAggroTarget target, uint32 position);
|
|
|
|
|
|
2009-04-29 00:15:18 -05:00
|
|
|
bool HealthBelowPct(uint32 pct) const { return me->GetHealth() * 100 < m_creature->GetMaxHealth() * pct; }
|
|
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
//Returns spells that meet the specified criteria from the creatures spell list
|
2009-05-10 14:29:28 -05:00
|
|
|
SpellEntry const* SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTargetType Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effect);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Checks if you can cast the specified spell
|
|
|
|
|
bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered = false);
|
2009-04-19 21:16:11 +02:00
|
|
|
|
|
|
|
|
void SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand = EQUIP_NO_CHANGE, int32 uiOffHand = EQUIP_NO_CHANGE, int32 uiRanged = EQUIP_NO_CHANGE);
|
|
|
|
|
|
|
|
|
|
void SetSheathState(SheathState newState);
|
2009-05-19 21:03:43 +02:00
|
|
|
|
|
|
|
|
void SetCombatMovement(bool CombatMove);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool CombatMovement;
|
2008-10-02 16:23:55 -05:00
|
|
|
};
|
|
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
struct TRINITY_DLL_DECL Scripted_NoMovementAI : public ScriptedAI
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
Scripted_NoMovementAI(Creature* creature) : ScriptedAI(creature) {}
|
|
|
|
|
|
|
|
|
|
//Called if IsVisible(Unit *who) is true at each *who move
|
2008-11-27 15:19:06 -06:00
|
|
|
//void MoveInLineOfSight(Unit *);
|
2008-10-02 16:23:55 -05:00
|
|
|
|
|
|
|
|
//Called at each attack of m_creature by any victim
|
|
|
|
|
void AttackStart(Unit *);
|
|
|
|
|
};
|
2008-11-09 14:54:13 -06:00
|
|
|
|
2009-05-10 22:48:22 -05:00
|
|
|
struct TRINITY_DLL_DECL BossAI : public ScriptedAI
|
|
|
|
|
{
|
2009-05-17 16:37:03 -05:00
|
|
|
BossAI(Creature *c, uint32 id);
|
2009-05-10 22:48:22 -05:00
|
|
|
|
2009-05-17 16:37:03 -05:00
|
|
|
const uint32 bossId;
|
2009-05-10 22:48:22 -05:00
|
|
|
EventMap events;
|
|
|
|
|
SummonList summons;
|
2009-05-17 16:37:03 -05:00
|
|
|
InstanceData * const instance;
|
|
|
|
|
const BossBoundaryMap * const boundary;
|
2009-05-10 22:48:22 -05:00
|
|
|
|
|
|
|
|
void JustSummoned(Creature *summon);
|
|
|
|
|
void SummonedCreatureDespawn(Creature *summon);
|
|
|
|
|
|
|
|
|
|
void UpdateAI(const uint32 diff) = 0;
|
|
|
|
|
|
|
|
|
|
void Reset() { _Reset(); }
|
|
|
|
|
void EnterCombat(Unit *who) { _EnterCombat(); }
|
|
|
|
|
void JustDied(Unit *killer) { _JustDied(); }
|
2009-05-27 23:26:08 -05:00
|
|
|
void JustReachedHome() { me->setActive(false); }
|
2009-05-17 16:37:03 -05:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void _Reset();
|
|
|
|
|
void _EnterCombat();
|
|
|
|
|
void _JustDied();
|
2009-05-27 23:26:08 -05:00
|
|
|
void _JustReachedHome() { me->setActive(false); }
|
2009-05-17 16:37:03 -05:00
|
|
|
|
|
|
|
|
bool CheckInRoom()
|
|
|
|
|
{
|
|
|
|
|
if(CheckBoundary(me))
|
|
|
|
|
return true;
|
|
|
|
|
EnterEvadeMode();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool CheckBoundary(Unit *who);
|
2009-05-26 19:55:41 -05:00
|
|
|
void TeleportCheaters();
|
2009-05-10 22:48:22 -05:00
|
|
|
};
|
|
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#endif
|
2009-02-17 20:07:49 -06:00
|
|
|
|