[9957] Alow sell item for money and extanded coset without momey in same time.
[getmangos.git] / src / game / Creature.h
blobc6dff5dfc4b2f52d76b6aef6b3134a796d9ae9ca
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 "DBCEnums.h"
28 #include "Database/DatabaseEnv.h"
29 #include "Cell.h"
31 #include <list>
33 struct SpellEntry;
35 class CreatureAI;
36 class Group;
37 class Quest;
38 class Player;
39 class WorldSession;
41 enum CreatureFlagsExtra
43 CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group
44 CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility)
45 CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry
46 CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry
47 CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block
48 CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks
49 CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
50 CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures)
51 CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me
54 // 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
55 #if defined( __GNUC__ )
56 #pragma pack(1)
57 #else
58 #pragma pack(push,1)
59 #endif
61 #define MAX_KILL_CREDIT 2
63 // from `creature_template` table
64 struct CreatureInfo
66 uint32 Entry;
67 uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
68 uint32 KillCredit[MAX_KILL_CREDIT];
69 uint32 DisplayID_A[2];
70 uint32 DisplayID_H[2];
71 char* Name;
72 char* SubName;
73 char* IconName;
74 uint32 GossipMenuId;
75 uint32 minlevel;
76 uint32 maxlevel;
77 uint32 minhealth;
78 uint32 maxhealth;
79 uint32 minmana;
80 uint32 maxmana;
81 uint32 armor;
82 uint32 faction_A;
83 uint32 faction_H;
84 uint32 npcflag;
85 float speed_walk;
86 float speed_run;
87 float scale;
88 uint32 rank;
89 float mindmg;
90 float maxdmg;
91 uint32 dmgschool;
92 uint32 attackpower;
93 float dmg_multiplier;
94 uint32 baseattacktime;
95 uint32 rangeattacktime;
96 uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures.
97 uint32 unit_flags; // enum UnitFlags mask values
98 uint32 dynamicflags;
99 uint32 family; // enum CreatureFamily values (optional)
100 uint32 trainer_type;
101 uint32 trainer_spell;
102 uint32 trainer_class;
103 uint32 trainer_race;
104 float minrangedmg;
105 float maxrangedmg;
106 uint32 rangedattackpower;
107 uint32 type; // enum CreatureType values
108 uint32 type_flags; // enum CreatureTypeFlags mask values
109 uint32 lootid;
110 uint32 pickpocketLootId;
111 uint32 SkinLootId;
112 int32 resistance1;
113 int32 resistance2;
114 int32 resistance3;
115 int32 resistance4;
116 int32 resistance5;
117 int32 resistance6;
118 uint32 spells[CREATURE_MAX_SPELLS];
119 uint32 PetSpellDataId;
120 uint32 mingold;
121 uint32 maxgold;
122 char const* AIName;
123 uint32 MovementType;
124 uint32 InhabitType;
125 float unk16;
126 float unk17;
127 bool RacialLeader;
128 uint32 questItems[6];
129 uint32 movementId;
130 bool RegenHealth;
131 uint32 equipmentId;
132 uint32 MechanicImmuneMask;
133 uint32 flags_extra;
134 uint32 ScriptID;
136 // helpers
137 SkillType GetRequiredLootSkill() const
139 if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
140 return SKILL_HERBALISM;
141 else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
142 return SKILL_MINING;
143 else if(type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
144 return SKILL_ENGINERING;
145 else
146 return SKILL_SKINNING; // normal case
149 bool IsExotic() const
151 return (type_flags & CREATURE_TYPEFLAGS_EXOTIC);
154 bool isTameable(bool exotic) const
156 if(type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
157 return false;
159 // if can tame exotic then can tame any temable
160 return exotic || !IsExotic();
164 struct CreatureLocale
166 std::vector<std::string> Name;
167 std::vector<std::string> SubName;
170 struct GossipMenuItemsLocale
172 std::vector<std::string> OptionText;
173 std::vector<std::string> BoxText;
176 struct PointOfInterestLocale
178 std::vector<std::string> IconName;
181 struct EquipmentInfo
183 uint32 entry;
184 uint32 equipentry[3];
187 // from `creature` table
188 struct CreatureData
190 uint32 id; // entry in creature_template
191 uint16 mapid;
192 uint16 phaseMask;
193 uint32 displayid;
194 int32 equipmentId;
195 float posX;
196 float posY;
197 float posZ;
198 float orientation;
199 uint32 spawntimesecs;
200 float spawndist;
201 uint32 currentwaypoint;
202 uint32 curhealth;
203 uint32 curmana;
204 bool is_dead;
205 uint8 movementType;
206 uint8 spawnMask;
209 struct CreatureDataAddonAura
211 uint32 spell_id;
212 SpellEffectIndex effect_idx;
215 // from `creature_addon` table
216 struct CreatureDataAddon
218 uint32 guidOrEntry;
219 uint32 mount;
220 uint32 bytes1;
221 uint32 bytes2;
222 uint32 emote;
223 uint32 splineFlags;
224 CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
227 struct CreatureModelInfo
229 uint32 modelid;
230 float bounding_radius;
231 float combat_reach;
232 uint8 gender;
233 uint32 modelid_other_gender;
236 enum InhabitTypeValues
238 INHABIT_GROUND = 1,
239 INHABIT_WATER = 2,
240 INHABIT_AIR = 4,
241 INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR
244 // Enums used by StringTextData::Type (CreatureEventAI)
245 enum ChatType
247 CHAT_TYPE_SAY = 0,
248 CHAT_TYPE_YELL = 1,
249 CHAT_TYPE_TEXT_EMOTE = 2,
250 CHAT_TYPE_BOSS_EMOTE = 3,
251 CHAT_TYPE_WHISPER = 4,
252 CHAT_TYPE_BOSS_WHISPER = 5,
253 CHAT_TYPE_ZONE_YELL = 6
256 // Selection method used by SelectAttackingTarget
257 enum AttackingTarget
259 ATTACKING_TARGET_RANDOM = 0, //Just selects a random target
260 ATTACKING_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom
261 ATTACKING_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top
262 /* not implemented
263 ATTACKING_TARGET_RANDOM_PLAYER, //Just selects a random target (player only)
264 ATTACKING_TARGET_TOPAGGRO_PLAYER, //Selects targes from top aggro to bottom (player only)
265 ATTACKING_TARGET_BOTTOMAGGRO_PLAYER, //Selects targets from bottom aggro to top (player only)
269 // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
270 #if defined( __GNUC__ )
271 #pragma pack()
272 #else
273 #pragma pack(pop)
274 #endif
276 // Vendors
277 struct VendorItem
279 VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, int32 _ExtendedCost)
280 : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
282 uint32 item;
283 uint32 maxcount; // 0 for infinity item amount
284 uint32 incrtime; // time for restore items amount if maxcount != 0
285 int32 ExtendedCost; // negative if need exclude normal item money cost
287 // helpers
288 uint32 IsExcludeMoneyPrice() const { return ExtendedCost < 0; }
289 uint32 GetExtendedCostId() const { return std::abs(ExtendedCost); }
291 typedef std::vector<VendorItem*> VendorItemList;
293 struct VendorItemData
295 VendorItemList m_items;
297 VendorItem* GetItem(uint32 slot) const
299 if(slot>=m_items.size()) return NULL;
300 return m_items[slot];
302 bool Empty() const { return m_items.empty(); }
303 uint8 GetItemCount() const { return m_items.size(); }
304 void AddItem( uint32 item, uint32 maxcount, uint32 ptime, int32 ExtendedCost)
306 m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
308 bool RemoveItem( uint32 item_id );
309 VendorItem const* FindItemCostPair(uint32 item_id, int32 extendedCost) const;
311 void Clear()
313 for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
314 delete (*itr);
315 m_items.clear();
319 struct VendorItemCount
321 explicit VendorItemCount(uint32 _item, uint32 _count)
322 : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
324 uint32 itemId;
325 uint32 count;
326 time_t lastIncrementTime;
329 typedef std::list<VendorItemCount> VendorItemCounts;
331 struct TrainerSpell
333 TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0), learnedSpell(0) {}
335 TrainerSpell(uint32 _spell, uint32 _spellCost, uint32 _reqSkill, uint32 _reqSkillValue, uint32 _reqLevel, uint32 _learnedspell)
336 : spell(_spell), spellCost(_spellCost), reqSkill(_reqSkill), reqSkillValue(_reqSkillValue), reqLevel(_reqLevel), learnedSpell(_learnedspell)
339 uint32 spell;
340 uint32 spellCost;
341 uint32 reqSkill;
342 uint32 reqSkillValue;
343 uint32 reqLevel;
344 uint32 learnedSpell;
346 // helpers
347 bool IsCastable() const { return learnedSpell != spell; }
350 typedef UNORDERED_MAP<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap;
352 struct TrainerSpellData
354 TrainerSpellData() : trainerType(0) {}
356 TrainerSpellMap spellList;
357 uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
358 // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
359 TrainerSpell const* Find(uint32 spell_id) const;
360 void Clear() { spellList.clear(); }
363 typedef std::map<uint32,time_t> CreatureSpellCooldowns;
365 // max different by z coordinate for creature aggro reaction
366 #define CREATURE_Z_ATTACK_RANGE 3
368 #define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY
370 enum CreatureSubtype
372 CREATURE_SUBTYPE_GENERIC, // new Creature
373 CREATURE_SUBTYPE_PET, // new Pet
374 CREATURE_SUBTYPE_TOTEM, // new Totem
375 CREATURE_SUBTYPE_VEHICLE, // new Vehicle
376 CREATURE_SUBTYPE_TEMPORARY_SUMMON, // new TemporarySummon
379 class MANGOS_DLL_SPEC Creature : public Unit
381 CreatureAI *i_AI;
383 public:
385 explicit Creature(CreatureSubtype subtype = CREATURE_SUBTYPE_GENERIC);
386 virtual ~Creature();
388 void AddToWorld();
389 void RemoveFromWorld();
391 bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL);
392 bool LoadCreaturesAddon(bool reload = false);
393 void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f);
394 void LoadEquipment(uint32 equip_entry, bool force=false);
396 uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
397 char const* GetSubName() const { return GetCreatureInfo()->SubName; }
399 void Update( uint32 time ); // overwrited Unit::Update
400 void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
401 uint32 GetEquipmentId() const { return m_equipmentId; }
403 CreatureSubtype GetSubtype() const { return m_subtype; }
404 bool isPet() const { return m_subtype == CREATURE_SUBTYPE_PET; }
405 bool isVehicle() const { return m_subtype == CREATURE_SUBTYPE_VEHICLE; }
406 bool isTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; }
407 bool isTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; }
409 void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
410 bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
411 bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
412 bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
413 bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
414 bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
415 ///// TODO RENAME THIS!!!!!
416 bool isCanTrainingOf(Player* player, bool msg) const;
417 bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
418 bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
419 bool IsOutOfThreatArea(Unit* pVictim) const;
420 bool IsImmunedToSpell(SpellEntry const* spellInfo);
421 // redefine Unit::IsImmunedToSpell
422 bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const;
423 // redefine Unit::IsImmunedToSpellEffect
424 bool isElite() const
426 if(isPet())
427 return false;
429 uint32 rank = GetCreatureInfo()->rank;
430 return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
433 bool isWorldBoss() const
435 if(isPet())
436 return false;
438 return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
441 uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
443 bool IsInEvadeMode() const;
445 bool AIM_Initialize();
447 void AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags MovementFlags, SplineType type);
448 CreatureAI* AI() { return i_AI; }
450 void AddSplineFlag(SplineFlags f)
452 bool need_walk_sync = (f & SPLINEFLAG_WALKMODE) != (m_splineFlags & SPLINEFLAG_WALKMODE);
453 m_splineFlags = SplineFlags(m_splineFlags | f);
454 if (need_walk_sync)
455 UpdateWalkMode(this, false);
457 void RemoveSplineFlag(SplineFlags f)
459 bool need_walk_sync = (f & SPLINEFLAG_WALKMODE) != (m_splineFlags & SPLINEFLAG_WALKMODE);
460 m_splineFlags = SplineFlags(m_splineFlags & ~f);
461 if (need_walk_sync)
462 UpdateWalkMode(this, false);
464 bool HasSplineFlag(SplineFlags f) const { return m_splineFlags & f; }
465 SplineFlags GetSplineFlags() const { return m_splineFlags; }
466 void SetSplineFlags(SplineFlags f)
468 bool need_walk_sync = (f & SPLINEFLAG_WALKMODE) != (m_splineFlags & SPLINEFLAG_WALKMODE);
469 m_splineFlags = f; // need set before
470 if (need_walk_sync)
471 UpdateWalkMode(this, false);
474 void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
476 uint32 GetShieldBlockValue() const //dunno mob block value
478 return (getLevel() / 2 + uint32(GetStat(STAT_STRENGTH) / 20));
481 SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
482 void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
484 void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
485 void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
486 void AddCreatureSpellCooldown(uint32 spellid);
487 bool HasSpellCooldown(uint32 spell_id) const;
488 bool HasCategoryCooldown(uint32 spell_id) const;
490 bool HasSpell(uint32 spellID) const;
492 bool UpdateEntry(uint32 entry, uint32 team = ALLIANCE, const CreatureData* data = NULL, bool preserveHPAndPower = true);
493 bool UpdateStats(Stats stat);
494 bool UpdateAllStats();
495 void UpdateResistances(uint32 school);
496 void UpdateArmor();
497 void UpdateMaxHealth();
498 void UpdateMaxPower(Powers power);
499 void UpdateAttackPowerAndDamage(bool ranged = false);
500 void UpdateDamagePhysical(WeaponAttackType attType);
501 uint32 GetCurrentEquipmentId() { return m_equipmentId; }
502 float GetSpellDamageMod(int32 Rank);
504 VendorItemData const* GetVendorItems() const;
505 uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
506 uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
508 TrainerSpellData const* GetTrainerSpells() const;
510 CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
511 CreatureDataAddon const* GetCreatureAddon() const;
513 std::string GetAIName() const;
514 std::string GetScriptName() const;
515 uint32 GetScriptId() const;
517 void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
518 void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
519 void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); }
520 void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); }
521 void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
523 // overwrite WorldObject function for proper name localization
524 const char* GetNameForLocaleIdx(int32 locale_idx) const;
526 void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState
527 bool FallGround();
529 bool LoadFromDB(uint32 guid, Map *map);
530 void SaveToDB();
531 // overwrited in Pet
532 virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
533 virtual void DeleteFromDB(); // overwrited in Pet
535 Loot loot;
536 bool lootForPickPocketed;
537 bool lootForBody;
538 bool lootForSkin;
540 void PrepareBodyLootState();
541 ObjectGuid GetLootRecipientGuid() const { return m_lootRecipientGuid; }
542 uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; }
543 Player* GetLootRecipient() const; // use group cases as prefered
544 Group* GetGroupLootRecipient() const;
545 bool HasLootRecipient() const { return m_lootGroupRecipientId || !m_lootRecipientGuid.IsEmpty(); }
546 bool IsGroupLootRecipient() const { return m_lootGroupRecipientId; }
547 void SetLootRecipient(Unit* unit);
548 void AllLootRemovedFromCorpse();
549 Player* GetOriginalLootRecipient() const; // ignore group changes/etc, not for looting
551 SpellEntry const *reachWithSpellAttack(Unit *pVictim);
552 SpellEntry const *reachWithSpellCure(Unit *pVictim);
554 uint32 m_spells[CREATURE_MAX_SPELLS];
555 CreatureSpellCooldowns m_CreatureSpellCooldowns;
556 CreatureSpellCooldowns m_CreatureCategoryCooldowns;
557 uint32 m_GlobalCooldown;
559 float GetAttackDistance(Unit const* pl) const;
561 void SendAIReaction(AiReaction reactionType);
563 void DoFleeToGetAssistance();
564 void CallForHelp(float fRadius);
565 void CallAssistance();
566 void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
567 void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; }
568 bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; }
569 bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
570 bool CanInitiateAttack();
572 MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
573 void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
575 // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
576 Cell const& GetCurrentCell() const { return m_currentCell; }
577 void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
579 bool IsVisibleInGridForPlayer(Player* pl) const;
581 void RemoveCorpse();
582 bool isDeadByDefault() const { return m_isDeadByDefault; };
584 void ForcedDespawn(uint32 timeMSToDespawn = 0);
586 time_t const& GetRespawnTime() const { return m_respawnTime; }
587 time_t GetRespawnTimeEx() const;
588 void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
589 void Respawn();
590 void SaveRespawnTime();
592 uint32 GetRespawnDelay() const { return m_respawnDelay; }
593 void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
595 float GetRespawnRadius() const { return m_respawnradius; }
596 void SetRespawnRadius(float dist) { m_respawnradius = dist; }
598 void StartGroupLoot(Group* group, uint32 timer);
600 void SendZoneUnderAttackMessage(Player* attacker);
602 void SetInCombatWithZone();
604 Unit* SelectAttackingTarget(AttackingTarget target, uint32 position) const;
606 bool hasQuest(uint32 quest_id) const;
607 bool hasInvolvedQuest(uint32 quest_id) const;
609 GridReference<Creature> &GetGridRef() { return m_gridRef; }
610 bool isRegeneratingHealth() { return m_regenHealth; }
611 virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
612 virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
614 if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
615 return 0;
616 else
617 return m_charmInfo->GetCharmSpell(pos)->GetAction();
620 void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; }
621 void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; }
623 void SetSummonPoint(float fX, float fY, float fZ, float fOrient) { m_summonXpoint = fX; m_summonYpoint = fY; m_summonZpoint = fZ; m_summonOrientation = fOrient; }
624 void GetSummonPoint(float &fX, float &fY, float &fZ, float &fOrient) const { fX = m_summonXpoint; fY = m_summonYpoint; fZ = m_summonZpoint; fOrient = m_summonOrientation; }
626 uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
628 void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; }
630 bool isActiveObject() const { return m_isActiveObject || HasAuraType(SPELL_AURA_BIND_SIGHT) || HasAuraType(SPELL_AURA_FAR_SIGHT); }
631 void SetActiveObjectState(bool on);
633 void SetNeedNotify() { m_needNotify = true; }
635 void SendAreaSpiritHealerQueryOpcode(Player *pl);
637 protected:
638 bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
639 bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
640 void RelocationNotify();
642 uint32 m_groupLootTimer; // (msecs)timer used for group loot
643 uint32 m_groupLootId; // used to find group which is looting corpse
644 void StopGroupLoot();
646 // vendor items
647 VendorItemCounts m_vendorItemCounts;
649 void _RealtimeSetCreatureInfo();
651 static float _GetHealthMod(int32 Rank);
652 static float _GetDamageMod(int32 Rank);
654 uint32 m_lootMoney;
655 ObjectGuid m_lootRecipientGuid; // player who will have rights for looting if m_lootGroupRecipient==0 or group disbanded
656 uint32 m_lootGroupRecipientId; // group who will have rights for looting if set and exist
658 /// Timers
659 uint32 m_deathTimer; // (msecs)timer for death or corpse disappearance
660 time_t m_respawnTime; // (secs) time of next respawn
661 uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
662 uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
663 float m_respawnradius;
665 CreatureSubtype m_subtype; // set in Creatures subclasses for fast it detect without dynamic_cast use
666 void RegenerateMana();
667 void RegenerateHealth();
668 MovementGeneratorType m_defaultMovementType;
669 Cell m_currentCell; // store current cell where creature listed
670 uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
671 uint32 m_equipmentId;
673 bool m_AlreadyCallAssistance;
674 bool m_AlreadySearchedAssistance;
675 bool m_regenHealth;
676 bool m_AI_locked;
677 bool m_isDeadByDefault;
678 bool m_needNotify;
680 SpellSchoolMask m_meleeDamageSchoolMask;
681 uint32 m_originalEntry;
683 float CombatStartX;
684 float CombatStartY;
685 float CombatStartZ;
687 float m_summonXpoint;
688 float m_summonYpoint;
689 float m_summonZpoint;
690 float m_summonOrientation;
692 private:
693 GridReference<Creature> m_gridRef;
694 CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from ObjMgr::GetCreatureTemplate(GetEntry())
695 bool m_isActiveObject;
696 SplineFlags m_splineFlags;
699 class AssistDelayEvent : public BasicEvent
701 public:
702 AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
704 bool Execute(uint64 e_time, uint32 p_time);
705 void AddAssistant(const uint64& guid) { m_assistants.push_back(guid); }
706 private:
707 AssistDelayEvent();
709 uint64 m_victim;
710 std::list<uint64> m_assistants;
711 Unit& m_owner;
714 class ForcedDespawnDelayEvent : public BasicEvent
716 public:
717 ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
718 bool Execute(uint64 e_time, uint32 p_time);
720 private:
721 Creature& m_owner;
724 #endif