[7732] Fixed compile warnings.
[getmangos.git] / src / game / Creature.h
blob9953a31be21f748d01a8218f52c62076e0ab7046
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 struct GossipOption
109 uint32 Id;
110 uint32 GossipId;
111 uint32 NpcFlag;
112 uint32 Icon;
113 uint32 Action;
114 uint32 BoxMoney;
115 bool Coded;
116 std::string OptionText;
117 std::string BoxText;
120 enum CreatureFlagsExtra
122 CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group
123 CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility)
124 CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry
125 CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry
126 CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block
127 CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks
128 CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
129 CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures)
132 // 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
133 #if defined( __GNUC__ )
134 #pragma pack(1)
135 #else
136 #pragma pack(push,1)
137 #endif
139 // from `creature_template` table
140 struct CreatureInfo
142 uint32 Entry;
143 uint32 HeroicEntry;
144 uint32 DisplayID_A;
145 uint32 DisplayID_A2;
146 uint32 DisplayID_H;
147 uint32 DisplayID_H2;
148 char* Name;
149 char* SubName;
150 char* IconName;
151 uint32 minlevel;
152 uint32 maxlevel;
153 uint32 minhealth;
154 uint32 maxhealth;
155 uint32 minmana;
156 uint32 maxmana;
157 uint32 armor;
158 uint32 faction_A;
159 uint32 faction_H;
160 uint32 npcflag;
161 float speed;
162 float scale;
163 uint32 rank;
164 float mindmg;
165 float maxdmg;
166 uint32 dmgschool;
167 uint32 attackpower;
168 uint32 baseattacktime;
169 uint32 rangeattacktime;
170 uint32 unit_flags; // enum UnitFlags mask values
171 uint32 dynamicflags;
172 uint32 family; // enum CreatureFamily values (optional)
173 uint32 trainer_type;
174 uint32 trainer_spell;
175 uint32 classNum;
176 uint32 race;
177 float minrangedmg;
178 float maxrangedmg;
179 uint32 rangedattackpower;
180 uint32 type; // enum CreatureType values
181 uint32 type_flags; // enum CreatureTypeFlags mask values
182 uint32 lootid;
183 uint32 pickpocketLootId;
184 uint32 SkinLootId;
185 int32 resistance1;
186 int32 resistance2;
187 int32 resistance3;
188 int32 resistance4;
189 int32 resistance5;
190 int32 resistance6;
191 uint32 spells[CREATURE_MAX_SPELLS];
192 uint32 PetSpellDataId;
193 uint32 mingold;
194 uint32 maxgold;
195 char const* AIName;
196 uint32 MovementType;
197 uint32 InhabitType;
198 float unk16;
199 float unk17;
200 bool RacialLeader;
201 bool RegenHealth;
202 uint32 equipmentId;
203 uint32 MechanicImmuneMask;
204 uint32 flags_extra;
205 uint32 ScriptID;
207 // helpers
208 SkillType GetRequiredLootSkill() const
210 if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
211 return SKILL_HERBALISM;
212 else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
213 return SKILL_MINING;
214 else if(type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
215 return SKILL_ENGINERING;
216 else
217 return SKILL_SKINNING; // normal case
220 bool isTameable() const
222 return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEABLE);
226 struct CreatureLocale
228 std::vector<std::string> Name;
229 std::vector<std::string> SubName;
232 struct NpcOptionLocale
234 std::vector<std::string> OptionText;
235 std::vector<std::string> BoxText;
238 struct PointOfInterestLocale
240 std::vector<std::string> IconName;
243 struct EquipmentInfo
245 uint32 entry;
246 uint32 equipentry[3];
249 // from `creature` table
250 struct CreatureData
252 uint32 id; // entry in creature_template
253 uint16 mapid;
254 uint16 phaseMask;
255 uint32 displayid;
256 int32 equipmentId;
257 float posX;
258 float posY;
259 float posZ;
260 float orientation;
261 uint32 spawntimesecs;
262 float spawndist;
263 uint32 currentwaypoint;
264 uint32 curhealth;
265 uint32 curmana;
266 bool is_dead;
267 uint8 movementType;
268 uint8 spawnMask;
271 struct CreatureDataAddonAura
273 uint16 spell_id;
274 uint8 effect_idx;
277 // from `creature_addon` table
278 struct CreatureDataAddon
280 uint32 guidOrEntry;
281 uint32 mount;
282 uint32 bytes0;
283 uint32 bytes1;
284 uint32 bytes2;
285 uint32 emote;
286 uint32 move_flags;
287 CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
290 struct CreatureModelInfo
292 uint32 modelid;
293 float bounding_radius;
294 float combat_reach;
295 uint8 gender;
296 uint32 modelid_other_gender;
299 enum InhabitTypeValues
301 INHABIT_GROUND = 1,
302 INHABIT_WATER = 2,
303 INHABIT_AIR = 4,
304 INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR
307 // Enums used by StringTextData::Type (CreatureEventAI)
308 enum ChatType
310 CHAT_TYPE_SAY = 0,
311 CHAT_TYPE_YELL = 1,
312 CHAT_TYPE_TEXT_EMOTE = 2,
313 CHAT_TYPE_BOSS_EMOTE = 3,
314 CHAT_TYPE_WHISPER = 4,
315 CHAT_TYPE_BOSS_WHISPER = 5,
316 CHAT_TYPE_ZONE_YELL = 6
319 //Selection method used by SelectTarget (CreatureEventAI)
320 enum AttackingTarget
322 ATTACKING_TARGET_RANDOM = 0, //Just selects a random target
323 ATTACKING_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom
324 ATTACKING_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top
325 /* not implemented
326 ATTACKING_TARGET_RANDOM_PLAYER, //Just selects a random target (player only)
327 ATTACKING_TARGET_TOPAGGRO_PLAYER, //Selects targes from top aggro to bottom (player only)
328 ATTACKING_TARGET_BOTTOMAGGRO_PLAYER, //Selects targets from bottom aggro to top (player only)
332 // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
333 #if defined( __GNUC__ )
334 #pragma pack()
335 #else
336 #pragma pack(pop)
337 #endif
339 // Vendors
340 struct VendorItem
342 VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
343 : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
345 uint32 item;
346 uint32 maxcount; // 0 for infinity item amount
347 uint32 incrtime; // time for restore items amount if maxcount != 0
348 uint32 ExtendedCost;
350 typedef std::vector<VendorItem*> VendorItemList;
352 struct VendorItemData
354 VendorItemList m_items;
356 VendorItem* GetItem(uint32 slot) const
358 if(slot>=m_items.size()) return NULL;
359 return m_items[slot];
361 bool Empty() const { return m_items.empty(); }
362 uint8 GetItemCount() const { return m_items.size(); }
363 void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
365 m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
367 bool RemoveItem( uint32 item_id );
368 VendorItem const* FindItem(uint32 item_id) const;
369 size_t FindItemSlot(uint32 item_id) const;
371 void Clear()
373 for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
374 delete (*itr);
375 m_items.clear();
379 struct VendorItemCount
381 explicit VendorItemCount(uint32 _item, uint32 _count)
382 : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
384 uint32 itemId;
385 uint32 count;
386 time_t lastIncrementTime;
389 typedef std::list<VendorItemCount> VendorItemCounts;
391 struct TrainerSpell
393 TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0), learnedSpell(0) {}
395 TrainerSpell(uint32 _spell, uint32 _spellCost, uint32 _reqSkill, uint32 _reqSkillValue, uint32 _reqLevel, uint32 _learnedspell)
396 : spell(_spell), spellCost(_spellCost), reqSkill(_reqSkill), reqSkillValue(_reqSkillValue), reqLevel(_reqLevel), learnedSpell(_learnedspell)
399 uint32 spell;
400 uint32 spellCost;
401 uint32 reqSkill;
402 uint32 reqSkillValue;
403 uint32 reqLevel;
404 uint32 learnedSpell;
406 // helpers
407 bool IsCastable() const { return learnedSpell != spell; }
410 typedef UNORDERED_MAP<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap;
412 struct TrainerSpellData
414 TrainerSpellData() : trainerType(0) {}
416 TrainerSpellMap spellList;
417 uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
418 // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
419 TrainerSpell const* Find(uint32 spell_id) const;
420 void Clear() { spellList.clear(); }
423 typedef std::list<GossipOption> GossipOptionList;
425 typedef std::map<uint32,time_t> CreatureSpellCooldowns;
427 // max different by z coordinate for creature aggro reaction
428 #define CREATURE_Z_ATTACK_RANGE 3
430 #define MAX_VENDOR_ITEMS 255 // Limitation in item count field size in SMSG_LIST_INVENTORY
432 class MANGOS_DLL_SPEC Creature : public Unit
434 CreatureAI *i_AI;
436 public:
438 explicit Creature();
439 virtual ~Creature();
441 void AddToWorld();
442 void RemoveFromWorld();
444 bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL);
445 bool LoadCreaturesAddon(bool reload = false);
446 void SelectLevel(const CreatureInfo *cinfo);
447 void LoadEquipment(uint32 equip_entry, bool force=false);
449 uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
450 char const* GetSubName() const { return GetCreatureInfo()->SubName; }
452 void Update( uint32 time ); // overwrited Unit::Update
453 void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
454 uint32 GetEquipmentId() const { return m_equipmentId; }
456 bool isPet() const { return m_isPet; }
457 bool isVehicle() const { return m_isVehicle; }
458 void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
459 bool isTotem() const { return m_isTotem; }
460 bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
461 bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
462 bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
463 bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
464 bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
465 ///// TODO RENAME THIS!!!!!
466 bool isCanTrainingOf(Player* player, bool msg) const;
467 bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
468 bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
469 bool IsOutOfThreatArea(Unit* pVictim) const;
470 bool IsImmunedToSpell(SpellEntry const* spellInfo);
471 // redefine Unit::IsImmunedToSpell
472 bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
473 // redefine Unit::IsImmunedToSpellEffect
474 bool isElite() const
476 if(isPet())
477 return false;
479 uint32 rank = GetCreatureInfo()->rank;
480 return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
483 bool isWorldBoss() const
485 if(isPet())
486 return false;
488 return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
491 uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
493 bool IsInEvadeMode() const;
495 bool AIM_Initialize();
497 void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
498 CreatureAI* AI() { return i_AI; }
500 uint32 GetShieldBlockValue() const //dunno mob block value
502 return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
505 SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
506 void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
508 void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
509 void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
510 void AddCreatureSpellCooldown(uint32 spellid);
511 bool HasSpellCooldown(uint32 spell_id) const;
512 bool HasCategoryCooldown(uint32 spell_id) const;
514 bool HasSpell(uint32 spellID) const;
516 bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
517 bool UpdateStats(Stats stat);
518 bool UpdateAllStats();
519 void UpdateResistances(uint32 school);
520 void UpdateArmor();
521 void UpdateMaxHealth();
522 void UpdateMaxPower(Powers power);
523 void UpdateAttackPowerAndDamage(bool ranged = false);
524 void UpdateDamagePhysical(WeaponAttackType attType);
525 uint32 GetCurrentEquipmentId() { return m_equipmentId; }
526 float GetSpellDamageMod(int32 Rank);
528 VendorItemData const* GetVendorItems() const;
529 uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
530 uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
532 TrainerSpellData const* GetTrainerSpells() const;
534 CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
535 CreatureDataAddon const* GetCreatureAddon() const;
537 std::string GetAIName() const;
538 std::string GetScriptName() const;
539 uint32 GetScriptId() const;
541 void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 );
542 void sendPreparedGossip( Player* player );
543 void OnGossipSelect(Player* player, uint32 option);
544 void OnPoiSelect(Player* player, GossipOption const *gossip);
546 uint32 GetGossipTextId(uint32 action, uint32 zoneid);
547 uint32 GetNpcTextId();
548 void LoadGossipOptions();
549 GossipOption const* GetGossipOption( uint32 id ) const;
550 void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); }
552 void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
553 void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
554 void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); }
555 void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); }
556 void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
558 // overwrite WorldObject function for proper name localization
559 const char* GetNameForLocaleIdx(int32 locale_idx) const;
561 void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState
562 bool FallGround();
564 bool LoadFromDB(uint32 guid, Map *map);
565 void SaveToDB();
566 // overwrited in Pet
567 virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
568 virtual void DeleteFromDB(); // overwrited in Pet
570 Loot loot;
571 bool lootForPickPocketed;
572 bool lootForBody;
573 Player *GetLootRecipient() const;
574 bool hasLootRecipient() const { return m_lootRecipient!=0; }
576 void SetLootRecipient (Unit* unit);
577 void AllLootRemovedFromCorpse();
579 SpellEntry const *reachWithSpellAttack(Unit *pVictim);
580 SpellEntry const *reachWithSpellCure(Unit *pVictim);
582 uint32 m_spells[CREATURE_MAX_SPELLS];
583 CreatureSpellCooldowns m_CreatureSpellCooldowns;
584 CreatureSpellCooldowns m_CreatureCategoryCooldowns;
585 uint32 m_GlobalCooldown;
587 float GetAttackDistance(Unit const* pl) const;
589 void CallAssistance();
590 void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
591 bool CanAssistTo(const Unit* u, const Unit* enemy) const;
593 MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
594 void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
596 // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
597 Cell const& GetCurrentCell() const { return m_currentCell; }
598 void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
600 bool IsVisibleInGridForPlayer(Player* pl) const;
602 void RemoveCorpse();
604 time_t const& GetRespawnTime() const { return m_respawnTime; }
605 time_t GetRespawnTimeEx() const;
606 void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
607 void Respawn();
608 void SaveRespawnTime();
610 uint32 GetRespawnDelay() const { return m_respawnDelay; }
611 void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
613 float GetRespawnRadius() const { return m_respawnradius; }
614 void SetRespawnRadius(float dist) { m_respawnradius = dist; }
616 uint32 m_groupLootTimer; // (msecs)timer used for group loot
617 uint64 lootingGroupLeaderGUID; // used to find group which is looting corpse
619 void SendZoneUnderAttackMessage(Player* attacker);
621 bool hasQuest(uint32 quest_id) const;
622 bool hasInvolvedQuest(uint32 quest_id) const;
624 GridReference<Creature> &GetGridRef() { return m_gridRef; }
625 bool isRegeneratingHealth() { return m_regenHealth; }
626 virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
627 virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
629 if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->active != ACT_ENABLED)
630 return 0;
631 else
632 return m_charmInfo->GetCharmSpell(pos)->spellId;
635 void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; }
636 void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; }
638 uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
640 void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; }
642 bool isActiveObject() const { return m_isActiveObject; }
643 void SetActiveObjectState(bool on);
645 protected:
646 bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
647 bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
649 // vendor items
650 VendorItemCounts m_vendorItemCounts;
652 void _RealtimeSetCreatureInfo();
654 static float _GetHealthMod(int32 Rank);
655 static float _GetDamageMod(int32 Rank);
657 uint32 m_lootMoney;
658 uint64 m_lootRecipient;
660 /// Timers
661 uint32 m_deathTimer; // (msecs)timer for death or corpse disappearance
662 time_t m_respawnTime; // (secs) time of next respawn
663 uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
664 uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
665 float m_respawnradius;
667 bool m_gossipOptionLoaded;
668 GossipOptionList m_goptions;
670 bool m_isPet; // set only in Pet::Pet
671 bool m_isVehicle; // set only in Vehicle::Vehicle
672 bool m_isTotem; // set only in Totem::Totem
673 void RegenerateMana();
674 void RegenerateHealth();
675 MovementGeneratorType m_defaultMovementType;
676 Cell m_currentCell; // store current cell where creature listed
677 uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
678 uint32 m_equipmentId;
680 bool m_AlreadyCallAssistance;
681 bool m_regenHealth;
682 bool m_AI_locked;
683 bool m_isDeadByDefault;
685 SpellSchoolMask m_meleeDamageSchoolMask;
686 uint32 m_originalEntry;
688 float CombatStartX;
689 float CombatStartY;
690 float CombatStartZ;
691 private:
692 GridReference<Creature> m_gridRef;
693 CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
694 bool m_isActiveObject;
697 class AssistDelayEvent : public BasicEvent
699 public:
700 AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
702 bool Execute(uint64 e_time, uint32 p_time);
703 void AddAssistant(const uint64& guid) { m_assistants.push_back(guid); }
704 private:
705 AssistDelayEvent();
707 uint64 m_victim;
708 std::list<uint64> m_assistants;
709 Unit& m_owner;
712 #endif