NPC.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 StartRunback();
  70. void InCombat(bool val);
  71. bool HandleUse(Client* client, string type);
  72. void SetRandomize(int32 value) {appearance.randomize = value;}
  73. void AddRandomize(sint32 value) {appearance.randomize += value;}
  74. int32 GetRandomize() {return appearance.randomize;}
  75. bool CheckSameAppearance(string name, int16 id);
  76. void Randomize(NPC* npc, int32 flags);
  77. Skill* GetSkillByName(const char* name, bool check_update = false);
  78. void SetAttackType(int8 type);
  79. int8 GetAttackType();
  80. void SetAIStrategy(int8 strategy);
  81. int8 GetAIStrategy();
  82. void SetPrimarySpellList(int32 id);
  83. int32 GetPrimarySpellList();
  84. void SetSecondarySpellList(int32 id);
  85. int32 GetSecondarySpellList();
  86. void SetPrimarySkillList(int32 id);
  87. int32 GetPrimarySkillList();
  88. void SetSecondarySkillList(int32 id);
  89. int32 GetSecondarySkillList();
  90. void SetEquipmentListID(int32 id);
  91. int32 GetEquipmentListID();
  92. Spell* GetNextSpell(float distance);
  93. virtual Spell* GetNextBuffSpell();
  94. void SetAggroRadius(float radius, bool overrideBaseValue = false);
  95. float GetAggroRadius();
  96. float GetBaseAggroRadius() { return base_aggro_radius; }
  97. void SetCastPercentage(int8 percentage);
  98. int8 GetCastPercentage();
  99. void SetSkills(map<string, Skill*>* in_skills);
  100. void SetSpells(vector<Spell*>* in_spells);
  101. void SetRunbackLocation(float x, float y, float z, int32 gridid);
  102. MovementLocation* GetRunbackLocation();
  103. float GetRunbackDistance();
  104. void Runback(float distance=0.0f, bool stopFollowing = true);
  105. void ClearRunback();
  106. virtual bool PauseMovement(int32 period_of_time_ms);
  107. virtual bool IsPauseMovementTimerActive();
  108. void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  109. virtual void RemoveSkillBonus(int32 spell_id);
  110. virtual void SetZone(ZoneServer* zone, int32 version=0);
  111. void SetMaxPetLevel(int8 val) { m_petMaxLevel = val; }
  112. int8 GetMaxPetLevel() { return m_petMaxLevel; }
  113. void ProcessCombat();
  114. /// <summary>Sets the brain this NPC should use</summary>
  115. /// <param name="brain">The brain this npc should use</param>
  116. void SetBrain(Brain* brain);
  117. /// <summary>Gets the current brain this NPC uses</summary>
  118. /// <returns>The Brain this NPC uses</returns>
  119. ::Brain* Brain() { return m_brain; }
  120. bool m_runningBack;
  121. sint16 m_runbackHeadingDir1;
  122. sint16 m_runbackHeadingDir2;
  123. int32 GetShardID() { return m_ShardID; }
  124. void SetShardID(int32 shardid) { m_ShardID = shardid; }
  125. int32 GetShardCharID() { return m_ShardCharID; }
  126. void SetShardCharID(int32 charid) { m_ShardCharID = charid; }
  127. sint64 GetShardCreatedTimestamp() { return m_ShardCreatedTimestamp; }
  128. void SetShardCreatedTimestamp(sint64 timestamp) { m_ShardCreatedTimestamp = timestamp; }
  129. private:
  130. MovementLocation* runback;
  131. int8 cast_percentage;
  132. float aggro_radius;
  133. float base_aggro_radius;
  134. Spell* GetNextSpell(float distance, int8 type);
  135. map<string, Skill*>* skills;
  136. vector<Spell*>* spells;
  137. int32 primary_spell_list;
  138. int32 secondary_spell_list;
  139. int32 primary_skill_list;
  140. int32 secondary_skill_list;
  141. int32 equipment_list_id;
  142. int8 attack_type;
  143. int8 ai_strategy;
  144. int32 appearance_id;
  145. int32 npc_id;
  146. MutexMap<int32, SkillBonus*> skill_bonus_list;
  147. int8 m_petMaxLevel;
  148. // Because I named the get function Brain() as well we need to use '::' to specify we are refering to
  149. // the brain class and not the function defined above
  150. ::Brain* m_brain;
  151. Mutex MBrain;
  152. int32 m_ShardID;
  153. int32 m_ShardCharID;
  154. sint64 m_ShardCreatedTimestamp;
  155. };
  156. #endif