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

Revision 230, 24.5 kB (checked in by yumileroy, 17 years ago)

[svn] *** Source: MaNGOS ***
* Implement localization of creature/gameobject name that say/yell. Author: evilstar (rewrited by: Vladimir)
* Fix auth login queue. Author: Derex
* Allowed switching INVTYPE_HOLDABLE items during combat, used correct spells for triggering global cooldown at weapon switch. Author: mobel/simak
* Fixed some format arg type/value pairs. Other warnings. Author: Vladimir
* [238_world.sql] Allow have team dependent graveyards at entrance map for instances. Author: Vladimir

NOTE:
Entrance map graveyards selected by same way as local (by distance from entrance) Until DB support will work in old way base at current DB data.

Original author: visagalis
Date: 2008-11-14 17:03:03-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    CreatureAI *i_AI_possessed;
399
400    public:
401
402        explicit Creature();
403        virtual ~Creature();
404
405        void AddToWorld();
406        void RemoveFromWorld();
407
408        bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data = NULL);
409        bool LoadCreaturesAddon(bool reload = false);
410        void SelectLevel(const CreatureInfo *cinfo);
411        void LoadEquipment(uint32 equip_entry, bool force=false);
412
413        uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
414        char const* GetSubName() const { return GetCreatureInfo()->SubName; }
415
416        void Update( uint32 time );                         // overwrited Unit::Update
417        void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
418        uint32 GetEquipmentId() const { return m_equipmentId; }
419
420        bool isPet() const { return m_isPet; }
421        void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
422        bool isTotem() const { return m_isTotem; }
423        bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
424        bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
425        bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
426        bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
427        bool canFly()  const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
428        ///// TODO RENAME THIS!!!!!
429        bool isCanTrainingOf(Player* player, bool msg) const;
430        bool isCanIneractWithBattleMaster(Player* player, bool msg) const;
431        bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
432        bool IsOutOfThreatArea(Unit* pVictim) const;
433        bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false);
434                                                            // redefine Unit::IsImmunedToSpell
435        bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const;
436                                                            // redefine Unit::IsImmunedToSpellEffect
437        bool isElite() const
438        {
439            if(isPet())
440                return false;
441
442            uint32 rank = GetCreatureInfo()->rank;
443            return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
444        }
445
446        bool isWorldBoss() const
447        {
448            if(isPet())
449                return false;
450
451            return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
452        }
453
454        uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
455
456        bool IsInEvadeMode() const;
457
458        bool AIM_Initialize();
459        void InitPossessedAI();
460        void DeletePossessedAI();
461
462        void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
463        CreatureAI* AI() { return isPossessed() && i_AI_possessed ? i_AI_possessed : i_AI; }
464
465        uint32 GetShieldBlockValue() const                  //dunno mob block value
466        {
467            return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
468        }
469
470        SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
471        void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
472
473        void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time);
474        void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time);
475        void AddCreatureSpellCooldown(uint32 spellid);
476        bool HasSpellCooldown(uint32 spell_id) const;
477        bool HasCategoryCooldown(uint32 spell_id) const;
478
479        bool HasSpell(uint32 spellID) const;
480
481        bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
482        bool UpdateStats(Stats stat);
483        bool UpdateAllStats();
484        void UpdateResistances(uint32 school);
485        void UpdateArmor();
486        void UpdateMaxHealth();
487        void UpdateMaxPower(Powers power);
488        void UpdateAttackPowerAndDamage(bool ranged = false);
489        void UpdateDamagePhysical(WeaponAttackType attType);
490        uint32 GetCurrentEquipmentId() { return m_equipmentId; }
491        float GetSpellDamageMod(int32 Rank);
492
493        VendorItemData const* GetVendorItems() const;
494        uint32 GetVendorItemCurrentCount(VendorItem const* vItem);
495        uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count);
496
497        TrainerSpellData const* GetTrainerSpells() const;
498
499        CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
500        CreatureDataAddon const* GetCreatureAddon() const;
501        char const* GetScriptName() const;
502
503        void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 );
504        void sendPreparedGossip( Player* player );
505        void OnGossipSelect(Player* player, uint32 option);
506        void OnPoiSelect(Player* player, GossipOption const *gossip);
507
508        uint32 GetGossipTextId(uint32 action, uint32 zoneid);
509        uint32 GetNpcTextId();
510        void LoadGossipOptions();
511        void ResetGossipOptions();
512        GossipOption const* GetGossipOption( uint32 id ) const;
513        void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); }
514
515        void setEmoteState(uint8 emote) { m_emoteState = emote; };
516        void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text,language,TargetGuid); }
517        void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text,language,TargetGuid); }
518        void TextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(text,TargetGuid,IsBossEmote); }
519        void Whisper(const char* text, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(text,receiver,IsBossWhisper); }
520        void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
521        void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
522        void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); }
523        void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); }
524
525        // overwrite WorldObject function for proper name localization
526        const char* GetNameForLocaleIdx(int32 locale_idx) const;
527   
528        void setDeathState(DeathState s);                   // overwrite virtual Unit::setDeathState
529
530        bool LoadFromDB(uint32 guid, Map *map);
531        void SaveToDB();
532                                                            // overwrited in Pet
533        virtual void SaveToDB(uint32 mapid, uint8 spawnMask);
534        virtual void DeleteFromDB();                        // overwrited in Pet
535
536        Loot loot;
537        bool lootForPickPocketed;
538        bool lootForBody;
539        Player *GetLootRecipient() const;
540        bool hasLootRecipient() const { return m_lootRecipient!=0; }
541
542        void SetLootRecipient (Unit* unit);
543        void AllLootRemovedFromCorpse();
544
545        SpellEntry const *reachWithSpellAttack(Unit *pVictim);
546        SpellEntry const *reachWithSpellCure(Unit *pVictim);
547
548        uint32 m_spells[CREATURE_MAX_SPELLS];
549        CreatureSpellCooldowns m_CreatureSpellCooldowns;
550        CreatureSpellCooldowns m_CreatureCategoryCooldowns;
551        uint32 m_GlobalCooldown;
552
553        bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const;
554        bool IsWithinSightDist(Unit const* u) const;
555        float GetAttackDistance(Unit const* pl) const;
556
557        void CallAssistence();
558        void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; }
559        void DoFleeToGetAssistance(float radius = 50);
560
561        MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
562        void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
563
564        // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
565        Cell const& GetCurrentCell() const { return m_currentCell; }
566        void SetCurrentCell(Cell const& cell) { m_currentCell = cell; }
567
568        bool IsVisibleInGridForPlayer(Player const* pl) const;
569
570        void RemoveCorpse();
571
572        time_t const& GetRespawnTime() const { return m_respawnTime; }
573        time_t GetRespawnTimeEx() const;
574        void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
575        void Respawn();
576        void SaveRespawnTime();
577
578        uint32 GetRespawnDelay() const { return m_respawnDelay; }
579        void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; }
580
581        float GetRespawnRadius() const { return m_respawnradius; }
582        void SetRespawnRadius(float dist) { m_respawnradius = dist; }
583
584        uint32 m_groupLootTimer;                            // (msecs)timer used for group loot
585        uint64 lootingGroupLeaderGUID;                      // used to find group which is looting corpse
586
587        void SendZoneUnderAttackMessage(Player* attacker);
588
589        bool hasQuest(uint32 quest_id) const;
590        bool hasInvolvedQuest(uint32 quest_id)  const;
591
592        GridReference<Creature> &GetGridRef() { return m_gridRef; }
593        bool isRegeneratingHealth() { return m_regenHealth; }
594        virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
595        virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
596        {
597            if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->active != ACT_ENABLED)
598                return 0;
599            else
600                return m_charmInfo->GetCharmSpell(pos)->spellId;
601        }
602
603        void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; }
604        void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; }
605
606        uint32 GetGlobalCooldown() const { return m_GlobalCooldown; }
607
608    protected:
609        bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
610        bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
611
612        // vendor items
613        VendorItemCounts m_vendorItemCounts;
614
615        void _RealtimeSetCreatureInfo();
616
617        static float _GetHealthMod(int32 Rank);
618        static float _GetDamageMod(int32 Rank);
619
620        uint32 m_lootMoney;
621        uint64 m_lootRecipient;
622
623        /// Timers
624        uint32 m_deathTimer;                                // (msecs)timer for death or corpse disappearance
625        time_t m_respawnTime;                               // (secs) time of next respawn
626        uint32 m_respawnDelay;                              // (secs) delay between corpse disappearance and respawning
627        uint32 m_corpseDelay;                               // (secs) delay between death and corpse disappearance
628        float m_respawnradius;
629
630        bool m_gossipOptionLoaded;
631        GossipOptionList m_goptions;
632
633        uint8 m_emoteState;
634        bool m_isPet;                                       // set only in Pet::Pet
635        bool m_isTotem;                                     // set only in Totem::Totem
636        void RegenerateMana();
637        void RegenerateHealth();
638        uint32 m_regenTimer;
639        MovementGeneratorType m_defaultMovementType;
640        Cell m_currentCell;                                 // store current cell where creature listed
641        uint32 m_DBTableGuid;                               ///< For new or temporary creatures is 0 for saved it is lowguid
642        uint32 m_equipmentId;
643
644        bool m_AlreadyCallAssistence;
645        bool m_regenHealth;
646        bool m_AI_locked;
647        bool m_isDeadByDefault;
648
649        SpellSchoolMask m_meleeDamageSchoolMask;
650        uint32 m_originalEntry;
651
652        float CombatStartX;
653        float CombatStartY;
654        float CombatStartZ;
655    private:
656        GridReference<Creature> m_gridRef;
657        CreatureInfo const* m_creatureInfo;                 // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
658};
659#endif
Note: See TracBrowser for help on using the browser.