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

Revision 168, 24.0 kB (checked in by yumileroy, 17 years ago)

[svn] *** Source Mangos ***
*Load npc_options at server startup, use cached data at creature gossip menu init.
* Also new .reload table command added
*Implement npc_option localization support, also store in DB BoxText/BoxMoney/Coded?
* Use characters.guid instead low guid value from characters.data in charcter enum data prepering for client.
* Fixed crash at .pinfo command use from console.
* Fixed windows ad.exe build
*Creature related code and DB cleanups.
* Rename 2 creature_template fields to more clean names and related code update also.
* Use enum values instead raw values for type_flags, use halper functions instead code repeating.
* Move tamed pet creating code to new function.

** Small code changes to make things compliant with above changes.
** Another rev with big changes so test away.

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