Spawn.h 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566
  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 <atomic>
  19. #include "../common/types.h"
  20. #include "../common/EQPacket.h"
  21. #include "../common/EQ2_Common_Structs.h"
  22. #include "../common/MiscFunctions.h"
  23. #include "../common/opcodemgr.h"
  24. #include "../common/timer.h"
  25. #include "Commands/Commands.h"
  26. #include "Zone/position.h"
  27. #include "SpawnLists.h"
  28. #include <vector>
  29. #include "../common/ConfigReader.h"
  30. #include "Items/Items.h"
  31. #include "Zone/map.h"
  32. #include "Zone/region_map.h"
  33. #include "Zone/region_map_v1.h"
  34. #include "../common/Mutex.h"
  35. #include "MutexList.h"
  36. #include <deque>
  37. #include <memory> // needed for LS to compile properly on linux
  38. #include <mutex>
  39. #include <algorithm>
  40. #define DAMAGE_PACKET_TYPE_SIPHON_SPELL 0x41
  41. #define DAMAGE_PACKET_TYPE_SIPHON_SPELL2 0x49
  42. #define DAMAGE_PACKET_TYPE_MULTIPLE_DAMAGE 0x80
  43. #define DAMAGE_PACKET_TYPE_SIMPLE_DAMAGE 0xC0
  44. #define DAMAGE_PACKET_TYPE_SPELL_DAMAGE 0xC1
  45. #define DAMAGE_PACKET_TYPE_SIMPLE_CRIT_DMG 0xC4
  46. #define DAMAGE_PACKET_TYPE_SPELL_CRIT_DMG 0xC5
  47. #define DAMAGE_PACKET_TYPE_SPELL_DAMAGE2 0xC8
  48. #define DAMAGE_PACKET_TYPE_SPELL_DAMAGE3 0xC9
  49. #define DAMAGE_PACKET_TYPE_RANGE_DAMAGE 0xE2
  50. #define DAMAGE_PACKET_TYPE_RANGE_SPELL_DMG 0xE3
  51. #define DAMAGE_PACKET_TYPE_RANGE_SPELL_DMG2 0xEA
  52. #define DAMAGE_PACKET_RESULT_NO_DAMAGE 0
  53. #define DAMAGE_PACKET_RESULT_SUCCESSFUL 1
  54. #define DAMAGE_PACKET_RESULT_MISS 4
  55. #define DAMAGE_PACKET_RESULT_DODGE 8
  56. #define DAMAGE_PACKET_RESULT_PARRY 12
  57. #define DAMAGE_PACKET_RESULT_RIPOSTE 16
  58. #define DAMAGE_PACKET_RESULT_BLOCK 20
  59. #define DAMAGE_PACKET_RESULT_DEATH_BLOW 24
  60. #define DAMAGE_PACKET_RESULT_INVULNERABLE 28
  61. #define DAMAGE_PACKET_RESULT_RESIST 36
  62. #define DAMAGE_PACKET_RESULT_REFLECT 40
  63. #define DAMAGE_PACKET_RESULT_IMMUNE 44
  64. #define DAMAGE_PACKET_RESULT_DEFLECT 48
  65. #define DAMAGE_PACKET_RESULT_COUNTER 52
  66. #define DAMAGE_PACKET_RESULT_FOCUS 56 // focus damage
  67. #define DAMAGE_PACKET_RESULT_COUNTER_STRIKE 60
  68. #define DAMAGE_PACKET_RESULT_BASH 64
  69. #define DAMAGE_PACKET_DAMAGE_TYPE_SLASH 0
  70. #define DAMAGE_PACKET_DAMAGE_TYPE_CRUSH 1
  71. #define DAMAGE_PACKET_DAMAGE_TYPE_PIERCE 2
  72. #define DAMAGE_PACKET_DAMAGE_TYPE_HEAT 3
  73. #define DAMAGE_PACKET_DAMAGE_TYPE_COLD 4
  74. #define DAMAGE_PACKET_DAMAGE_TYPE_MAGIC 5
  75. #define DAMAGE_PACKET_DAMAGE_TYPE_MENTAL 6
  76. #define DAMAGE_PACKET_DAMAGE_TYPE_DIVINE 7
  77. #define DAMAGE_PACKET_DAMAGE_TYPE_DISEASE 8
  78. #define DAMAGE_PACKET_DAMAGE_TYPE_POISON 9
  79. #define DAMAGE_PACKET_DAMAGE_TYPE_DROWN 10
  80. #define DAMAGE_PACKET_DAMAGE_TYPE_FALLING 11
  81. #define DAMAGE_PACKET_DAMAGE_TYPE_PAIN 12
  82. #define DAMAGE_PACKET_DAMAGE_TYPE_HIT 13
  83. #define DAMAGE_PACKET_DAMAGE_TYPE_FOCUS 14 // used as a placeholder to translate over to focus from LUA functions and weapons
  84. #define HEAL_PACKET_TYPE_SIMPLE_HEAL 0
  85. #define HEAL_PACKET_TYPE_CRIT_HEAL 1
  86. #define HEAL_PACKET_TYPE_ABSORB 2
  87. #define HEAL_PACKET_TYPE_REGEN_ABSORB 4
  88. #define HEAL_PACKET_TYPE_SIMPLE_MANA 8
  89. #define HEAL_PACKET_TYPE_CRIT_MANA 9
  90. #define HEAL_PACKET_TYPE_SAVAGERY 16
  91. #define HEAL_PACKET_TYPE_CRIT_SAVAGERY 17
  92. #define HEAL_PACKET_TYPE_REPAIR 64
  93. #define HEAL_PACKET_TYPE_CRIT_REPAIR 65
  94. #define ARROW_COLOR_GRAY 0 // 3
  95. #define ARROW_COLOR_GREEN 1 // 1
  96. #define ARROW_COLOR_BLUE 2
  97. #define ARROW_COLOR_WHITE 3 // 3
  98. #define ARROW_COLOR_YELLOW 4 // 4
  99. #define ARROW_COLOR_ORANGE 5 // 5
  100. #define ARROW_COLOR_RED 6
  101. #define ACTIVITY_STATUS_ROLEPLAYING 1
  102. #define ACTIVITY_STATUS_ANONYMOUS 2
  103. #define ACTIVITY_STATUS_LINKDEAD 4
  104. #define ACTIVITY_STATUS_CAMPING 8
  105. #define ACTIVITY_STATUS_LFG 16
  106. #define ACTIVITY_STATUS_LFW 32
  107. #define ACTIVITY_STATUS_SOLID 64 //used by zone objects to remain solid
  108. #define ACTIVITY_STATUS_IMMUNITY_GAINED 8192
  109. #define ACTIVITY_STATUS_IMMUNITY_REMAINING 16384
  110. // WE ARE UNSURE OF THESE OLD CLIENT VALUES USED AS TEMP PLACEHOLDERS FOR NEWER CLIENTS
  111. #define ACTIVITY_STATUS_AFK 32768 // whats the real one?
  112. #define ACTIVITY_STATUS_CORPSE_561 1
  113. #define ACTIVITY_STATUS_NPC_561 1<<1
  114. #define ACTIVITY_STATUS_STATICOBJECT_561 1<<2
  115. #define ACTIVITY_STATUS_MERCHANT_561 1<<4
  116. #define ACTIVITY_STATUS_HIDEICON_561 1<<8
  117. #define ACTIVITY_STATUS_INTERACTABLE_561 1<<9
  118. #define ACTIVITY_STATUS_NOTARGET_561 1<<10
  119. #define ACTIVITY_STATUS_ISTRANSPORT_561 1<<11
  120. #define ACTIVITY_STATUS_SHOWHOUSEICON_561 1<<12
  121. #define ACTIVITY_STATUS_LOOTABLE_561 1<<13
  122. #define ACTIVITY_STATUS_INCOMBAT_561 1<<14
  123. #define ACTIVITY_STATUS_AFK_561 1<<15
  124. #define ACTIVITY_STATUS_ROLEPLAYING_561 1<<16
  125. #define ACTIVITY_STATUS_ANONYMOUS_561 1<<17
  126. #define ACTIVITY_STATUS_LINKDEAD_561 1<<18
  127. #define ACTIVITY_STATUS_CAMPING_561 1<<19
  128. #define ACTIVITY_STATUS_LFG_561 1<<20
  129. #define ACTIVITY_STATUS_LFW_561 1<<21
  130. #define ACTIVITY_STATUS_SOLID_561 1<<23 //used by zone objects to remain solid
  131. #define ACTIVITY_STATUS_MENTORING_561 1<<28
  132. #define ACTIVITY_STATUS_IMMUNITY_GAINED_561 1<<30
  133. #define ACTIVITY_STATUS_IMMUNITY_REMAINING_561 1<<31
  134. #define ACTIVITY_STATUS_MERCENARY_1188 1<<2
  135. #define ACTIVITY_STATUS_STATICOBJECT_1188 1<<3
  136. #define ACTIVITY_STATUS_MERCHANT_1188 1<<4
  137. #define ACTIVITY_STATUS_HIDEICON_1188 1<<9
  138. #define ACTIVITY_STATUS_INTERACTABLE_1188 1<<10
  139. #define ACTIVITY_STATUS_NOTARGET_1188 1<<11
  140. #define ACTIVITY_STATUS_ISTRANSPORT_1188 1<<12
  141. #define ACTIVITY_STATUS_SHOWHOUSEICON_1188 1<<13
  142. #define ACTIVITY_STATUS_LOOTABLE_1188 1<<14
  143. #define ACTIVITY_STATUS_INCOMBAT_1188 1<<15
  144. #define ACTIVITY_STATUS_AFK_1188 1<<16
  145. #define ACTIVITY_STATUS_ROLEPLAYING_1188 1<<17
  146. #define ACTIVITY_STATUS_ANONYMOUS_1188 1<<18
  147. #define ACTIVITY_STATUS_LINKDEAD_1188 1<<19
  148. #define ACTIVITY_STATUS_CAMPING_1188 1<<20
  149. #define ACTIVITY_STATUS_LFG_1188 1<<21
  150. #define ACTIVITY_STATUS_LFW_1188 1<<22
  151. #define ACTIVITY_STATUS_SOLID_1188 1<<23 //used by zone objects to remain solid
  152. #define ACTIVITY_STATUS_MENTORING_1188 1<<28
  153. #define ACTIVITY_STATUS_IMMUNITY_GAINED_1188 1<<30
  154. #define ACTIVITY_STATUS_IMMUNITY_REMAINING_1188 1<<31
  155. #define POS_STATE_KNEELING 64
  156. #define POS_STATE_SOLID 128 //used by most mobs to remaind solid (cant walk through them)
  157. #define POS_STATE_NOTARGET_CURSOR 256 //cant target and no cursor is displayed
  158. #define POS_STATE_CROUCHING 512
  159. #define MERCHANT_TYPE_NO_BUY 1
  160. #define MERCHANT_TYPE_NO_BUY_BACK 2
  161. #define MERCHANT_TYPE_SPELLS 4
  162. #define MERCHANT_TYPE_CRAFTING 8
  163. #define MERCHANT_TYPE_REPAIR 16
  164. #define MERCHANT_TYPE_LOTTO 32
  165. #define MERCHANT_TYPE_CITYMERCHANT 64
  166. #define INFO_VIS_FLAG_INVIS 1
  167. #define INFO_VIS_FLAG_HIDE_HOOD 2
  168. #define INFO_VIS_FLAG_MOUNTED 4
  169. #define INFO_VIS_FLAG_CROUCH 8
  170. #define ENCOUNTER_STATE_NONE 0
  171. #define ENCOUNTER_STATE_AVAILABLE 1
  172. #define ENCOUNTER_STATE_BROKEN 2
  173. #define ENCOUNTER_STATE_LOCKED 3
  174. #define ENCOUNTER_STATE_OVERMATCHED 4
  175. #define ENCOUNTER_STATE_NO_REWARD 5
  176. #define VISUAL_STATE_COLLECTION_TURN_IN 6674
  177. #define VISUAL_STATE_IDLE_AFRAID 17953
  178. #define INFO_CLASSIC_FLAG_INVIS 1
  179. #define INFO_CLASSIC_FLAG_SHOW_HOOD 2
  180. #define INFO_CLASSIC_FLAG_NOLOOK 4
  181. #define INFO_CLASSIC_FLAG_CROUCH 8
  182. using namespace std;
  183. class Spell;
  184. class ZoneServer;
  185. class Quest;
  186. struct LUAHistory;
  187. struct Cell;
  188. struct CellInfo {
  189. Cell* CurrentCell;
  190. int CellListIndex;
  191. };
  192. struct MovementData{
  193. float x;
  194. float y;
  195. float z;
  196. float speed;
  197. int32 delay;
  198. string lua_function;
  199. float heading;
  200. bool use_movement_location_heading;
  201. };
  202. struct BasicInfoStruct{
  203. sint32 cur_hp;
  204. sint32 max_hp;
  205. sint32 hp_base;
  206. sint32 hp_base_instance;
  207. sint32 cur_power;
  208. sint32 max_power;
  209. sint32 power_base;
  210. sint32 power_base_instance;
  211. sint32 cur_savagery;
  212. sint32 max_savagery;
  213. sint32 savagery_base;
  214. sint32 cur_dissonance;
  215. sint32 max_dissonance;
  216. sint32 dissonance_base;
  217. sint16 assigned_aa;
  218. sint16 unassigned_aa;
  219. sint16 tradeskill_aa;
  220. sint16 unassigned_tradeskill_aa;
  221. sint16 prestige_aa;
  222. sint16 unassigned_prestige_aa;
  223. sint16 tradeskill_prestige_aa;
  224. sint16 unassigned_tradeskill_prestige_aa;
  225. int32 aaxp_rewards;
  226. };
  227. struct MovementLocation{
  228. float x;
  229. float y;
  230. float z;
  231. float speed;
  232. //int32 start_time;
  233. //int32 end_time;
  234. bool attackable;
  235. string lua_function;
  236. bool mapped;
  237. int32 gridid;
  238. int8 stage;
  239. bool reset_hp_on_runback;
  240. };
  241. struct SpawnUpdate {
  242. int32 spawn_id;
  243. bool info_changed;
  244. bool vis_changed;
  245. bool pos_changed;
  246. shared_ptr<Client> client;
  247. };
  248. struct SpawnData {
  249. Spawn* spawn;
  250. uchar* data;
  251. int32 size;
  252. };
  253. struct TimedGridData {
  254. int32 timestamp;
  255. int32 grid_id;
  256. float x;
  257. float y;
  258. float z;
  259. bool npc_save;
  260. int32 widget_id;
  261. };
  262. enum GroupLootMethod {
  263. METHOD_LEADER=0,
  264. METHOD_FFA=1,
  265. METHOD_LOTTO=2,
  266. METHOD_NEED_BEFORE_GREED=3,
  267. METHOD_ROUND_ROBIN=4
  268. };
  269. enum AutoLootMode {
  270. METHOD_DISABLED=0,
  271. METHOD_ACCEPT=1,
  272. METHOD_DECLINE=2
  273. };
  274. enum LootTier {
  275. ITEMS_ALL=0,
  276. ITEMS_TREASURED_PLUS=1,
  277. ITEMS_LEGENDARY_PLUS=2,
  278. ITEMS_FABLED_PLUS=3
  279. };
  280. class Spawn {
  281. public:
  282. Spawn();
  283. virtual ~Spawn();
  284. template <class Field, class Value> void Set(Field* field, Value value, bool setUpdateFlags = true){
  285. if (setUpdateFlags) {
  286. changed = true;
  287. AddChangedZoneSpawn();
  288. }
  289. *field = value;
  290. }
  291. template <class Field> void Set(Field* field, const char* value, bool setUpdateFlags = true){
  292. if (setUpdateFlags) {
  293. changed = true;
  294. AddChangedZoneSpawn();
  295. }
  296. strcpy(field, value);
  297. }
  298. template <class Field, class Value> void SetPos(Field* field, Value value, bool setUpdateFlags = true){
  299. if(setUpdateFlags){
  300. position_changed = true;
  301. }
  302. Set(field, value, setUpdateFlags);
  303. }
  304. template <class Field, class Value> void SetInfo(Field* field, Value value, bool setUpdateFlags = true){
  305. if(setUpdateFlags){
  306. info_changed = true;
  307. }
  308. Set(field, value);
  309. }
  310. template <class Field, class Value> void SetVis(Field* field, Value value, bool setUpdateFlags = true){
  311. if(setUpdateFlags)
  312. vis_changed = true;
  313. Set(field, value);
  314. }
  315. template <class Field> void SetPos(Field* field, char* value, bool setUpdateFlags = true){
  316. if(setUpdateFlags){
  317. position_changed = true;
  318. }
  319. Set(field, value, setUpdateFlags);
  320. }
  321. template <class Field> void SetInfo(Field* field, char* value, bool setUpdateFlags = true){
  322. if(setUpdateFlags){
  323. info_changed = true;
  324. }
  325. Set(field, value);
  326. }
  327. EntityCommand* CreateEntityCommand(EntityCommand* old_command){
  328. EntityCommand* entity_command = new EntityCommand;
  329. entity_command->name = old_command->name;
  330. entity_command->distance = old_command->distance;
  331. entity_command->command = old_command->command;
  332. entity_command->error_text = old_command->error_text;
  333. entity_command->cast_time = old_command->cast_time;
  334. entity_command->spell_visual = old_command->spell_visual;
  335. entity_command->default_allow_list = old_command->default_allow_list;
  336. return entity_command;
  337. }
  338. EntityCommand* CreateEntityCommand(const char* name, float distance, const char* command, const char* error_text, int16 cast_time, int32 spell_visual, bool default_allow_list=true){
  339. EntityCommand* entity_command = new EntityCommand;
  340. entity_command->name = name;
  341. entity_command->distance = distance;
  342. entity_command->command = command;
  343. entity_command->error_text = error_text;
  344. entity_command->cast_time = cast_time;
  345. entity_command->spell_visual = spell_visual;
  346. entity_command->default_allow_list = default_allow_list;
  347. return entity_command;
  348. }
  349. virtual Client* GetClient() { return 0; }
  350. void AddChangedZoneSpawn();
  351. void AddPrimaryEntityCommand(const char* name, float distance, const char* command, const char* error_text, int16 cast_time, int32 spell_visual, bool defaultDenyList = false, Player* player = NULL);
  352. void RemovePrimaryEntityCommand(const char* command);
  353. bool SetPermissionToEntityCommand(EntityCommand* command, Player* player, bool permissionValue);
  354. bool SetPermissionToEntityCommandByCharID(EntityCommand* command, int32 charID, bool permissionValue);
  355. void RemoveSpawnFromPlayer(Player* player);
  356. void AddSecondaryEntityCommand(const char* name, float distance, const char* command, const char* error_text, int16 cast_time, int32 spell_visual){
  357. secondary_command_list.push_back(CreateEntityCommand(name, distance, command, error_text, cast_time, spell_visual));
  358. }
  359. int8 GetLockedNoLoot(){
  360. return appearance.locked_no_loot;
  361. }
  362. int16 GetEmoteState(){
  363. return appearance.emote_state;
  364. }
  365. int8 GetHideHood(){
  366. return appearance.hide_hood;
  367. }
  368. void SetLockedNoLoot(int8 new_val, bool updateFlags = true){
  369. SetVis(&appearance.locked_no_loot, new_val, updateFlags);
  370. }
  371. void SetHandFlag(int8 new_val, bool updateFlags = true){
  372. SetVis(&appearance.display_hand_icon, new_val, updateFlags);
  373. }
  374. void SetHideHood(int8 new_val, bool updateFlags = true){
  375. SetInfo(&appearance.hide_hood, new_val, updateFlags);
  376. }
  377. void SetEmoteState(int8 new_val, bool updateFlags = true){
  378. SetInfo(&appearance.emote_state, new_val, updateFlags);
  379. }
  380. void SetName(const char* new_name, bool updateFlags = true){
  381. SetInfo(appearance.name, new_name, updateFlags);
  382. }
  383. void SetPrefixTitle(const char* new_prefix_title, bool updateFlags = true) {
  384. SetInfo(appearance.prefix_title, new_prefix_title, updateFlags);
  385. }
  386. void SetSuffixTitle(const char* new_suffix_title, bool updateFlags = true) {
  387. SetInfo(appearance.suffix_title, new_suffix_title, updateFlags);
  388. }
  389. void SetSubTitle(const char* new_sub_title, bool updateFlags = true) {
  390. SetInfo(appearance.sub_title, new_sub_title, updateFlags);
  391. }
  392. void SetLastName(const char* new_last_name, bool updateFlags = true) {
  393. SetInfo(appearance.last_name, new_last_name, updateFlags);
  394. }
  395. void SetAdventureClass(int8 new_class, bool updateFlags = true) {
  396. SetInfo(&appearance.adventure_class, new_class, updateFlags);
  397. }
  398. void SetTradeskillClass(int8 new_class, bool updateFlags = true) {
  399. SetInfo(&appearance.tradeskill_class, new_class, updateFlags);
  400. }
  401. void SetSize(int16 new_size, bool updateFlags = true) {
  402. SetPos(&size, new_size, updateFlags);
  403. }
  404. void SetSpeedX(float speed_x, bool updateFlags = true) {
  405. SetPos(&appearance.pos.SpeedX, speed_x, updateFlags);
  406. }
  407. void SetSpeedY(float speed_y, bool updateFlags = true) {
  408. SetPos(&appearance.pos.SpeedY, speed_y, updateFlags);
  409. }
  410. void SetSpeedZ(float speed_z, bool updateFlags = true) {
  411. SetPos(&appearance.pos.SpeedZ, speed_z, updateFlags);
  412. }
  413. void SetX(float x, bool updateFlags = true){
  414. SetPos(&appearance.pos.X, x, updateFlags);
  415. }
  416. void SetY(float y, bool updateFlags = true, bool disableYMapFix = false);
  417. void SetZ(float z, bool updateFlags = true){
  418. SetPos(&appearance.pos.Z, z, updateFlags);
  419. }
  420. void SetHeading(sint16 dir1, sint16 dir2, bool updateFlags = true){
  421. SetPos(&appearance.pos.Dir1, dir1, updateFlags);
  422. SetPos(&appearance.pos.Dir2, dir2, updateFlags);
  423. }
  424. void SetHeading(float heading, bool updateFlags = true){
  425. last_heading_angle = heading;
  426. if (heading != 180)
  427. heading = (heading - 180) * 64;
  428. SetHeading((sint16)heading, (sint16)heading, updateFlags);
  429. }
  430. void SetPitch(sint16 pitch1, sint16 pitch2, bool updateFlags = true){
  431. SetPos(&appearance.pos.Pitch1, (sint16)pitch1, updateFlags);
  432. SetPos(&appearance.pos.Pitch2, (sint16)pitch2, updateFlags);
  433. }
  434. void SetPitch(float pitch, bool updateFlags = true){
  435. if (pitch == 0){
  436. SetPos(&appearance.pos.Pitch1, (sint16)0, updateFlags);
  437. SetPos(&appearance.pos.Pitch2, (sint16)0, updateFlags);
  438. return;
  439. }
  440. if (pitch != 180)
  441. pitch = (pitch - 180) * 64;
  442. SetPos(&appearance.pos.Pitch1, (sint16)pitch, updateFlags);
  443. SetPos(&appearance.pos.Pitch2, (sint16)pitch, updateFlags);
  444. }
  445. void SetRoll(float roll, bool updateFlags = true){
  446. if (roll == 0){
  447. SetPos(&appearance.pos.Roll, (sint16)0, updateFlags);
  448. return;
  449. }
  450. else if (roll != 180)
  451. roll = (roll - 180) * 64;
  452. SetPos(&appearance.pos.Roll, (sint16)roll, updateFlags);
  453. }
  454. void SetVisualState(int16 state, bool updateFlags = true){
  455. SetInfo(&appearance.visual_state, state, updateFlags);
  456. }
  457. void SetActionState(int16 state, bool updateFlags = true){
  458. SetInfo(&appearance.action_state, state, updateFlags);
  459. }
  460. void SetMoodState(int16 state, bool updateFlags = true){
  461. SetInfo(&appearance.mood_state, state, updateFlags);
  462. }
  463. void SetInitialState(int16 state, bool updateFlags = true){
  464. SetPos(&appearance.pos.state, state, updateFlags);
  465. }
  466. void SetActivityStatus(int16 state, bool updateFlags = true){
  467. SetInfo(&appearance.activity_status, state, updateFlags);
  468. }
  469. void SetCollisionRadius(int32 radius, bool updateFlags = true){
  470. SetPos(&appearance.pos.collision_radius, radius, updateFlags);
  471. }
  472. int16 GetCollisionRadius(){
  473. return appearance.pos.collision_radius;
  474. }
  475. int16 GetVisualState(){
  476. return appearance.visual_state;
  477. }
  478. int16 GetActionState(){
  479. return appearance.action_state;
  480. }
  481. int16 GetMoodState(){
  482. return appearance.mood_state;
  483. }
  484. int16 GetInitialState(){
  485. return appearance.pos.state;
  486. }
  487. int16 GetActivityStatus(){
  488. return appearance.activity_status;
  489. }
  490. int32 GetPrimaryCommandListID(){
  491. return primary_command_list_id;
  492. }
  493. int32 GetSecondaryCommandListID(){
  494. return secondary_command_list_id;
  495. }
  496. void SetID(int32 in_id){
  497. Set(&id, in_id);
  498. }
  499. void SetDifficulty(int8 difficulty, bool setUpdateFlags = true){
  500. SetInfo(&appearance.difficulty, difficulty, setUpdateFlags);
  501. }
  502. virtual void SetLevel(int16 level, bool setUpdateFlags = true){
  503. SetInfo(&appearance.level, level, setUpdateFlags);
  504. }
  505. void SetTSLevel(int16 tradeskill_level, bool setUpdateFlags = true){
  506. SetInfo(&appearance.tradeskill_level, tradeskill_level, setUpdateFlags);
  507. }
  508. void SetGender(int8 gender, bool setUpdateFlags = true){
  509. SetInfo(&appearance.gender, gender, setUpdateFlags);
  510. }
  511. void SetShowName(int8 new_val, bool setUpdateFlags = true){
  512. SetVis(&appearance.display_name, new_val, setUpdateFlags);
  513. }
  514. void SetShowLevel(int8 new_val, bool setUpdateFlags = true){
  515. SetVis(&appearance.show_level, new_val, setUpdateFlags);
  516. }
  517. void SetHeroic(int8 new_val, bool setUpdateFlags = true){
  518. SetInfo(&appearance.heroic_flag, new_val, setUpdateFlags);
  519. }
  520. void SetTargetable(int8 new_val, bool setUpdateFlags = true){
  521. SetVis(&appearance.targetable, new_val, setUpdateFlags);
  522. }
  523. void SetShowCommandIcon(int8 new_val, bool setUpdateFlags = true){
  524. SetVis(&appearance.show_command_icon, new_val, setUpdateFlags);
  525. }
  526. void SetShowHandIcon(int8 new_val, bool setUpdateFlags = true){
  527. SetVis(&appearance.display_hand_icon, new_val, setUpdateFlags);
  528. }
  529. void SetAttackable(int8 new_val, bool setUpdateFlags = true){
  530. SetInfo(&appearance.attackable, new_val, setUpdateFlags);
  531. }
  532. void SetLocation(int32 id, bool setUpdateFlags = true);
  533. void SetRace(int8 race, bool setUpdateFlags = true){
  534. SetInfo(&appearance.race, race, setUpdateFlags);
  535. }
  536. void SetIcon(int8 icon, bool setUpdateFlags = true){
  537. SetInfo(&appearance.icon, icon, setUpdateFlags);
  538. }
  539. void AddIconValue(int8 val){
  540. if(!(appearance.icon & val))
  541. SetIcon(appearance.icon+val);
  542. }
  543. void RemoveIconValue(int8 val){
  544. if((appearance.icon & val))
  545. SetIcon(appearance.icon-val);
  546. }
  547. int8 GetIconValue(){
  548. return appearance.icon;
  549. }
  550. virtual void SetSpeed(float speed){
  551. SetPos(&appearance.pos.Speed1, (int8)speed);
  552. }
  553. virtual float GetSpeed(){
  554. return (float)appearance.pos.Speed1;
  555. }
  556. virtual float GetBaseSpeed(){
  557. return (float)appearance.pos.Speed1;
  558. }
  559. void SetSpawnType(int8 new_type){
  560. SetInfo(&spawn_type, new_type);
  561. }
  562. int8 GetSpawnType(){
  563. return spawn_type;
  564. }
  565. void SetDatabaseID(int32 new_id){
  566. database_id = new_id;
  567. }
  568. int32 GetDatabaseID(){
  569. return database_id;
  570. }
  571. int8 GetShowHandIcon(){
  572. return appearance.display_hand_icon;
  573. }
  574. int32 GetLocation(){
  575. return appearance.pos.grid_id;
  576. }
  577. int8 GetAttackable(){
  578. return appearance.attackable;
  579. }
  580. int8 GetShowName(){
  581. return appearance.display_name;
  582. }
  583. int8 GetShowLevel(){
  584. return appearance.show_level;
  585. }
  586. int8 GetHeroic(){
  587. return appearance.heroic_flag;
  588. }
  589. int8 GetTargetable(){
  590. return appearance.targetable;
  591. }
  592. int8 GetShowCommandIcon(){
  593. return appearance.show_command_icon;
  594. }
  595. char* GetName(){
  596. return appearance.name;
  597. }
  598. char* GetPrefixTitle(){
  599. return appearance.prefix_title;
  600. }
  601. char* GetSuffixTitle(){
  602. return appearance.suffix_title;
  603. }
  604. char* GetSubTitle() {
  605. return appearance.sub_title;
  606. }
  607. char* GetLastName() {
  608. return appearance.last_name;
  609. }
  610. int8 GetAdventureClass() {
  611. return appearance.adventure_class;
  612. }
  613. int8 GetTradeskillClass() {
  614. return appearance.tradeskill_class;
  615. }
  616. float GetDestinationX(){
  617. return appearance.pos.X2;
  618. }
  619. float GetX() {
  620. return appearance.pos.X;
  621. }
  622. float GetSpeedX() {
  623. return appearance.pos.SpeedX;
  624. }
  625. float GetSpeedY() {
  626. return appearance.pos.SpeedY;
  627. }
  628. float GetSpeedZ() {
  629. return appearance.pos.SpeedZ;
  630. }
  631. float GetDestinationY(){
  632. return appearance.pos.Y2;
  633. }
  634. float GetY(){
  635. return appearance.pos.Y;
  636. }
  637. float GetDestinationZ(){
  638. return appearance.pos.Z2;
  639. }
  640. float GetZ(){
  641. return appearance.pos.Z;
  642. }
  643. float GetHeading(){
  644. float heading = 0;
  645. if(appearance.pos.Dir1 != 0){
  646. heading = ((float)appearance.pos.Dir1)/((float)64);
  647. if(heading >= 180)
  648. heading -= 180;
  649. else
  650. heading += 180;
  651. }
  652. return heading;
  653. }
  654. float GetPitch(){
  655. float pitch = 0;
  656. if(appearance.pos.Pitch1 != 0){
  657. pitch = ((float)appearance.pos.Pitch1)/((float)64);
  658. if(pitch >= 180)
  659. pitch -= 180;
  660. else
  661. pitch += 180;
  662. }
  663. return pitch;
  664. }
  665. float GetRoll(){
  666. float roll = 0;
  667. if(appearance.pos.Roll != 0){
  668. roll = ((float)appearance.pos.Roll)/((float)64);
  669. if(roll >= 180)
  670. roll -= 180;
  671. else
  672. roll += 180;
  673. }
  674. return roll;
  675. }
  676. int32 GetID(){
  677. return id;
  678. }
  679. float GetDistance(float x1, float y1, float z1, float x2, float y2, float z2);
  680. float GetDistance(float x, float y, float z, float radius, bool ignore_y = false);
  681. float GetDistance(float x, float y, float z, bool ignore_y = false);
  682. float GetDistance(Spawn* spawn, bool ignore_y = false, bool includeRadius=true);
  683. float GetDistance(Spawn* spawn, float x1, float y1, float z1, bool includeRadius=true);
  684. float CalculateRadius(Spawn* target);
  685. int8 GetDifficulty(){
  686. return appearance.difficulty;
  687. }
  688. sint32 GetTotalPower();
  689. sint32 GetPower();
  690. sint32 GetTotalHP();
  691. sint32 GetHP();
  692. sint32 GetTotalHPBase();
  693. sint32 GetTotalHPBaseInstance();
  694. sint32 GetTotalPowerBase();
  695. sint32 GetTotalPowerBaseInstance();
  696. float GetHPRatio() { return GetHP() == 0 || GetTotalHP() == 0 ? 0 : ((float) GetHP() / GetTotalHP() * 100); }
  697. int GetIntHPRatio() { return GetTotalHP() == 0 ? 0 : static_cast<int>(GetHPRatio()); }
  698. sint32 GetTotalSavagery();
  699. sint32 GetSavagery();
  700. sint32 GetTotalDissonance();
  701. sint32 GetDissonance();
  702. sint32 GetTotalSavageryBase();
  703. sint32 GetTotalDissonanceBase();
  704. sint16 GetAssignedAA();
  705. sint16 GetUnassignedAA();
  706. sint16 GetTradeskillAA();
  707. sint16 GetUnassignedTradeskillAA();
  708. sint16 GetPrestigeAA();
  709. sint16 GetUnassignedPretigeAA();
  710. sint16 GetTradeskillPrestigeAA();
  711. sint16 GetUnassignedTradeskillPrestigeAA();
  712. int32 GetAAXPRewards();
  713. void SetTotalPower(sint32 new_val);
  714. void SetTotalHP(sint32 new_val);
  715. void SetTotalSavagery(sint32 new_val);
  716. void SetTotalDissonance(sint32 new_val);
  717. void SetTotalPowerBase(sint32 new_val);
  718. void SetTotalPowerBaseInstance(sint32 new_val);
  719. void SetTotalHPBase(sint32 new_val);
  720. void SetTotalHPBaseInstance(sint32 new_val);
  721. void SetTotalSavageryBase(sint32 new_val);
  722. void SetTotalDissonanceBase(sint32 new_val);
  723. void SetPower(sint32 power, bool setUpdateFlags = true);
  724. void SetHP(sint32 new_val, bool setUpdateFlags = true);
  725. void SetSavagery(sint32 savagery, bool setUpdateFlags = true);
  726. void SetDissonance(sint32 dissonance, bool setUpdateFlags = true);
  727. void SetAssignedAA(sint16 new_val);
  728. void SetUnassignedAA(sint16 new_val);
  729. void SetTradeskillAA(sint16 new_val);
  730. void SetUnassignedTradeskillAA(sint16 new_val);
  731. void SetPrestigeAA(sint16 new_val);
  732. void SetUnassignedPrestigeAA(sint16 new_val);
  733. void SetTradeskillPrestigeAA(sint16 new_val);
  734. void SetUnassignedTradeskillPrestigeAA(sint16 new_val);
  735. void SetAAXPRewards(int32 amount);
  736. void SetPrivateQuestSpawn(bool val) {req_quests_private = val;}
  737. void SetQuestsRequiredOverride(int16 val) {req_quests_override = val;}
  738. void SetQuestsRequiredContinuedAccess(bool val) {req_quests_continued_access = val;}
  739. bool GetPrivateQuestSpawn() {return req_quests_private;}
  740. int16 GetQuestsRequiredOverride() {return req_quests_override;}
  741. bool GetQuestsRequiredContinuedAccess() {return req_quests_continued_access;}
  742. bool Alive(){ return is_alive; }
  743. void SetAlive(bool val) { is_alive = val; }
  744. int16 GetLevel(){
  745. return appearance.level;
  746. }
  747. int16 GetTSLevel(){
  748. return appearance.tradeskill_level;
  749. }
  750. int8 GetGender(){
  751. return appearance.gender;
  752. }
  753. int8 GetRace(){
  754. return appearance.race;
  755. }
  756. int32 GetSize(){
  757. return size;
  758. }
  759. int32 GetDeviation(){
  760. return deviation;
  761. }
  762. void SetDeviation(int32 in_dev){
  763. deviation = in_dev;
  764. }
  765. float GetSpawnOrigHeading(){
  766. return appearance.pos.SpawnOrigHeading;
  767. }
  768. void SetSpawnOrigHeading(float val){
  769. appearance.pos.SpawnOrigHeading = val;
  770. }
  771. float GetSpawnOrigX(){
  772. return appearance.pos.SpawnOrigX;
  773. }
  774. float GetSpawnOrigY(){
  775. return appearance.pos.SpawnOrigY;
  776. }
  777. float GetSpawnOrigZ(){
  778. return appearance.pos.SpawnOrigZ;
  779. }
  780. float GetSpawnOrigPitch(){
  781. return appearance.pos.SpawnOrigPitch;
  782. }
  783. float GetSpawnOrigRoll(){
  784. return appearance.pos.SpawnOrigRoll;
  785. }
  786. void SetSpawnOrigX(float val){
  787. appearance.pos.SpawnOrigX = val;
  788. }
  789. void SetSpawnOrigY(float val){
  790. appearance.pos.SpawnOrigY = val;
  791. }
  792. void SetSpawnOrigZ(float val){
  793. appearance.pos.SpawnOrigZ = val;
  794. }
  795. void SetSpawnOrigRoll(float val){
  796. appearance.pos.SpawnOrigRoll = val;
  797. }
  798. void SetSpawnOrigPitch(float val){
  799. appearance.pos.SpawnOrigPitch = val;
  800. }
  801. void SetSogaModelType(int16 new_val, bool setUpdateFlags = true){
  802. SetInfo(&appearance.soga_model_type, new_val, setUpdateFlags);
  803. }
  804. void SetModelType(int16 model_type, bool setUpdateFlags = true){
  805. SetInfo(&appearance.model_type, model_type, setUpdateFlags);
  806. SetInfo(&appearance.soga_model_type, model_type, setUpdateFlags);
  807. SetFlyingCreature();
  808. SetWaterCreature();
  809. }
  810. int16 GetSogaModelType(){
  811. return appearance.soga_model_type;
  812. }
  813. int16 GetModelType(){
  814. return appearance.model_type;
  815. }
  816. bool IsFlyingCreature();
  817. bool IsWaterCreature();
  818. bool InWater();
  819. bool InLava();
  820. void SetFlyingCreature();
  821. void SetWaterCreature();
  822. void SetPrimaryCommand(const char* name, const char* command, float distance = 10);
  823. void SetPrimaryCommands(vector<EntityCommand*>* commands);
  824. void SetSecondaryCommands(vector<EntityCommand*>* commands);
  825. vector<EntityCommand*>* GetPrimaryCommands() {return &primary_command_list;}
  826. vector<EntityCommand*>* GetSecondaryCommands() {return &secondary_command_list;}
  827. EntityCommand* FindEntityCommand(string command, bool primaryOnly=false);
  828. virtual EQ2Packet* serialize(Player* player, int16 version);
  829. EQ2Packet* spawn_serialize(Player* player, int16 version, int16 offset = 0, int32 value = 0, int16 offset2 = 0, int16 offset3 = 0, int16 offset4 = 0, int32 value2 = 0);
  830. EQ2Packet* spawn_update_packet(Player* player, int16 version, bool override_changes = false, bool override_vis_changes = false);
  831. EQ2Packet* player_position_update_packet(Player* player, int16 version, bool override_ = false);
  832. uchar* spawn_info_changes(Player* spawn, int16 version, int16* info_packet_size);
  833. uchar* spawn_pos_changes(Player* spawn, int16 version, int16* pos_packet_size, bool override_ = false);
  834. uchar* spawn_vis_changes(Player* spawn, int16 version, int16* vis_packet_size);
  835. uchar* spawn_info_changes_ex(Player* spawn, int16 version, int16* info_packet_size);
  836. uchar* spawn_pos_changes_ex(Player* spawn, int16 version, int16* pos_packet_size);
  837. uchar* spawn_vis_changes_ex(Player* spawn, int16 version, int16* vis_packet_size);
  838. virtual bool EngagedInCombat(){ return false; }
  839. virtual bool IsObject(){ return false; }
  840. virtual bool IsGroundSpawn(){ return false; }
  841. virtual bool IsNPC(){ return false; }
  842. virtual bool IsEntity(){ return false; }
  843. virtual bool IsPlayer(){ return false; }
  844. virtual bool IsWidget(){ return false; }
  845. virtual bool IsSign(){ return false; }
  846. virtual bool IsBot() { return false; }
  847. bool HasInfoChanged(){ return info_changed; }
  848. bool HasPositionChanged(){ return position_changed; }
  849. bool HasTarget(){ return target ? true : false; }
  850. int32 GetRespawnTime();
  851. void SetRespawnTime(int32 time);
  852. int32 GetExpireTime() { return expire_time; }
  853. void SetExpireTime(int32 new_expire_time) { expire_time = new_expire_time; }
  854. int32 GetExpireOffsetTime();
  855. void SetExpireOffsetTime(int32 time);
  856. int32 GetSpawnLocationID();
  857. void SetSpawnLocationID(int32 id);
  858. int32 GetSpawnEntryID();
  859. void SetSpawnEntryID(int32 id);
  860. int32 GetSpawnLocationPlacementID();
  861. void SetSpawnLocationPlacementID(int32 id);
  862. float GetXOffset() { return x_offset; }
  863. void SetXOffset(float new_x_offset) { x_offset = new_x_offset; }
  864. float GetYOffset() { return y_offset; }
  865. void SetYOffset(float new_y_offset) { y_offset = new_y_offset; }
  866. float GetZOffset() { return z_offset; }
  867. void SetZOffset(float new_z_offset) { z_offset = new_z_offset; }
  868. bool HasTrapTriggered() {
  869. return trap_triggered;
  870. }
  871. int32 GetTrapState() {
  872. return trap_state;
  873. }
  874. void SetChestDropTime() {
  875. chest_drop_time = Timer::GetCurrentTime2();
  876. trap_opened_time = 0;
  877. }
  878. void SetTrapTriggered(bool triggered, int32 state) {
  879. if(!trap_triggered && triggered)
  880. trap_opened_time = Timer::GetCurrentTime2();
  881. trap_triggered = triggered;
  882. trap_state = state;
  883. }
  884. int32 GetChestDropTime() {
  885. return chest_drop_time;
  886. }
  887. int32 GetTrapOpenedTime() {
  888. return trap_opened_time;
  889. }
  890. void AddLootItem(int32 id, int16 charges = 1) {
  891. Item* master_item = master_item_list.GetItem(id);
  892. if (master_item) {
  893. Item* item = new Item(master_item);
  894. item->details.count = charges;
  895. LockLoot();
  896. loot_items.push_back(item);
  897. UnlockLoot();
  898. }
  899. }
  900. void AddLootItem(Item* item) {
  901. if(item) {
  902. LockLoot();
  903. loot_items.push_back(item);
  904. UnlockLoot();
  905. }
  906. }
  907. bool HasLoot() {
  908. LockLoot();
  909. if (loot_items.size() == 0 && loot_coins == 0) {
  910. UnlockLoot();
  911. return false;
  912. }
  913. UnlockLoot();
  914. return true;
  915. }
  916. void TransferLoot(Spawn* spawn);
  917. bool HasLootItemID(int32 id);
  918. int32 GetLootItemID();
  919. Item* LootItem(int32 id);
  920. vector<Item*>* GetLootItems() {
  921. return &loot_items;
  922. }
  923. void LockLoot() {
  924. MLootItems.lock();
  925. }
  926. void UnlockLoot() {
  927. MLootItems.unlock();
  928. }
  929. void ClearLoot() {
  930. MLootItems.lock();
  931. vector<Item*>::iterator itr;
  932. for (itr = loot_items.begin(); itr != loot_items.end();) {
  933. Item* itm = *itr;
  934. itr++;
  935. safe_delete(itm);
  936. }
  937. loot_items.clear();
  938. MLootItems.unlock();
  939. }
  940. int32 GetLootCount() {
  941. int32 loot_item_count = 0;
  942. MLootItems.lock();
  943. loot_item_count = loot_items.size();
  944. MLootItems.unlock();
  945. return loot_item_count;
  946. }
  947. void ClearNonBodyLoot() {
  948. MLootItems.lock();
  949. vector<Item*>::iterator itr;
  950. for (itr = loot_items.begin(); itr != loot_items.end();) {
  951. Item* itm = *itr;
  952. if(!itm->IsBodyDrop())
  953. {
  954. itr = loot_items.erase(itr);
  955. safe_delete(itm);
  956. }
  957. else
  958. itr++;
  959. }
  960. MLootItems.unlock();
  961. }
  962. int32 GetLootCoins() {
  963. LockLoot();
  964. int32 coins = loot_coins;
  965. UnlockLoot();
  966. return coins;
  967. }
  968. void SetLootCoins(int32 val, bool lockloot = true) {
  969. if(lockloot)
  970. LockLoot();
  971. loot_coins = val;
  972. if(lockloot)
  973. UnlockLoot();
  974. }
  975. void AddLootCoins(int32 coins) {
  976. LockLoot();
  977. loot_coins += coins;
  978. UnlockLoot();
  979. }
  980. Spawn* GetTarget();
  981. void SetTarget(Spawn* spawn);
  982. Spawn* GetLastAttacker();
  983. void SetLastAttacker(Spawn* spawn);
  984. bool TakeDamage(int32 damage);
  985. ZoneServer* GetZone();
  986. virtual void SetZone(ZoneServer* in_zone, int32 version=0);
  987. void SetFactionID(int32 val) { faction_id = val; }
  988. int32 GetFactionID(){
  989. return faction_id;
  990. }
  991. static int32 NextID() {
  992. static CriticalSection id_lock;
  993. id_lock.lock();
  994. int32 ret = ++next_id;
  995. if (next_id == 0xFFFFFFFE)
  996. next_id = 1;
  997. else if ((next_id - 255) % 256 == 0) { //we dont want it to end in 255, it will confuse/crash the client
  998. id_lock.unlock();
  999. return NextID();
  1000. }
  1001. id_lock.unlock();
  1002. return ret;
  1003. }
  1004. void AddProvidedQuest(int32 val){
  1005. quest_ids.push_back(val);
  1006. }
  1007. vector<int32>* GetProvidedQuests(){
  1008. return &quest_ids;
  1009. }
  1010. bool HasProvidedQuests(){
  1011. return (quest_ids.size() > 0);
  1012. }
  1013. void SetSpawnScript(string name);
  1014. const char* GetSpawnScript();
  1015. vector<Spawn*>* GetSpawnGroup();
  1016. bool HasSpawnGroup();
  1017. bool IsInSpawnGroup(Spawn* spawn);
  1018. Spawn* IsSpawnGroupMembersAlive(Spawn* ignore_spawn=nullptr, bool npc_only = true);
  1019. void UpdateEncounterState(int8 new_state);
  1020. void CheckEncounterState(Entity* victim, bool test_auto_lock = false);
  1021. void AddTargetToEncounter(Entity* entity);
  1022. void SendSpawnChanges(bool val){ send_spawn_changes = val; }
  1023. void SetSpawnGroupID(int32 id);
  1024. int32 GetSpawnGroupID();
  1025. void AddSpawnToGroup(Spawn* spawn);
  1026. void SetSpawnGroupList(vector<Spawn*>* list, Mutex* mutex);
  1027. void RemoveSpawnFromGroup(bool erase_all = false);
  1028. void SetRunningTo(Spawn* spawn){ running_to = spawn->GetID(); }
  1029. Spawn* GetRunningTo();
  1030. void SetTempVisualState(int val, bool update = true) { SetInfo(&tmp_visual_state, val, update); }
  1031. int GetTempVisualState(){ return tmp_visual_state; }
  1032. void SetTempActionState(int val, bool update = true) { SetInfo(&tmp_action_state, val, update); }
  1033. int GetTempActionState(){ return tmp_action_state; }
  1034. void AddAllowAccessSpawn(Spawn* spawn){ allowed_access[spawn->GetID()] = 1; }
  1035. void RemoveSpawnAccess(Spawn* spawn);
  1036. bool IsPrivateSpawn(){ return allowed_access.size() > 0 ;}
  1037. bool AllowedAccess(Spawn* spawn){ return allowed_access.count(spawn->GetID()) > 0; }
  1038. void MakeSpawnPublic() { allowed_access.clear(); }
  1039. void SetSizeOffset(int8 offset);
  1040. int8 GetSizeOffset();
  1041. void SetMerchantID(int32 val);
  1042. int32 GetMerchantID();
  1043. void SetMerchantType(int8 val);
  1044. int8 GetMerchantType();
  1045. void SetCollector(bool is_it) { is_collector = is_it; }
  1046. bool IsCollector() { return is_collector; }
  1047. void SetMerchantLevelRange(int32 minLvl = 0, int32 maxLvl = 0);
  1048. bool IsClientInMerchantLevelRange(Client* ent, bool sendMessageIfDenied = true);
  1049. int32 GetMerchantMinLevel();
  1050. int32 GetMerchantMaxLevel();
  1051. void SetQuestsRequired(Spawn* new_spawn);
  1052. void SetQuestsRequired(int32 quest_id, int16 quest_step);
  1053. bool HasQuestsRequired();
  1054. bool HasHistoryRequired();
  1055. void SetRequiredHistory(int32 event_id, int32 value1, int32 value2);
  1056. void SetTransporterID(int32 id);
  1057. int32 GetTransporterID();
  1058. bool MeetsSpawnAccessRequirements(Player* player);
  1059. void RemovePrimaryCommands();
  1060. void InitializePosPacketData(Player* player, PacketStruct* packet, bool bSpawnUpdate = false);
  1061. void InitializeInfoPacketData(Player* player, PacketStruct* packet);
  1062. void InitializeVisPacketData(Player* player, PacketStruct* packet);
  1063. void InitializeHeaderPacketData(Player* player, PacketStruct* packet, int16 index);
  1064. void InitializeFooterPacketData(Player* player, PacketStruct* packet);
  1065. void MoveToLocation(Spawn* spawn, float distance, bool immediate = true, bool isMappedLocation = false);
  1066. void AddMovementLocation(float x, float y, float z, float speed, int16 delay, const char* lua_function, float heading, bool include_heading = false);
  1067. void ProcessMovement(bool isSpawnListLocked=false);
  1068. void ResetMovement();
  1069. bool ValidateRunning(bool lockMovementLocation, bool lockMovementLoop);
  1070. bool IsRunning();
  1071. void CalculateRunningLocation(bool stop = false);
  1072. void RunToLocation(float x, float y, float z, float following_x = 0, float following_y = 0, float following_z = 0);
  1073. MovementLocation* GetCurrentRunningLocation();
  1074. MovementLocation* GetLastRunningLocation();
  1075. void NewWaypointChange(MovementLocation* data);
  1076. bool CalculateChange();
  1077. 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);
  1078. bool RemoveRunningLocation();
  1079. void ClearRunningLocations();
  1080. void CopySpawnAppearance(Spawn* spawn);
  1081. bool MovementInterrupted(){ return movement_interrupted; }
  1082. void MovementInterrupted(bool val) { movement_interrupted = val; }
  1083. bool NeedsToResumeMovement(){ return attack_resume_needed; }
  1084. void NeedsToResumeMovement(bool val) { attack_resume_needed = val; }
  1085. bool HasMovementLoop(){ return movement_loop.size() > 0; }
  1086. bool HasMovementLocations() {
  1087. bool hasLocations = false;
  1088. MMovementLocations.lock_shared();
  1089. hasLocations = movement_locations ? movement_locations->size() > 0 : false;
  1090. MMovementLocations.unlock_shared();
  1091. return hasLocations;
  1092. }
  1093. Timer* GetRunningTimer();
  1094. float GetFaceTarget(float x, float z);
  1095. void FaceTarget(float x, float z);
  1096. void FaceTarget(Spawn* target, bool disable_action_state = true);
  1097. void SetInvulnerable(bool val);
  1098. bool GetInvulnerable();
  1099. void SetScaredByStrongPlayers(bool val) { scared_by_strong_players = val; }
  1100. bool IsScaredByStrongPlayers() { return scared_by_strong_players; }
  1101. std::atomic<bool> changed;
  1102. std::atomic<bool> position_changed;
  1103. std::atomic<bool> info_changed;
  1104. std::atomic<bool> vis_changed;
  1105. std::atomic<bool> is_running;
  1106. int16 size;
  1107. int32 faction_id;
  1108. int8 oversized_packet; //0xff
  1109. int32 id;
  1110. int8 unknown1;
  1111. int32 unknown2;
  1112. int32 primary_command_list_id;
  1113. int32 secondary_command_list_id;
  1114. vector<EntityCommand*> primary_command_list;
  1115. vector<EntityCommand*> secondary_command_list;
  1116. int32 group_id;
  1117. int8 group_len;
  1118. vector<Spawn*>* spawn_group_list;
  1119. AppearanceData appearance;
  1120. int32 last_movement_update;
  1121. int32 last_location_update;
  1122. bool forceMapCheck;
  1123. bool is_water_creature;
  1124. bool is_flying_creature;
  1125. int32 trigger_widget_id;
  1126. std::atomic<bool> following;
  1127. bool IsPet() { return is_pet; }
  1128. void SetPet(bool val) { is_pet = val; }
  1129. Mutex m_requiredQuests;
  1130. Mutex m_requiredHistory;
  1131. void SetFollowTarget(Spawn* spawn, int32 followDistance=0);
  1132. Spawn* GetFollowTarget();
  1133. /// <summary>Sets a user defined variable</summary>
  1134. /// <param name='var'>Variable we are setting</param>
  1135. /// <param name='val'>Value to set the variable to</param>
  1136. void AddTempVariable(string var, string val);
  1137. void AddTempVariable(string var, Spawn* val);
  1138. void AddTempVariable(string var, ZoneServer* val);
  1139. void AddTempVariable(string var, Quest* val);
  1140. void AddTempVariable(string var, Item* val);
  1141. /// <summary>Gets the value for the given variable</summary>
  1142. /// <param name='var'>Variable to check</param>
  1143. /// <returns>The value for the given variable, "" if variable was not set</returns>
  1144. string GetTempVariable(string var);
  1145. Spawn* GetTempVariableSpawn(string var);
  1146. ZoneServer* GetTempVariableZone(string var);
  1147. Item* GetTempVariableItem(string var);
  1148. Quest* GetTempVariableQuest(string var);
  1149. int8 GetTempVariableType(string var);
  1150. void DeleteTempVariable(string var);
  1151. void SetIllusionModel(int16 val, bool setUpdateFlags = true) {
  1152. SetInfo(&m_illusionModel, val, setUpdateFlags);
  1153. }
  1154. int16 GetIllusionModel() { return m_illusionModel; }
  1155. CellInfo Cell_Info;
  1156. int32 GetSpawnAnim() { return m_spawnAnim; }
  1157. void SetSpawnAnim(int32 value) { m_spawnAnim = value; }
  1158. int32 GetAddedToWorldTimestamp() { return m_addedToWorldTimestamp; }
  1159. void SetAddedToWorldTimestamp(int32 value) { m_addedToWorldTimestamp = value; }
  1160. int16 GetSpawnAnimLeeway() { return m_spawnAnimLeeway; }
  1161. void SetSpawnAnimLeeway(int16 value) { m_spawnAnimLeeway = value; }
  1162. float FindDestGroundZ(glm::vec3 dest, float z_offset);
  1163. float FindBestZ(glm::vec3 loc, glm::vec3* result=nullptr, int32* new_grid_id=nullptr, int32* new_widget_id=nullptr);
  1164. float GetFixedZ(const glm::vec3& destination, int32 z_find_offset = 1);
  1165. void FixZ(bool forceUpdate=false);
  1166. bool CheckLoS(Spawn* target);
  1167. bool CheckLoS(glm::vec3 myloc, glm::vec3 oloc);
  1168. void CalculateNewFearpoint();
  1169. enum SpawnProximityType {
  1170. SPAWNPROXIMITY_DATABASE_ID = 0,
  1171. SPAWNPROXIMITY_LOCATION_ID = 1
  1172. };
  1173. struct SpawnProximity {
  1174. float x;
  1175. float y;
  1176. float z;
  1177. int32 spawn_value;
  1178. int8 spawn_type;
  1179. float distance;
  1180. string in_range_lua_function;
  1181. string leaving_range_lua_function;
  1182. map<int32, bool> spawns_in_proximity;
  1183. };
  1184. void AddSpawnToProximity(int32 spawnValue, SpawnProximityType type);
  1185. void RemoveSpawnFromProximity(int32 spawnValue, SpawnProximityType type);
  1186. SpawnProximity* AddLUASpawnProximity(int32 spawnValue, SpawnProximityType type, float distance, string in_range_function, string leaving_range_function) {
  1187. SpawnProximity* prox = new SpawnProximity;
  1188. prox->spawn_value = spawnValue;
  1189. prox->spawn_type = type;
  1190. prox->distance = distance;
  1191. prox->in_range_lua_function = in_range_function;
  1192. prox->leaving_range_lua_function = leaving_range_function;
  1193. spawn_proximities.Add(prox);
  1194. has_spawn_proximities = true;
  1195. return prox;
  1196. }
  1197. void RemoveSpawnProximities() {
  1198. MutexList<SpawnProximity*>::iterator itr = spawn_proximities.begin();
  1199. while (itr.Next()) {
  1200. safe_delete(itr->value);
  1201. }
  1202. spawn_proximities.clear();
  1203. has_spawn_proximities = false;
  1204. }
  1205. Mutex MCommandMutex;
  1206. bool has_spawn_proximities;
  1207. void SetPickupItemID(int32 itemid)
  1208. {
  1209. pickup_item_id = itemid;
  1210. }
  1211. void SetPickupUniqueItemID(int32 uniqueid)
  1212. {
  1213. pickup_unique_item_id = uniqueid;
  1214. }
  1215. int32 GetPickupItemID() { return pickup_item_id; }
  1216. int32 GetPickupUniqueItemID() { return pickup_unique_item_id; }
  1217. bool IsSoundsDisabled() { return disable_sounds; }
  1218. void SetSoundsDisabled(bool val) { disable_sounds = val; }
  1219. RegionMap* GetRegionMap() { return region_map; }
  1220. Map* GetMap() { return current_map; }
  1221. std::map<int32,TimedGridData> established_grid_id;
  1222. void DeleteRegion(Region_Node* inNode, ZBSP_Node* rootNode);
  1223. bool InRegion(Region_Node* inNode, ZBSP_Node* rootNode);
  1224. int32 GetRegionType(Region_Node* inNode, ZBSP_Node* rootNode);
  1225. float SpawnAngle(Spawn* target, float selfx, float selfz);
  1226. bool BehindSpawn(Spawn *target, float selfx, float selfz)
  1227. { return (!target || target == this) ? false : SpawnAngle(target, selfx, selfz) > 90.0f; }
  1228. bool InFrontSpawn(Spawn *target, float selfx, float selfz)
  1229. { return (!target || target == this) ? false : SpawnAngle(target, selfx, selfz) < 63.0f; }
  1230. bool IsFlankingSpawn(Spawn *target, float selfx, float selfz)
  1231. { return (!target || target == this) ? false : SpawnAngle(target, selfx, selfz) > 63.0f; }
  1232. std::map<std::map<Region_Node*, ZBSP_Node*>, Region_Status> Regions;
  1233. Mutex RegionMutex;
  1234. virtual void StopMovement();
  1235. virtual bool PauseMovement(int32 period_of_time_ms);
  1236. virtual bool IsPauseMovementTimerActive();
  1237. bool IsTransportSpawn() { return is_transport_spawn; }
  1238. void SetTransportSpawn(bool val) { is_transport_spawn = val; }
  1239. sint64 GetRailID() { return rail_id; }
  1240. void SetRailID(sint64 val) { rail_id = val; }
  1241. void AddRailPassenger(int32 char_id);
  1242. void RemoveRailPassenger(int32 char_id);
  1243. vector<Spawn*> GetPassengersOnRail();
  1244. void SetAppearancePosition(float x, float y, float z);
  1245. void SetOmittedByDBFlag(bool val) { is_omitted_by_db_flag = val; }
  1246. bool IsOmittedByDBFlag() { return is_omitted_by_db_flag; }
  1247. int32 GetLootTier() { return loot_tier; }
  1248. void SetLootTier(int32 tier) { loot_tier = tier; }
  1249. int32 GetLootDropType() { return loot_drop_type; }
  1250. void SetLootDropType(int32 type) { loot_drop_type = type; }
  1251. void SetDeletedSpawn(bool val) { deleted_spawn = val; }
  1252. bool IsDeletedSpawn() { return deleted_spawn; }
  1253. int32 InsertRegionToSpawn(Region_Node* node, ZBSP_Node* bsp_root, WaterRegionType regionType, bool in_region = true);
  1254. bool HasRegionTracked(Region_Node* node, ZBSP_Node* bsp_root, bool in_region);
  1255. int8 GetArrowColor(int8 spawn_level);
  1256. void AddIgnoredWidget(int32 id);
  1257. void SendGroupUpdate();
  1258. void OverrideLootMethod(GroupLootMethod newMethod) { loot_method = newMethod; }
  1259. void SetLootMethod(GroupLootMethod method, int8 item_rarity = 0, int32 group_id = 0);
  1260. int32 GetLootGroupID() { return loot_group_id; }
  1261. GroupLootMethod GetLootMethod() { return loot_method; }
  1262. int8 GetLootRarity() { return loot_rarity; }
  1263. int32 GetLootTimeRemaining() { return loot_timer.GetRemainingTime(); }
  1264. bool IsLootTimerRunning() { return loot_timer.Enabled(); }
  1265. bool CheckLootTimer() { return loot_timer.Check(); }
  1266. void DisableLootTimer() { return loot_timer.Disable(); }
  1267. int32 GetLooterSpawnID() { return looter_spawn_id; }
  1268. void SetLooterSpawnID(int32 id) { looter_spawn_id = id; }
  1269. bool AddNeedGreedItemRequest(int32 item_id, int32 spawn_id, bool need_item);
  1270. bool AddLottoItemRequest(int32 item_id, int32 spawn_id);
  1271. void AddSpawnLootWindowCompleted(int32 spawn_id, bool status_);
  1272. bool SetSpawnLootWindowCompleted(int32 spawn_id);
  1273. bool HasSpawnLootWindowCompleted(int32 spawn_id);
  1274. bool HasSpawnNeedGreedEntry(int32 item_id, int32 spawn_id);
  1275. bool HasSpawnLottoEntry(int32 item_id, int32 spawn_id);
  1276. void GetSpawnLottoEntries(int32 item_id, std::map<int32, int32>* out_entries);
  1277. void GetLootItemsList(std::vector<int32>* out_entries);
  1278. void GetSpawnNeedGreedEntries(int32 item_id, bool need_item, std::map<int32, int32>* out_entries);
  1279. bool HasLootWindowCompleted();
  1280. bool IsLootWindowComplete() { return is_loot_complete; }
  1281. void SetLootDispensed() { is_loot_dispensed = true; }
  1282. bool IsLootDispensed() { return is_loot_dispensed; }
  1283. std::map<int32, bool>* GetLootWindowList() { return &loot_complete; }
  1284. void StartLootTimer(Spawn* looter);
  1285. void CloseLoot(Spawn* sender);
  1286. void SetLootName(char* name) {
  1287. if(name != nullptr) {
  1288. loot_name = std::string(name);
  1289. }
  1290. }
  1291. const char* GetLootName() { return loot_name.c_str(); }
  1292. bool IsItemInLootTier(Item* item);
  1293. void DistributeGroupLoot_RoundRobin(std::vector<int32>* item_list, bool roundRobinTrashLoot = false); // trash loot is what falls under the item tier requirement by group options
  1294. void CalculateInitialVelocity(float heading, float distanceHorizontal, float distanceVertical, float distanceDepth, float duration);
  1295. glm::vec3 CalculateProjectilePosition(glm::vec3 initialVelocity, float time);
  1296. bool CalculateSpawnProjectilePosition(float x, float y, float z);
  1297. void SetKnockback(Spawn* target, int32 duration, float vertical, float horizontal);
  1298. void ResetKnockedBack();
  1299. mutable std::shared_mutex MIgnoredWidgets;
  1300. std::map<int32, bool> ignored_widgets;
  1301. EquipmentItemList equipment_list;
  1302. EquipmentItemList appearance_equipment_list;
  1303. protected:
  1304. bool has_quests_required;
  1305. bool has_history_required;
  1306. bool send_spawn_changes;
  1307. bool invulnerable;
  1308. bool attack_resume_needed;
  1309. bool resume_movement;
  1310. bool movement_interrupted;
  1311. int32 running_timer_begin;
  1312. int32 running_timer_end;
  1313. vector<MovementData*> movement_loop;
  1314. bool running_timer_updated;
  1315. int16 movement_index;
  1316. int32 last_grid_update;
  1317. int32 movement_start_time;
  1318. Mutex MMovementLoop;
  1319. map<int32, int8> allowed_access;
  1320. vector<int32> quest_ids;
  1321. int32 database_id;
  1322. int32 packet_num;
  1323. int32 target;
  1324. int8 spawn_type;
  1325. int32 last_attacker;
  1326. int32 merchant_id;
  1327. int8 merchant_type;
  1328. int32 merchant_min_level;
  1329. int32 merchant_max_level;
  1330. int32 transporter_id;
  1331. int32 pickup_item_id;
  1332. int32 pickup_unique_item_id;
  1333. map<int32, vector<int16>* > required_quests;
  1334. map<int32, LUAHistory*> required_history;
  1335. MutexList<SpawnProximity*> spawn_proximities;
  1336. void CheckProximities();
  1337. Timer pause_timer;
  1338. bool IsKnockedBack() { return knocked_back; }
  1339. private:
  1340. int32 loot_group_id;
  1341. GroupLootMethod loot_method;
  1342. int8 loot_rarity;
  1343. Timer loot_timer;
  1344. int32 looter_spawn_id;
  1345. vector<Item*> loot_items;
  1346. int32 loot_coins;
  1347. std::multimap<int32, int32> lotto_items;
  1348. std::multimap<int32, std::pair<int32, bool>> need_greed_items;
  1349. std::map<int32, bool> loot_complete;
  1350. bool is_loot_complete;
  1351. bool is_loot_dispensed;
  1352. std::string loot_name;
  1353. bool trap_triggered;
  1354. int32 trap_state;
  1355. int32 chest_drop_time;
  1356. int32 trap_opened_time;
  1357. deque<MovementLocation*>* movement_locations;
  1358. Mutex MLootItems;
  1359. mutable std::shared_mutex MMovementLocations;
  1360. Mutex* MSpawnGroup;
  1361. int8 size_offset;
  1362. int tmp_visual_state;
  1363. int tmp_action_state;
  1364. int32 running_to;
  1365. string spawn_script;
  1366. static int32 next_id;
  1367. ZoneServer* zone;
  1368. int32 spawn_location_id;
  1369. int32 spawn_entry_id;
  1370. int32 spawn_location_spawns_id;
  1371. int32 respawn;
  1372. int32 expire_time;
  1373. int32 expire_offset;
  1374. float x_offset;
  1375. float y_offset;
  1376. float z_offset;
  1377. int32 deviation;
  1378. BasicInfoStruct basic_info;
  1379. //string data;
  1380. bool is_pet;
  1381. // m_followTarget = spawn to follow around
  1382. int32 m_followTarget;
  1383. int32 m_followDistance;
  1384. bool req_quests_private;
  1385. int16 req_quests_override;
  1386. bool req_quests_continued_access;
  1387. float last_heading_angle;
  1388. map<string, int8> m_tempVariableTypes;
  1389. map<string, int32> m_tempVariableSpawn;
  1390. map<string, ZoneServer*> m_tempVariableZone;
  1391. map<string, Item*> m_tempVariableItem;
  1392. map<string, Quest*> m_tempVariableQuest;
  1393. // m_tempVariables = stores user defined variables from lua, will not persist through a zone
  1394. map<string, string> m_tempVariables;
  1395. int16 m_illusionModel;
  1396. int32 m_spawnAnim;
  1397. int32 m_addedToWorldTimestamp;
  1398. int16 m_spawnAnimLeeway;
  1399. Mutex m_Update;
  1400. Mutex m_SpawnMutex;
  1401. bool disable_sounds;
  1402. RegionMap* region_map;
  1403. Map* current_map;
  1404. bool is_transport_spawn;
  1405. sint64 rail_id;
  1406. map<int32, bool> rail_passengers;
  1407. mutex m_RailMutex;
  1408. bool is_omitted_by_db_flag; // this particular spawn is omitted by an expansion or holiday flag
  1409. int32 loot_tier;
  1410. int32 loot_drop_type;
  1411. std::atomic<bool> deleted_spawn;
  1412. std::atomic<bool> reset_movement;
  1413. Mutex m_GridMutex;
  1414. bool is_collector;
  1415. bool scared_by_strong_players;
  1416. std::atomic<bool> is_alive;
  1417. std::atomic<bool> knocked_back;
  1418. float knocked_back_time_step;
  1419. float knocked_back_h_distance;
  1420. float knocked_back_v_distance;
  1421. float knocked_back_duration;
  1422. float knocked_back_start_x;
  1423. float knocked_back_start_y;
  1424. float knocked_back_start_z;
  1425. int32 knocked_back_end_time;
  1426. float knocked_angle;
  1427. glm::vec3 knocked_velocity;
  1428. };
  1429. #endif