aboutsummaryrefslogtreecommitdiff
path: root/src/game/Creature.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Creature.h')
-rw-r--r--src/game/Creature.h213
1 files changed, 152 insertions, 61 deletions
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 2abd3041385..d0bd7c7261f 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,25 @@ 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,
+ SUMMON_MASK_PUPPET = 0x00000040,
+ SUMMON_MASK_HUNTER_PET = 0x00000080,
+};
+
// 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)
@@ -150,10 +177,10 @@ struct CreatureInfo
{
uint32 Entry;
uint32 HeroicEntry;
- uint32 Modelid_A1;
- uint32 Modelid_A2;
- uint32 Modelid_H1;
- uint32 Modelid_H2;
+ uint32 unk1;
+ uint32 unk2;
+ uint32 DisplayID_A[2];
+ uint32 DisplayID_H[2];
char* Name;
char* SubName;
char* IconName;
@@ -174,15 +201,17 @@ struct CreatureInfo
float maxdmg;
uint32 dmgschool;
uint32 attackpower;
+ float dmg_multiplier;
uint32 baseattacktime;
uint32 rangeattacktime;
+ uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures.
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;
- uint32 race;
+ uint32 trainer_class;
+ uint32 trainer_race;
float minrangedmg;
float maxrangedmg;
uint32 rangedattackpower;
@@ -197,17 +226,19 @@ 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;
+ uint32 questItems[4];
+ uint32 movementId;
bool RegenHealth;
uint32 equipmentId;
uint32 MechanicImmuneMask;
@@ -223,13 +254,19 @@ 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
}
- bool isTameable() const
+ bool isTameable(bool exotic) const
{
- return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEABLE);
+ if(type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE)==0)
+ return false;
+
+ // if can tame exotic then can tame any temable
+ return exotic || (type_flags & CREATURE_TYPEFLAGS_EXOTIC)==0;
}
};
@@ -245,19 +282,24 @@ 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
struct CreatureData
{
+ explicit CreatureData() : dbData(true) {}
uint32 id; // entry in creature_template
uint16 mapid;
+ uint16 phaseMask;
uint32 displayid;
int32 equipmentId;
float posX;
@@ -272,6 +314,7 @@ struct CreatureData
bool is_dead;
uint8 movementType;
uint8 spawnMask;
+ bool dbData;
};
struct CreatureDataAddonAura
@@ -284,9 +327,7 @@ struct CreatureDataAddonAura
struct CreatureDataAddon
{
uint32 guidOrEntry;
- uint32 path_id;
uint32 mount;
- uint32 bytes0;
uint32 bytes1;
uint32 bytes2;
uint32 emote;
@@ -311,6 +352,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 +418,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 +438,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;
@@ -399,7 +475,7 @@ typedef std::map<uint32,time_t> CreatureSpellCooldowns;
// max different by z coordinate for creature aggro reaction
#define CREATURE_Z_ATTACK_RANGE 3
-#define MAX_VENDOR_ITEMS 255 // Limitation in item count field size in SMSG_LIST_INVENTORY
+#define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY
class TRINITY_DLL_SPEC Creature : public Unit
{
@@ -411,7 +487,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, float x, float y, float z, float ang, const CreatureData *data = NULL);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel(const CreatureInfo *cinfo);
void LoadEquipment(uint32 equip_entry, bool force=false);
@@ -423,15 +499,22 @@ 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 isGuardian() const { return m_summonMask & SUMMON_MASK_GUARDIAN; }
+ bool isPet() const { return m_summonMask & SUMMON_MASK_PET; }
+ bool isHunterPet() const{ return m_summonMask & SUMMON_MASK_HUNTER_PET; }
+ bool isVehicle() const { return m_summonMask & SUMMON_MASK_VEHICLE; }
+ bool isTotem() const { return m_summonMask & SUMMON_MASK_TOTEM; }
+ bool isWorldCreature() const { return m_summonMask & SUMMON_MASK_PET; }
+
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; }
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
- bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
+ //bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
void SetReactState(ReactStates st) { m_reactState = st; }
ReactStates GetReactState() { return m_reactState; }
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
@@ -440,9 +523,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 +549,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; }
@@ -505,10 +589,12 @@ class TRINITY_DLL_SPEC Creature : public Unit
TrainerSpellData const* GetTrainerSpells() const;
CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
+ CreatureData const *GetCreatureData() const { return m_creatureData; }
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 +608,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 +623,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;
@@ -563,14 +645,17 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
bool IsWithinSightDist(Unit const* u) const;
- bool canStartAttack(Unit const* u) const;
+ bool canStartAttack(Unit const* u, bool force) const;
float GetAttackDistance(Unit const* pl) const;
Unit* SelectNearestTarget(float dist = 0) const;
+ void DoFleeToGetAssistance();
+ void CallForHelp(float fRadius);
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,11 +667,14 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool IsVisibleInGridForPlayer(Player const* pl) const;
void RemoveCorpse();
+ bool isDeadByDefault() const { return m_isDeadByDefault; };
+
+ void ForcedDespawn();
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
- void Respawn();
+ void Respawn(bool force = false);
void SaveRespawnTime();
uint32 GetRespawnDelay() const { return m_respawnDelay; }
@@ -623,17 +711,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; }
@@ -646,6 +735,9 @@ class TRINITY_DLL_SPEC Creature : public Unit
void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
uint32 m_PlayerDamageReq;
+ void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
+
+ static float _GetDamageMod(int32 Rank);
protected:
bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
@@ -656,7 +748,6 @@ class TRINITY_DLL_SPEC Creature : public Unit
void _RealtimeSetCreatureInfo();
static float _GetHealthMod(int32 Rank);
- static float _GetDamageMod(int32 Rank);
uint32 m_lootMoney;
uint64 m_lootRecipient;
@@ -671,19 +762,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;
@@ -698,16 +787,18 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool DisableReputationGain;
+ CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
+ CreatureData const* m_creatureData;
+
private:
//WaypointMovementGenerator vars
uint32 m_waypointID;
- uint32 m_path_id;
+ uint32 m_pathId;
//Formation var
CreatureGroup *m_formation;
GridReference<Creature> m_gridRef;
- CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
};
class AssistDelayEvent : public BasicEvent