[9290] Some cleanups in realmd, no functional changes
[getmangos.git] / src / game / Creature.h
blob931ea285e926b6ed3e42b872e511a00ad06ad6ad
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOSSERVER_CREATURE_H
20 #define MANGOSSERVER_CREATURE_H
22 #include "Common.h"
23 #include "Unit.h"
24 #include "UpdateMask.h"
25 #include "ItemPrototype.h"
26 #include "LootMgr.h"
27 #include "Database/DatabaseEnv.h"
28 #include "Cell.h"
30 #include <list>
32 struct SpellEntry;
34 class CreatureAI;
35 class Quest;
36 class Player;
37 class WorldSession;
39 enum CreatureFlagsExtra
41 CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group
42 CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility)
43 CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry
44 CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry
45 CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block
46 CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks
47 CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
48 CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures)
49 CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me
52 // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
53 #if defined( __GNUC__ )
54 #pragma pack(1)
55 #else
56 #pragma pack(push,1)
57 #endif
59 #define MAX_KILL_CREDIT 2
61 // from `creature_template` table
62 struct CreatureInfo
64 uint32 Entry;
65 uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
66 uint32 KillCredit[MAX_KILL_CREDIT];
67 uint32 DisplayID_A[2];
68 uint32 DisplayID_H[2];
69 char* Name;
70 char* SubName;
71 char* IconName;
72 uint32 GossipMenuId;
73 uint32 minlevel;
74 uint32 maxlevel;
75 uint32 minhealth;
76 uint32 maxhealth;
77 uint32 minmana;
78 uint32 maxmana;
79 uint32 armor;
80 uint32 faction_A;
81 uint32 faction_H;
82 uint32 npcflag;
83 float speed;
84 float scale;
85 uint32 rank;
86 float mindmg;
87 float maxdmg;
88 uint32 dmgschool;
89 uint32 attackpower;
90 float dmg_multiplier;
91 uint32 baseattacktime;
92 uint32 rangeattacktime;
93 uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures.
94 uint32 unit_flags; // enum UnitFlags mask values
95 uint32 dynamicflags;
96 uint32 family; // enum CreatureFamily values (optional)
97 uint32 trainer_type;
98 uint32 trainer_spell;
99 uint32 trainer_class;
100 uint32 trainer_race;
101 float minrangedmg;
102 float maxrangedmg;
103 uint32 rangedattackpower;
104 uint32 type; // enum CreatureType values
105 uint32 type_flags; // enum CreatureTypeFlags mask values
106 uint32 lootid;
107 uint32 pickpocketLootId;
108 uint32 SkinLootId;
109 int32 resistance1;
110 int32 resistance2;
111 int32 resistance3;
112 int32 resistance4;
113 int32 resistance5;
114 int32 resistance6;
115 uint32 spells[CREATURE_MAX_SPELLS];
116 uint32 PetSpellDataId;
117 uint32 mingold;
118 uint32 maxgold;
119 char const* AIName;
120 uint32 MovementType;
121 uint32 InhabitType;
122 float unk16;
123 float unk17;
124 bool RacialLeader;
125 uint32 questItems[6];
126 uint32 movementId;
127 bool RegenHealth;
128 uint32 equipmentId;
129 uint32 MechanicImmuneMask;
130 uint32 flags_extra;
131 uint32 ScriptID;
133 // helpers
134 SkillType GetRequiredLootSkill() const
136 if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
137 return SKILL_HERBALISM;
138 else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
139 return SKILL_MINING;
140 else if(type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
141 return SKILL_ENGINERING;
142 else
143 return SKILL_SKINNING; // normal case
146 bool IsExotic() const
148 return (type_flags & CREATURE_TYPEFLAGS_EXOTIC);
151 bool isTameable(bool exotic) const
153 if(type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
154 return false;
156 // if can tame exotic then can tame any temable
157 return exotic || !IsExotic();
161 struct CreatureLocale
163 std::vector<std::string> Name;
164 std::vector<std::string> SubName;
167 struct GossipMenuItemsLocale
169 std::vector<std::string> OptionText;
170 std::vector<std::string> BoxText;
173 struct PointOfInterestLocale
175 std::vector<std::string> IconName;
178 struct EquipmentInfo
180 uint32 entry;
181 uint32 equipentry[3];
184 // from `creature` table
185 struct CreatureData
187 uint32 id; // entry in creature_template
188 uint16 mapid;
189 uint16 phaseMask;
190 uint32 displayid;
191 int32 equipmentId;
192 float posX;
193 float posY;
194 float posZ;
195 float orientation;
196 uint32 spawntimesecs;
197 float spawndist;
198 uint32 currentwaypoint;
199 uint32 curhealth;
200 uint32 curmana;
201 bool is_dead;
202 uint8 movementType;
203 uint8 spawnMask;
206 struct CreatureDataAddonAura
208 uint32 spell_id;
209 uint8 effect_idx;
212 // from `creature_addon` table
213 struct CreatureDataAddon
215 uint32 guidOrEntry;
216 uint32 mount;
217 uint32 bytes1;
218 uint32 bytes2;
219 uint32 emote;
220 uint32 move_flags;
221 CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
224 struct CreatureModelInfo
226 uint32 modelid;
227 float bounding_radius;
228 float combat_reach;
229 uint8 gender;
230 uint32 modelid_other_gender;
233 enum InhabitTypeValues
235 INHABIT_GROUND = 1,
236 INHABIT_WATER = 2,
237 INHABIT_AIR = 4,
238 INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR
241 // Enums used by StringTextData::Type (CreatureEventAI)
242 enum ChatType
244 CHAT_TYPE_SAY = 0,
245 CHAT_TYPE_YELL = 1,
246 CHAT_TYPE_TEXT_EMOTE = 2,
247 CHAT_TYPE_BOSS_EMOTE = 3,
248 CHAT_TYPE_WHISPER = 4,
249 CHAT_TYPE_BOSS_WHISPER = 5,
250 CHAT_TYPE_ZONE_YELL = 6
253 //Selection method used by SelectTarget (CreatureEventAI)
254 enum AttackingTarget
256 ATTACKING_TARGET_RANDOM = 0, //Just selects a random target
257 ATTACKING_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom
258 ATTACKING_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top
259 /* not implemented
260 ATTACKING_TARGET_RANDOM_PLAYER, //Just selects a random target (player only)
261 ATTACKING_TARGET_TOPAGGRO_PLAYER, //Selects targes from top aggro to bottom (player only)
262 ATTACKING_TARGET_BOTTOMAGGRO_PLAYER, //Selects targets from bottom aggro to top (player only)
266 // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
267 #if defined( __GNUC__ )
268 #pragma pack()
269 #else
270 #pragma pack(pop)
271 #endif
273 // Vendors
274 struct VendorItem
276 VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
277 : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
279 uint32 item;
280 uint32 maxcount; // 0 for infinity item amount
281 uint32 incrtime; // time for restore items amount if maxcount != 0
282 uint32 ExtendedCost;
284 typedef std::vector<VendorItem*> VendorItemList;
286 struct VendorItemData
288 VendorItemList m_items;
290 VendorItem* GetItem(uint32 slot) const
292 if(slot>=m_items.size()) return NULL;
293 return m_items[slot];
295 bool Empty() const { return m_items.empty(); }
296 uint8 GetItemCount() const { return m_items.size(); }
297 void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
299 m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
301 bool RemoveItem( uint32 item_id );
302 VendorItem const* FindItem(uint32 item_id) const;
303 size_t FindItemSlot(uint32 item_id) const;
305 void Clear()
307 for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
308 delete (*itr);
309 m_items.clear();
313 struct VendorItemCount
315 explicit VendorItemCount(uint32 _item, uint32 _count)
316 : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
318 uint32 itemId;
319 uint32 count;
320 time_t lastIncrementTime;
323 typedef std::list<VendorItemCount> VendorItemCounts;
325 struct TrainerSpell
327 TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0), learnedSpell(0) {}
329 TrainerSpell(uint32 _spell, uint32 _spellCost, uint32 _reqSkill, uint32 _reqSkillValue, uint32 _reqLevel, uint32 _learnedspell)
330 : spell(_spell), spellCost(_spellCost), reqSkill(_reqSkill), reqSkillValue(_reqSkillValue), reqLevel(_reqLevel), learnedSpell(_learnedspell)
333 uint32 spell;
334 uint32 spellCost;
335 uint32 reqSkill;
336 uint32 reqSkillValue;
337 uint32 reqLevel;
338 uint32 learnedSpell;
340 // helpers
341 bool IsCastable() const { return learnedSpell != spell; }
344 typedef UNORDERED_MAP<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap;
346 struct TrainerSpellData
348 TrainerSpellData() : trainerType(0) {}
350 TrainerSpellMap spellList;
351 uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
352 // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
353 TrainerSpell const* Find(uint32 spell_id) const;
354 void Clear() { spellList.clear(); }
357 typedef std::map<uint32,time_t> CreatureSpellCooldowns;
359 // max different by z coordinate for creature aggro reaction
360 #define CREATURE_Z_ATTACK_RANGE 3
362 #define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY
364 enum CreatureSubtype
366 CREATURE_SUBTYPE_GENERIC, // new Creature
367 CREATURE_SUBTYPE_PET, // new Pet
368 CREATURE_SUBTYPE_TOTEM, // new Totem
369 CREATURE_SUBTYPE_VEHICLE, // new Vehicle
370 CREATURE_SUBTYPE_TEMPORARY_SUMMON, // new TemporarySummon
373 class MANGOS_DLL_SPEC Creature : public Unit
375 CreatureAI *i_AI;
377 public:
379 explicit Creature(CreatureSubtype subtype = CREATURE_SUBTYPE_GENERIC);
380 virtual ~Creature();
382 void AddToWorld();
383 void RemoveFromWorld();
385 bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL);
386 bool LoadCreaturesAddon(bool reload = false);
387 void SelectLevel(const CreatureInfo *cinfo);
388 void LoadEquipment(uint32 equip_entry, bool force=false);
390 uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
391 char const* GetSubName() const { return GetCreatureInfo()->SubName; }
393 void Update( uint32 time ); // overwrited Unit::Update
394 void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
395 uint32 GetEquipmentId() const { return m_equipmentId; }
397 CreatureSubtype GetSubtype() const { return m_subtype; }
398 bool isPet() const { return m_subtype == CREATURE_SUBTYPE_PET; }
399 bool isVehicle() const { return m_subtype == CREATURE_SUBTYPE_VEHICLE; }
400 bool isTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; }
401 bool isTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; }
403 void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
404 bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
405 bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
406 bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
407 bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
408 bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
409 ///// TODO RENAME THIS!!!!!
410 bool isCanTrainingOf(Player* player, bool msg) const;
411 bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
412 bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
413 bool IsOutOfThreatArea(Unit* pVictim) const;
414 bool IsImmunedToSpell(SpellEntry const* spellInfo);
415 // redefine Unit::IsImmunedToSpell
416 bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
417 // redefine Unit::IsImmunedToSpellEffect
418 bool isElite() const
420 if(isPet())
421 return false;
423 uint32 rank = GetCreatureInfo()->rank;
424 return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
427 bool isWorldBoss() const
429 if(isPet())
430 return false;
432 return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
435 uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
437 bool IsInEvadeMode() const;
439 bool AIM_Initialize();
441 void AI_SendMoveToPacket(float x, float y, float z, uint32 time, MonsterMovementFlags MovementFlags, uint8 type);
442 CreatureAI* AI() { return i_AI; }
444 void AddMonsterMoveFlag(MonsterMovementFlags f)
446 bool need_walk_sync = (f & MONSTER_MOVE_WALK) != (m_monsterMoveFlags & MONSTER_MOVE_WALK);
447 m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags | f);
448 if (need_walk_sync)
449 UpdateWalkMode(this,false);
451 void RemoveMonsterMoveFlag(MonsterMovementFlags f)
453 bool need_walk_sync = (f & MONSTER_MOVE_WALK) != (m_monsterMoveFlags & MONSTER_MOVE_WALK);
454 m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags & ~f);
455 if (need_walk_sync)
456 UpdateWalkMode(this,false);
458 bool HasMonsterMoveFlag(MonsterMovementFlags f) const { return m_monsterMoveFlags & f; }
459 MonsterMovementFlags GetMonsterMoveFlags() const { return m_monsterMoveFlags; }
460 void SetMonsterMoveFlags(MonsterMovementFlags f)
462 bool need_walk_sync = (f & MONSTER_MOVE_WALK) != (m_monsterMoveFlags & MONSTER_MOVE_WALK);
463 m_monsterMoveFlags = f; // need set before
464 if (need_walk_sync)
465 UpdateWalkMode(this,false);
468 void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
469 void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
471 uint32 GetShieldBlockValue() const //dunno mob block value
473 return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
476 SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
477 void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
479 void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
480 void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
481 void AddCreatureSpellCooldown(uint32 spellid);
482 bool HasSpellCooldown(uint32 spell_id) const;
483 bool HasCategoryCooldown(uint32 spell_id) const;
485 bool HasSpell(uint32 spellID) const;
487 bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
488 bool UpdateStats(Stats stat);
489 bool UpdateAllStats();
490 void UpdateResistances(uint32 school);
491 void UpdateArmor();
492 void UpdateMaxHealth();
493 void UpdateMaxPower(Powers power);
494 void UpdateAttackPowerAndDamage(bool ranged = false);
495 void UpdateDamagePhysical(WeaponAttackType attType);
496 uint32 GetCurrentEquipmentId() { return m_equipmentId; }
497 float GetSpellDamageMod(int32 Rank);
499 VendorItemData const* GetVendorItems() const;
500 uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
501 uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
503 TrainerSpellData const* GetTrainerSpells() const;
505 CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
506 CreatureDataAddon const* GetCreatureAddon() const;
508 std::string GetAIName() const;
509 std::string GetScriptName() const;
510 uint32 GetScriptId() const;
512 void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
513 void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
514 void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); }
515 void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); }
516 void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
518 // overwrite WorldObject function for proper name localization
519 const char* GetNameForLocaleIdx(int32 locale_idx) const;
521 void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState
522 bool FallGround();
524 bool LoadFromDB(uint32 guid, Map *map);
525 void SaveToDB();
526 // overwrited in Pet
527 virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
528 virtual void DeleteFromDB(); // overwrited in Pet
530 Loot loot;
531 bool lootForPickPocketed;
532 bool lootForBody;
533 Player *GetLootRecipient() const;
534 bool hasLootRecipient() const { return m_lootRecipient!=0; }
536 void SetLootRecipient (Unit* unit);
537 void AllLootRemovedFromCorpse();
539 SpellEntry const *reachWithSpellAttack(Unit *pVictim);
540 SpellEntry const *reachWithSpellCure(Unit *pVictim);
542 uint32 m_spells[CREATURE_MAX_SPELLS];
543 CreatureSpellCooldowns m_CreatureSpellCooldowns;
544 CreatureSpellCooldowns m_CreatureCategoryCooldowns;
545 uint32 m_GlobalCooldown;
547 float GetAttackDistance(Unit const* pl) const;
549 void SendAIReaction(AiReaction reactionType);
551 void DoFleeToGetAssistance();
552 void CallForHelp(float fRadius);
553 void CallAssistance();
554 void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
555 void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
556 bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
557 bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
559 MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
560 void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
562 // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
563 Cell const& GetCurrentCell() const { return m_currentCell; }
564 void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
566 bool IsVisibleInGridForPlayer(Player* pl) const;
568 void RemoveCorpse();
569 bool isDeadByDefault() const { return m_isDeadByDefault; };
571 void ForcedDespawn(uint32 timeMSToDespawn = 0);
573 time_t const& GetRespawnTime() const { return m_respawnTime; }
574 time_t GetRespawnTimeEx() const;
575 void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
576 void Respawn();
577 void SaveRespawnTime();
579 uint32 GetRespawnDelay() const { return m_respawnDelay; }
580 void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
582 float GetRespawnRadius() const { return m_respawnradius; }
583 void SetRespawnRadius(float dist) { m_respawnradius = dist; }
585 uint32 m_groupLootTimer; // (msecs)timer used for group loot
586 uint64 lootingGroupLeaderGUID; // used to find group which is looting corpse
588 void SendZoneUnderAttackMessage(Player* attacker);
590 void SetInCombatWithZone();
592 bool hasQuest(uint32 quest_id) const;
593 bool hasInvolvedQuest(uint32 quest_id) const;
595 GridReference<Creature> &GetGridRef() { return m_gridRef; }
596 bool isRegeneratingHealth() { return m_regenHealth; }
597 virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
598 virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
600 if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
601 return 0;
602 else
603 return m_charmInfo->GetCharmSpell(pos)->GetAction();
606 void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; }
607 void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; }
609 void SetSummonPoint(float fX, float fY, float fZ, float fOrient) { m_summonXpoint = fX; m_summonYpoint = fY; m_summonZpoint = fZ; m_summonOrientation = fOrient; }
610 void GetSummonPoint(float &fX, float &fY, float &fZ, float &fOrient) const { fX = m_summonXpoint; fY = m_summonYpoint; fZ = m_summonZpoint; fOrient = m_summonOrientation; }
612 uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
614 void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; }
616 bool isActiveObject() const { return m_isActiveObject || HasAuraType(SPELL_AURA_BIND_SIGHT) || HasAuraType(SPELL_AURA_FAR_SIGHT); }
617 void SetActiveObjectState(bool on);
619 void SendAreaSpiritHealerQueryOpcode(Player *pl);
621 protected:
622 bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
623 bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
625 // vendor items
626 VendorItemCounts m_vendorItemCounts;
628 void _RealtimeSetCreatureInfo();
630 static float _GetHealthMod(int32 Rank);
631 static float _GetDamageMod(int32 Rank);
633 uint32 m_lootMoney;
634 uint64 m_lootRecipient;
636 /// Timers
637 uint32 m_deathTimer; // (msecs)timer for death or corpse disappearance
638 time_t m_respawnTime; // (secs) time of next respawn
639 uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
640 uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
641 float m_respawnradius;
643 CreatureSubtype m_subtype; // set in Creatures subclasses for fast it detect without dynamic_cast use
644 void RegenerateMana();
645 void RegenerateHealth();
646 MovementGeneratorType m_defaultMovementType;
647 Cell m_currentCell; // store current cell where creature listed
648 uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
649 uint32 m_equipmentId;
651 bool m_AlreadyCallAssistance;
652 bool m_AlreadySearchedAssistance;
653 bool m_regenHealth;
654 bool m_AI_locked;
655 bool m_isDeadByDefault;
657 SpellSchoolMask m_meleeDamageSchoolMask;
658 uint32 m_originalEntry;
660 float CombatStartX;
661 float CombatStartY;
662 float CombatStartZ;
664 float m_summonXpoint;
665 float m_summonYpoint;
666 float m_summonZpoint;
667 float m_summonOrientation;
669 private:
670 GridReference<Creature> m_gridRef;
671 CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from ObjMgr::GetCreatureTemplate(GetEntry())
672 bool m_isActiveObject;
673 MonsterMovementFlags m_monsterMoveFlags;
676 class AssistDelayEvent : public BasicEvent
678 public:
679 AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
681 bool Execute(uint64 e_time, uint32 p_time);
682 void AddAssistant(const uint64& guid) { m_assistants.push_back(guid); }
683 private:
684 AssistDelayEvent();
686 uint64 m_victim;
687 std::list<uint64> m_assistants;
688 Unit& m_owner;
691 class ForcedDespawnDelayEvent : public BasicEvent
693 public:
694 ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
695 bool Execute(uint64 e_time, uint32 p_time);
697 private:
698 Creature& m_owner;
701 #endif