Spawn.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  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_SPAWN__
  17. #define __EQ2_SPAWN__
  18. #include "../common/types.h"
  19. #include "../common/EQPacket.h"
  20. #include "../common/EQ2_Common_Structs.h"
  21. #include "../common/MiscFunctions.h"
  22. #include "../common/opcodemgr.h"
  23. #include "../common/timer.h"
  24. #include "Commands/Commands.h"
  25. #include "Zone/position.h"
  26. #include "SpawnLists.h"
  27. #include <vector>
  28. #include "../common/ConfigReader.h"
  29. #include "Items/Items.h"
  30. #include "Zone/map.h"
  31. #include "../common/Mutex.h"
  32. #include "MutexList.h"
  33. #include <deque>
  34. #include <memory> // needed for LS to compile properly on linux
  35. #define DAMAGE_PACKET_TYPE_SIPHON_SPELL 0x41
  36. #define DAMAGE_PACKET_TYPE_SIPHON_SPELL2 0x49
  37. #define DAMAGE_PACKET_TYPE_MULTIPLE_DAMAGE 0x80
  38. #define DAMAGE_PACKET_TYPE_SIMPLE_DAMAGE 0xC0
  39. #define DAMAGE_PACKET_TYPE_SPELL_DAMAGE 0xC1
  40. #define DAMAGE_PACKET_TYPE_SIMPLE_CRIT_DMG 0xC4
  41. #define DAMAGE_PACKET_TYPE_SPELL_CRIT_DMG 0xC5
  42. #define DAMAGE_PACKET_TYPE_SPELL_DAMAGE2 0xC8
  43. #define DAMAGE_PACKET_TYPE_SPELL_DAMAGE3 0xC9
  44. #define DAMAGE_PACKET_TYPE_RANGE_DAMAGE 0xE2
  45. #define DAMAGE_PACKET_TYPE_RANGE_SPELL_DMG 0xE3
  46. #define DAMAGE_PACKET_TYPE_RANGE_SPELL_DMG2 0xEA
  47. #define DAMAGE_PACKET_RESULT_NO_DAMAGE 0
  48. #define DAMAGE_PACKET_RESULT_SUCCESSFUL 1
  49. #define DAMAGE_PACKET_RESULT_MISS 4
  50. #define DAMAGE_PACKET_RESULT_DODGE 8
  51. #define DAMAGE_PACKET_RESULT_PARRY 12
  52. #define DAMAGE_PACKET_RESULT_RIPOSTE 16
  53. #define DAMAGE_PACKET_RESULT_BLOCK 20
  54. #define DAMAGE_PACKET_RESULT_DEATH_BLOW 24
  55. #define DAMAGE_PACKET_RESULT_INVULNERABLE 28
  56. #define DAMAGE_PACKET_RESULT_RESIST 36
  57. #define DAMAGE_PACKET_RESULT_REFLECT 40
  58. #define DAMAGE_PACKET_RESULT_IMMUNE 44
  59. #define DAMAGE_PACKET_RESULT_DEFLECT 48
  60. #define DAMAGE_PACKET_RESULT_COUNTER 52
  61. #define DAMAGE_PACKET_RESULT_COUNTER_STRIKE 60
  62. #define DAMAGE_PACKET_RESULT_BASH 64
  63. #define DAMAGE_PACKET_DAMAGE_TYPE_SLASH 0
  64. #define DAMAGE_PACKET_DAMAGE_TYPE_CRUSH 1
  65. #define DAMAGE_PACKET_DAMAGE_TYPE_PIERCE 2
  66. #define DAMAGE_PACKET_DAMAGE_TYPE_HEAT 3
  67. #define DAMAGE_PACKET_DAMAGE_TYPE_COLD 4
  68. #define DAMAGE_PACKET_DAMAGE_TYPE_MAGIC 5
  69. #define DAMAGE_PACKET_DAMAGE_TYPE_MENTAL 6
  70. #define DAMAGE_PACKET_DAMAGE_TYPE_DIVINE 7
  71. #define DAMAGE_PACKET_DAMAGE_TYPE_DISEASE 8
  72. #define DAMAGE_PACKET_DAMAGE_TYPE_POISON 9
  73. #define DAMAGE_PACKET_DAMAGE_TYPE_DROWN 10
  74. #define DAMAGE_PACKET_DAMAGE_TYPE_FALLING 11
  75. #define DAMAGE_PACKET_DAMAGE_TYPE_PAIN 12
  76. #define HEAL_PACKET_TYPE_SIMPLE_HEAL 0
  77. #define HEAL_PACKET_TYPE_CRIT_HEAL 1
  78. #define HEAL_PACKET_TYPE_ABSORB 2
  79. #define HEAL_PACKET_TYPE_REGEN_ABSORB 4
  80. #define HEAL_PACKET_TYPE_SIMPLE_MANA 8
  81. #define HEAL_PACKET_TYPE_CRIT_MANA 9
  82. #define HEAL_PACKET_TYPE_SAVAGERY 16
  83. #define HEAL_PACKET_TYPE_CRIT_SAVAGERY 17
  84. #define HEAL_PACKET_TYPE_REPAIR 64
  85. #define HEAL_PACKET_TYPE_CRIT_REPAIR 65
  86. #define ARROW_COLOR_GRAY 0 // 3
  87. #define ARROW_COLOR_GREEN 1 // 1
  88. #define ARROW_COLOR_BLUE 2
  89. #define ARROW_COLOR_WHITE 3 // 3
  90. #define ARROW_COLOR_YELLOW 4 // 4
  91. #define ARROW_COLOR_ORANGE 5 // 5
  92. #define ARROW_COLOR_RED 6
  93. #define ACTIVITY_STATUS_ROLEPLAYING 1
  94. #define ACTIVITY_STATUS_ANONYMOUS 2
  95. #define ACTIVITY_STATUS_LINKDEAD 4
  96. #define ACTIVITY_STATUS_CAMPING 8
  97. #define ACTIVITY_STATUS_LFG 16
  98. #define ACTIVITY_STATUS_LFW 32
  99. #define ACTIVITY_STATUS_SOLID 64 //used by zone objects to remain solid
  100. #define ACTIVITY_STATUS_IMMUNITY_GAINED 8192
  101. #define ACTIVITY_STATUS_IMMUNITY_REMAINING 16384
  102. // WE ARE UNSURE OF THESE OLD CLIENT VALUES USED AS TEMP PLACEHOLDERS FOR NEWER CLIENTS
  103. #define ACTIVITY_STATUS_AFK 32768 // whats the real one?
  104. #define ACTIVITY_STATUS_MERCENARY_1188 1<<2
  105. #define ACTIVITY_STATUS_STATICOBJECT_1188 1<<3
  106. #define ACTIVITY_STATUS_MERCHANT_1188 1<<4
  107. #define ACTIVITY_STATUS_HIDEICON_1188 1<<9
  108. #define ACTIVITY_STATUS_INTERACTABLE_1188 1<<10
  109. #define ACTIVITY_STATUS_NOTARGET_1188 1<<11
  110. #define ACTIVITY_STATUS_ISTRANSPORT_1188 1<<12
  111. #define ACTIVITY_STATUS_SHOWHOUSEICON_1188 1<<13
  112. #define ACTIVITY_STATUS_LOOTABLE_1188 1<<14
  113. #define ACTIVITY_STATUS_INCOMBAT_1188 1<<15
  114. #define ACTIVITY_STATUS_AFK_1188 1<<16
  115. #define ACTIVITY_STATUS_ROLEPLAYING_1188 1<<17
  116. #define ACTIVITY_STATUS_ANONYMOUS_1188 1<<18
  117. #define ACTIVITY_STATUS_LINKDEAD_1188 1<<19
  118. #define ACTIVITY_STATUS_CAMPING_1188 1<<20
  119. #define ACTIVITY_STATUS_LFG_1188 1<<21
  120. #define ACTIVITY_STATUS_LFW_1188 1<<22
  121. #define ACTIVITY_STATUS_SOLID_1188 1<<23 //used by zone objects to remain solid
  122. #define ACTIVITY_STATUS_MENTORING_1188 1<<28
  123. #define ACTIVITY_STATUS_IMMUNITY_GAINED_1188 1<<30
  124. #define ACTIVITY_STATUS_IMMUNITY_REMAINING_1188 1<<31
  125. #define POS_STATE_KNEELING 64
  126. #define POS_STATE_SOLID 128 //used by most mobs to remaind solid (cant walk through them)
  127. #define POS_STATE_NOTARGET_CURSOR 256 //cant target and no cursor is displayed
  128. #define POS_STATE_CROUCHING 512
  129. #define MERCHANT_TYPE_NO_BUY 1
  130. #define MERCHANT_TYPE_NO_BUY_BACK 2
  131. #define MERCHANT_TYPE_SPELLS 4
  132. #define MERCHANT_TYPE_CRAFTING 8
  133. #define MERCHANT_TYPE_REPAIR 16
  134. #define MERCHANT_TYPE_LOTTO 32
  135. #define INFO_VIS_FLAG_INVIS 1
  136. #define INFO_VIS_FLAG_HIDE_HOOD 2
  137. #define INFO_VIS_FLAG_MOUNTED 4
  138. #define INFO_VIS_FLAG_CROUCH 8
  139. using namespace std;
  140. class Spell;
  141. class ZoneServer;
  142. class Quest;
  143. struct LUAHistory;
  144. struct Cell;
  145. struct CellInfo {
  146. Cell* CurrentCell;
  147. int CellListIndex;
  148. };
  149. struct MovementData{
  150. float x;
  151. float y;
  152. float z;
  153. float speed;
  154. int32 delay;
  155. string lua_function;
  156. };
  157. struct BasicInfoStruct{
  158. sint32 cur_hp;
  159. sint32 max_hp;
  160. sint32 hp_base;
  161. sint32 cur_power;
  162. sint32 max_power;
  163. sint32 power_base;
  164. sint32 cur_savagery;
  165. sint32 max_savagery;
  166. sint32 savagery_base;
  167. sint32 cur_dissonance;
  168. sint32 max_dissonance;
  169. sint32 dissonance_base;
  170. sint16 assigned_aa;
  171. sint16 unassigned_aa;
  172. sint16 tradeskill_aa;
  173. sint16 unassigned_tradeskill_aa;
  174. sint16 prestige_aa;
  175. sint16 unassigned_prestige_aa;
  176. sint16 tradeskill_prestige_aa;
  177. sint16 unassigned_tradeskill_prestige_aa;
  178. };
  179. struct MovementLocation{
  180. float x;
  181. float y;
  182. float z;
  183. float speed;
  184. //int32 start_time;
  185. //int32 end_time;
  186. bool attackable;
  187. string lua_function;
  188. bool mapped;
  189. int32 gridid;
  190. };
  191. struct SpawnUpdate {
  192. int32 spawn_id;
  193. bool info_changed;
  194. bool vis_changed;
  195. bool pos_changed;
  196. shared_ptr<Client> client;
  197. };
  198. struct SpawnData {
  199. Spawn* spawn;
  200. uchar* data;
  201. int32 size;
  202. };
  203. class Spawn {
  204. public:
  205. Spawn();
  206. virtual ~Spawn();
  207. template <class Field, class Value> void Set(Field* field, Value value, bool setUpdateFlags = true){
  208. if (setUpdateFlags) {
  209. changed = true;
  210. AddChangedZoneSpawn();
  211. }
  212. *field = value;
  213. }
  214. template <class Field> void Set(Field* field, const char* value, bool setUpdateFlags = true){
  215. if (setUpdateFlags) {
  216. changed = true;
  217. AddChangedZoneSpawn();
  218. }
  219. strcpy(field, value);
  220. }
  221. template <class Field, class Value> void SetPos(Field* field, Value value, bool setUpdateFlags = true){
  222. if(setUpdateFlags){
  223. position_changed = true;
  224. }
  225. Set(field, value, setUpdateFlags);
  226. }
  227. template <class Field, class Value> void SetInfo(Field* field, Value value, bool setUpdateFlags = true){
  228. if(setUpdateFlags){
  229. info_changed = true;
  230. }
  231. Set(field, value);
  232. }
  233. template <class Field, class Value> void SetVis(Field* field, Value value, bool setUpdateFlags = true){
  234. if(setUpdateFlags)
  235. vis_changed = true;
  236. Set(field, value);
  237. }
  238. template <class Field> void SetPos(Field* field, char* value, bool setUpdateFlags = true){
  239. if(setUpdateFlags){
  240. position_changed = true;
  241. }
  242. Set(field, value, setUpdateFlags);
  243. }
  244. template <class Field> void SetInfo(Field* field, char* value, bool setUpdateFlags = true){
  245. if(setUpdateFlags){
  246. info_changed = true;
  247. }
  248. Set(field, value);
  249. }
  250. EntityCommand* CreateEntityCommand(EntityCommand* old_command){
  251. EntityCommand* entity_command = new EntityCommand;
  252. entity_command->name = old_command->name;
  253. entity_command->distance = old_command->distance;
  254. entity_command->command = old_command->command;
  255. entity_command->error_text = old_command->error_text;
  256. entity_command->cast_time = old_command->cast_time;
  257. entity_command->spell_visual = old_command->spell_visual;
  258. return entity_command;
  259. }
  260. EntityCommand* CreateEntityCommand(const char* name, float distance, const char* command, const char* error_text, int16 cast_time, int32 spell_visual){
  261. EntityCommand* entity_command = new EntityCommand;
  262. entity_command->name = name;
  263. entity_command->distance = distance;
  264. entity_command->command = command;
  265. entity_command->error_text = error_text;
  266. entity_command->cast_time = cast_time;
  267. entity_command->spell_visual = spell_visual;
  268. return entity_command;
  269. }
  270. void AddChangedZoneSpawn();
  271. void AddPrimaryEntityCommand(const char* name, float distance, const char* command, const char* error_text, int16 cast_time, int32 spell_visual){
  272. primary_command_list.push_back(CreateEntityCommand(name, distance, command, error_text, cast_time, spell_visual));
  273. }
  274. void AddSecondaryEntityCommand(const char* name, float distance, const char* command, const char* error_text, int16 cast_time, int32 spell_visual){
  275. secondary_command_list.push_back(CreateEntityCommand(name, distance, command, error_text, cast_time, spell_visual));
  276. }
  277. int8 GetLockedNoLoot(){
  278. return appearance.locked_no_loot;
  279. }
  280. int16 GetEmoteState(){
  281. return appearance.emote_state;
  282. }
  283. int8 GetHideHood(){
  284. return appearance.hide_hood;
  285. }
  286. void SetLockedNoLoot(int8 new_val, bool updateFlags = true){
  287. SetVis(&appearance.locked_no_loot, new_val, updateFlags);
  288. }
  289. void SetHandFlag(int8 new_val, bool updateFlags = true){
  290. SetVis(&appearance.display_hand_icon, new_val, updateFlags);
  291. }
  292. void SetHideHood(int8 new_val, bool updateFlags = true){
  293. SetInfo(&appearance.hide_hood, new_val, updateFlags);
  294. }
  295. void SetEmoteState(int8 new_val, bool updateFlags = true){
  296. SetInfo(&appearance.emote_state, new_val, updateFlags);
  297. }
  298. void SetName(const char* new_name, bool updateFlags = true){
  299. SetInfo(appearance.name, new_name, updateFlags);
  300. }
  301. void SetPrefixTitle(const char* new_prefix_title, bool updateFlags = true) {
  302. SetInfo(appearance.prefix_title, new_prefix_title, updateFlags);
  303. }
  304. void SetSuffixTitle(const char* new_suffix_title, bool updateFlags = true) {
  305. SetInfo(appearance.suffix_title, new_suffix_title, updateFlags);
  306. }
  307. void SetSubTitle(const char* new_sub_title, bool updateFlags = true) {
  308. SetInfo(appearance.sub_title, new_sub_title, updateFlags);
  309. }
  310. void SetLastName(const char* new_last_name, bool updateFlags = true) {
  311. SetInfo(appearance.last_name, new_last_name, updateFlags);
  312. }
  313. void SetAdventureClass(int8 new_class, bool updateFlags = true) {
  314. SetInfo(&appearance.adventure_class, new_class, updateFlags);
  315. }
  316. void SetTradeskillClass(int8 new_class, bool updateFlags = true) {
  317. SetInfo(&appearance.tradeskill_class, new_class, updateFlags);
  318. }
  319. void SetSize(int16 new_size, bool updateFlags = true) {
  320. SetPos(&size, new_size, updateFlags);
  321. }
  322. void SetSpeedX(float speed_x, bool updateFlags = true) {
  323. SetPos(&appearance.pos.SpeedX, speed_x, updateFlags);
  324. }
  325. void SetSpeedY(float speed_y, bool updateFlags = true) {
  326. SetPos(&appearance.pos.SpeedY, speed_y, updateFlags);
  327. }
  328. void SetSpeedZ(float speed_z, bool updateFlags = true) {
  329. SetPos(&appearance.pos.SpeedZ, speed_z, updateFlags);
  330. }
  331. void SetX(float x, bool updateFlags = true){
  332. SetPos(&appearance.pos.X, x, updateFlags);
  333. }
  334. void SetY(float y, bool updateFlags = true, bool disableYMapFix = false);
  335. void SetZ(float z, bool updateFlags = true){
  336. SetPos(&appearance.pos.Z, z, updateFlags);
  337. }
  338. void SetHeading(sint16 dir1, sint16 dir2, bool updateFlags = true){
  339. SetPos(&appearance.pos.Dir1, dir1, updateFlags);
  340. SetPos(&appearance.pos.Dir2, dir2, updateFlags);
  341. }
  342. void SetHeading(float heading, bool updateFlags = true){
  343. last_heading_angle = heading;
  344. if (heading != 180)
  345. heading = (heading - 180) * 64;
  346. SetHeading((sint16)heading, (sint16)heading, updateFlags);
  347. }
  348. void SetPitch(sint16 pitch1, sint16 pitch2, bool updateFlags = true){
  349. SetPos(&appearance.pos.Pitch1, (sint16)pitch1, updateFlags);
  350. SetPos(&appearance.pos.Pitch2, (sint16)pitch2, updateFlags);
  351. }
  352. void SetPitch(float pitch, bool updateFlags = true){
  353. if (pitch == 0){
  354. SetPos(&appearance.pos.Pitch1, (sint16)0, updateFlags);
  355. SetPos(&appearance.pos.Pitch2, (sint16)0, updateFlags);
  356. return;
  357. }
  358. if (pitch != 180)
  359. pitch = (pitch - 180) * 64;
  360. SetPos(&appearance.pos.Pitch1, (sint16)pitch, updateFlags);
  361. SetPos(&appearance.pos.Pitch2, (sint16)pitch, updateFlags);
  362. }
  363. void SetRoll(float roll, bool updateFlags = true){
  364. if (roll == 0){
  365. SetPos(&appearance.pos.Roll, (sint16)0, updateFlags);
  366. return;
  367. }
  368. else if (roll != 180)
  369. roll = (roll - 180) * 64;
  370. SetPos(&appearance.pos.Roll, (sint16)roll, updateFlags);
  371. }
  372. void SetVisualState(int16 state, bool updateFlags = true){
  373. SetInfo(&appearance.visual_state, state, updateFlags);
  374. }
  375. void SetActionState(int16 state, bool updateFlags = true){
  376. SetInfo(&appearance.action_state, state, updateFlags);
  377. }
  378. void SetMoodState(int16 state, bool updateFlags = true){
  379. SetInfo(&appearance.mood_state, state, updateFlags);
  380. }
  381. void SetInitialState(int16 state, bool updateFlags = true){
  382. SetPos(&appearance.pos.state, state, updateFlags);
  383. }
  384. void SetActivityStatus(int16 state, bool updateFlags = true){
  385. SetInfo(&appearance.activity_status, state, updateFlags);
  386. }
  387. void SetCollisionRadius(int32 radius, bool updateFlags = true){
  388. SetPos(&appearance.pos.collision_radius, radius, updateFlags);
  389. }
  390. int16 GetCollisionRadius(){
  391. return appearance.pos.collision_radius;
  392. }
  393. int16 GetVisualState(){
  394. return appearance.visual_state;
  395. }
  396. int16 GetActionState(){
  397. return appearance.action_state;
  398. }
  399. int16 GetMoodState(){
  400. return appearance.mood_state;
  401. }
  402. int16 GetInitialState(){
  403. return appearance.pos.state;
  404. }
  405. int16 GetActivityStatus(){
  406. return appearance.activity_status;
  407. }
  408. int32 GetPrimaryCommandListID(){
  409. return primary_command_list_id;
  410. }
  411. int32 GetSecondaryCommandListID(){
  412. return secondary_command_list_id;
  413. }
  414. void SetID(int32 in_id){
  415. Set(&id, in_id);
  416. }
  417. void SetEncounterLevel(int8 enc_level, bool setUpdateFlags = true){
  418. SetInfo(&appearance.encounter_level, enc_level, setUpdateFlags);
  419. }
  420. void SetLevel(int16 level, bool setUpdateFlags = true){
  421. SetInfo(&appearance.level, level, setUpdateFlags);
  422. }
  423. void SetTSLevel(int16 tradeskill_level, bool setUpdateFlags = true){
  424. SetInfo(&appearance.tradeskill_level, tradeskill_level, setUpdateFlags);
  425. }
  426. void SetGender(int8 gender, bool setUpdateFlags = true){
  427. SetInfo(&appearance.gender, gender, setUpdateFlags);
  428. }
  429. void SetShowName(int8 new_val, bool setUpdateFlags = true){
  430. SetVis(&appearance.display_name, new_val, setUpdateFlags);
  431. }
  432. void SetShowLevel(int8 new_val, bool setUpdateFlags = true){
  433. SetVis(&appearance.show_level, new_val, setUpdateFlags);
  434. }
  435. void SetHeroic(int8 new_val, bool setUpdateFlags = true){
  436. SetInfo(&appearance.heroic_flag, new_val, setUpdateFlags);
  437. }
  438. void SetTargetable(int8 new_val, bool setUpdateFlags = true){
  439. SetVis(&appearance.targetable, new_val, setUpdateFlags);
  440. }
  441. void SetShowCommandIcon(int8 new_val, bool setUpdateFlags = true){
  442. SetVis(&appearance.show_command_icon, new_val, setUpdateFlags);
  443. }
  444. void SetShowHandIcon(int8 new_val, bool setUpdateFlags = true){
  445. SetVis(&appearance.display_hand_icon, new_val, setUpdateFlags);
  446. }
  447. void SetAttackable(int8 new_val, bool setUpdateFlags = true){
  448. SetInfo(&appearance.attackable, new_val, setUpdateFlags);
  449. }
  450. void SetLocation(int32 id, bool setUpdateFlags = true){
  451. SetPos(&appearance.pos.grid_id, id, setUpdateFlags);
  452. }
  453. void SetRace(int8 race, bool setUpdateFlags = true){
  454. SetInfo(&appearance.race, race, setUpdateFlags);
  455. }
  456. void SetIcon(int8 icon, bool setUpdateFlags = true){
  457. SetInfo(&appearance.icon, icon, setUpdateFlags);
  458. }
  459. void AddIconValue(int8 val){
  460. if(!(appearance.icon & val))
  461. SetIcon(appearance.icon+val);
  462. }
  463. void RemoveIconValue(int8 val){
  464. if((appearance.icon & val))
  465. SetIcon(appearance.icon-val);
  466. }
  467. int8 GetIconValue(){
  468. return appearance.icon;
  469. }
  470. virtual void SetSpeed(float speed){
  471. SetPos(&appearance.pos.Speed1, (int8)speed);
  472. }
  473. virtual float GetSpeed(){
  474. return (float)appearance.pos.Speed1;
  475. }
  476. virtual float GetBaseSpeed(){
  477. return (float)appearance.pos.Speed1;
  478. }
  479. void SetSpawnType(int8 new_type){
  480. SetInfo(&spawn_type, new_type);
  481. }
  482. int8 GetSpawnType(){
  483. return spawn_type;
  484. }
  485. void SetDatabaseID(int32 new_id){
  486. database_id = new_id;
  487. }
  488. int32 GetDatabaseID(){
  489. return database_id;
  490. }
  491. int8 GetShowHandIcon(){
  492. return appearance.display_hand_icon;
  493. }
  494. int32 GetLocation(){
  495. return appearance.pos.grid_id;
  496. }
  497. int8 GetAttackable(){
  498. return appearance.attackable;
  499. }
  500. int8 GetShowName(){
  501. return appearance.display_name;
  502. }
  503. int8 GetShowLevel(){
  504. return appearance.show_level;
  505. }
  506. int8 GetHeroic(){
  507. return appearance.heroic_flag;
  508. }
  509. int8 GetTargetable(){
  510. return appearance.targetable;
  511. }
  512. int8 GetShowCommandIcon(){
  513. return appearance.show_command_icon;
  514. }
  515. char* GetName(){
  516. return appearance.name;
  517. }
  518. char* GetPrefixTitle(){
  519. return appearance.prefix_title;
  520. }
  521. char* GetSuffixTitle(){
  522. return appearance.suffix_title;
  523. }
  524. char* GetSubTitle() {
  525. return appearance.sub_title;
  526. }
  527. char* GetLastName() {
  528. return appearance.last_name;
  529. }
  530. int8 GetAdventureClass() {
  531. return appearance.adventure_class;
  532. }
  533. int8 GetTradeskillClass() {
  534. return appearance.tradeskill_class;
  535. }
  536. float GetDestinationX(){
  537. return appearance.pos.X2;
  538. }
  539. float GetX() {
  540. return appearance.pos.X;
  541. }
  542. float GetSpeedX() {
  543. return appearance.pos.SpeedX;
  544. }
  545. float GetSpeedY() {
  546. return appearance.pos.SpeedY;
  547. }
  548. float GetSpeedZ() {
  549. return appearance.pos.SpeedZ;
  550. }
  551. float GetDestinationY(){
  552. return appearance.pos.Y2;
  553. }
  554. float GetY(){
  555. return appearance.pos.Y;
  556. }
  557. float GetDestinationZ(){
  558. return appearance.pos.Z2;
  559. }
  560. float GetZ(){
  561. return appearance.pos.Z;
  562. }
  563. float GetHeading(){
  564. float heading = 0;
  565. if(appearance.pos.Dir1 != 0){
  566. heading = ((float)appearance.pos.Dir1)/((float)64);
  567. if(heading >= 180)
  568. heading -= 180;
  569. else
  570. heading += 180;
  571. }
  572. return heading;
  573. }
  574. float GetPitch(){
  575. float pitch = 0;
  576. if(appearance.pos.Pitch1 != 0){
  577. pitch = ((float)appearance.pos.Pitch1)/((float)64);
  578. if(pitch >= 180)
  579. pitch -= 180;
  580. else
  581. pitch += 180;
  582. }
  583. return pitch;
  584. }
  585. float GetRoll(){
  586. float roll = 0;
  587. if(appearance.pos.Roll != 0){
  588. roll = ((float)appearance.pos.Roll)/((float)64);
  589. if(roll >= 180)
  590. roll -= 180;
  591. else
  592. roll += 180;
  593. }
  594. return roll;
  595. }
  596. int32 GetID(){
  597. return id;
  598. }
  599. float GetDistance(float x1, float y1, float z1, float x2, float y2, float z2);
  600. float GetDistance(float x, float y, float z, float radius, bool ignore_y = false);
  601. float GetDistance(float x, float y, float z, bool ignore_y = false);
  602. float GetDistance(Spawn* spawn, bool ignore_y = false, bool includeRadius=true);
  603. float GetDistance(Spawn* spawn, float x1, float y1, float z1, bool includeRadius=true);
  604. float CalculateRadius(Spawn* target);
  605. int8 GetEncounterLevel(){
  606. return appearance.encounter_level;
  607. }
  608. sint32 GetTotalPower();
  609. sint32 GetPower();
  610. sint32 GetTotalHP();
  611. sint32 GetHP();
  612. sint32 GetTotalHPBase();
  613. sint32 GetTotalPowerBase();
  614. sint32 GetTotalSavagery();
  615. sint32 GetSavagery();
  616. sint32 GetTotalDissonance();
  617. sint32 GetDissonance();
  618. sint32 GetTotalSavageryBase();
  619. sint32 GetTotalDissonanceBase();
  620. sint16 GetAssignedAA();
  621. sint16 GetUnassignedAA();
  622. sint16 GetTradeskillAA();
  623. sint16 GetUnassignedTradeskillAA();
  624. sint16 GetPrestigeAA();
  625. sint16 GetUnassignedPretigeAA();
  626. sint16 GetTradeskillPrestigeAA();
  627. sint16 GetUnassignedTradeskillPrestigeAA();
  628. void SetTotalPower(sint32 new_val);
  629. void SetTotalHP(sint32 new_val);
  630. void SetTotalSavagery(sint32 new_val);
  631. void SetTotalDissonance(sint32 new_val);
  632. void SetTotalPowerBase(sint32 new_val);
  633. void SetTotalHPBase(sint32 new_val);
  634. void SetTotalSavageryBase(sint32 new_val);
  635. void SetTotalDissonanceBase(sint32 new_val);
  636. void SetPower(sint32 power, bool setUpdateFlags = true);
  637. void SetHP(sint32 new_val, bool setUpdateFlags = true);
  638. void SetSavagery(sint32 savagery, bool setUpdateFlags = true);
  639. void SetDissonance(sint32 dissonance, bool setUpdateFlags = true);
  640. void SetAssignedAA(sint16 new_val);
  641. void SetUnassignedAA(sint16 new_val);
  642. void SetTradeskillAA(sint16 new_val);
  643. void SetUnassignedTradeskillAA(sint16 new_val);
  644. void SetPrestigeAA(sint16 new_val);
  645. void SetUnassignedPrestigeAA(sint16 new_val);
  646. void SetTradeskillPrestigeAA(sint16 new_val);
  647. void SetUnassignedTradeskillPrestigeAA(sint16 new_val);
  648. void SetPrivateQuestSpawn(bool val) {req_quests_private = val;}
  649. void SetQuestsRequiredOverride(int16 val) {req_quests_override = val;}
  650. void SetQuestsRequiredContinuedAccess(bool val) {req_quests_continued_access = val;}
  651. bool GetPrivateQuestSpawn() {return req_quests_private;}
  652. int16 GetQuestsRequiredOverride() {return req_quests_override;}
  653. bool GetQuestsRequiredContinuedAccess() {return req_quests_continued_access;}
  654. bool Alive(){ return GetHP() > 0; }
  655. int16 GetLevel(){
  656. return appearance.level;
  657. }
  658. int16 GetTSLevel(){
  659. return appearance.tradeskill_level;
  660. }
  661. int8 GetGender(){
  662. return appearance.gender;
  663. }
  664. int8 GetRace(){
  665. return appearance.race;
  666. }
  667. int8 GetLuaRaceId() {
  668. return appearance.lua_race_id;
  669. }
  670. int32 GetSize(){
  671. return size;
  672. }
  673. int32 GetDeviation(){
  674. return deviation;
  675. }
  676. void SetDeviation(int32 in_dev){
  677. deviation = in_dev;
  678. }
  679. float GetSpawnOrigHeading(){
  680. return appearance.pos.SpawnOrigHeading;
  681. }
  682. void SetSpawnOrigHeading(float val){
  683. appearance.pos.SpawnOrigHeading = val;
  684. }
  685. float GetSpawnOrigX(){
  686. return appearance.pos.SpawnOrigX;
  687. }
  688. float GetSpawnOrigY(){
  689. return appearance.pos.SpawnOrigY;
  690. }
  691. float GetSpawnOrigZ(){
  692. return appearance.pos.SpawnOrigZ;
  693. }
  694. float GetSpawnOrigPitch(){
  695. return appearance.pos.SpawnOrigPitch;
  696. }
  697. float GetSpawnOrigRoll(){
  698. return appearance.pos.SpawnOrigRoll;
  699. }
  700. void SetSpawnOrigX(float val){
  701. appearance.pos.SpawnOrigX = val;
  702. }
  703. void SetSpawnOrigY(float val){
  704. appearance.pos.SpawnOrigY = val;
  705. }
  706. void SetSpawnOrigZ(float val){
  707. appearance.pos.SpawnOrigZ = val;
  708. }
  709. void SetSpawnOrigRoll(float val){
  710. appearance.pos.SpawnOrigRoll = val;
  711. }
  712. void SetSpawnOrigPitch(float val){
  713. appearance.pos.SpawnOrigPitch = val;
  714. }
  715. void SetSogaModelType(int16 new_val, bool setUpdateFlags = true){
  716. SetInfo(&appearance.soga_model_type, new_val, setUpdateFlags);
  717. }
  718. void SetModelType(int16 model_type, bool setUpdateFlags = true){
  719. SetInfo(&appearance.model_type, model_type, setUpdateFlags);
  720. SetInfo(&appearance.soga_model_type, model_type, setUpdateFlags);
  721. }
  722. int16 GetSogaModelType(){
  723. return appearance.soga_model_type;
  724. }
  725. int16 GetModelType(){
  726. return appearance.model_type;
  727. }
  728. bool IsFlying() { return (GetInitialState() == 49156); }
  729. void SetPrimaryCommand(const char* name, const char* command, float distance = 10);
  730. void SetPrimaryCommands(vector<EntityCommand*>* commands);
  731. void SetSecondaryCommands(vector<EntityCommand*>* commands);
  732. vector<EntityCommand*>* GetPrimaryCommands() {return &primary_command_list;}
  733. vector<EntityCommand*>* GetSecondaryCommands() {return &secondary_command_list;}
  734. EntityCommand* FindEntityCommand(string command);
  735. virtual EQ2Packet* serialize(Player* player, int16 version);
  736. EQ2Packet* spawn_serialize(Player* player, int16 version);
  737. EQ2Packet* spawn_update_packet(Player* player, int16 version, bool override_changes = false, bool override_vis_changes = false);
  738. EQ2Packet* player_position_update_packet(Player* player, int16 version);
  739. uchar* spawn_info_changes(Player* spawn, int16 version);
  740. uchar* spawn_pos_changes(Player* spawn, int16 version);
  741. uchar* spawn_vis_changes(Player* spawn, int16 version);
  742. uchar* spawn_info_changes_ex(Player* spawn, int16 version);
  743. uchar* spawn_pos_changes_ex(Player* spawn, int16 version);
  744. uchar* spawn_vis_changes_ex(Player* spawn, int16 version);
  745. virtual bool EngagedInCombat(){ return false; }
  746. virtual bool IsObject(){ return false; }
  747. virtual bool IsGroundSpawn(){ return false; }
  748. virtual bool IsNPC(){ return false; }
  749. virtual bool IsEntity(){ return false; }
  750. virtual bool IsPlayer(){ return false; }
  751. virtual bool IsWidget(){ return false; }
  752. virtual bool IsSign(){ return false; }
  753. virtual bool IsBot() { return false; }
  754. bool HasInfoChanged(){ return info_changed; }
  755. bool HasPositionChanged(){ return position_changed; }
  756. bool HasTarget(){ return target ? true : false; }
  757. int32 GetRespawnTime();
  758. void SetRespawnTime(int32 time);
  759. int32 GetExpireTime() { return expire_time; }
  760. void SetExpireTime(int32 new_expire_time) { expire_time = new_expire_time; }
  761. int32 GetExpireOffsetTime();
  762. void SetExpireOffsetTime(int32 time);
  763. int32 GetSpawnLocationID();
  764. void SetSpawnLocationID(int32 id);
  765. int32 GetSpawnEntryID();
  766. void SetSpawnEntryID(int32 id);
  767. int32 GetSpawnLocationPlacementID();
  768. void SetSpawnLocationPlacementID(int32 id);
  769. float GetXOffset() { return x_offset; }
  770. void SetXOffset(float new_x_offset) { x_offset = new_x_offset; }
  771. float GetYOffset() { return y_offset; }
  772. void SetYOffset(float new_y_offset) { y_offset = new_y_offset; }
  773. float GetZOffset() { return z_offset; }
  774. void SetZOffset(float new_z_offset) { z_offset = new_z_offset; }
  775. Spawn* GetTarget();
  776. void SetTarget(Spawn* spawn);
  777. Spawn* GetLastAttacker();
  778. void SetLastAttacker(Spawn* spawn);
  779. bool TakeDamage(int32 damage);
  780. void TakeDamage(Spawn* attacker, int32 damage);
  781. ZoneServer* GetZone();
  782. virtual void SetZone(ZoneServer* in_zone);
  783. void SetFactionID(int32 val) { faction_id = val; }
  784. int32 GetFactionID(){
  785. return faction_id;
  786. }
  787. static int32 NextID() {
  788. static CriticalSection id_lock;
  789. id_lock.lock();
  790. int32 ret = ++next_id;
  791. if (next_id == 0xFFFFFFFE)
  792. next_id = 1;
  793. else if ((next_id - 255) % 256 == 0) { //we dont want it to end in 255, it will confuse/crash the client
  794. id_lock.unlock();
  795. return NextID();
  796. }
  797. id_lock.unlock();
  798. return ret;
  799. }
  800. void AddProvidedQuest(int32 val){
  801. quest_ids.push_back(val);
  802. }
  803. vector<int32>* GetProvidedQuests(){
  804. return &quest_ids;
  805. }
  806. bool HasProvidedQuests(){
  807. return (quest_ids.size() > 0);
  808. }
  809. void SetSpawnScript(string name);
  810. const char* GetSpawnScript();
  811. vector<Spawn*>* GetSpawnGroup();
  812. bool HasSpawnGroup();
  813. bool IsInSpawnGroup(Spawn* spawn);
  814. void SendSpawnChanges(bool val){ send_spawn_changes = val; }
  815. void SetSpawnGroupID(int32 id);
  816. int32 GetSpawnGroupID();
  817. void AddSpawnToGroup(Spawn* spawn);
  818. void SetSpawnGroupList(vector<Spawn*>* list, Mutex* mutex);
  819. void RemoveSpawnFromGroup(bool erase_all = false);
  820. void SetRunningTo(Spawn* spawn){ running_to = spawn->GetID(); }
  821. Spawn* GetRunningTo();
  822. void SetTempVisualState(int val, bool update = true) { SetInfo(&tmp_visual_state, val, update); }
  823. int GetTempVisualState(){ return tmp_visual_state; }
  824. void SetTempActionState(int val, bool update = true) { SetInfo(&tmp_action_state, val, update); }
  825. int GetTempActionState(){ return tmp_action_state; }
  826. void AddAllowAccessSpawn(Spawn* spawn){ allowed_access[spawn->GetID()] = 1; }
  827. void RemoveSpawnAccess(Spawn* spawn);
  828. bool IsPrivateSpawn(){ return allowed_access.size() > 0 ;}
  829. bool AllowedAccess(Spawn* spawn){ return allowed_access.count(spawn->GetID()) > 0; }
  830. void MakeSpawnPublic() { allowed_access.clear(); }
  831. void SetSizeOffset(int8 offset);
  832. int8 GetSizeOffset();
  833. void SetMerchantID(int32 val);
  834. int32 GetMerchantID();
  835. void SetMerchantType(int8 val);
  836. int8 GetMerchantType();
  837. void SetQuestsRequired(map<int32, vector<int16>* >* quests);
  838. void SetQuestsRequired(int32 quest_id, int16 quest_step);
  839. void SetRequiredHistory(int32 event_id, int32 value1, int32 value2);
  840. map<int32, vector<int16>* >* GetQuestsRequired();
  841. void SetTransporterID(int32 id);
  842. int32 GetTransporterID();
  843. bool MeetsSpawnAccessRequirements(Player* player);
  844. void InitializePosPacketData(Player* player, PacketStruct* packet, bool bSpawnUpdate = false);
  845. void InitializeInfoPacketData(Player* player, PacketStruct* packet);
  846. void InitializeVisPacketData(Player* player, PacketStruct* packet);
  847. void InitializeHeaderPacketData(Player* player, PacketStruct* packet, int16 index);
  848. void InitializeFooterPacketData(Player* player, PacketStruct* packet);
  849. void MoveToLocation(Spawn* spawn, float distance, bool immediate = true, bool isMappedLocation = false);
  850. void AddMovementLocation(float x, float y, float z, float speed, int16 delay, const char* lua_function);
  851. void ProcessMovement(bool isSpawnListLocked=false);
  852. void ResetMovement();
  853. bool IsRunning();
  854. void CalculateRunningLocation(bool stop = false);
  855. void RunToLocation(float x, float y, float z, float following_x = 0, float following_y = 0, float following_z = 0);
  856. MovementLocation* GetCurrentRunningLocation();
  857. MovementLocation* GetLastRunningLocation();
  858. bool CalculateChange();
  859. void AddRunningLocation(float x, float y, float z, float speed, float distance_away = 0, bool attackable = true, bool finished_adding_locations = true, string lua_function = "", bool isMapped=false);
  860. bool RemoveRunningLocation();
  861. void ClearRunningLocations();
  862. void CopySpawnAppearance(Spawn* spawn);
  863. bool MovementInterrupted(){ return movement_interrupted; }
  864. void MovementInterrupted(bool val) { movement_interrupted = val; }
  865. bool NeedsToResumeMovement(){ return attack_resume_needed; }
  866. void NeedsToResumeMovement(bool val) { attack_resume_needed = val; }
  867. bool HasMovementLoop(){ return movement_loop.size() > 0; }
  868. Timer* GetRunningTimer();
  869. float GetFaceTarget(float x, float z);
  870. void FaceTarget(float x, float z);
  871. void FaceTarget(Spawn* target);
  872. void SetInvulnerable(bool val);
  873. bool GetInvulnerable();
  874. bool changed;
  875. bool position_changed;
  876. bool info_changed;
  877. bool vis_changed;
  878. int16 size;
  879. int32 faction_id;
  880. int8 oversized_packet; //0xff
  881. int16 opcode;
  882. int32 id;
  883. int8 unknown1;
  884. int32 unknown2;
  885. int32 primary_command_list_id;
  886. int32 secondary_command_list_id;
  887. vector<EntityCommand*> primary_command_list;
  888. vector<EntityCommand*> secondary_command_list;
  889. int32 group_id;
  890. int8 group_len;
  891. vector<Spawn*>* spawn_group_list;
  892. AppearanceData appearance;
  893. int32 last_movement_update;
  894. int32 last_location_update;
  895. bool forceMapCheck;
  896. bool following;
  897. bool IsPet() { return is_pet; }
  898. void SetPet(bool val) { is_pet = val; }
  899. Mutex m_requiredQuests;
  900. Mutex m_requiredHistory;
  901. void SetFollowTarget(Spawn* spawn, int32 followDistance=0);
  902. Spawn* GetFollowTarget();
  903. /// <summary>Sets a user defined variable</summary>
  904. /// <param name='var'>Variable we are setting</param>
  905. /// <param name='val'>Value to set the variable to</param>
  906. void AddTempVariable(string var, string val);
  907. void AddTempVariable(string var, Spawn* val);
  908. void AddTempVariable(string var, ZoneServer* val);
  909. void AddTempVariable(string var, Quest* val);
  910. void AddTempVariable(string var, Item* val);
  911. /// <summary>Gets the value for the given variable</summary>
  912. /// <param name='var'>Variable to check</param>
  913. /// <returns>The value for the given variable, "" if variable was not set</returns>
  914. string GetTempVariable(string var);
  915. Spawn* GetTempVariableSpawn(string var);
  916. ZoneServer* GetTempVariableZone(string var);
  917. Item* GetTempVariableItem(string var);
  918. Quest* GetTempVariableQuest(string var);
  919. int8 GetTempVariableType(string var);
  920. void DeleteTempVariable(string var);
  921. void SetIllusionModel(int16 val, bool setUpdateFlags = true) {
  922. SetInfo(&m_illusionModel, val, setUpdateFlags);
  923. }
  924. int16 GetIllusionModel() { return m_illusionModel; }
  925. CellInfo Cell_Info;
  926. int32 GetSpawnAnim() { return m_spawnAnim; }
  927. void SetSpawnAnim(int32 value) { m_spawnAnim = value; }
  928. int32 GetAddedToWorldTimestamp() { return m_addedToWorldTimestamp; }
  929. void SetAddedToWorldTimestamp(int32 value) { m_addedToWorldTimestamp = value; }
  930. int16 GetSpawnAnimLeeway() { return m_spawnAnimLeeway; }
  931. void SetSpawnAnimLeeway(int16 value) { m_spawnAnimLeeway = value; }
  932. float FindDestGroundZ(glm::vec3 dest, float z_offset);
  933. float GetFixedZ(const glm::vec3& destination, int32 z_find_offset = 1);
  934. void FixZ(bool forceUpdate=false);
  935. bool CheckLoS(Spawn* target);
  936. bool CheckLoS(glm::vec3 myloc, glm::vec3 oloc);
  937. void CalculateNewFearpoint();
  938. void StopMoving() {
  939. if (movement_locations)
  940. movement_locations->clear();
  941. }
  942. int16 pos_packet_size;
  943. int16 info_packet_size;
  944. int16 vis_packet_size;
  945. enum SpawnProximityType {
  946. SPAWNPROXIMITY_DATABASE_ID = 0,
  947. SPAWNPROXIMITY_LOCATION_ID = 1
  948. };
  949. struct SpawnProximity {
  950. float x;
  951. float y;
  952. float z;
  953. int32 spawn_value;
  954. int8 spawn_type;
  955. float distance;
  956. string in_range_lua_function;
  957. string leaving_range_lua_function;
  958. map<int32, bool> spawns_in_proximity;
  959. };
  960. void AddSpawnToProximity(int32 spawnValue, SpawnProximityType type);
  961. void RemoveSpawnFromProximity(int32 spawnValue, SpawnProximityType type);
  962. SpawnProximity* AddLUASpawnProximity(int32 spawnValue, SpawnProximityType type, float distance, string in_range_function, string leaving_range_function) {
  963. SpawnProximity* prox = new SpawnProximity;
  964. prox->spawn_value = spawnValue;
  965. prox->spawn_type = type;
  966. prox->distance = distance;
  967. prox->in_range_lua_function = in_range_function;
  968. prox->leaving_range_lua_function = leaving_range_function;
  969. spawn_proximities.Add(prox);
  970. has_spawn_proximities = true;
  971. return prox;
  972. }
  973. void RemoveSpawnProximities() {
  974. MutexList<SpawnProximity*>::iterator itr = spawn_proximities.begin();
  975. while (itr.Next()) {
  976. safe_delete(itr->value);
  977. }
  978. spawn_proximities.clear();
  979. has_spawn_proximities = false;
  980. }
  981. Mutex MCommandMutex;
  982. bool has_spawn_proximities;
  983. protected:
  984. bool send_spawn_changes;
  985. bool invulnerable;
  986. bool attack_resume_needed;
  987. bool resume_movement;
  988. bool movement_interrupted;
  989. int32 running_timer_begin;
  990. int32 running_timer_end;
  991. vector<MovementData*> movement_loop;
  992. bool running_timer_updated;
  993. int16 movement_index;
  994. int32 last_grid_update;
  995. int32 movement_start_time;
  996. Mutex MMovementLoop;
  997. map<int32, int8> allowed_access;
  998. vector<int32> quest_ids;
  999. int32 database_id;
  1000. int32 packet_num;
  1001. int32 target;
  1002. int8 spawn_type;
  1003. int32 last_attacker;
  1004. int32 merchant_id;
  1005. int8 merchant_type;
  1006. int32 transporter_id;
  1007. map<int32, vector<int16>* > required_quests;
  1008. map<int32, LUAHistory> required_history;
  1009. EquipmentItemList equipment_list;
  1010. MutexList<SpawnProximity*> spawn_proximities;
  1011. void CheckProximities();
  1012. private:
  1013. deque<MovementLocation*>* movement_locations;
  1014. Mutex* MMovementLocations;
  1015. Mutex* MSpawnGroup;
  1016. int8 size_offset;
  1017. int tmp_visual_state;
  1018. int tmp_action_state;
  1019. int32 running_to;
  1020. string spawn_script;
  1021. static int32 next_id;
  1022. ZoneServer* zone;
  1023. int32 spawn_location_id;
  1024. int32 spawn_entry_id;
  1025. int32 spawn_location_spawns_id;
  1026. int32 respawn;
  1027. int32 expire_time;
  1028. int32 expire_offset;
  1029. float x_offset;
  1030. float y_offset;
  1031. float z_offset;
  1032. int32 deviation;
  1033. BasicInfoStruct basic_info;
  1034. //string data;
  1035. bool is_pet;
  1036. // m_followTarget = spawn to follow around
  1037. int32 m_followTarget;
  1038. int32 m_followDistance;
  1039. bool req_quests_private;
  1040. int16 req_quests_override;
  1041. bool req_quests_continued_access;
  1042. float last_heading_angle;
  1043. map<string, int8> m_tempVariableTypes;
  1044. map<string, int32> m_tempVariableSpawn;
  1045. map<string, ZoneServer*> m_tempVariableZone;
  1046. map<string, Item*> m_tempVariableItem;
  1047. map<string, Quest*> m_tempVariableQuest;
  1048. // m_tempVariables = stores user defined variables from lua, will not persist through a zone
  1049. map<string, string> m_tempVariables;
  1050. int16 m_illusionModel;
  1051. int32 m_spawnAnim;
  1052. int32 m_addedToWorldTimestamp;
  1053. int16 m_spawnAnimLeeway;
  1054. Mutex m_Update;
  1055. };
  1056. #endif