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