9
3

Entity.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  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_ENTITY__
  17. #define __EQ2_ENTITY__
  18. #include "Spawn.h"
  19. #include "../common/Mutex.h"
  20. #include "Skills.h"
  21. #include "MutexList.h"
  22. #include "MutexVector.h"
  23. #include <set>
  24. using namespace std;
  25. class Entity;
  26. class NPC;
  27. class Trade;
  28. struct LuaSpell;
  29. struct GroupMemberInfo;
  30. struct BonusValues{
  31. int32 spell_id;
  32. int8 tier;
  33. int16 type;
  34. sint32 value;
  35. int64 class_req;
  36. vector<int16> race_req;
  37. vector<int16> faction_req;
  38. LuaSpell* luaspell;
  39. };
  40. struct MaintainedEffects{
  41. char name[60]; //name of the spell
  42. int32 target;
  43. int8 target_type;
  44. int32 spell_id;
  45. int32 slot_pos;
  46. int16 icon;
  47. int16 icon_backdrop;
  48. int8 conc_used;
  49. int8 tier;
  50. float total_time;
  51. int32 expire_timestamp;
  52. LuaSpell* spell;
  53. };
  54. struct SpellEffects{
  55. int32 spell_id;
  56. Entity* caster;
  57. float total_time;
  58. int32 expire_timestamp;
  59. int16 icon;
  60. int16 icon_backdrop;
  61. int8 tier;
  62. LuaSpell* spell;
  63. };
  64. struct DetrimentalEffects {
  65. int32 spell_id;
  66. Entity* caster;
  67. int32 expire_timestamp;
  68. int16 icon;
  69. int16 icon_backdrop;
  70. int8 tier;
  71. int8 det_type;
  72. bool incurable;
  73. LuaSpell* spell;
  74. int8 control_effect;
  75. float total_time;
  76. };
  77. struct CombatData{
  78. int32 range_last_attack_time;
  79. int32 primary_last_attack_time;
  80. int32 secondary_last_attack_time;
  81. int16 primary_attack_delay;
  82. int16 secondary_attack_delay;
  83. int16 ranged_attack_delay;
  84. int8 primary_weapon_type;
  85. int8 secondary_weapon_type;
  86. int8 ranged_weapon_type;
  87. int32 primary_weapon_damage_low;
  88. int32 primary_weapon_damage_high;
  89. int32 secondary_weapon_damage_low;
  90. int32 secondary_weapon_damage_high;
  91. int32 ranged_weapon_damage_low;
  92. int32 ranged_weapon_damage_high;
  93. int8 wield_type;
  94. int16 primary_weapon_delay;
  95. int16 secondary_weapon_delay;
  96. int16 ranged_weapon_delay;
  97. };
  98. struct InfoStruct{
  99. char name[40];
  100. int8 class1;
  101. int8 class2;
  102. int8 class3;
  103. int8 race;
  104. int8 gender;
  105. int16 level;
  106. int16 max_level;
  107. int16 tradeskill_level;
  108. int16 tradeskill_max_level;
  109. int8 cur_concentration;
  110. int8 max_concentration;
  111. int16 cur_attack;
  112. int16 attack_base;
  113. int16 cur_mitigation;
  114. int16 max_mitigation;
  115. int16 mitigation_base;
  116. int16 avoidance_display;
  117. int16 cur_avoidance;
  118. int16 base_avoidance_pct;
  119. int16 avoidance_base;
  120. int16 max_avoidance;
  121. int16 parry;
  122. int16 parry_base;
  123. int16 deflection;
  124. int16 deflection_base;
  125. int16 block;
  126. int16 block_base;
  127. float str; //int16
  128. float sta; //int16
  129. float agi;//int16
  130. float wis;//int16
  131. float intel;//int16
  132. float str_base;//int16
  133. float sta_base;//int16
  134. float agi_base;//int16
  135. float wis_base;//int16
  136. float intel_base;//int16
  137. int16 heat;
  138. int16 cold;
  139. int16 magic;
  140. int16 mental;
  141. int16 divine;
  142. int16 disease;
  143. int16 poison;
  144. int16 disease_base;
  145. int16 cold_base;
  146. int16 divine_base;
  147. int16 magic_base;
  148. int16 mental_base;
  149. int16 heat_base;
  150. int16 poison_base;
  151. int16 elemental_base;
  152. int16 noxious_base;
  153. int16 arcane_base;
  154. int32 coin_copper;
  155. int32 coin_silver;
  156. int32 coin_gold;
  157. int32 coin_plat;
  158. int32 bank_coin_copper;
  159. int32 bank_coin_silver;
  160. int32 bank_coin_gold;
  161. int32 bank_coin_plat;
  162. int32 status_points;
  163. char deity[32];
  164. int32 weight;
  165. int32 max_weight;
  166. SpellEffects spell_effects[45];
  167. MaintainedEffects maintained_effects[30];
  168. int8 tradeskill_class1;
  169. int8 tradeskill_class2;
  170. int8 tradeskill_class3;
  171. int16 account_age_base;
  172. int8 account_age_bonus[19];
  173. int16 absorb;
  174. int32 xp;
  175. int32 xp_needed;
  176. int32 xp_debt;
  177. int16 xp_yellow;
  178. int16 xp_yellow_vitality_bar;
  179. int16 xp_blue_vitality_bar;
  180. int16 xp_blue;
  181. int32 ts_xp;
  182. int32 ts_xp_needed;
  183. int16 tradeskill_exp_yellow;
  184. int16 tradeskill_exp_blue;
  185. int32 flags;
  186. int32 flags2;
  187. float xp_vitality;
  188. float tradeskill_xp_vitality;
  189. int16 mitigation_skill1;
  190. int16 mitigation_skill2;
  191. int16 mitigation_skill3;
  192. float ability_modifier;
  193. float critical_mitigation;
  194. float block_chance;
  195. float uncontested_parry;
  196. float uncontested_block;
  197. float uncontested_dodge;
  198. float uncontested_riposte;
  199. float crit_chance;
  200. float crit_bonus;
  201. float potency;
  202. float hate_mod;
  203. float reuse_speed;
  204. float casting_speed;
  205. float recovery_speed;
  206. float spell_reuse_speed;
  207. float spell_multi_attack;
  208. float dps;
  209. float dps_multiplier;
  210. float attackspeed;
  211. float haste;
  212. float multi_attack;
  213. float flurry;
  214. float melee_ae;
  215. float strikethrough;
  216. float accuracy;
  217. float offensivespeed;
  218. float rain;
  219. float wind;
  220. sint8 alignment;
  221. int32 pet_id;
  222. char pet_name[32];
  223. float pet_health_pct;
  224. float pet_power_pct;
  225. int8 pet_movement;
  226. int8 pet_behavior;
  227. int8 vision;
  228. int8 breathe_underwater;
  229. char biography[512];
  230. float drunk;
  231. };
  232. struct WardInfo {
  233. LuaSpell* Spell;
  234. int32 BaseDamage;
  235. int32 DamageLeft;
  236. int8 WardType;
  237. int8 DamageType;
  238. bool keepWard;
  239. int32 DamageAbsorptionPercentage;
  240. int32 DamageAbsorptionMaxHealthPercent;
  241. int32 RedirectDamagePercent;
  242. int32 LastRedirectDamage;
  243. int32 LastAbsorbedDamage;
  244. int32 HitCount;
  245. int32 MaxHitCount;
  246. bool AbsorbAllDamage; // damage is always absorbed, usually spells based on hits, when we pass damage in AddWard as 0 this will be set to true
  247. };
  248. #define WARD_TYPE_ALL 0
  249. #define WARD_TYPE_PHYSICAL 1
  250. #define WARD_TYPE_MAGICAL 2
  251. struct Proc {
  252. LuaSpell* spell;
  253. Item* item;
  254. float chance;
  255. };
  256. #define PROC_TYPE_OFFENSIVE 1
  257. #define PROC_TYPE_DEFENSIVE 2
  258. #define PROC_TYPE_PHYSICAL_OFFENSIVE 3
  259. #define PROC_TYPE_PHYSICAL_DEFENSIVE 4
  260. #define PROC_TYPE_MAGICAL_OFFENSIVE 5
  261. #define PROC_TYPE_MAGICAL_DEFENSIVE 6
  262. #define PROC_TYPE_BLOCK 7
  263. #define PROC_TYPE_PARRY 8
  264. #define PROC_TYPE_RIPOSTE 9
  265. #define PROC_TYPE_EVADE 10
  266. #define PROC_TYPE_HEALING 11
  267. #define PROC_TYPE_BENEFICIAL 12
  268. #define PROC_TYPE_DEATH 13
  269. #define PROC_TYPE_KILL 14
  270. #define PROC_TYPE_DAMAGED 15
  271. #define PROC_TYPE_DAMAGED_MELEE 16
  272. #define PROC_TYPE_DAMAGED_MAGIC 17
  273. #define PROC_TYPE_RANGED_ATTACK 18
  274. #define PROC_TYPE_RANGED_DEFENSE 19
  275. struct ThreatTransfer {
  276. int32 Target;
  277. float Amount;
  278. LuaSpell* Spell;
  279. };
  280. #define DET_TYPE_TRAUMA 1
  281. #define DET_TYPE_ARCANE 2
  282. #define DET_TYPE_NOXIOUS 3
  283. #define DET_TYPE_ELEMENTAL 4
  284. #define DET_TYPE_CURSE 5
  285. #define DISPELL_TYPE_CURE 0
  286. #define DISPELL_TYPE_DISPELL 1
  287. #define CONTROL_EFFECT_TYPE_MEZ 1
  288. #define CONTROL_EFFECT_TYPE_STIFLE 2
  289. #define CONTROL_EFFECT_TYPE_DAZE 3
  290. #define CONTROL_EFFECT_TYPE_STUN 4
  291. #define CONTROL_EFFECT_TYPE_ROOT 5
  292. #define CONTROL_EFFECT_TYPE_FEAR 6
  293. #define CONTROL_EFFECT_TYPE_WALKUNDERWATER 7
  294. #define CONTROL_EFFECT_TYPE_JUMPUNDERWATER 8
  295. #define CONTROL_EFFECT_TYPE_INVIS 9
  296. #define CONTROL_EFFECT_TYPE_STEALTH 10
  297. #define CONTROL_EFFECT_TYPE_SNARE 11
  298. #define CONTROL_EFFECT_TYPE_FLIGHT 12
  299. #define CONTROL_EFFECT_TYPE_GLIDE 13
  300. #define CONTROL_EFFECT_TYPE_SAFEFALL 14
  301. #define CONTROL_MAX_EFFECTS 15 // always +1 to highest control effect
  302. #define IMMUNITY_TYPE_MEZ 1
  303. #define IMMUNITY_TYPE_STIFLE 2
  304. #define IMMUNITY_TYPE_DAZE 3
  305. #define IMMUNITY_TYPE_STUN 4
  306. #define IMMUNITY_TYPE_ROOT 5
  307. #define IMMUNITY_TYPE_FEAR 6
  308. #define IMMUNITY_TYPE_AOE 7
  309. //class Spell;
  310. //class ZoneServer;
  311. //The entity class is for NPCs and Players, spawns which are able to fight
  312. class Entity : public Spawn{
  313. public:
  314. Entity();
  315. virtual ~Entity();
  316. virtual float GetShieldBlockChance();
  317. virtual float GetDodgeChance();
  318. virtual void AddMaintainedSpell(LuaSpell* spell);
  319. virtual void AddSpellEffect(LuaSpell* spell);
  320. virtual void RemoveMaintainedSpell(LuaSpell* spell);
  321. virtual void RemoveSpellEffect(LuaSpell* spell);
  322. virtual bool HasActiveMaintainedSpell(Spell* spell, Spawn* target);
  323. virtual bool HasActiveSpellEffect(Spell* spell, Spawn* target);
  324. virtual void AddSkillBonus(int32 spell_id, int32 skill_id, float value);
  325. void AddDetrimentalSpell(LuaSpell* spell);
  326. DetrimentalEffects* GetDetrimentalEffect(int32 spell_id, Entity* caster);
  327. virtual MaintainedEffects* GetMaintainedSpell(int32 spell_id);
  328. void RemoveDetrimentalSpell(LuaSpell* spell);
  329. void SetDeity(int8 new_deity){
  330. deity = new_deity;
  331. }
  332. int8 GetDeity(){ return deity; }
  333. EquipmentItemList* GetEquipmentList();
  334. bool IsEntity(){ return true; }
  335. void CalculateBonuses();
  336. float CalculateBonusMod();
  337. float CalculateDPSMultiplier();
  338. float CalculateCastingSpeedMod();
  339. InfoStruct* GetInfoStruct();
  340. int16 GetStr();
  341. int16 GetSta();
  342. int16 GetInt();
  343. int16 GetWis();
  344. int16 GetAgi();
  345. int16 GetPrimaryStat();
  346. int16 GetHeatResistance();
  347. int16 GetColdResistance();
  348. int16 GetMagicResistance();
  349. int16 GetMentalResistance();
  350. int16 GetDivineResistance();
  351. int16 GetDiseaseResistance();
  352. int16 GetPoisonResistance();
  353. int16 GetStrBase();
  354. int16 GetStaBase();
  355. int16 GetIntBase();
  356. int16 GetWisBase();
  357. int16 GetAgiBase();
  358. int16 GetHeatResistanceBase();
  359. int16 GetColdResistanceBase();
  360. int16 GetMagicResistanceBase();
  361. int16 GetMentalResistanceBase();
  362. int16 GetDivineResistanceBase();
  363. int16 GetDiseaseResistanceBase();
  364. int16 GetPoisonResistanceBase();
  365. int8 GetConcentrationCurrent();
  366. int8 GetConcentrationMax();
  367. sint8 GetAlignment();
  368. void SetAlignment(sint8 new_value);
  369. bool HasMoved(bool include_heading);
  370. void SetHPRegen(int16 new_val);
  371. void SetPowerRegen(int16 new_val);
  372. int16 GetHPRegen();
  373. int16 GetPowerRegen();
  374. void DoRegenUpdate();
  375. MaintainedEffects* GetFreeMaintainedSpellSlot();
  376. SpellEffects* GetFreeSpellEffectSlot();
  377. SpellEffects* GetSpellEffect(int32 id, Entity* caster = 0);
  378. //flags
  379. int32 GetFlags() { return info_struct.flags; }
  380. int32 GetFlags2() { return info_struct.flags2; }
  381. bool query_flags(int flag) {
  382. if (flag > 63) return false;
  383. if (flag < 32) return ((info_struct.flags & (1 << flag))?true:false);
  384. return ((info_struct.flags2 & (1 << (flag - 32)))?true:false);
  385. }
  386. float GetMaxSpeed();
  387. void SetMaxSpeed(float val);
  388. //combat stuff:
  389. int32 GetRangeLastAttackTime();
  390. void SetRangeLastAttackTime(int32 time);
  391. int16 GetRangeAttackDelay();
  392. int16 GetRangeWeaponDelay() {return ranged_combat_data.ranged_weapon_delay;}
  393. void SetRangeWeaponDelay(int16 new_delay) {ranged_combat_data.ranged_weapon_delay = new_delay * 100;}
  394. void SetRangeAttackDelay(int16 new_delay) {ranged_combat_data.ranged_attack_delay = new_delay;}
  395. int32 GetPrimaryLastAttackTime();
  396. int16 GetPrimaryAttackDelay();
  397. void SetPrimaryAttackDelay(int16 new_delay);
  398. void SetPrimaryLastAttackTime(int32 new_time);
  399. void SetPrimaryWeaponDelay(int16 new_delay) {melee_combat_data.primary_weapon_delay = new_delay * 100;}
  400. int32 GetSecondaryLastAttackTime();
  401. int16 GetSecondaryAttackDelay();
  402. void SetSecondaryAttackDelay(int16 new_delay);
  403. void SetSecondaryLastAttackTime(int32 new_time);
  404. void SetSecondaryWeaponDelay(int16 new_delay) {melee_combat_data.primary_weapon_delay = new_delay * 100;}
  405. int32 GetPrimaryWeaponMinDamage();
  406. int32 GetPrimaryWeaponMaxDamage();
  407. int32 GetSecondaryWeaponMinDamage();
  408. int32 GetSecondaryWeaponMaxDamage();
  409. int32 GetRangedWeaponMinDamage();
  410. int32 GetRangedWeaponMaxDamage();
  411. int8 GetPrimaryWeaponType();
  412. int8 GetSecondaryWeaponType();
  413. int8 GetRangedWeaponType();
  414. int8 GetWieldType();
  415. int16 GetPrimaryWeaponDelay() {return melee_combat_data.primary_weapon_delay;}
  416. int16 GetSecondaryWeaponDelay() {return melee_combat_data.secondary_weapon_delay;}
  417. bool IsDualWield();
  418. bool BehindTarget(Spawn* target);
  419. bool FlankingTarget(Spawn* target);
  420. void ChangePrimaryWeapon();
  421. void ChangeSecondaryWeapon();
  422. void ChangeRangedWeapon();
  423. virtual Skill* GetSkillByName(const char* name, bool check_update = false);
  424. bool AttackAllowed(Entity* target, float distance = 0, bool range_attack = false);
  425. bool PrimaryWeaponReady();
  426. bool SecondaryWeaponReady();
  427. bool RangeWeaponReady();
  428. void MeleeAttack(Spawn* victim, float distance, bool primary, bool multi_attack = false);
  429. void RangeAttack(Spawn* victim, float distance, Item* weapon, Item* ammo, bool multi_attack = false);
  430. bool SpellAttack(Spawn* victim, float distance, LuaSpell* luaspell, int8 damage_type, int32 low_damage, int32 high_damage, int8 crit_mod = 0, bool no_calcs = false);
  431. bool ProcAttack(Spawn* victim, int8 damage_type, int32 low_damage, int32 high_damage, string name, string success_msg, string effect_msg);
  432. bool SpellHeal(Spawn* target, float distance, LuaSpell* luaspell, string heal_type, int32 low_heal, int32 high_heal, int8 crit_mod = 0, bool no_calcs = false);
  433. int8 DetermineHit(Spawn* victim, int8 damage_type, float ToHitBonus, bool spell);
  434. float GetDamageTypeResistPercentage(int8 damage_type);
  435. Skill* GetSkillByWeaponType(int8 type, bool update);
  436. bool DamageSpawn(Entity* victim, int8 type, int8 damage_type, int32 low_damage, int32 high_damage, const char* spell_name, int8 crit_mod = 0, bool is_tick = false, bool no_damage_calcs = false);
  437. void AddHate(Entity* attacker, sint32 hate);
  438. bool CheckInterruptSpell(Entity* attacker);
  439. void KillSpawn(Spawn* dead, int8 damage_type = 0, int16 kill_blow_type = 0);
  440. void SetAttackDelay(bool primary = false, bool ranged = false);
  441. float CalculateAttackSpeedMod();
  442. virtual void ProcessCombat();
  443. bool EngagedInCombat();
  444. virtual void InCombat(bool val);
  445. bool IsCasting();
  446. void IsCasting(bool val);
  447. bool HasLoot(){
  448. if(loot_items.size() == 0 && loot_coins == 0)
  449. return false;
  450. return true;
  451. }
  452. bool HasLootItemID(int32 id);
  453. int32 GetLootItemID();
  454. Item* LootItem(int32 id);
  455. vector<Item*>* GetLootItems(){
  456. return &loot_items;
  457. }
  458. void LockLoot(){
  459. MLootItems.lock();
  460. }
  461. void UnlockLoot(){
  462. MLootItems.unlock();
  463. }
  464. int32 GetLootCoins(){
  465. return loot_coins;
  466. }
  467. void SetLootCoins(int32 val){
  468. loot_coins = val;
  469. }
  470. void AddLootCoins(int32 coins){
  471. loot_coins += coins;
  472. }
  473. bool HasTrapTriggered() {
  474. return trap_triggered;
  475. }
  476. void SetTrapTriggered(bool triggered) {
  477. trap_triggered = triggered;
  478. }
  479. void AddLootItem(int32 id, int16 charges = 1){
  480. Item* master_item = master_item_list.GetItem(id);
  481. if(master_item){
  482. Item* item = new Item(master_item);
  483. item->details.count = charges;
  484. loot_items.push_back(item);
  485. }
  486. }
  487. void SetMount(int16 mount_id, int8 red = 0xFF, int8 green = 0xFF, int8 blue = 0xFF, bool setUpdateFlags = true)
  488. {
  489. if (mount_id == 0) {
  490. EQ2_Color color;
  491. color.red = 0;
  492. color.green = 0;
  493. color.blue = 0;
  494. SetMountColor(&color);
  495. SetMountSaddleColor(&color);
  496. }
  497. else
  498. {
  499. EQ2_Color color;
  500. color.red = red;
  501. color.green = green;
  502. color.blue = blue;
  503. SetMountColor(&color);
  504. SetMountSaddleColor(&color);
  505. }
  506. SetInfo(&features.mount_model_type, mount_id, setUpdateFlags);
  507. }
  508. void SetEquipment(Item* item, int8 slot = 255);
  509. void SetEquipment(int8 slot, int16 type, int8 red, int8 green, int8 blue, int8 h_r, int8 h_g, int8 h_b){
  510. SetInfo(&equipment.equip_id[slot], type);
  511. SetInfo(&equipment.color[slot].red, red);
  512. SetInfo(&equipment.color[slot].green, green);
  513. SetInfo(&equipment.color[slot].blue, blue);
  514. SetInfo(&equipment.highlight[slot].red, h_r);
  515. SetInfo(&equipment.highlight[slot].green, h_g);
  516. SetInfo(&equipment.highlight[slot].blue, h_b);
  517. }
  518. void SetHairType(int16 new_val, bool setUpdateFlags = true){
  519. SetInfo(&features.hair_type, new_val, setUpdateFlags);
  520. }
  521. void SetHairColor(EQ2_Color new_val, bool setUpdateFlags = true){
  522. SetInfo(&features.hair_type_color, new_val, setUpdateFlags);
  523. }
  524. void SetHairHighlightColor(EQ2_Color new_val, bool setUpdateFlags = true){
  525. SetInfo(&features.hair_type_highlight_color, new_val, setUpdateFlags);
  526. }
  527. void SetFacialHairType(int16 new_val, bool setUpdateFlags = true){
  528. SetInfo(&features.hair_face_type, new_val, setUpdateFlags);
  529. }
  530. void SetFacialHairColor(EQ2_Color new_val, bool setUpdateFlags = true){
  531. SetInfo(&features.hair_face_color, new_val, setUpdateFlags);
  532. }
  533. void SetFacialHairHighlightColor(EQ2_Color new_val, bool setUpdateFlags = true){
  534. SetInfo(&features.hair_face_highlight_color, new_val, setUpdateFlags);
  535. }
  536. void SetWingType(int16 new_val, bool setUpdateFlags = true){
  537. SetInfo(&features.wing_type, new_val, setUpdateFlags);
  538. }
  539. void SetWingColor1(EQ2_Color new_val, bool setUpdateFlags = true){
  540. SetInfo(&features.wing_color1, new_val, setUpdateFlags);
  541. }
  542. void SetWingColor2(EQ2_Color new_val, bool setUpdateFlags = true){
  543. SetInfo(&features.wing_color2, new_val, setUpdateFlags);
  544. }
  545. void SetChestType(int16 new_val, bool setUpdateFlags = true){
  546. SetInfo(&features.chest_type, new_val, setUpdateFlags);
  547. }
  548. void SetLegsType(int16 new_val, bool setUpdateFlags = true){
  549. SetInfo(&features.legs_type, new_val, setUpdateFlags);
  550. }
  551. void SetSogaHairType(int16 new_val, bool setUpdateFlags = true){
  552. SetInfo(&features.soga_hair_type, new_val, setUpdateFlags);
  553. }
  554. void SetSogaFacialHairType(int16 new_val, bool setUpdateFlags = true){
  555. SetInfo(&features.soga_hair_face_type, new_val, setUpdateFlags);
  556. }
  557. void SetSogaChestType(int16 new_val, bool setUpdateFlags = true){
  558. SetInfo(&features.soga_chest_type, new_val, setUpdateFlags);
  559. }
  560. void SetSogaLegType(int16 new_val, bool setUpdateFlags = true){
  561. SetInfo(&features.soga_legs_type, new_val, setUpdateFlags);
  562. }
  563. void SetSkinColor(EQ2_Color color){
  564. SetInfo(&features.skin_color, color);
  565. }
  566. void SetCombatVoice(int16 val, bool setUpdateFlags = true) {
  567. SetInfo(&features.combat_voice, val, setUpdateFlags);
  568. }
  569. void SetEmoteVoice(int16 val, bool setUpdateFlags = true) {
  570. SetInfo(&features.emote_voice, val, setUpdateFlags);
  571. }
  572. int16 GetCombatVoice(){ return features.combat_voice; }
  573. int16 GetEmoteVoice(){ return features.emote_voice; }
  574. int16 GetMount(){ return features.mount_model_type; }
  575. void SetMountSaddleColor(EQ2_Color* color){
  576. SetInfo(&features.mount_saddle_color, *color);
  577. }
  578. void SetMountColor(EQ2_Color* color){
  579. SetInfo(&features.mount_color, *color);
  580. }
  581. void SetEyeColor(EQ2_Color eye_color){
  582. SetInfo(&features.eye_color, eye_color);
  583. }
  584. int16 GetHairType(){
  585. return features.hair_type;
  586. }
  587. int16 GetFacialHairType(){
  588. return features.hair_face_type;
  589. }
  590. int16 GetWingType(){
  591. return features.wing_type;
  592. }
  593. int16 GetChestType(){
  594. return features.chest_type;
  595. }
  596. int16 GetLegsType(){
  597. return features.legs_type;
  598. }
  599. int16 GetSogaHairType(){
  600. return features.soga_hair_type;
  601. }
  602. int16 GetSogaFacialHairType(){
  603. return features.soga_hair_face_type;
  604. }
  605. int16 GetSogaChestType(){
  606. return features.soga_chest_type;
  607. }
  608. int16 GetSogaLegType(){
  609. return features.soga_legs_type;
  610. }
  611. EQ2_Color* GetSkinColor(){
  612. return &features.skin_color;
  613. }
  614. EQ2_Color* GetEyeColor(){
  615. return &features.eye_color;
  616. }
  617. EQ2_Color* GetMountSaddleColor(){
  618. return &features.mount_saddle_color;
  619. }
  620. EQ2_Color* GetMountColor(){
  621. return &features.mount_color;
  622. }
  623. EQ2_Equipment equipment;
  624. CharFeatures features;
  625. void AddSpellBonus(LuaSpell* spell, int16 type, float value, int64 class_req =0, vector<int16> race_req = vector<int16>(), vector<int16> faction_req = vector<int16>());
  626. BonusValues* GetSpellBonus(int32 spell_id);
  627. vector<BonusValues*>* GetAllSpellBonuses(LuaSpell* spell);
  628. bool CheckSpellBonusRemoval(LuaSpell* spell, int16 type);
  629. void RemoveSpellBonus(const LuaSpell* spell);
  630. void CalculateSpellBonuses(ItemStatsValues* stats);
  631. void AddMezSpell(LuaSpell* spell);
  632. void RemoveMezSpell(LuaSpell* spell);
  633. void RemoveAllMezSpells();
  634. bool IsMezzed();
  635. void AddStifleSpell(LuaSpell* spell);
  636. void RemoveStifleSpell(LuaSpell* spell);
  637. bool IsStifled();
  638. void AddDazeSpell(LuaSpell* spell);
  639. void RemoveDazeSpell(LuaSpell* spell);
  640. bool IsDazed();
  641. void AddStunSpell(LuaSpell* spell);
  642. void RemoveStunSpell(LuaSpell* spell);
  643. bool IsStunned();
  644. bool IsMezzedOrStunned() {return IsMezzed() || IsStunned();}
  645. void AddRootSpell(LuaSpell* spell);
  646. void RemoveRootSpell(LuaSpell* spell);
  647. bool IsRooted();
  648. void AddFearSpell(LuaSpell* spell);
  649. void RemoveFearSpell(LuaSpell* spell);
  650. bool IsFeared();
  651. void AddSnareSpell(LuaSpell* spell);
  652. void RemoveSnareSpell(LuaSpell* spell);
  653. void SetSnareValue(LuaSpell* spell, float snare_val);
  654. bool IsSnared();
  655. float GetHighestSnare();
  656. void HaltMovement();
  657. void SetCombatPet(Entity* pet) { this->pet = pet; }
  658. void SetCharmedPet(Entity* pet) { charmedPet = pet; }
  659. void SetDeityPet(Entity* pet) { deityPet = pet; }
  660. void SetCosmeticPet(Entity* pet) { cosmeticPet = pet; }
  661. Entity* GetPet() { return pet; }
  662. Entity* GetCharmedPet() { return charmedPet; }
  663. Entity* GetDeityPet() { return deityPet; }
  664. Entity* GetCosmeticPet() { return cosmeticPet; }
  665. /// <summary>Check to see if the entity has a combat pet</summary>
  666. /// <returns>True if the entity has a combat pet</returns>
  667. bool HasPet() { return (pet || charmedPet) ? true : false; }
  668. void HideDeityPet(bool val);
  669. void HideCosmeticPet(bool val);
  670. void DismissPet(NPC* pet, bool from_death = false);
  671. /// <summary>Creates a loot chest to drop in the world</summary>
  672. /// <returns>Pointer to the chest</returns>
  673. NPC* DropChest();
  674. /// <summary>Add a ward to the entities ward list</summary>
  675. /// <param name='spellID'>Spell id of the ward to add</param>
  676. /// <param name='ward'>WardInfo* of the ward we are adding</parma>
  677. void AddWard(int32 spellID, WardInfo* ward);
  678. /// <summary>Gets ward info for the given spell id</summary>
  679. /// <param name='spellID'>The spell id of the ward we want to get</param>
  680. /// <returns>WardInfo for the given spell id</returns>
  681. WardInfo* GetWard(int32 spellID);
  682. /// <summary>Removes the ward with the given spell id</summary>
  683. /// <param name='spellID'>The spell id of the ward to remove</param>
  684. void RemoveWard(int32 spellID);
  685. /// <summary>Subtracts the given damage from the wards</summary>
  686. /// <param name='damage'>The damage to subtract from the wards</param>
  687. /// <returns>The amount of damage left after wards</returns>
  688. int32 CheckWards(Entity* attacker, int32 damage, int8 damage_type);
  689. map<int16, float> stats;
  690. /// <summary>Adds a proc to the list of current procs</summary>
  691. /// <param name='type'>The type of proc to add</param>
  692. /// <param name='chance'>The percent chance the proc has to go off</param>
  693. /// <param name='item'>The item the proc is coming from if any</param>
  694. /// <param name='spell'>The spell the proc is coming from if any</param>
  695. void AddProc(int8 type, float chance, Item* item = 0, LuaSpell* spell = 0);
  696. /// <summary>Removes a proc from the list of current procs</summary>
  697. /// <param name='item'>Item the proc is from</param>
  698. /// <param name='spell'>Spell the proc is from</param>
  699. void RemoveProc(Item* item = 0, LuaSpell* spell = 0);
  700. /// <summary>Cycles through the proc list and executes them if they can go off</summary>
  701. /// <param name='type'>The proc type to check</param>
  702. /// <param name='target'>The target of the proc if it goes off</param>
  703. void CheckProcs(int8 type, Spawn* target);
  704. /// <summary>Clears the entire proc list</summary>
  705. void ClearProcs();
  706. float GetSpeed();
  707. float GetAirSpeed();
  708. float GetBaseSpeed() { return base_speed; }
  709. void SetSpeed(float val, bool override_ = false) { if ((base_speed == 0.0f && val > 0.0f) || override_) base_speed = val; speed = val; }
  710. void SetSpeedMultiplier(float val) { speed_multiplier = val; }
  711. void SetThreatTransfer(ThreatTransfer* transfer) { m_threatTransfer = transfer; }
  712. ThreatTransfer* GetThreatTransfer() { return m_threatTransfer; }
  713. int8 GetTraumaCount();
  714. int8 GetArcaneCount();
  715. int8 GetNoxiousCount();
  716. int8 GetElementalCount();
  717. int8 GetCurseCount();
  718. int8 GetDetTypeCount(int8 det_type);
  719. int8 GetDetCount();
  720. bool HasCurableDetrimentType(int8 det_type);
  721. Mutex* GetDetrimentMutex();
  722. Mutex* GetMaintainedMutex();
  723. Mutex* GetSpellEffectMutex();
  724. void ClearAllDetriments();
  725. void CureDetrimentByType(int8 cure_count, int8 det_type, string cure_name, Entity* caster, int8 cure_level = 0);
  726. void CureDetrimentByControlEffect(int8 cure_count, int8 det_type, string cure_name, Entity* caster, int8 cure_level = 0);
  727. vector<DetrimentalEffects>* GetDetrimentalSpellEffects();
  728. void RemoveEffectsFromLuaSpell(LuaSpell* spell);
  729. virtual void RemoveSkillBonus(int32 spell_id);
  730. virtual bool CanSeeInvis(Entity* target);
  731. void CancelAllStealth();
  732. bool IsStealthed();
  733. bool IsInvis();
  734. void AddInvisSpell(LuaSpell* spell);
  735. void AddStealthSpell(LuaSpell* spell);
  736. void RemoveStealthSpell(LuaSpell* spell);
  737. void RemoveInvisSpell(LuaSpell* spell);
  738. void AddWaterwalkSpell(LuaSpell* spell);
  739. void AddWaterjumpSpell(LuaSpell* spell);
  740. void RemoveWaterwalkSpell(LuaSpell* spell);
  741. void RemoveWaterjumpSpell(LuaSpell* spell);
  742. void AddAOEImmunity(LuaSpell* spell);
  743. bool IsAOEImmune();
  744. void RemoveAOEImmunity(LuaSpell* spell);
  745. void AddStunImmunity(LuaSpell* spell);
  746. void RemoveStunImmunity(LuaSpell* spell);
  747. bool IsStunImmune();
  748. void AddStifleImmunity(LuaSpell* spell);
  749. void RemoveStifleImmunity(LuaSpell* spell);
  750. bool IsStifleImmune();
  751. void AddMezImmunity(LuaSpell* spell);
  752. void RemoveMezImmunity(LuaSpell* spell);
  753. bool IsMezImmune();
  754. void AddRootImmunity(LuaSpell* spell);
  755. void RemoveRootImmunity(LuaSpell* spell);
  756. bool IsRootImmune();
  757. void AddFearImmunity(LuaSpell* spell);
  758. void RemoveFearImmunity(LuaSpell* spell);
  759. bool IsFearImmune();
  760. void AddDazeImmunity(LuaSpell* spell);
  761. void RemoveDazeImmunity(LuaSpell* spell);
  762. bool IsDazeImmune();
  763. void AddFlightSpell(LuaSpell* spell);
  764. void RemoveFlightSpell(LuaSpell* spell);
  765. void AddSafefallSpell(LuaSpell* spell);
  766. void RemoveSafefallSpell(LuaSpell* spell);
  767. void AddGlideSpell(LuaSpell* spell);
  768. void RemoveGlideSpell(LuaSpell* spell);
  769. GroupMemberInfo* GetGroupMemberInfo() { return group_member_info; }
  770. void SetGroupMemberInfo(GroupMemberInfo* info) { group_member_info = info; }
  771. void UpdateGroupMemberInfo();
  772. void CustomizeAppearance(PacketStruct* packet);
  773. void ClearLootList() {
  774. vector<Item*>::iterator itr;
  775. for (itr = loot_items.begin(); itr != loot_items.end(); itr++)
  776. safe_delete(*itr);
  777. loot_items.clear();
  778. }
  779. Trade* trade;
  780. // Keep track of entities that hate this spawn.
  781. set<int32> HatedBy;
  782. Mutex MCommandMutex;
  783. bool HasSeeInvisSpell() { return hasSeeInvisSpell; }
  784. void SetSeeInvisSpell(bool val) { hasSeeInvisSpell = val; }
  785. bool HasSeeHideSpell() { return hasSeeHideSpell; }
  786. void SetSeeHideSpell(bool val) { hasSeeHideSpell = val; }
  787. protected:
  788. bool in_combat;
  789. private:
  790. MutexList<BonusValues*> bonus_list;
  791. map<int8, MutexList<LuaSpell*>*> control_effects;
  792. map<int8, MutexList<LuaSpell*>*> immunities;
  793. float max_speed;
  794. vector<Item*> loot_items;
  795. int32 loot_coins;
  796. bool trap_triggered;
  797. int8 deity;
  798. sint16 regen_hp_rate;
  799. sint16 regen_power_rate;
  800. float last_x;
  801. float last_y;
  802. float last_z;
  803. float last_heading;
  804. bool casting;
  805. InfoStruct info_struct;
  806. CombatData melee_combat_data;
  807. CombatData ranged_combat_data;
  808. map<int8, int8> det_count_list;
  809. Mutex MDetriments;
  810. Mutex MMaintainedSpells;
  811. Mutex MSpellEffects;
  812. vector<DetrimentalEffects> detrimental_spell_effects;
  813. Mutex MLootItems;
  814. // Pointers for the 4 types of pets (Summon, Charm, Deity, Cosmetic)
  815. Entity* pet;
  816. Entity* charmedPet;
  817. Entity* deityPet;
  818. Entity* cosmeticPet;
  819. // int32 = spell id, WardInfo* = pointer to ward info
  820. map<int32, WardInfo*> m_wardList;
  821. // int8 = type, vector<Proc*> = list of pointers to proc info
  822. map <int8, vector<Proc*> > m_procList;
  823. Mutex MProcList;
  824. /// <summary>Actually calls the lua script to cast the proc</summary>
  825. /// <param name='proc'>Proc to be cast</param>
  826. /// <param name='type'>Type of proc going off</type>
  827. /// <param name='target'>Target of the proc</param>
  828. bool CastProc(Proc* proc, int8 type, Spawn* target);
  829. float base_speed;
  830. float speed;
  831. float speed_multiplier;
  832. map<LuaSpell*, float> snare_values;
  833. ThreatTransfer* m_threatTransfer;
  834. GroupMemberInfo* group_member_info;
  835. bool hasSeeInvisSpell;
  836. bool hasSeeHideSpell;
  837. };
  838. #endif