NPC.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __EQ2_NPC__
  17. #define __EQ2_NPC__
  18. #include "Entity.h"
  19. #include "MutexMap.h"
  20. #define AI_STRATEGY_BALANCED 1
  21. #define AI_STRATEGY_OFFENSIVE 2
  22. #define AI_STRATEGY_DEFENSIVE 3
  23. // Randomize Appearances
  24. #define RANDOMIZE_GENDER 1
  25. #define RANDOMIZE_RACE 2
  26. #define RANDOMIZE_MODEL_TYPE 4
  27. // Randomize appearance id (spawn_npcs table values)
  28. #define RANDOMIZE_FACIAL_HAIR_TYPE 8 // was RANDOMIZE_FACIAL_HAIR
  29. #define RANDOMIZE_HAIR_TYPE 16 // was RANDOMIZE_HAIR
  30. //#define RANDOMIZE_LEGS_TYPE 32 // spare!
  31. #define RANDOMIZE_WING_TYPE 64
  32. // Randomize parameters (npc_appearances, sInt values)
  33. #define RANDOMIZE_CHEEK_TYPE 128
  34. #define RANDOMIZE_CHIN_TYPE 256
  35. #define RANDOMIZE_EAR_TYPE 512
  36. #define RANDOMIZE_EYE_BROW_TYPE 1024
  37. #define RANDOMIZE_EYE_TYPE 2048
  38. #define RANDOMIZE_LIP_TYPE 4096
  39. #define RANDOMIZE_NOSE_TYPE 8192
  40. // Randomize colors/hues (npc_appearances, RGB values)
  41. #define RANDOMIZE_EYE_COLOR 16384
  42. #define RANDOMIZE_HAIR_COLOR1 32768
  43. #define RANDOMIZE_HAIR_COLOR2 65536
  44. #define RANDOMIZE_HAIR_HIGHLIGHT 131072
  45. #define RANDOMIZE_HAIR_FACE_COLOR 262144 // was RANDOMIZE_FACIAL_HAIR_COLOR
  46. #define RANDOMIZE_HAIR_FACE_HIGHLIGHT_COLOR 524288
  47. #define RANDOMIZE_HAIR_TYPE_COLOR 1048576 // was RANDOMIZE_HAIR_COLOR
  48. #define RANDOMIZE_HAIR_TYPE_HIGHLIGHT_COLOR 2097152
  49. #define RANDOMIZE_SKIN_COLOR 4194304
  50. #define RANDOMIZE_WING_COLOR1 8388608
  51. #define RANDOMIZE_WING_COLOR2 16777216
  52. // All Flags On: 33554431
  53. #define PET_TYPE_COMBAT 1
  54. #define PET_TYPE_CHARMED 2
  55. #define PET_TYPE_DEITY 3
  56. #define PET_TYPE_COSMETIC 4
  57. #define PET_TYPE_DUMBFIRE 5
  58. class Brain;
  59. class NPC : public Entity {
  60. public:
  61. NPC();
  62. NPC(NPC* old_npc);
  63. virtual ~NPC();
  64. void Initialize();
  65. EQ2Packet* serialize(Player* player, int16 version);
  66. void SetAppearanceID(int32 id){ appearance_id = id; }
  67. int32 GetAppearanceID(){ return appearance_id; }
  68. bool IsNPC(){ return true; }
  69. void InCombat(bool val);
  70. bool HandleUse(Client* client, string type);
  71. void SetRandomize(int32 value) {appearance.randomize = value;}
  72. void AddRandomize(sint32 value) {appearance.randomize += value;}
  73. int32 GetRandomize() {return appearance.randomize;}
  74. bool CheckSameAppearance(string name, int16 id);
  75. void Randomize(NPC* npc, int32 flags);
  76. Skill* GetSkillByName(const char* name, bool check_update = false);
  77. void SetAttackType(int8 type);
  78. int8 GetAttackType();
  79. void SetAIStrategy(int8 strategy);
  80. int8 GetAIStrategy();
  81. void SetPrimarySpellList(int32 id);
  82. int32 GetPrimarySpellList();
  83. void SetSecondarySpellList(int32 id);
  84. int32 GetSecondarySpellList();
  85. void SetPrimarySkillList(int32 id);
  86. int32 GetPrimarySkillList();
  87. void SetSecondarySkillList(int32 id);
  88. int32 GetSecondarySkillList();
  89. void SetEquipmentListID(int32 id);
  90. int32 GetEquipmentListID();
  91. Spell* GetNextSpell(float distance);
  92. virtual Spell* GetNextBuffSpell();
  93. void SetAggroRadius(float radius, bool overrideBaseValue = false);
  94. float GetAggroRadius();
  95. float GetBaseAggroRadius() { return base_aggro_radius; }
  96. void SetCastPercentage(int8 percentage);
  97. int8 GetCastPercentage();
  98. void SetSkills(map<string, Skill*>* in_skills);
  99. void SetSpells(vector<Spell*>* in_spells);
  100. void SetRunbackLocation(float x, float y, float z, int32 gridid);
  101. MovementLocation* GetRunbackLocation();
  102. float GetRunbackDistance();
  103. void Runback(float distance=0.0f);
  104. void ClearRunback();
  105. void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  106. virtual void RemoveSkillBonus(int32 spell_id);
  107. virtual void SetZone(ZoneServer* zone);
  108. void SetOwner(Entity* owner) { if (owner) { this->owner = owner->GetID(); } else { owner = 0; } }
  109. Entity* GetOwner();
  110. int8 GetPetType() { return m_petType; }
  111. void SetPetType(int8 val) { m_petType = val; }
  112. void SetPetSpellID(int32 val) { m_petSpellID = val; }
  113. int32 GetPetSpellID() { return m_petSpellID; }
  114. void SetPetSpellTier(int8 val) { m_petSpellTier = val; }
  115. int8 GetPetSpellTier() { return m_petSpellTier; }
  116. void SetMaxPetLevel(int8 val) { m_petMaxLevel = val; }
  117. int8 GetMaxPetLevel() { return m_petMaxLevel; }
  118. void ProcessCombat();
  119. /// <summary>Sets the brain this NPC should use</summary>
  120. /// <param name="brain">The brain this npc should use</param>
  121. void SetBrain(Brain* brain);
  122. /// <summary>Gets the current brain this NPC uses</summary>
  123. /// <returns>The Brain this NPC uses</returns>
  124. ::Brain* Brain() { return m_brain; }
  125. bool m_runningBack;
  126. sint16 m_runbackHeadingDir1;
  127. sint16 m_runbackHeadingDir2;
  128. bool IsDismissing() { return m_petDismissing; }
  129. void SetDismissing(bool val) { m_petDismissing = val; }
  130. private:
  131. MovementLocation* runback;
  132. int8 cast_percentage;
  133. float aggro_radius;
  134. float base_aggro_radius;
  135. Spell* GetNextSpell(float distance, int8 type);
  136. map<string, Skill*>* skills;
  137. vector<Spell*>* spells;
  138. int32 primary_spell_list;
  139. int32 secondary_spell_list;
  140. int32 primary_skill_list;
  141. int32 secondary_skill_list;
  142. int32 equipment_list_id;
  143. int8 attack_type;
  144. int8 ai_strategy;
  145. int32 appearance_id;
  146. int32 npc_id;
  147. MutexMap<int32, SkillBonus*> skill_bonus_list;
  148. int8 m_petType;
  149. // m_petSpellID holds the spell id used to create this pet
  150. int32 m_petSpellID;
  151. int8 m_petSpellTier;
  152. int32 owner;
  153. int8 m_petMaxLevel;
  154. bool m_petDismissing;
  155. // Because I named the get function Brain() as well we need to use '::' to specify we are refering to
  156. // the brain class and not the function defined above
  157. ::Brain* m_brain;
  158. Mutex MBrain;
  159. };
  160. #endif