root/trunk/src/game/Creature.h @ 135

Revision 135, 23.1 kB (checked in by yumileroy, 17 years ago)

[svn] Merge from mangos.
Wed Oct 29 15:06:00 http://github.com/mangos/mangos/commit/034b8a34a9b621443e97d0ac4b667b603ba31ef1
Mon Oct 27 14:36:42 http://github.com/mangos/mangos/commit/fa072d15107b44344af8c9ef686839984e241a1b

Original author: megamage
Date: 2008-10-29 18:06:01-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef TRINITYCORE_CREATURE_H
22#define TRINITYCORE_CREATURE_H
23
24#include "Common.h"
25#include "Unit.h"
26#include "UpdateMask.h"
27#include "ItemPrototype.h"
28#include "LootMgr.h"
29#include "Database/DatabaseEnv.h"
30#include "Cell.h"
31
32struct SpellEntry;
33
34class CreatureAI;
35class Quest;
36class Player;
37class WorldSession;
38
39enum Gossip_Option
40{
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)
59    GOSSIP_OPTION_OUTDOORPVP        = 18                    //added by code (option for outdoor pvp creatures)
60};
61
62enum Gossip_Guard
63{
64    GOSSIP_GUARD_BANK               = 32,
65    GOSSIP_GUARD_RIDE               = 33,
66    GOSSIP_GUARD_GUILD              = 34,
67    GOSSIP_GUARD_INN                = 35,
68    GOSSIP_GUARD_MAIL               = 36,
69    GOSSIP_GUARD_AUCTION            = 37,
70    GOSSIP_GUARD_WEAPON             = 38,
71    GOSSIP_GUARD_STABLE             = 39,
72    GOSSIP_GUARD_BATTLE             = 40,
73    GOSSIP_GUARD_SPELLTRAINER       = 41,
74    GOSSIP_GUARD_SKILLTRAINER       = 42
75};
76
77enum Gossip_Guard_Spell
78{
79    GOSSIP_GUARD_SPELL_WARRIOR      = 64,
80    GOSSIP_GUARD_SPELL_PALADIN      = 65,
81    GOSSIP_GUARD_SPELL_HUNTER       = 66,
82    GOSSIP_GUARD_SPELL_ROGUE        = 67,
83    GOSSIP_GUARD_SPELL_PRIEST       = 68,
84    GOSSIP_GUARD_SPELL_UNKNOWN1     = 69,
85    GOSSIP_GUARD_SPELL_SHAMAN       = 70,
86    GOSSIP_GUARD_SPELL_MAGE         = 71,
87    GOSSIP_GUARD_SPELL_WARLOCK      = 72,
88    GOSSIP_GUARD_SPELL_UNKNOWN2     = 73,
89    GOSSIP_GUARD_SPELL_DRUID        = 74
90};
91
92enum Gossip_Guard_Skill
93{
94    GOSSIP_GUARD_SKILL_ALCHEMY      = 80,
95    GOSSIP_GUARD_SKILL_BLACKSMITH   = 81,
96    GOSSIP_GUARD_SKILL_COOKING      = 82,
97    GOSSIP_GUARD_SKILL_ENCHANT      = 83,
98    GOSSIP_GUARD_SKILL_FIRSTAID     = 84,
99    GOSSIP_GUARD_SKILL_FISHING      = 85,
100    GOSSIP_GUARD_SKILL_HERBALISM    = 86,
101    GOSSIP_GUARD_SKILL_LEATHER      = 87,
102    GOSSIP_GUARD_SKILL_MINING       = 88,
103    GOSSIP_GUARD_SKILL_SKINNING     = 89,
104    GOSSIP_GUARD_SKILL_TAILORING    = 90,
105    GOSSIP_GUARD_SKILL_ENGINERING   = 91
106};
107
108struct GossipOption
109{
110    uint32 Id;
111    uint32 GossipId;
112    uint32 NpcFlag;
113    uint32 Icon;
114    uint32 Action;
115    std::string Option;
116};
117
118enum CreatureFlagsExtra
119{
120    CREATURE_FLAG_EXTRA_INSTANCE_BIND   = 0x00000001,       // creature kill bind instance with killer and killer's group
121    CREATURE_FLAG_EXTRA_CIVILIAN        = 0x00000002,       // not aggro (ignore faction/reputation hostility)
122    CREATURE_FLAG_EXTRA_NO_PARRY        = 0x00000004,       // creature can't parry
123    CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008,       // creature can't counter-attack at parry
124    CREATURE_FLAG_EXTRA_NO_BLOCK        = 0x00000010,       // creature can't block
125    CREATURE_FLAG_EXTRA_NO_CRUSH        = 0x00000020,       // creature can't do crush attacks
126    CREATURE_FLAG_EXTRA_NO_XP_AT_KILL   = 0x00000040,       // creature kill not provide XP
127    CREATURE_FLAG_EXTRA_TRIGGER         = 0x00000080,       // trigger creature
128    CREATURE_FLAG_EXTRA_WORLDEVENT      = 0x00004000,       // custom flag for world event creatures (left room for merging)
129};
130
131// 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
132#if defined( __GNUC__ )
133#pragma pack(1)
134#else
135#pragma pack(push,1)
136#endif
137
138// from `creature_template` table
139struct CreatureInfo
140{
141    uint32  Entry;
142    uint32  HeroicEntry;
143    uint32  Modelid1;
144    uint32  Modelid2;
145    uint32  Modelid3;
146    uint32  Modelid4;
147    char*   Name;
148    char*   SubName;
149    char*   IconName;
150    uint32  minlevel;
151    uint32  maxlevel;
152    uint32  minhealth;
153    uint32  maxhealth;
154    uint32  minmana;
155    uint32  maxmana;
156    uint32  armor;
157    uint32  faction_A;
158    uint32  faction_H;
159    uint32  npcflag;
160    float   speed;
161    float   scale;
162    uint32  rank;
163    float   mindmg;
164    float   maxdmg;
165    uint32  dmgschool;
166    uint32  attackpower;
167    uint32  baseattacktime;
168    uint32  rangeattacktime;
169    uint32  Flags;
170    uint32  dynamicflags;
171    uint32  family;
172    uint32  trainer_type;
173    uint32  trainer_spell;
174    uint32  classNum;
175    uint32  race;
176    float   minrangedmg;
177    float   maxrangedmg;
178    uint32  rangedattackpower;
179    uint32  type;
180    uint32  flag1;
181    uint32  lootid;
182    uint32  pickpocketLootId;
183    uint32  SkinLootId;
184    int32   resistance1;
185    int32   resistance2;
186    int32   resistance3;
187    int32   resistance4;
188    int32   resistance5;
189    int32   resistance6;
190    uint32  spell1;
191    uint32  spell2;
192    uint32  spell3;
193    uint32  spell4;
194    uint32  PetSpellDataId;
195    uint32  mingold;
196    uint32  maxgold;
197    char const* AIName;
198    uint32  MovementType;
199    uint32  InhabitType;
200    bool    RacialLeader;
201    bool    RegenHealth;
202    uint32  equipmentId;
203    uint32  MechanicImmuneMask;
204    uint32  flags_extra;
205    char const* ScriptName;
206    uint32 GetRandomValidModelId() const;
207    uint32 GetFirstValidModelId() const;
208};
209
210struct CreatureLocale
211{
212    std::vector<std::string> Name;
213    std::vector<std::string> SubName;
214};
215
216struct EquipmentInfo
217{
218    uint32  entry;
219    uint32  equipmodel[3];
220    uint32  equipinfo[3];
221    uint32  equipslot[3];
222};
223
224// from `creature` table
225struct CreatureData
226{
227    uint32 id;                                              // entry in creature_template
228    uint16 mapid;
229    uint32 displayid;
230    int32 equipmentId;
231    float posX;
232    float posY;
233    float posZ;
234    float orientation;
235    uint32 spawntimesecs;
236    float spawndist;
237    uint32 currentwaypoint;
238    uint32 curhealth;
239    uint32 curmana;
240    bool  is_dead;
241    uint8 movementType;
242    uint8 spawnMask;
243};
244
245struct CreatureDataAddonAura
246{
247    uint16 spell_id;
248    uint8 effect_idx;
249};
250
251// from `creature_addon` table
252struct CreatureDataAddon
253{
254    uint32 guidOrEntry;
255    uint32 mount;
256    uint32 bytes0;
257    uint32 bytes1;
258    uint32 bytes2;
259    uint32 emote;
260    uint32 move_flags;
261    CreatureDataAddonAura const* auras;                     // loaded as char* "spell1 eff1 spell2 eff2 ... "
262};
263
264struct CreatureModelInfo
265{
266    uint32 modelid;
267    float bounding_radius;
268    float combat_reach;
269    uint8 gender;
270    uint32 modelid_other_gender;
271};
272
273enum InhabitTypeValues
274{
275    INHABIT_GROUND = 1,
276    INHABIT_WATER  = 2,
277    INHABIT_AIR    = 4,
278    INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR
279};
280
281// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
282#if defined( __GNUC__ )
283#pragma pack()
284#else
285#pragma pack(pop)
286#endif
287
288// Vendors
289struct VendorItem
290{
291    VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)
292        : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {}
293
294    uint32 item;
295    uint32 maxcount;                                        // 0 for infinity item amount
296    uint32 incrtime;                                        // time for restore items amount if maxcount != 0
297    uint32 ExtendedCost;
298};
299typedef std::vector<VendorItem*> VendorItemList;
300
301struct VendorItemData
302{
303    VendorItemList m_items;
304
305    VendorItem* GetItem(uint32 slot) const
306    {
307        if(slot>=m_items.size()) return NULL;
308        return m_items[slot];
309    }
310    bool Empty() const { return m_items.empty(); }
311    uint8 GetItemCount() const { return m_items.size(); }
312    void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
313    {
314        m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
315    }
316    bool RemoveItem( uint32 item_id );
317    VendorItem const* FindItem(uint32 item_id) const;
318    size_t FindItemSlot(uint32 item_id) const;
319
320    void Clear()
321    {
322        for (VendorItemList::iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
323            delete (*itr);
324    }
325};
326
327struct VendorItemCount
328{
329    explicit VendorItemCount(uint32 _item, uint32 _count)
330        : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
331
332    uint32 itemId;
333    uint32 count;
334    time_t lastIncrementTime;
335};
336
337typedef std::list<VendorItemCount> VendorItemCounts;
338
339struct TrainerSpell
340{
341    uint32 spell;
342    uint32 spellcost;
343    uint32 reqskill;
344    uint32 reqskillvalue;
345    uint32 reqlevel;
346};
347
348typedef std::vector<TrainerSpell*> TrainerSpellList;
349
350struct TrainerSpellData
351{
352    TrainerSpellData() : trainerType(0) {}
353
354    TrainerSpellList spellList;
355    uint32 trainerType;                                     // trainer type based at trainer spells, can be different from creature_template value.
356                                                            // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
357
358    void Clear();
359    TrainerSpell const* Find(uint32 spell_id) const;
360};
361
362typedef std::list<GossipOption> GossipOptionList;
363
364typedef std::map<uint32,time_t> CreatureSpellCooldowns;
365
366// max different by z coordinate for creature aggro reaction
367#define CREATURE_Z_ATTACK_RANGE 3
368
369#define MAX_VENDOR_ITEMS 255                                // Limitation in item count field size in SMSG_LIST_INVENTORY
370
371class TRINITY_DLL_SPEC Creature : public Unit
372{
373    CreatureAI *i_AI;
374
375    public:
376
377        explicit Creature();
378        virtual ~Creature();
379
380        void AddToWorld();
381        void RemoveFromWorld();
382
383        bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data = NULL);
384        bool LoadCreaturesAddon(bool reload = false);
385        void SelectLevel(const CreatureInfo *cinfo);
386        void LoadEquipment(uint32 equip_entry, bool force=false);
387
388        uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
389        char const* GetSubName() const { return GetCreatureInfo()->SubName; }
390
391        void Update( uint32 time );                         // overwrited Unit::Update
392        void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
393        uint32 GetEquipmentId() const { return m_equipmentId; }
394
395        bool isPet() const { return m_isPet; }
396        void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
397        bool isTotem() const { return m_isTotem; }
398        bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
399        bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
400        bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
401        bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
402        bool canFly()  const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
403        ///// TODO RENAME THIS!!!!!
404        bool isCanTrainingOf(Player* player, bool msg) const;
405        bool isCanIneractWithBattleMaster(Player* player, bool msg) const;
406        bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
407        bool IsOutOfThreatArea(Unit* pVictim) const;
408        bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false);
409                                                            // redefine Unit::IsImmunedToSpell
410        bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const;
411                                                            // redefine Unit::IsImmunedToSpellEffect
412        bool isElite() const
413        {
414            if(isPet())
415                return false;
416
417            uint32 rank = GetCreatureInfo()->rank;
418            return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
419        }
420
421        bool isWorldBoss() const
422        {
423            if(isPet())
424                return false;
425
426            return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
427        }
428
429        uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
430
431        bool IsInEvadeMode() const;
432
433        bool AIM_Initialize();
434
435        void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
436        CreatureAI* AI() { return i_AI; }
437
438        uint32 GetShieldBlockValue() const                  //dunno mob block value
439        {
440            return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
441        }
442
443        SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
444        void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
445
446        void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
447        void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
448        void AddCreatureSpellCooldown(uint32 spellid);
449        bool HasSpellCooldown(uint32 spell_id) const;
450        bool HasCategoryCooldown(uint32 spell_id) const;
451
452        bool HasSpell(uint32 spellID) const;
453
454        bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
455        bool UpdateStats(Stats stat);
456        bool UpdateAllStats();
457        void UpdateResistances(uint32 school);
458        void UpdateArmor();
459        void UpdateMaxHealth();
460        void UpdateMaxPower(Powers power);
461        void UpdateAttackPowerAndDamage(bool ranged = false);
462        void UpdateDamagePhysical(WeaponAttackType attType);
463        uint32 GetCurrentEquipmentId() { return m_equipmentId; }
464        float GetSpellDamageMod(int32 Rank);
465
466        VendorItemData const* GetVendorItems() const;
467        uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
468        uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
469
470        TrainerSpellData const* GetTrainerSpells() const;
471
472        CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
473        CreatureDataAddon const* GetCreatureAddon() const;
474        char const* GetScriptName() const;
475
476        void prepareGossipMenu( Player *pPlayer,uint32 gossipid );
477        void sendPreparedGossip( Player* player);
478        void OnGossipSelect(Player* player, uint32 option);
479        void OnPoiSelect(Player* player, GossipOption const *gossip);
480
481        uint32 GetGossipTextId(uint32 action, uint32 zoneid);
482        uint32 GetNpcTextId();
483        void LoadGossipOptions();
484        void ResetGossipOptions();
485        GossipOption const* GetGossipOption( uint32 id ) const;
486        void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); }
487
488        void setEmoteState(uint8 emote) { m_emoteState = emote; };
489        void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text,language,TargetGuid); }
490        void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text,language,TargetGuid); }
491        void TextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(text,TargetGuid,IsBossEmote); }
492        void Whisper(const char* text, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(text,receiver,IsBossWhisper); }
493        void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
494        void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
495        void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); }
496        void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); }
497
498        void setDeathState(DeathState s);                   // overwrite virtual Unit::setDeathState
499
500        bool LoadFromDB(uint32 guid, Map *map);
501        void SaveToDB();
502                                                            // overwrited in Pet
503        virtual void SaveToDB(uint32 mapid, uint8 spawnMask);
504        virtual void DeleteFromDB();                        // overwrited in Pet
505
506        Loot loot;
507        bool lootForPickPocketed;
508        bool lootForBody;
509        Player *GetLootRecipient() const;
510        bool hasLootRecipient() const { return m_lootRecipient!=0; }
511
512        void SetLootRecipient (Unit* unit);
513        void AllLootRemovedFromCorpse();
514
515        SpellEntry const *reachWithSpellAttack(Unit *pVictim);
516        SpellEntry const *reachWithSpellCure(Unit *pVictim);
517
518        uint32 m_spells[CREATURE_MAX_SPELLS];
519        CreatureSpellCooldowns m_CreatureSpellCooldowns;
520        CreatureSpellCooldowns m_CreatureCategoryCooldowns;
521        uint32 m_GlobalCooldown;
522
523        float GetAttackDistance(Unit const* pl) const;
524
525        void CallAssistence();
526        void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; }
527        void DoFleeToGetAssistance(float radius = 50);
528
529        MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
530        void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
531
532        // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
533        Cell const& GetCurrentCell() const { return m_currentCell; }
534        void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
535
536        bool IsVisibleInGridForPlayer(Player* pl) const;
537
538        void RemoveCorpse();
539
540        time_t const& GetRespawnTime() const { return m_respawnTime; }
541        time_t GetRespawnTimeEx() const;
542        void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
543        void Respawn();
544        void SaveRespawnTime();
545
546        uint32 GetRespawnDelay() const { return m_respawnDelay; }
547        void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
548
549        float GetRespawnRadius() const { return m_respawnradius; }
550        void SetRespawnRadius(float dist) { m_respawnradius = dist; }
551
552        uint32 m_groupLootTimer;                            // (msecs)timer used for group loot
553        uint64 lootingGroupLeaderGUID;                      // used to find group which is looting corpse
554
555        void SendZoneUnderAttackMessage(Player* attacker);
556
557        bool hasQuest(uint32 quest_id) const;
558        bool hasInvolvedQuest(uint32 quest_id)  const;
559
560        GridReference<Creature> &GetGridRef() { return m_gridRef; }
561        bool isRegeneratingHealth() { return m_regenHealth; }
562        virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
563        virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
564        {
565            if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->active != ACT_ENABLED)
566                return 0;
567            else
568                return m_charmInfo->GetCharmSpell(pos)->spellId;
569        }
570
571        void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; }
572        void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; }
573
574        uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
575
576    protected:
577        bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
578        bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
579
580        // vendor items
581        VendorItemCounts m_vendorItemCounts;
582
583        void _RealtimeSetCreatureInfo();
584
585        static float _GetHealthMod(int32 Rank);
586        static float _GetDamageMod(int32 Rank);
587
588        uint32 m_lootMoney;
589        uint64 m_lootRecipient;
590
591        /// Timers
592        uint32 m_deathTimer;                                // (msecs)timer for death or corpse disappearance
593        time_t m_respawnTime;                               // (secs) time of next respawn
594        uint32 m_respawnDelay;                              // (secs) delay between corpse disappearance and respawning
595        uint32 m_corpseDelay;                               // (secs) delay between death and corpse disappearance
596        float m_respawnradius;
597
598        bool m_gossipOptionLoaded;
599        GossipOptionList m_goptions;
600
601        uint8 m_emoteState;
602        bool m_isPet;                                       // set only in Pet::Pet
603        bool m_isTotem;                                     // set only in Totem::Totem
604        void RegenerateMana();
605        void RegenerateHealth();
606        uint32 m_regenTimer;
607        MovementGeneratorType m_defaultMovementType;
608        Cell m_currentCell;                                 // store current cell where creature listed
609        uint32 m_DBTableGuid;                               ///< For new or temporary creatures is 0 for saved it is lowguid
610        uint32 m_equipmentId;
611
612        bool m_AlreadyCallAssistence;
613        bool m_regenHealth;
614        bool m_AI_locked;
615        bool m_isDeadByDefault;
616
617        SpellSchoolMask m_meleeDamageSchoolMask;
618        uint32 m_originalEntry;
619
620        float CombatStartX;
621        float CombatStartY;
622        float CombatStartZ;
623    private:
624        GridReference<Creature> m_gridRef;
625        CreatureInfo const* m_creatureInfo;                 // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
626};
627#endif
Note: See TracBrowser for help on using the browser.