diff options
Diffstat (limited to 'src/game/Creature.h')
-rw-r--r-- | src/game/Creature.h | 161 |
1 files changed, 115 insertions, 46 deletions
diff --git a/src/game/Creature.h b/src/game/Creature.h index b25893b5ba9..2f583e25be0 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,6 @@ #include "LootMgr.h" #include "Database/DatabaseEnv.h" #include "Cell.h" -#include "CreatureGroups.h" #include <list> @@ -109,6 +108,21 @@ enum Gossip_Guard_Skill GOSSIP_GUARD_SKILL_ENGINERING = 91 }; +enum GossipOptionIcon +{ + GOSSIP_ICON_CHAT = 0, //white chat bubble + GOSSIP_ICON_VENDOR = 1, //brown bag + GOSSIP_ICON_TAXI = 2, //flight + GOSSIP_ICON_TRAINER = 3, //book + GOSSIP_ICON_INTERACT_1 = 4, //interaction wheel + GOSSIP_ICON_INTERACT_2 = 5, //interaction wheel + GOSSIP_ICON_MONEY_BAG = 6, //brown bag with yellow dot + GOSSIP_ICON_TALK = 7, //white chat bubble with black dots + GOSSIP_ICON_TABARD = 8, //tabard + GOSSIP_ICON_BATTLE = 9, //two swords + GOSSIP_ICON_DOT = 10 //yellow dot +}; + struct GossipOption { uint32 Id; @@ -132,12 +146,23 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature + CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00000100, // creature is immune to taunt auras and effect attack me CREATURE_FLAG_EXTRA_WORLDEVENT = 0x00004000, // custom flag for world event creatures (left room for merging) //CREATURE_FLAG_EXTRA_CHARM_AI = 0x00008000, // use ai when charmed - CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00010000, // cannot be taunted CREATURE_FLAG_EXTRA_NO_CRIT = 0x00020000, // creature can't do critical strikes }; +enum SummonMask +{ + SUMMON_MASK_NONE = 0x00000000, + SUMMON_MASK_SUMMON = 0x00000001, + SUMMON_MASK_MINION = 0x00000002, + SUMMON_MASK_GUARDIAN = 0x00000004, + SUMMON_MASK_TOTEM = 0x00000008, + SUMMON_MASK_PET = 0x00000010, + SUMMON_MASK_VEHICLE = 0x00000020, +}; + // 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 #if defined( __GNUC__ ) #pragma pack(1) @@ -178,7 +203,7 @@ struct CreatureInfo uint32 rangeattacktime; uint32 unit_flags; // enum UnitFlags mask values uint32 dynamicflags; - uint32 family; // enum CreatureFamily values for type==CREATURE_TYPE_BEAST, or 0 in another cases + uint32 family; // enum CreatureFamily values (optional) uint32 trainer_type; uint32 trainer_spell; uint32 classNum; @@ -197,16 +222,16 @@ struct CreatureInfo int32 resistance4; int32 resistance5; int32 resistance6; - uint32 spell1; - uint32 spell2; - uint32 spell3; - uint32 spell4; + uint32 spells[CREATURE_MAX_SPELLS]; uint32 PetSpellDataId; + uint32 VehicleId; uint32 mingold; uint32 maxgold; char const* AIName; uint32 MovementType; uint32 InhabitType; + float unk16; + float unk17; bool RacialLeader; bool RegenHealth; uint32 equipmentId; @@ -223,6 +248,8 @@ struct CreatureInfo return SKILL_HERBALISM; else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT) return SKILL_MINING; + else if(type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT) + return SKILL_ENGINERING; else return SKILL_SKINNING; // normal case } @@ -245,12 +272,15 @@ struct NpcOptionLocale std::vector<std::string> BoxText; }; +struct PointOfInterestLocale +{ + std::vector<std::string> IconName; +}; + struct EquipmentInfo { uint32 entry; - uint32 equipmodel[3]; - uint32 equipinfo[3]; - uint32 equipslot[3]; + uint32 equipentry[3]; }; // from `creature` table @@ -258,6 +288,7 @@ struct CreatureData { uint32 id; // entry in creature_template uint16 mapid; + uint16 phaseMask; uint32 displayid; int32 equipmentId; float posX; @@ -284,7 +315,6 @@ struct CreatureDataAddonAura struct CreatureDataAddon { uint32 guidOrEntry; - uint32 path_id; uint32 mount; uint32 bytes0; uint32 bytes1; @@ -311,6 +341,31 @@ enum InhabitTypeValues INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR }; +// Enums used by StringTextData::Type (CreatureEventAI) +enum ChatType +{ + CHAT_TYPE_SAY = 0, + CHAT_TYPE_YELL = 1, + CHAT_TYPE_TEXT_EMOTE = 2, + CHAT_TYPE_BOSS_EMOTE = 3, + CHAT_TYPE_WHISPER = 4, + CHAT_TYPE_BOSS_WHISPER = 5, + CHAT_TYPE_ZONE_YELL = 6 +}; + +//Selection method used by SelectTarget (CreatureEventAI) +enum AttackingTarget +{ + ATTACKING_TARGET_RANDOM = 0, //Just selects a random target + ATTACKING_TARGET_TOPAGGRO, //Selects targes from top aggro to bottom + ATTACKING_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top + /* not implemented + ATTACKING_TARGET_RANDOM_PLAYER, //Just selects a random target (player only) + ATTACKING_TARGET_TOPAGGRO_PLAYER, //Selects targes from top aggro to bottom (player only) + ATTACKING_TARGET_BOTTOMAGGRO_PLAYER, //Selects targets from bottom aggro to top (player only) + */ +}; + // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform #if defined( __GNUC__ ) #pragma pack() @@ -352,8 +407,9 @@ struct VendorItemData void Clear() { - for (VendorItemList::iterator itr = m_items.begin(); itr != m_items.end(); ++itr) + for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr) delete (*itr); + m_items.clear(); } }; @@ -371,25 +427,34 @@ typedef std::list<VendorItemCount> VendorItemCounts; struct TrainerSpell { + TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0), learnedSpell(0) {} + + TrainerSpell(uint32 _spell, uint32 _spellCost, uint32 _reqSkill, uint32 _reqSkillValue, uint32 _reqLevel, uint32 _learnedspell) + : spell(_spell), spellCost(_spellCost), reqSkill(_reqSkill), reqSkillValue(_reqSkillValue), reqLevel(_reqLevel), learnedSpell(_learnedspell) + {} + uint32 spell; - uint32 spellcost; - uint32 reqskill; - uint32 reqskillvalue; - uint32 reqlevel; + uint32 spellCost; + uint32 reqSkill; + uint32 reqSkillValue; + uint32 reqLevel; + uint32 learnedSpell; + + // helpers + bool IsCastable() const { return learnedSpell != spell; } }; -typedef std::vector<TrainerSpell*> TrainerSpellList; +typedef UNORDERED_MAP<uint32 /*spellid*/, TrainerSpell> TrainerSpellMap; struct TrainerSpellData { TrainerSpellData() : trainerType(0) {} - TrainerSpellList spellList; + TrainerSpellMap spellList; uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value. // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2. - - void Clear(); TrainerSpell const* Find(uint32 spell_id) const; + void Clear() { spellList.clear(); } }; typedef std::list<GossipOption> GossipOptionList; @@ -411,7 +476,7 @@ class TRINITY_DLL_SPEC Creature : public Unit void AddToWorld(); void RemoveFromWorld(); - bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data = NULL); + bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, const CreatureData *data = NULL); bool LoadCreaturesAddon(bool reload = false); void SelectLevel(const CreatureInfo *cinfo); void LoadEquipment(uint32 equip_entry, bool force=false); @@ -423,9 +488,13 @@ class TRINITY_DLL_SPEC Creature : public Unit void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; uint32 GetEquipmentId() const { return m_equipmentId; } - bool isPet() const { return m_isPet; } + uint32 HasSummonMask(uint32 mask) const { return mask & m_summonMask; } + bool isSummon() const { return m_summonMask & SUMMON_MASK_SUMMON; } + bool isPet() const { return m_summonMask & SUMMON_MASK_PET; } + bool isVehicle() const { return m_summonMask & SUMMON_MASK_VEHICLE; } + bool isWorldCreature() const { return m_summonMask & SUMMON_MASK_PET; } + bool isTotem() const { return m_summonMask & SUMMON_MASK_TOTEM; } void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } - bool isTotem() const { return m_isTotem; } bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; } bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } bool isTrigger() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; } @@ -440,9 +509,9 @@ class TRINITY_DLL_SPEC Creature : public Unit bool isCanInteractWithBattleMaster(Player* player, bool msg) const; bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const; bool IsOutOfThreatArea(Unit* pVictim) const; - bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false); + bool IsImmunedToSpell(SpellEntry const* spellInfo); // redefine Unit::IsImmunedToSpell - bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const; + bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const; // redefine Unit::IsImmunedToSpellEffect bool isElite() const { @@ -466,6 +535,7 @@ class TRINITY_DLL_SPEC Creature : public Unit bool IsInEvadeMode() const; bool AIM_Initialize(CreatureAI* ai = NULL); + void Motion_Initialize(); void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); CreatureAI* AI() { return (CreatureAI*)i_AI; } @@ -507,8 +577,9 @@ class TRINITY_DLL_SPEC Creature : public Unit CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } CreatureDataAddon const* GetCreatureAddon() const; - std::string GetScriptName(); - uint32 GetScriptId(); + std::string GetAIName() const; + std::string GetScriptName() const; + uint32 GetScriptId() const; void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 ); void sendPreparedGossip( Player* player ); @@ -522,15 +593,11 @@ class TRINITY_DLL_SPEC Creature : public Unit GossipOption const* GetGossipOption( uint32 id ) const; void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); } - void setEmoteState(uint8 emote) { m_emoteState = emote; }; - void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text,language,TargetGuid); } - void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text,language,TargetGuid); } - void TextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(text,TargetGuid,IsBossEmote); } - void Whisper(const char* text, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(text,receiver,IsBossWhisper); } void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); } void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); } void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); } void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); } + void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); } // overwrite WorldObject function for proper name localization const char* GetNameForLocaleIdx(int32 locale_idx) const; @@ -541,7 +608,7 @@ class TRINITY_DLL_SPEC Creature : public Unit bool LoadFromDB(uint32 guid, Map *map); void SaveToDB(); // overwrited in Pet - virtual void SaveToDB(uint32 mapid, uint8 spawnMask); + virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); virtual void DeleteFromDB(); // overwrited in Pet Loot loot; @@ -567,10 +634,12 @@ class TRINITY_DLL_SPEC Creature : public Unit float GetAttackDistance(Unit const* pl) const; Unit* SelectNearestTarget(float dist = 0) const; + void DoFleeToGetAssistance(); void CallAssistance(); void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; } - bool CanAssistTo(const Unit* u, const Unit* enemy) const; - void DoFleeToGetAssistance(float radius = 50); + void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; } + bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; } + bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const; MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } @@ -582,6 +651,7 @@ class TRINITY_DLL_SPEC Creature : public Unit bool IsVisibleInGridForPlayer(Player const* pl) const; void RemoveCorpse(); + bool isDeadByDefault() const { return m_isDeadByDefault; }; time_t const& GetRespawnTime() const { return m_respawnTime; } time_t GetRespawnTimeEx() const; @@ -623,17 +693,18 @@ class TRINITY_DLL_SPEC Creature : public Unit uint32 GetGlobalCooldown() const { return m_GlobalCooldown; } - uint32 GetWaypointPath(){return m_path_id;} - void LoadPath(uint32 pathid) { m_path_id = pathid; } + uint32 GetWaypointPathId() const { return m_pathId; } + void SetWaypointPathId(uint32 pathid) { m_pathId = pathid; } uint32 GetCurrentWaypointID(){return m_waypointID;} void UpdateWaypointID(uint32 wpID){m_waypointID = wpID;} - void SearchFormation(); - CreatureGroup *GetFormation(){return m_formation;} + void SearchFormationAndPath(); + CreatureGroup *GetFormation() {return m_formation;} void SetFormation(CreatureGroup *formation) {m_formation = formation;} Unit *SelectVictim(); + void SetDeadByDefault (bool death_state) {m_isDeadByDefault = death_state;} void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; } bool IsReputationGainDisabled() { return DisableReputationGain; } @@ -667,19 +738,17 @@ class TRINITY_DLL_SPEC Creature : public Unit bool m_gossipOptionLoaded; GossipOptionList m_goptions; - uint8 m_emoteState; - bool m_isPet; // set only in Pet::Pet - bool m_isTotem; // set only in Totem::Totem + uint32 m_summonMask; ReactStates m_reactState; // for AI, not charmInfo void RegenerateMana(); void RegenerateHealth(); - uint32 m_regenTimer; MovementGeneratorType m_defaultMovementType; Cell m_currentCell; // store current cell where creature listed uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid uint32 m_equipmentId; bool m_AlreadyCallAssistance; + bool m_AlreadySearchedAssistance; bool m_regenHealth; bool m_AI_locked; bool m_isDeadByDefault; @@ -697,7 +766,7 @@ class TRINITY_DLL_SPEC Creature : public Unit private: //WaypointMovementGenerator vars uint32 m_waypointID; - uint32 m_path_id; + uint32 m_pathId; //Formation var CreatureGroup *m_formation; |