[8483] Implement glyph 43361.
[getmangos.git] / src / game / Creature.h
blobede6c61dc43de1ea31f5afe8d9c5677fbbac0db1
1 /*
2 * Copyright (C) 2005-2009 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 Gossip_Option
41 GOSSIP_OPTION_NONE = 0, //UNIT_NPC_FLAG_NONE = 0,
42 GOSSIP_OPTION_GOSSIP = 1, //UNIT_NPC_FLAG_GOSSIP = 1,
43 GOSSIP_OPTION_QUESTGIVER = 2, //UNIT_NPC_FLAG_QUESTGIVER = 2,
44 GOSSIP_OPTION_VENDOR = 3, //UNIT_NPC_FLAG_VENDOR = 4,
45 GOSSIP_OPTION_TAXIVENDOR = 4, //UNIT_NPC_FLAG_TAXIVENDOR = 8,
46 GOSSIP_OPTION_TRAINER = 5, //UNIT_NPC_FLAG_TRAINER = 16,
47 GOSSIP_OPTION_SPIRITHEALER = 6, //UNIT_NPC_FLAG_SPIRITHEALER = 32,
48 GOSSIP_OPTION_SPIRITGUIDE = 7, //UNIT_NPC_FLAG_SPIRITGUIDE = 64,
49 GOSSIP_OPTION_INNKEEPER = 8, //UNIT_NPC_FLAG_INNKEEPER = 128,
50 GOSSIP_OPTION_BANKER = 9, //UNIT_NPC_FLAG_BANKER = 256,
51 GOSSIP_OPTION_PETITIONER = 10, //UNIT_NPC_FLAG_PETITIONER = 512,
52 GOSSIP_OPTION_TABARDDESIGNER = 11, //UNIT_NPC_FLAG_TABARDDESIGNER = 1024,
53 GOSSIP_OPTION_BATTLEFIELD = 12, //UNIT_NPC_FLAG_BATTLEFIELDPERSON = 2048,
54 GOSSIP_OPTION_AUCTIONEER = 13, //UNIT_NPC_FLAG_AUCTIONEER = 4096,
55 GOSSIP_OPTION_STABLEPET = 14, //UNIT_NPC_FLAG_STABLE = 8192,
56 GOSSIP_OPTION_ARMORER = 15, //UNIT_NPC_FLAG_ARMORER = 16384,
57 GOSSIP_OPTION_UNLEARNTALENTS = 16, //UNIT_NPC_FLAG_TRAINER (bonus option for GOSSIP_OPTION_TRAINER)
58 GOSSIP_OPTION_UNLEARNPETSKILLS = 17 //UNIT_NPC_FLAG_TRAINER (bonus option for GOSSIP_OPTION_TRAINER)
61 enum Gossip_Guard
63 GOSSIP_GUARD_BANK = 32,
64 GOSSIP_GUARD_RIDE = 33,
65 GOSSIP_GUARD_GUILD = 34,
66 GOSSIP_GUARD_INN = 35,
67 GOSSIP_GUARD_MAIL = 36,
68 GOSSIP_GUARD_AUCTION = 37,
69 GOSSIP_GUARD_WEAPON = 38,
70 GOSSIP_GUARD_STABLE = 39,
71 GOSSIP_GUARD_BATTLE = 40,
72 GOSSIP_GUARD_SPELLTRAINER = 41,
73 GOSSIP_GUARD_SKILLTRAINER = 42
76 enum Gossip_Guard_Spell
78 GOSSIP_GUARD_SPELL_WARRIOR = 64,
79 GOSSIP_GUARD_SPELL_PALADIN = 65,
80 GOSSIP_GUARD_SPELL_HUNTER = 66,
81 GOSSIP_GUARD_SPELL_ROGUE = 67,
82 GOSSIP_GUARD_SPELL_PRIEST = 68,
83 GOSSIP_GUARD_SPELL_UNKNOWN1 = 69,
84 GOSSIP_GUARD_SPELL_SHAMAN = 70,
85 GOSSIP_GUARD_SPELL_MAGE = 71,
86 GOSSIP_GUARD_SPELL_WARLOCK = 72,
87 GOSSIP_GUARD_SPELL_UNKNOWN2 = 73,
88 GOSSIP_GUARD_SPELL_DRUID = 74
91 enum Gossip_Guard_Skill
93 GOSSIP_GUARD_SKILL_ALCHEMY = 80,
94 GOSSIP_GUARD_SKILL_BLACKSMITH = 81,
95 GOSSIP_GUARD_SKILL_COOKING = 82,
96 GOSSIP_GUARD_SKILL_ENCHANT = 83,
97 GOSSIP_GUARD_SKILL_FIRSTAID = 84,
98 GOSSIP_GUARD_SKILL_FISHING = 85,
99 GOSSIP_GUARD_SKILL_HERBALISM = 86,
100 GOSSIP_GUARD_SKILL_LEATHER = 87,
101 GOSSIP_GUARD_SKILL_MINING = 88,
102 GOSSIP_GUARD_SKILL_SKINNING = 89,
103 GOSSIP_GUARD_SKILL_TAILORING = 90,
104 GOSSIP_GUARD_SKILL_ENGINERING = 91
107 enum GossipOptionIcon
109 GOSSIP_ICON_CHAT = 0, //white chat bubble
110 GOSSIP_ICON_VENDOR = 1, //brown bag
111 GOSSIP_ICON_TAXI = 2, //flight
112 GOSSIP_ICON_TRAINER = 3, //book
113 GOSSIP_ICON_INTERACT_1 = 4, //interaction wheel
114 GOSSIP_ICON_INTERACT_2 = 5, //interaction wheel
115 GOSSIP_ICON_MONEY_BAG = 6, //brown bag with yellow dot
116 GOSSIP_ICON_TALK = 7, //white chat bubble with black dots
117 GOSSIP_ICON_TABARD = 8, //tabard
118 GOSSIP_ICON_BATTLE = 9, //two swords
119 GOSSIP_ICON_DOT = 10 //yellow dot
122 struct GossipOption
124 uint32 Id;
125 uint32 GossipId;
126 uint32 NpcFlag;
127 uint32 Icon;
128 uint32 Action;
129 uint32 BoxMoney;
130 bool Coded;
131 std::string OptionText;
132 std::string BoxText;
135 enum CreatureFlagsExtra
137 CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group
138 CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility)
139 CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry
140 CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry
141 CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block
142 CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks
143 CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
144 CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures)
145 CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me
148 // 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
149 #if defined( __GNUC__ )
150 #pragma pack(1)
151 #else
152 #pragma pack(push,1)
153 #endif
155 #define MAX_KILL_CREDIT 2
157 // from `creature_template` table
158 struct CreatureInfo
160 uint32 Entry;
161 uint32 HeroicEntry;
162 uint32 KillCredit[MAX_KILL_CREDIT];
163 uint32 DisplayID_A[2];
164 uint32 DisplayID_H[2];
165 char* Name;
166 char* SubName;
167 char* IconName;
168 uint32 minlevel;
169 uint32 maxlevel;
170 uint32 minhealth;
171 uint32 maxhealth;
172 uint32 minmana;
173 uint32 maxmana;
174 uint32 armor;
175 uint32 faction_A;
176 uint32 faction_H;
177 uint32 npcflag;
178 float speed;
179 float scale;
180 uint32 rank;
181 float mindmg;
182 float maxdmg;
183 uint32 dmgschool;
184 uint32 attackpower;
185 float dmg_multiplier;
186 uint32 baseattacktime;
187 uint32 rangeattacktime;
188 uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures.
189 uint32 unit_flags; // enum UnitFlags mask values
190 uint32 dynamicflags;
191 uint32 family; // enum CreatureFamily values (optional)
192 uint32 trainer_type;
193 uint32 trainer_spell;
194 uint32 trainer_class;
195 uint32 trainer_race;
196 float minrangedmg;
197 float maxrangedmg;
198 uint32 rangedattackpower;
199 uint32 type; // enum CreatureType values
200 uint32 type_flags; // enum CreatureTypeFlags mask values
201 uint32 lootid;
202 uint32 pickpocketLootId;
203 uint32 SkinLootId;
204 int32 resistance1;
205 int32 resistance2;
206 int32 resistance3;
207 int32 resistance4;
208 int32 resistance5;
209 int32 resistance6;
210 uint32 spells[CREATURE_MAX_SPELLS];
211 uint32 PetSpellDataId;
212 uint32 mingold;
213 uint32 maxgold;
214 char const* AIName;
215 uint32 MovementType;
216 uint32 InhabitType;
217 float unk16;
218 float unk17;
219 bool RacialLeader;
220 uint32 questItems[4];
221 uint32 movementId;
222 bool RegenHealth;
223 uint32 equipmentId;
224 uint32 MechanicImmuneMask;
225 uint32 flags_extra;
226 uint32 ScriptID;
228 // helpers
229 SkillType GetRequiredLootSkill() const
231 if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
232 return SKILL_HERBALISM;
233 else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
234 return SKILL_MINING;
235 else if(type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
236 return SKILL_ENGINERING;
237 else
238 return SKILL_SKINNING; // normal case
241 bool isTameable(bool exotic) const
243 if(type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE)==0)
244 return false;
246 // if can tame exotic then can tame any temable
247 return exotic || (type_flags & CREATURE_TYPEFLAGS_EXOTIC)==0;
251 struct CreatureLocale
253 std::vector<std::string> Name;
254 std::vector<std::string> SubName;
257 struct NpcOptionLocale
259 std::vector<std::string> OptionText;
260 std::vector<std::string> BoxText;
263 struct PointOfInterestLocale
265 std::vector<std::string> IconName;
268 struct EquipmentInfo
270 uint32 entry;
271 uint32 equipentry[3];
274 // from `creature` table
275 struct CreatureData
277 uint32 id; // entry in creature_template
278 uint16 mapid;
279 uint16 phaseMask;
280 uint32 displayid;
281 int32 equipmentId;
282 float posX;
283 float posY;
284 float posZ;
285 float orientation;
286 uint32 spawntimesecs;
287 float spawndist;
288 uint32 currentwaypoint;
289 uint32 curhealth;
290 uint32 curmana;
291 bool is_dead;
292 uint8 movementType;
293 uint8 spawnMask;
296 struct CreatureDataAddonAura
298 uint32 spell_id;
299 uint8 effect_idx;
302 // from `creature_addon` table
303 struct CreatureDataAddon
305 uint32 guidOrEntry;
306 uint32 mount;
307 uint32 bytes1;
308 uint32 bytes2;
309 uint32 emote;
310 uint32 move_flags;
311 CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
314 struct CreatureModelInfo
316 uint32 modelid;
317 float bounding_radius;
318 float combat_reach;
319 uint8 gender;
320 uint32 modelid_other_gender;
323 enum InhabitTypeValues
325 INHABIT_GROUND = 1,
326 INHABIT_WATER = 2,
327 INHABIT_AIR = 4,
328 INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR
331 // Enums used by StringTextData::Type (CreatureEventAI)
332 enum ChatType
334 CHAT_TYPE_SAY = 0,
335 CHAT_TYPE_YELL = 1,
336 CHAT_TYPE_TEXT_EMOTE = 2,
337 CHAT_TYPE_BOSS_EMOTE = 3,
338 CHAT_TYPE_WHISPER = 4,
339 CHAT_TYPE_BOSS_WHISPER = 5,
340 CHAT_TYPE_ZONE_YELL = 6
343 //Selection method used by SelectTarget (CreatureEventAI)
344 enum AttackingTarget
346 ATTACKING_TARGET_RANDOM = 0, //Just selects a random target
347 ATTACKING_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom
348 ATTACKING_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top
349 /* not implemented
350 ATTACKING_TARGET_RANDOM_PLAYER, //Just selects a random target (player only)
351 ATTACKING_TARGET_TOPAGGRO_PLAYER, //Selects targes from top aggro to bottom (player only)
352 ATTACKING_TARGET_BOTTOMAGGRO_PLAYER, //Selects targets from bottom aggro to top (player only)
356 // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
357 #if defined( __GNUC__ )
358 #pragma pack()
359 #else
360 #pragma pack(pop)
361 #endif
363 // Vendors
364 struct VendorItem
366 VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
367 : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
369 uint32 item;
370 uint32 maxcount; // 0 for infinity item amount
371 uint32 incrtime; // time for restore items amount if maxcount != 0
372 uint32 ExtendedCost;
374 typedef std::vector<VendorItem*> VendorItemList;
376 struct VendorItemData
378 VendorItemList m_items;
380 VendorItem* GetItem(uint32 slot) const
382 if(slot>=m_items.size()) return NULL;
383 return m_items[slot];
385 bool Empty() const { return m_items.empty(); }
386 uint8 GetItemCount() const { return m_items.size(); }
387 void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
389 m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
391 bool RemoveItem( uint32 item_id );
392 VendorItem const* FindItem(uint32 item_id) const;
393 size_t FindItemSlot(uint32 item_id) const;
395 void Clear()
397 for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
398 delete (*itr);
399 m_items.clear();
403 struct VendorItemCount
405 explicit VendorItemCount(uint32 _item, uint32 _count)
406 : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
408 uint32 itemId;
409 uint32 count;
410 time_t lastIncrementTime;
413 typedef std::list<VendorItemCount> VendorItemCounts;
415 struct TrainerSpell
417 TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0), learnedSpell(0) {}
419 TrainerSpell(uint32 _spell, uint32 _spellCost, uint32 _reqSkill, uint32 _reqSkillValue, uint32 _reqLevel, uint32 _learnedspell)
420 : spell(_spell), spellCost(_spellCost), reqSkill(_reqSkill), reqSkillValue(_reqSkillValue), reqLevel(_reqLevel), learnedSpell(_learnedspell)
423 uint32 spell;
424 uint32 spellCost;
425 uint32 reqSkill;
426 uint32 reqSkillValue;
427 uint32 reqLevel;
428 uint32 learnedSpell;
430 // helpers
431 bool IsCastable() const { return learnedSpell != spell; }
434 typedef UNORDERED_MAP<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap;
436 struct TrainerSpellData
438 TrainerSpellData() : trainerType(0) {}
440 TrainerSpellMap spellList;
441 uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
442 // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
443 TrainerSpell const* Find(uint32 spell_id) const;
444 void Clear() { spellList.clear(); }
447 typedef std::list<GossipOption> GossipOptionList;
449 typedef std::map<uint32,time_t> CreatureSpellCooldowns;
451 // max different by z coordinate for creature aggro reaction
452 #define CREATURE_Z_ATTACK_RANGE 3
454 #define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY
456 class MANGOS_DLL_SPEC Creature : public Unit
458 CreatureAI *i_AI;
460 public:
462 explicit Creature();
463 virtual ~Creature();
465 void AddToWorld();
466 void RemoveFromWorld();
468 bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL);
469 bool LoadCreaturesAddon(bool reload = false);
470 void SelectLevel(const CreatureInfo *cinfo);
471 void LoadEquipment(uint32 equip_entry, bool force=false);
473 uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
474 char const* GetSubName() const { return GetCreatureInfo()->SubName; }
476 void Update( uint32 time ); // overwrited Unit::Update
477 void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
478 uint32 GetEquipmentId() const { return m_equipmentId; }
480 bool isPet() const { return m_isPet; }
481 bool isVehicle() const { return m_isVehicle; }
482 void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
483 bool isTotem() const { return m_isTotem; }
484 bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
485 bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
486 bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
487 bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
488 bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
489 ///// TODO RENAME THIS!!!!!
490 bool isCanTrainingOf(Player* player, bool msg) const;
491 bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
492 bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
493 bool IsOutOfThreatArea(Unit* pVictim) const;
494 bool IsImmunedToSpell(SpellEntry const* spellInfo);
495 // redefine Unit::IsImmunedToSpell
496 bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
497 // redefine Unit::IsImmunedToSpellEffect
498 bool isElite() const
500 if(isPet())
501 return false;
503 uint32 rank = GetCreatureInfo()->rank;
504 return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
507 bool isWorldBoss() const
509 if(isPet())
510 return false;
512 return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
515 uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
517 bool IsInEvadeMode() const;
519 bool AIM_Initialize();
521 void AI_SendMoveToPacket(float x, float y, float z, uint32 time, MonsterMovementFlags MovementFlags, uint8 type);
522 CreatureAI* AI() { return i_AI; }
524 void AddMonsterMoveFlag(MonsterMovementFlags f) { m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags | f); }
525 void RemoveMonsterMoveFlag(MonsterMovementFlags f) { m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags & ~f); }
526 bool HasMonsterMoveFlag(MonsterMovementFlags f) const { return m_monsterMoveFlags & f; }
527 MonsterMovementFlags GetMonsterMoveFlags() const { return m_monsterMoveFlags; }
528 void SetMonsterMoveFlags(MonsterMovementFlags f) { m_monsterMoveFlags = f; }
530 void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
531 void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
533 uint32 GetShieldBlockValue() const //dunno mob block value
535 return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
538 SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
539 void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
541 void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
542 void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
543 void AddCreatureSpellCooldown(uint32 spellid);
544 bool HasSpellCooldown(uint32 spell_id) const;
545 bool HasCategoryCooldown(uint32 spell_id) const;
547 bool HasSpell(uint32 spellID) const;
549 bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
550 bool UpdateStats(Stats stat);
551 bool UpdateAllStats();
552 void UpdateResistances(uint32 school);
553 void UpdateArmor();
554 void UpdateMaxHealth();
555 void UpdateMaxPower(Powers power);
556 void UpdateAttackPowerAndDamage(bool ranged = false);
557 void UpdateDamagePhysical(WeaponAttackType attType);
558 uint32 GetCurrentEquipmentId() { return m_equipmentId; }
559 float GetSpellDamageMod(int32 Rank);
561 VendorItemData const* GetVendorItems() const;
562 uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
563 uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
565 TrainerSpellData const* GetTrainerSpells() const;
567 CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
568 CreatureDataAddon const* GetCreatureAddon() const;
570 std::string GetAIName() const;
571 std::string GetScriptName() const;
572 uint32 GetScriptId() const;
574 void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 );
575 void sendPreparedGossip( Player* player );
576 void OnGossipSelect(Player* player, uint32 option);
577 void OnPoiSelect(Player* player, GossipOption const *gossip);
579 uint32 GetGossipTextId(uint32 action, uint32 zoneid);
580 uint32 GetNpcTextId();
581 void LoadGossipOptions();
582 GossipOption const* GetGossipOption( uint32 id ) const;
583 void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); }
585 void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
586 void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
587 void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); }
588 void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); }
589 void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
591 // overwrite WorldObject function for proper name localization
592 const char* GetNameForLocaleIdx(int32 locale_idx) const;
594 void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState
595 bool FallGround();
597 bool LoadFromDB(uint32 guid, Map *map);
598 void SaveToDB();
599 // overwrited in Pet
600 virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
601 virtual void DeleteFromDB(); // overwrited in Pet
603 Loot loot;
604 bool lootForPickPocketed;
605 bool lootForBody;
606 Player *GetLootRecipient() const;
607 bool hasLootRecipient() const { return m_lootRecipient!=0; }
609 void SetLootRecipient (Unit* unit);
610 void AllLootRemovedFromCorpse();
612 SpellEntry const *reachWithSpellAttack(Unit *pVictim);
613 SpellEntry const *reachWithSpellCure(Unit *pVictim);
615 uint32 m_spells[CREATURE_MAX_SPELLS];
616 CreatureSpellCooldowns m_CreatureSpellCooldowns;
617 CreatureSpellCooldowns m_CreatureCategoryCooldowns;
618 uint32 m_GlobalCooldown;
620 float GetAttackDistance(Unit const* pl) const;
622 void DoFleeToGetAssistance();
623 void CallForHelp(float fRadius);
624 void CallAssistance();
625 void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
626 void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
627 bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
628 bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
630 MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
631 void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
633 // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
634 Cell const& GetCurrentCell() const { return m_currentCell; }
635 void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
637 bool IsVisibleInGridForPlayer(Player* pl) const;
639 void RemoveCorpse();
640 bool isDeadByDefault() const { return m_isDeadByDefault; };
642 void ForcedDespawn();
644 time_t const& GetRespawnTime() const { return m_respawnTime; }
645 time_t GetRespawnTimeEx() const;
646 void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
647 void Respawn();
648 void SaveRespawnTime();
650 uint32 GetRespawnDelay() const { return m_respawnDelay; }
651 void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
653 float GetRespawnRadius() const { return m_respawnradius; }
654 void SetRespawnRadius(float dist) { m_respawnradius = dist; }
656 uint32 m_groupLootTimer; // (msecs)timer used for group loot
657 uint64 lootingGroupLeaderGUID; // used to find group which is looting corpse
659 void SendZoneUnderAttackMessage(Player* attacker);
661 void SetInCombatWithZone();
663 bool hasQuest(uint32 quest_id) const;
664 bool hasInvolvedQuest(uint32 quest_id) const;
666 GridReference<Creature> &GetGridRef() { return m_gridRef; }
667 bool isRegeneratingHealth() { return m_regenHealth; }
668 virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
669 virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
671 if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
672 return 0;
673 else
674 return m_charmInfo->GetCharmSpell(pos)->GetAction();
677 void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; }
678 void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; }
680 uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
682 void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; }
684 bool isActiveObject() const { return m_isActiveObject || HasAuraType(SPELL_AURA_BIND_SIGHT) || HasAuraType(SPELL_AURA_FAR_SIGHT); }
685 void SetActiveObjectState(bool on);
687 protected:
688 bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
689 bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
691 // vendor items
692 VendorItemCounts m_vendorItemCounts;
694 void _RealtimeSetCreatureInfo();
696 static float _GetHealthMod(int32 Rank);
697 static float _GetDamageMod(int32 Rank);
699 uint32 m_lootMoney;
700 uint64 m_lootRecipient;
702 /// Timers
703 uint32 m_deathTimer; // (msecs)timer for death or corpse disappearance
704 time_t m_respawnTime; // (secs) time of next respawn
705 uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
706 uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
707 float m_respawnradius;
709 bool m_gossipOptionLoaded;
710 GossipOptionList m_goptions;
712 bool m_isPet; // set only in Pet::Pet
713 bool m_isVehicle; // set only in Vehicle::Vehicle
714 bool m_isTotem; // set only in Totem::Totem
715 void RegenerateMana();
716 void RegenerateHealth();
717 MovementGeneratorType m_defaultMovementType;
718 Cell m_currentCell; // store current cell where creature listed
719 uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
720 uint32 m_equipmentId;
722 bool m_AlreadyCallAssistance;
723 bool m_AlreadySearchedAssistance;
724 bool m_regenHealth;
725 bool m_AI_locked;
726 bool m_isDeadByDefault;
728 SpellSchoolMask m_meleeDamageSchoolMask;
729 uint32 m_originalEntry;
731 float CombatStartX;
732 float CombatStartY;
733 float CombatStartZ;
734 private:
735 GridReference<Creature> m_gridRef;
736 CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
737 bool m_isActiveObject;
738 MonsterMovementFlags m_monsterMoveFlags;
741 class AssistDelayEvent : public BasicEvent
743 public:
744 AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
746 bool Execute(uint64 e_time, uint32 p_time);
747 void AddAssistant(const uint64& guid) { m_assistants.push_back(guid); }
748 private:
749 AssistDelayEvent();
751 uint64 m_victim;
752 std::list<uint64> m_assistants;
753 Unit& m_owner;
756 #endif