9
3

NPC.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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);
  94. float GetAggroRadius();
  95. void SetCastPercentage(int8 percentage);
  96. int8 GetCastPercentage();
  97. void SetSkills(map<string, Skill*>* in_skills);
  98. void SetSpells(vector<Spell*>* in_spells);
  99. void SetRunbackLocation(float x, float y, float z);
  100. MovementLocation* GetRunbackLocation();
  101. float GetRunbackDistance();
  102. void Runback();
  103. void ClearRunback();
  104. void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  105. virtual void RemoveSkillBonus(int32 spell_id);
  106. virtual void SetZone(ZoneServer* zone);
  107. void SetOwner(Entity* owner) { if (owner) { this->owner = owner->GetID(); } else { owner = 0; } }
  108. Entity* GetOwner();
  109. int8 GetPetType() { return m_petType; }
  110. void SetPetType(int8 val) { m_petType = val; }
  111. void SetPetSpellID(int32 val) { m_petSpellID = val; }
  112. int32 GetPetSpellID() { return m_petSpellID; }
  113. void SetPetSpellTier(int8 val) { m_petSpellTier = val; }
  114. int8 GetPetSpellTier() { return m_petSpellTier; }
  115. void SetMaxPetLevel(int8 val) { m_petMaxLevel = val; }
  116. int8 GetMaxPetLevel() { return m_petMaxLevel; }
  117. void ProcessCombat();
  118. /// <summary>Sets the brain this NPC should use</summary>
  119. /// <param name="brain">The brain this npc should use</param>
  120. void SetBrain(Brain* brain);
  121. /// <summary>Gets the current brain this NPC uses</summary>
  122. /// <returns>The Brain this NPC uses</returns>
  123. ::Brain* Brain() { return m_brain; }
  124. bool m_runningBack;
  125. sint16 m_runbackHeading;
  126. bool IsDismissing() { return m_petDismissing; }
  127. void SetDismissing(bool val) { m_petDismissing = val; }
  128. private:
  129. MovementLocation* runback;
  130. int8 cast_percentage;
  131. float aggro_radius;
  132. Spell* GetNextSpell(float distance, int8 type);
  133. map<string, Skill*>* skills;
  134. vector<Spell*>* spells;
  135. int32 primary_spell_list;
  136. int32 secondary_spell_list;
  137. int32 primary_skill_list;
  138. int32 secondary_skill_list;
  139. int32 equipment_list_id;
  140. int8 attack_type;
  141. int8 ai_strategy;
  142. int32 appearance_id;
  143. int32 npc_id;
  144. MutexMap<int32, SkillBonus*> skill_bonus_list;
  145. int8 m_petType;
  146. // m_petSpellID holds the spell id used to create this pet
  147. int32 m_petSpellID;
  148. int8 m_petSpellTier;
  149. int32 owner;
  150. int8 m_petMaxLevel;
  151. bool m_petDismissing;
  152. // Because I named the get function Brain() as well we need to use '::' to specify we are refering to
  153. // the brain class and not the function defined above
  154. ::Brain* m_brain;
  155. Mutex MBrain;
  156. };
  157. #endif