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.h89
1 files changed, 58 insertions, 31 deletions
diff --git a/src/game/Creature.h b/src/game/Creature.h
index b477ea00f1d..5dd9dc9afdc 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
@@ -136,6 +136,16 @@ enum CreatureFlagsExtra
CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00010000, // cannot be taunted
};
+enum SummonMask
+{
+ SUMMON_MASK_NONE = 0x00000000,
+ SUMMON_MASK_SUMMON = 0x00000001,
+ SUMMON_MASK_GUARDIAN = 0x00000002,
+ SUMMON_MASK_TOTEM = 0x00000004,
+ SUMMON_MASK_PET = 0x00000008,
+ SUMMON_MASK_VEHICLE = 0x00000010,
+};
+
// 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)
@@ -176,7 +186,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;
@@ -195,16 +205,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;
@@ -221,6 +231,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
}
@@ -243,12 +255,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
@@ -256,6 +271,7 @@ struct CreatureData
{
uint32 id; // entry in creature_template
uint16 mapid;
+ uint16 phaseMask;
uint32 displayid;
int32 equipmentId;
float posX;
@@ -352,6 +368,7 @@ struct VendorItemData
{
for (VendorItemList::iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
delete (*itr);
+ m_items.clear();
}
};
@@ -369,25 +386,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;
@@ -409,7 +435,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);
@@ -421,9 +447,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; }
@@ -438,9 +468,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
{
@@ -521,14 +551,11 @@ class TRINITY_DLL_SPEC Creature : public Unit
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;
@@ -539,7 +566,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;
@@ -628,6 +655,8 @@ class TRINITY_DLL_SPEC Creature : public Unit
uint32 GetFormationID(){return m_formationID;}
Unit *SelectVictim();
+ void SetDeadByDefault (bool death_state) {m_isDeadByDefault = death_state;}
+
protected:
bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL);
bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL);
@@ -654,12 +683,10 @@ class TRINITY_DLL_SPEC Creature : public Unit
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