pc.hpp 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef PC_HPP
  4. #define PC_HPP
  5. #include <bitset>
  6. #include <memory>
  7. #include <vector>
  8. #include <common/cbasetypes.hpp>
  9. #include <common/database.hpp>
  10. #include <common/mmo.hpp> // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
  11. #include <common/strlib.hpp>// StringBuf
  12. #include <common/timer.hpp>
  13. #include "battleground.hpp"
  14. #include "buyingstore.hpp" // struct s_buyingstore
  15. #include "clif.hpp" //e_wip_block
  16. #include "itemdb.hpp" // MAX_ITEMGROUP
  17. #include "map.hpp" // RC_ALL
  18. #include "mob.hpp" //e_size
  19. #include "pc_groups.hpp" // s_player_group
  20. #include "script.hpp" // struct script_reg, struct script_regstr
  21. #include "searchstore.hpp" // struct s_search_store_info
  22. #include "status.hpp" // unit_data
  23. #include "unit.hpp" // unit_data
  24. #include "vending.hpp" // struct s_vending
  25. enum AtCommandType : uint8;
  26. enum e_instance_mode : uint8;
  27. //enum e_log_chat_type : uint8;
  28. enum e_log_pick_type : uint32;
  29. enum sc_type : int16;
  30. class MapGuild;
  31. #define MAX_PC_BONUS 50 /// Max bonus, usually used by item bonus
  32. #define MAX_PC_FEELHATE 3 /// Max feel hate info
  33. #define DAMAGELOG_SIZE_PC 100 /// Damage log
  34. #define MAX_SPIRITBALL 15 /// Max spirit balls
  35. #define MAX_DEVOTION 5 /// Max Devotion slots
  36. #define MAX_SPIRITCHARM 10 /// Max spirit charms
  37. #define MAX_SOUL_BALL 20 /// Max soul ball
  38. #define MAX_STELLAR_MARKS 5 /// Max stellar marks
  39. #define MAX_UNITED_SOULS 12 /// Max united souls
  40. #define MAX_SERVANTBALL 5 /// Max servant weapons
  41. #define MAX_SERVANT_SIGN 5 /// Max servant signs
  42. #define MAX_ABYSSBALL 5 /// Max abyss spheres
  43. #define LANGTYPE_VAR "#langtype"
  44. #define CASHPOINT_VAR "#CASHPOINTS"
  45. #define KAFRAPOINT_VAR "#KAFRAPOINTS"
  46. #define BANK_VAULT_VAR "#BANKVAULT"
  47. #define ROULETTE_BRONZE_VAR "RouletteBronze"
  48. #define ROULETTE_SILVER_VAR "RouletteSilver"
  49. #define ROULETTE_GOLD_VAR "RouletteGold"
  50. #define COOKMASTERY_VAR "COOK_MASTERY"
  51. #define PCDIECOUNTER_VAR "PC_DIE_COUNTER"
  52. #define JOBCHANGE2ND_VAR "jobchange_level"
  53. #define JOBCHANGE3RD_VAR "jobchange_level_3rd"
  54. #define JOBCHANGE4TH_VAR "jobchange_level_4th"
  55. #define TKMISSIONID_VAR "TK_MISSION_ID"
  56. #define TKMISSIONCOUNT_VAR "TK_MISSION_COUNT"
  57. #define ATTENDANCE_DATE_VAR "#AttendanceDate"
  58. #define ATTENDANCE_COUNT_VAR "#AttendanceCounter"
  59. #define ACHIEVEMENTLEVEL "AchievementLevel"
  60. //Total number of classes (for data storage)
  61. #define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
  62. //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
  63. //where the arrows are equipped)
  64. enum equip_index {
  65. EQI_COMPOUND_ON = -1,
  66. EQI_ACC_L = 0,
  67. EQI_ACC_R,
  68. EQI_SHOES,
  69. EQI_GARMENT,
  70. EQI_HEAD_LOW,
  71. EQI_HEAD_MID,
  72. EQI_HEAD_TOP,
  73. EQI_ARMOR,
  74. EQI_HAND_L,
  75. EQI_HAND_R,
  76. EQI_COSTUME_HEAD_TOP,
  77. EQI_COSTUME_HEAD_MID,
  78. EQI_COSTUME_HEAD_LOW,
  79. EQI_COSTUME_GARMENT,
  80. EQI_AMMO,
  81. EQI_SHADOW_ARMOR,
  82. EQI_SHADOW_WEAPON,
  83. EQI_SHADOW_SHIELD,
  84. EQI_SHADOW_SHOES,
  85. EQI_SHADOW_ACC_R,
  86. EQI_SHADOW_ACC_L,
  87. EQI_MAX
  88. };
  89. enum prevent_logout_trigger {
  90. PLT_NONE = 0,
  91. PLT_LOGIN = 1,
  92. PLT_ATTACK = 2,
  93. PLT_SKILL = 4,
  94. PLT_DAMAGE = 8
  95. };
  96. enum e_chkitem_result : uint8 {
  97. CHKADDITEM_EXIST,
  98. CHKADDITEM_NEW,
  99. CHKADDITEM_OVERAMOUNT
  100. };
  101. enum e_additem_result : uint8 {
  102. ADDITEM_SUCCESS,
  103. ADDITEM_INVALID,
  104. ADDITEM_OVERWEIGHT,
  105. ADDITEM_ITEM,
  106. ADDITEM_OVERITEM,
  107. ADDITEM_OVERAMOUNT,
  108. ADDITEM_REFUSED_TIME,
  109. ADDITEM_STACKLIMIT
  110. };
  111. enum e_lr_flag : uint8 {
  112. LR_FLAG_NONE = 0,
  113. LR_FLAG_WEAPON,
  114. LR_FLAG_ARROW,
  115. LR_FLAG_SHIELD
  116. };
  117. #ifndef CAPTCHA_ANSWER_SIZE
  118. #define CAPTCHA_ANSWER_SIZE 16
  119. #endif
  120. #ifndef CAPTCHA_BMP_SIZE
  121. #define CAPTCHA_BMP_SIZE (2 + 52 + (3 * 220 * 90)) // sizeof("BM") + sizeof(BITMAPV2INFOHEADER) + 24bits 220x90 BMP
  122. #endif
  123. #ifndef MAX_CAPTCHA_CHUNK_SIZE
  124. #define MAX_CAPTCHA_CHUNK_SIZE 1024
  125. #endif
  126. struct s_captcha_data {
  127. uint16 index;
  128. uint16 image_size;
  129. char image_data[CAPTCHA_BMP_SIZE];
  130. char captcha_answer[CAPTCHA_ANSWER_SIZE];
  131. script_code *bonus_script;
  132. ~s_captcha_data() {
  133. if (this->bonus_script)
  134. script_free_code(this->bonus_script);
  135. }
  136. };
  137. struct s_macro_detect {
  138. std::shared_ptr<s_captcha_data> cd;
  139. int32 reporter_aid;
  140. int32 retry;
  141. int32 timer;
  142. };
  143. enum e_macro_detect_status : uint8 {
  144. MCD_TIMEOUT = 0,
  145. MCD_INCORRECT = 1,
  146. MCD_GOOD = 2,
  147. };
  148. enum e_macro_report_status : uint8 {
  149. MCR_MONITORING = 0,
  150. MCR_NO_DATA = 1,
  151. MCR_INPROGRESS = 2,
  152. };
  153. class CaptchaDatabase : public TypesafeYamlDatabase<int16, s_captcha_data> {
  154. public:
  155. CaptchaDatabase() : TypesafeYamlDatabase("CAPTCHA_DB", 1) {
  156. }
  157. const std::string getDefaultLocation() override;
  158. uint64 parseBodyNode(const ryml::NodeRef &node) override;
  159. };
  160. extern CaptchaDatabase captcha_db;
  161. struct skill_cooldown_entry {
  162. unsigned short skill_id;
  163. int32 timer;
  164. };
  165. #ifdef VIP_ENABLE
  166. struct vip_info {
  167. uint32 enabled : 1;
  168. time_t time;
  169. bool disableshowrate; //State to disable clif_display_pinfo(). [Cydh]
  170. };
  171. #endif
  172. enum npc_timeout_type {
  173. NPCT_INPUT = 0,
  174. NPCT_MENU = 1,
  175. NPCT_WAIT = 2,
  176. };
  177. /// Enum of Player's Parameter
  178. enum e_params {
  179. PARAM_STR = 0,
  180. PARAM_AGI,
  181. PARAM_VIT,
  182. PARAM_INT,
  183. PARAM_DEX,
  184. PARAM_LUK,
  185. PARAM_POW,
  186. PARAM_STA,
  187. PARAM_WIS,
  188. PARAM_SPL,
  189. PARAM_CON,
  190. PARAM_CRT,
  191. PARAM_MAX
  192. };
  193. static const char* parameter_names[PARAM_MAX] = {
  194. "Str",
  195. "Agi",
  196. "Vit",
  197. "Int",
  198. "Dex",
  199. "Luk",
  200. "Pow",
  201. "Sta",
  202. "Wis",
  203. "Spl",
  204. "Con",
  205. "Crt"
  206. };
  207. extern uint32 equip_bitmask[EQI_MAX];
  208. #define equip_index_check(i) ( (i) >= EQI_ACC_L && (i) < EQI_MAX )
  209. /// Miscellaneous item bonus struct
  210. struct s_item_bonus {
  211. uint16 id;
  212. int32 val;
  213. };
  214. /// AddEle bonus struct
  215. struct s_addele2 {
  216. short flag, rate;
  217. unsigned char ele;
  218. };
  219. /// AddRace bonus struct
  220. struct s_addrace2 {
  221. short flag, rate;
  222. unsigned char race;
  223. };
  224. struct weapon_data {
  225. int32 atkmods[SZ_ALL];
  226. // all the variables except atkmods get zero'ed in each call of status_calc_pc
  227. // NOTE: if you want to add a non-zeroed variable, you need to update the memset call
  228. // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex]
  229. int32 overrefine;
  230. int32 star;
  231. int32 ignore_def_ele;
  232. int32 ignore_def_race;
  233. int32 ignore_def_class;
  234. int32 def_ratio_atk_ele;
  235. int32 def_ratio_atk_race;
  236. int32 def_ratio_atk_class;
  237. int32 addele[ELE_MAX];
  238. int32 addrace[RC_MAX];
  239. int32 addclass[CLASS_MAX];
  240. int32 addrace2[RC2_MAX];
  241. int32 addsize[SZ_MAX];
  242. short hp_drain_race[RC_MAX];
  243. short sp_drain_race[RC_MAX];
  244. short hp_drain_class[CLASS_MAX];
  245. short sp_drain_class[CLASS_MAX];
  246. struct drain_data {
  247. short rate; ///< Success rate 10000 = 100%
  248. short per; ///< Drain value/rate per attack
  249. } hp_drain_rate, sp_drain_rate;
  250. std::vector<s_item_bonus> add_dmg;
  251. std::vector<s_addele2> addele2;
  252. std::vector<s_addrace2> addrace3;
  253. };
  254. enum e_autospell_flags{
  255. AUTOSPELL_FORCE_SELF = 0x0,
  256. AUTOSPELL_FORCE_TARGET = 0x1,
  257. AUTOSPELL_FORCE_RANDOM_LEVEL = 0x2,
  258. AUTOSPELL_FORCE_ALL = 0x3
  259. };
  260. /// AutoSpell bonus struct
  261. struct s_autospell {
  262. uint16 id, lv, trigger_skill;
  263. short rate, battle_flag;
  264. t_itemid card_id;
  265. uint8 flag;
  266. bool lock; // bAutoSpellOnSkill: blocks autospell from triggering again, while being executed
  267. };
  268. /// AddEff and AddEff2 bonus struct
  269. struct s_addeffect {
  270. enum sc_type sc; /// SC type/effect
  271. int32 rate; /// Rate
  272. short arrow_rate; /// Arrow rate
  273. unsigned char flag; /// Flag
  274. uint32 duration; /// Duration the effect applied
  275. };
  276. /// AddEffOnSkill bonus struct
  277. struct s_addeffectonskill {
  278. enum sc_type sc; /// SC type/effect
  279. int32 rate; /// Rate
  280. short skill_id; /// Skill ID
  281. unsigned char target; /// Target
  282. uint32 duration; /// Duration the effect applied
  283. };
  284. ///Struct of add drop item/group rate
  285. struct s_add_drop {
  286. t_itemid nameid; ///Item ID
  287. unsigned short group; ///Group ID
  288. int32 rate; ///Rate, 1 ~ 10000, -1 ~ -100000
  289. short race; ///Target Race, bitwise value of 1<<x. if < 0 means Monster ID
  290. unsigned short class_; ///Target Class, bitwise value of 1<<x
  291. };
  292. struct s_vanish_bonus {
  293. int16 rate; // 1000 = 100%
  294. int16 per; // 100 = 100%
  295. int32 flag;
  296. };
  297. /// AutoBonus bonus struct
  298. struct s_autobonus {
  299. short rate;
  300. uint16 atk_type;
  301. uint32 duration;
  302. char *bonus_script, *other_script;
  303. int32 active;
  304. uint32 pos;
  305. ~s_autobonus();
  306. };
  307. /// Timed bonus 'bonus_script' struct [Cydh]
  308. struct s_bonus_script_entry {
  309. struct script_code *script;
  310. StringBuf *script_buf; //Used for comparing and storing on table
  311. t_tick tick;
  312. uint16 flag;
  313. enum efst_type icon;
  314. uint8 type; //0 - Ignore; 1 - Buff; 2 - Debuff
  315. int32 tid;
  316. };
  317. /// HP/SP bonus struct
  318. struct s_regen {
  319. short value;
  320. int32 rate;
  321. int32 tick;
  322. };
  323. /// Item combo struct
  324. struct s_combos {
  325. script_code *bonus;
  326. uint32 id;
  327. uint32 pos;
  328. };
  329. struct s_qi_display {
  330. bool is_active;
  331. e_questinfo_types icon;
  332. e_questinfo_markcolor color;
  333. };
  334. class map_session_data {
  335. public:
  336. struct block_list bl;
  337. struct unit_data ud;
  338. struct view_data vd;
  339. struct status_data base_status, battle_status;
  340. status_change sc;
  341. struct regen_data regen;
  342. struct regen_data_sub sregen, ssregen;
  343. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
  344. //status_calc_pc, while special_state is recalculated in each call. [Skotlex]
  345. struct s_state {
  346. uint32 active : 1; //Marks active player (not active is logging in/out, or changing map servers)
  347. uint32 menu_or_input : 1;// if a script is waiting for feedback from the player
  348. uint32 dead_sit : 2;
  349. e_lr_flag lr_flag;
  350. uint32 connect_new : 1;
  351. uint32 arrow_atk : 1;
  352. uint32 gangsterparadise : 1;
  353. uint32 rest : 1;
  354. uint32 storage_flag : 3; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex], 3: Premium Storage
  355. uint32 snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
  356. uint32 abra_flag : 2; // Abracadabra bugfix by Aru
  357. uint32 autocast : 1; // Autospell flag [Inkfish]
  358. uint32 autotrade : 3; //By Fantik. &2 Requested by vending autotrade; &4 Requested by buyingstore autotrade
  359. uint32 showdelay :1;
  360. uint32 showexp :1;
  361. uint32 showzeny :1;
  362. uint32 noask :1; // [LuzZza]
  363. uint32 trading :1; //[Skotlex] is 1 only after a trade has started.
  364. uint32 deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
  365. uint32 size :2; // for tiny/large types
  366. uint32 night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
  367. uint32 using_fake_npc :1;
  368. uint32 rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex]
  369. uint32 killer : 1;
  370. uint32 killable : 1;
  371. uint32 doridori : 1;
  372. uint32 ignoreAll : 1;
  373. uint32 debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
  374. uint32 buyingstore : 1;
  375. uint32 lesseffect : 1;
  376. uint32 vending : 1;
  377. uint32 noks : 3; // [Zeph Kill Steal Protection]
  378. uint32 changemap : 1;
  379. uint32 callshop : 1; // flag to indicate that a script used callshop; on a shop
  380. short pmap; // Previous map on Map Change
  381. unsigned short autoloot;
  382. t_itemid autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
  383. unsigned short autoloottype;
  384. uint32 autolooting : 1; //performance-saver, autolooting state for @alootid
  385. uint32 gmaster_flag : 1;
  386. uint32 prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
  387. bool pending_vending_ui; // flag whether the vending packet should still be sent to this player or not
  388. uint32 warping : 1;//states whether you're in the middle of a warp processing
  389. uint32 permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
  390. bool hold_recalc;
  391. uint32 banking : 1; //1 when we using the banking system 0 when closed
  392. uint32 hpmeter_visible : 1;
  393. unsigned disable_atcommand_on_npc : 1; //Prevent to use atcommand while talking with NPC [Kichi]
  394. uint8 isBoundTrading; // Player is currently add bound item to trade list [Cydh]
  395. bool ignoretimeout; // Prevent the SECURE_NPCTIMEOUT function from closing current script.
  396. uint32 workinprogress : 2; // See clif.hpp::e_workinprogress
  397. bool pc_loaded; // Ensure inventory data and status data is loaded before we calculate player stats
  398. bool keepshop; // Whether shop data should be removed when the player disconnects
  399. bool mail_writing; // Whether the player is currently writing a mail in RODEX or not
  400. bool cashshop_open;
  401. bool sale_open;
  402. bool stylist_open;
  403. bool barter_open;
  404. bool barter_extended_open;
  405. bool enchantgrade_open; // Whether the enchantgrade window is open or not
  406. // Bitmask of e_pcblock_action_flag values
  407. uint16 block_action;
  408. bool refineui_open;
  409. t_itemid inventory_expansion_confirmation;
  410. uint16 inventory_expansion_amount;
  411. t_itemid laphine_synthesis;
  412. t_itemid laphine_upgrade;
  413. bool roulette_open;
  414. t_itemid item_reform;
  415. uint64 item_enchant_index;
  416. } state;
  417. struct {
  418. unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
  419. uint32 restart_full_recover : 1;
  420. uint32 no_castcancel : 1;
  421. uint32 no_castcancel2 : 1;
  422. uint32 no_sizefix : 1;
  423. uint32 no_gemstone : 2;
  424. uint32 intravision : 1; // Maya Purple Card effect [DracoRPG]
  425. uint32 perfect_hiding : 1; // [Valaris]
  426. uint32 no_knockback : 1;
  427. uint32 bonus_coma : 1;
  428. uint32 no_mado_fuel : 1; // Disable Magic_Gear_Fuel consumption [Secret]
  429. uint32 no_walk_delay : 1;
  430. } special_state;
  431. uint32 login_id1, login_id2;
  432. uint64 class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
  433. int32 group_id;
  434. std::shared_ptr<s_player_group> group;
  435. std::bitset<PC_PERM_MAX> permissions; // group permissions have to be copied, because they might be adjusted by atcommand addperm
  436. int32 count_rewarp; //count how many time we being rewarped
  437. int32 langtype;
  438. struct mmo_charstatus status;
  439. // Item Storages
  440. struct s_storage storage, premiumStorage;
  441. struct s_storage inventory;
  442. struct s_storage cart;
  443. struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
  444. short equip_index[EQI_MAX];
  445. short equip_switch_index[EQI_MAX];
  446. uint32 weight,max_weight,add_max_weight;
  447. int32 cart_weight,cart_num,cart_weight_max;
  448. int32 fd;
  449. unsigned short mapindex;
  450. unsigned char head_dir; //0: Look forward. 1: Look right, 2: Look left.
  451. t_tick client_tick;
  452. int32 npc_id,npc_shopid; //for script follow scriptoid; ,npcid
  453. std::vector<int> npc_id_dynamic;
  454. std::vector<int> areanpc, npc_ontouch_; ///< Array of OnTouch and OnTouch_ NPC ID
  455. int32 npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
  456. int32 npc_menu; // internal variable, used in npc menu handling
  457. int32 npc_amount;
  458. struct script_state *st;
  459. char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
  460. int32 npc_timer_id; //For player attached npc timers. [Skotlex]
  461. uint32 chatID;
  462. time_t idletime;
  463. time_t idletime_hom;
  464. time_t idletime_mer;
  465. struct s_progressbar {
  466. int32 npc_id;
  467. t_tick timeout;
  468. } progressbar; //Progress Bar [Inkfish]
  469. struct s_ignore {
  470. char name[NAME_LENGTH];
  471. } ignore[MAX_IGNORE_LIST];
  472. int32 followtimer; // [MouseJstr]
  473. int32 followtarget;
  474. time_t emotionlasttime; // to limit flood with emotion packets
  475. short skillitem,skillitemlv;
  476. bool skillitem_keep_requirement;
  477. uint16 skill_id_old,skill_lv_old;
  478. uint16 skill_id_dance,skill_lv_dance;
  479. uint16 skill_id_song, skill_lv_song;
  480. short cook_mastery; // range: [0,1999] [Inkfish]
  481. struct skill_cooldown_entry * scd[MAX_SKILLCOOLDOWN]; // Skill Cooldown
  482. uint16 cloneskill_idx, ///Stores index of copied skill by Intimidate/Plagiarism
  483. reproduceskill_idx; ///Stores index of copied skill by Reproduce
  484. int32 menuskill_id, menuskill_val, menuskill_val2;
  485. int32 invincible_timer;
  486. t_tick canlog_tick;
  487. t_tick canuseitem_tick; // [Skotlex]
  488. t_tick canusecashfood_tick;
  489. t_tick canequip_tick; // [Inkfish]
  490. t_tick cantalk_tick;
  491. t_tick canskill_tick; // used to prevent abuse from no-delay ACT files
  492. t_tick cansendmail_tick; // [Mail System Flood Protection]
  493. t_tick ks_floodprotect_tick; // [Kill Steal Protection]
  494. t_tick equipswitch_tick; // Equip switch
  495. struct s_item_delay {
  496. t_itemid nameid;
  497. t_tick tick;
  498. } item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
  499. short weapontype1,weapontype2;
  500. short disguise; // [Valaris]
  501. struct weapon_data right_weapon, left_weapon;
  502. // here start arrays to be globally zeroed at the beginning of status_calc_pc()
  503. struct s_indexed_bonus {
  504. int32 param_bonus[PARAM_MAX], param_equip[PARAM_MAX]; //Stores card/equipment bonuses.
  505. int32 subele[ELE_MAX];
  506. int32 subele_script[ELE_MAX];
  507. int32 subdefele[ELE_MAX];
  508. int32 subrace[RC_MAX];
  509. int32 subclass[CLASS_MAX];
  510. int32 subrace2[RC2_MAX];
  511. int32 subsize[SZ_MAX];
  512. short coma_class[CLASS_MAX];
  513. short coma_race[RC_MAX];
  514. short weapon_coma_ele[ELE_MAX];
  515. short weapon_coma_race[RC_MAX];
  516. short weapon_coma_class[CLASS_MAX];
  517. int32 weapon_atk[16];
  518. int32 weapon_damage_rate[16];
  519. int32 arrow_addele[ELE_MAX];
  520. int32 arrow_addrace[RC_MAX];
  521. int32 arrow_addclass[CLASS_MAX];
  522. int32 arrow_addsize[SZ_MAX];
  523. int32 magic_addele[ELE_MAX];
  524. int32 magic_addele_script[ELE_MAX];
  525. int32 magic_addrace[RC_MAX];
  526. int32 magic_addclass[CLASS_MAX];
  527. int32 magic_addsize[SZ_MAX];
  528. int32 magic_atk_ele[ELE_MAX];
  529. int32 weapon_subsize[SZ_MAX];
  530. int32 magic_subsize[SZ_MAX];
  531. int32 critaddrace[RC_MAX];
  532. int32 expaddrace[RC_MAX];
  533. int32 expaddclass[CLASS_MAX];
  534. int32 ignore_mdef_by_race[RC_MAX];
  535. int32 ignore_mdef_by_class[CLASS_MAX];
  536. int32 ignore_def_by_race[RC_MAX];
  537. int32 ignore_def_by_class[CLASS_MAX];
  538. short sp_gain_race[RC_MAX];
  539. int32 magic_addrace2[RC2_MAX];
  540. int32 ignore_mdef_by_race2[RC2_MAX];
  541. int32 dropaddrace[RC_MAX];
  542. int32 dropaddclass[CLASS_MAX];
  543. int32 magic_subdefele[ELE_MAX];
  544. int32 ignore_res_by_race[RC_MAX];
  545. int32 ignore_mres_by_race[RC_MAX];
  546. } indexed_bonus;
  547. // zeroed arrays end here.
  548. std::vector<s_autospell> autospell, autospell2, autospell3;
  549. std::vector<s_addeffect> addeff, addeff_atked;
  550. std::vector<s_addeffectonskill> addeff_onskill;
  551. std::vector<s_item_bonus> skillatk, skillusesprate, skillusesp, skillheal, skillheal2, skillblown, skillcastrate, skillfixcastrate, subskill, skillcooldown, skillfixcast,
  552. skillvarcast, skilldelay, itemhealrate, add_def, add_mdef, add_mdmg, reseff, itemgrouphealrate, itemsphealrate, itemgroupsphealrate;
  553. std::vector<s_add_drop> add_drop;
  554. std::vector<s_addele2> subele2;
  555. std::vector<s_vanish_bonus> sp_vanish, hp_vanish;
  556. std::vector<s_addrace2> subrace3;
  557. std::vector<std::shared_ptr<s_autobonus>> autobonus, autobonus2, autobonus3; //Auto script on attack, when attacked, on skill usage
  558. // zeroed structures start here
  559. struct s_regen {
  560. short value;
  561. int32 rate;
  562. t_tick tick;
  563. } hp_loss, sp_loss, hp_regen, sp_regen, percent_hp_regen, percent_sp_regen;
  564. struct {
  565. short value;
  566. int32 rate, tick;
  567. } def_set_race[RC_MAX], mdef_set_race[RC_MAX], norecover_state_race[RC_MAX];
  568. struct s_bonus_vanish_gain {
  569. short rate, ///< Success rate 0 - 1000 (100%)
  570. per; ///< % HP/SP vanished/gained
  571. } hp_vanish_race[RC_MAX], sp_vanish_race[RC_MAX];
  572. // zeroed structures end here
  573. // zeroed vars start here.
  574. struct s_bonus {
  575. int32 hp, sp, ap;
  576. int32 atk_rate;
  577. int32 arrow_atk,arrow_ele,arrow_cri,arrow_hit;
  578. int32 nsshealhp,nsshealsp;
  579. int32 critical_def,double_rate;
  580. int32 short_attack_atk_rate; // Short range atk rate, not weapon based.
  581. int32 long_attack_atk_rate; //Long range atk rate, not weapon based. [Skotlex]
  582. int32 near_attack_def_rate,long_attack_def_rate,magic_def_rate,misc_def_rate;
  583. int32 ignore_mdef_ele;
  584. int32 ignore_mdef_race;
  585. int32 ignore_mdef_class;
  586. int32 perfect_hit;
  587. int32 perfect_hit_add;
  588. int32 get_zeny_rate;
  589. int32 get_zeny_num; //Added Get Zeny Rate [Skotlex]
  590. int32 double_add_rate;
  591. int32 short_weapon_damage_return,long_weapon_damage_return,reduce_damage_return;
  592. int32 magic_damage_return; // AppleGirl Was Here
  593. int32 break_weapon_rate,break_armor_rate;
  594. int32 crit_atk_rate;
  595. int32 crit_def_rate;
  596. int32 classchange; // [Valaris]
  597. int32 speed_rate, speed_add_rate, aspd_add;
  598. int32 itemhealrate2; // [Epoque] Increase heal rate of all healing items.
  599. int32 itemsphealrate2;
  600. int32 shieldmdef;//royal guard's
  601. uint32 setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int32 ranges. [Skotlex]
  602. short splash_range, splash_add_range;
  603. short add_steal_rate;
  604. int32 add_heal_rate, add_heal2_rate;
  605. int32 sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value, long_sp_gain_value, long_hp_gain_value;
  606. unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
  607. unsigned short unbreakable_equip; //100% break resistance on certain equipment
  608. unsigned short unstripable_equip;
  609. int32 fixcastrate, varcastrate, delayrate; // n/100
  610. int32 add_fixcast, add_varcast; // in milliseconds
  611. int32 ematk; // matk bonus from equipment
  612. int32 eatk; // atk bonus from equipment
  613. uint8 absorb_dmg_maxhp; // [Cydh]
  614. uint8 absorb_dmg_maxhp2;
  615. short critical_rangeatk;
  616. short weapon_atk_rate, weapon_matk_rate;
  617. } bonus;
  618. // zeroed vars end here.
  619. int32 castrate,hprate,sprate,aprate,dsprate;
  620. int32 hprecov_rate,sprecov_rate;
  621. int32 matk_rate;
  622. int32 critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
  623. int32 patk_rate,smatk_rate,res_rate,mres_rate,hplus_rate,crate_rate;
  624. t_itemid itemid;
  625. short itemindex; //Used item's index in sd->inventory [Skotlex]
  626. int8 spiritball, spiritball_old;
  627. int32 spirit_timer[MAX_SPIRITBALL];
  628. short spiritcharm; //No. of spirit
  629. int32 spiritcharm_type; //Spirit type
  630. int32 spiritcharm_timer[MAX_SPIRITCHARM];
  631. int8 soulball, soulball_old;
  632. int8 servantball, servantball_old;
  633. int8 abyssball, abyssball_old;
  634. unsigned char potion_success_counter; //Potion successes in row counter
  635. unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
  636. short mission_mobid; //Stores the target mob_id for TK_MISSION
  637. int32 die_counter; //Total number of times you've died
  638. int32 devotion[MAX_DEVOTION]; //Stores the account IDs of chars devoted to.
  639. int32 stellar_mark[MAX_STELLAR_MARKS]; // Stores the account ID's of character's with a stellar mark.
  640. int32 united_soul[MAX_UNITED_SOULS]; // Stores the account ID's of character's who's soul is united.
  641. int32 servant_sign[MAX_SERVANT_SIGN]; // Stores the account ID's of character's with a servant sign.
  642. struct{
  643. uint32 id;
  644. uint32 lv;
  645. }trade_partner;
  646. struct s_deal {
  647. struct s_item {
  648. short index, amount;
  649. } item[10];
  650. int32 zeny, weight;
  651. } deal;
  652. bool party_creating; // whether the char is requesting party creation
  653. bool party_joining; // whether the char is accepting party invitation
  654. int32 party_invite, party_invite_account; // for handling party invitation (holds party id and account id)
  655. int32 adopt_invite; // Adoption
  656. std::shared_ptr<MapGuild> guild; // [Ind] speed everything up
  657. int32 guild_invite,guild_invite_account;
  658. int32 guild_emblem_id,guild_alliance,guild_alliance_account;
  659. short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo]
  660. int32 guildspy; // [Syrus22]
  661. int32 partyspy; // [Syrus22]
  662. int32 clanspy;
  663. struct clan *clan;
  664. int32 vended_id;
  665. int32 vender_id;
  666. int32 vend_num;
  667. uint16 vend_skill_lv;
  668. char message[MESSAGE_SIZE];
  669. struct s_vending vending[MAX_VENDING];
  670. uint32 buyer_id; // uid of open buying store
  671. struct s_buyingstore buyingstore;
  672. struct s_search_store_info searchstore;
  673. struct pet_data *pd;
  674. struct homun_data *hd; // [blackhole89]
  675. s_mercenary_data *md;
  676. s_elemental_data *ed;
  677. struct s_hate_mob {
  678. int32 m; //-1 - none, other: map index corresponding to map name.
  679. unsigned short index; //map index
  680. } feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
  681. short hate_mob[3];
  682. int32 pvp_timer;
  683. short pvp_point;
  684. unsigned short pvp_rank, pvp_lastusers;
  685. unsigned short pvp_won, pvp_lost;
  686. char eventqueue[MAX_EVENTQUEUE][EVENT_NAME_LENGTH];
  687. int32 eventtimer[MAX_EVENTTIMER];
  688. unsigned short eventcount; // [celest]
  689. uint16 change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value]
  690. uint16 change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value]
  691. uint16 change_level_4th; // job level when changing from 3rd to 4th class [jobchange_level_4rd in global_reg_value]
  692. char fakename[NAME_LENGTH]; // fake names [Valaris]
  693. size_t duel_group; // duel vars [LuzZza]
  694. size_t duel_invite;
  695. int32 killerrid, killedrid, killedgid;
  696. int32 cashPoints, kafraPoints;
  697. int32 rental_timer;
  698. // Auction System [Zephyrus]
  699. struct s_auction{
  700. int32 index, amount;
  701. } auction;
  702. // Mail System [Zephyrus]
  703. struct s_mail {
  704. struct {
  705. t_itemid nameid;
  706. int32 index, amount;
  707. } item[MAIL_MAX_ITEM];
  708. int32 zeny;
  709. struct mail_data inbox;
  710. bool changed; // if true, should sync with charserver on next mailbox request
  711. uint32 pending_weight;
  712. uint32 pending_zeny;
  713. uint16 pending_slots;
  714. uint32 dest_id;
  715. } mail;
  716. //Quest log system
  717. int32 num_quests; ///< Number of entries in quest_log
  718. int32 avail_quests; ///< Number of Q_ACTIVE and Q_INACTIVE entries in quest log (index of the first Q_COMPLETE entry)
  719. struct quest *quest_log; ///< Quest log entries (note: Q_COMPLETE quests follow the first <avail_quests>th enties
  720. bool save_quest; ///< Whether the quest_log entries were modified and are waitin to be saved
  721. // Achievement log system
  722. struct s_achievement_data {
  723. int32 total_score; ///< Total achievement points
  724. int32 level; ///< Achievement level
  725. bool save; ///< Flag to know if achievements need to be saved
  726. uint16 count; ///< Total achievements in log
  727. uint16 incompleteCount; ///< Total incomplete achievements in log
  728. struct achievement *achievements; ///< Achievement log entries
  729. } achievement_data;
  730. // Title system
  731. std::vector<int> titles;
  732. std::vector<int> cloaked_npc;
  733. /* ShowEvent Data Cache flags from map */
  734. std::vector<s_qi_display> qi_display;
  735. // temporary debug [flaviojs]
  736. const char* debug_file;
  737. int32 debug_line;
  738. const char* debug_func;
  739. // Battlegrounds queue system [MasterOfMuppets]
  740. int32 bg_id, bg_queue_id;
  741. int32 tid_queue_active; ///< Timer ID associated with players joining an active BG
  742. #ifdef SECURE_NPCTIMEOUT
  743. /**
  744. * ID of the timer
  745. * @info
  746. * - value is -1 (INVALID_TIMER constant) when not being used
  747. * - timer is cancelled upon closure of the current npc's instance
  748. **/
  749. int32 npc_idle_timer;
  750. /**
  751. * Tick on the last recorded NPC iteration (next/menu/whatever)
  752. * @info
  753. * - It is updated on every NPC iteration as mentioned above
  754. **/
  755. t_tick npc_idle_tick;
  756. /* */
  757. enum npc_timeout_type npc_idle_type;
  758. #endif
  759. std::vector<std::shared_ptr<s_combos>> combos;
  760. /**
  761. * Guarantees your friend request is legit (for bugreport:4629)
  762. **/
  763. int32 friend_req;
  764. int32 shadowform_id;
  765. /* Channel System [Ind] */
  766. struct Channel **channels;
  767. unsigned char channel_count;
  768. struct Channel *gcbind;
  769. bool stealth;
  770. unsigned char fontcolor;
  771. t_tick *channel_tick;
  772. /* [Ind] */
  773. struct sc_display_entry **sc_display;
  774. unsigned char sc_display_count;
  775. unsigned char delayed_damage; //[Ind]
  776. /**
  777. * Account/Char variables & array control of those variables
  778. **/
  779. struct reg_db regs;
  780. unsigned char vars_received; // char loading is only complete when you get it all.
  781. bool vars_ok;
  782. bool vars_dirty;
  783. uint16 dmglog[DAMAGELOG_SIZE_PC]; ///target ids
  784. int32 c_marker[MAX_SKILL_CRIMSON_MARKER]; /// Store target that marked by Crimson Marker [Cydh]
  785. bool flicker; /// Check RL_FLICKER usage status [Cydh]
  786. #ifdef VIP_ENABLE
  787. struct vip_info vip;
  788. #endif
  789. /// Bonus Script [Cydh]
  790. struct s_bonus_script_list {
  791. struct linkdb_node *head; ///< Bonus script head node. data: struct s_bonus_script_entry *entry, key: (intptr_t)entry
  792. uint16 count;
  793. } bonus_script;
  794. /* Expiration Timer ID */
  795. int32 expiration_tid;
  796. time_t expiration_time;
  797. short last_addeditem_index; /// Index of latest item added
  798. int32 autotrade_tid;
  799. int32 respawn_tid;
  800. int32 bank_vault; ///< Bank Vault
  801. #ifdef PACKET_OBFUSCATION
  802. uint32 cryptKey; ///< Packet obfuscation key to be used for the next received packet
  803. #endif
  804. struct {
  805. int32 bronze, silver, gold; ///< Roulette Coin
  806. } roulette_point;
  807. struct {
  808. short stage;
  809. int8 prizeIdx;
  810. t_itemid bonusItemID;
  811. short prizeStage;
  812. bool claimPrize;
  813. t_tick tick;
  814. } roulette;
  815. int32 instance_id;
  816. e_instance_mode instance_mode; ///< Mode of instance player last leaves from (used for instance destruction button)
  817. short setlook_head_top, setlook_head_mid, setlook_head_bottom, setlook_robe; ///< Stores 'setlook' script command values.
  818. #if PACKETVER_MAIN_NUM >= 20150507 || PACKETVER_RE_NUM >= 20150429 || defined(PACKETVER_ZERO)
  819. std::vector<int16> hatEffects;
  820. #endif
  821. struct{
  822. int32 tid;
  823. uint16 skill_id;
  824. uint16 level;
  825. int32 target;
  826. } skill_keep_using;
  827. struct {
  828. std::shared_ptr<s_captcha_data> cd;
  829. uint16 upload_size;
  830. } captcha_upload;
  831. s_macro_detect macro_detect;
  832. std::vector<uint32> party_booking_requests;
  833. };
  834. extern struct eri *pc_sc_display_ers; /// Player's SC display table
  835. /**
  836. * ERS for the bulk of pc vars
  837. **/
  838. extern struct eri *num_reg_ers;
  839. extern struct eri *str_reg_ers;
  840. /* Global Expiration Timer ID */
  841. extern int32 pc_expiration_tid;
  842. enum weapon_type : uint8 {
  843. W_FIST, //Bare hands
  844. W_DAGGER, //1
  845. W_1HSWORD, //2
  846. W_2HSWORD, //3
  847. W_1HSPEAR, //4
  848. W_2HSPEAR, //5
  849. W_1HAXE, //6
  850. W_2HAXE, //7
  851. W_MACE, //8
  852. W_2HMACE, //9 (unused)
  853. W_STAFF, //10
  854. W_BOW, //11
  855. W_KNUCKLE, //12
  856. W_MUSICAL, //13
  857. W_WHIP, //14
  858. W_BOOK, //15
  859. W_KATAR, //16
  860. W_REVOLVER, //17
  861. W_RIFLE, //18
  862. W_GATLING, //19
  863. W_SHOTGUN, //20
  864. W_GRENADE, //21
  865. W_HUUMA, //22
  866. W_2HSTAFF, //23
  867. MAX_WEAPON_TYPE,
  868. // dual-wield constants
  869. W_DOUBLE_DD, // 2 daggers
  870. W_DOUBLE_SS, // 2 swords
  871. W_DOUBLE_AA, // 2 axes
  872. W_DOUBLE_DS, // dagger + sword
  873. W_DOUBLE_DA, // dagger + axe
  874. W_DOUBLE_SA, // sword + axe
  875. MAX_WEAPON_TYPE_ALL,
  876. W_SHIELD = MAX_WEAPON_TYPE,
  877. };
  878. #define WEAPON_TYPE_ALL ((1<<MAX_WEAPON_TYPE)-1)
  879. enum e_ammo_type : uint8 {
  880. AMMO_NONE = 0,
  881. AMMO_ARROW,
  882. AMMO_DAGGER,
  883. AMMO_BULLET,
  884. AMMO_SHELL,
  885. AMMO_GRENADE,
  886. AMMO_SHURIKEN,
  887. AMMO_KUNAI,
  888. AMMO_CANNONBALL,
  889. AMMO_THROWWEAPON,
  890. MAX_AMMO_TYPE
  891. };
  892. enum e_card_type : uint8 {
  893. CARD_NORMAL = 0,
  894. CARD_ENCHANT,
  895. MAX_CARD_TYPE
  896. };
  897. enum idletime_option {
  898. IDLE_WALK = 0x0001,
  899. IDLE_USESKILLTOID = 0x0002,
  900. IDLE_USESKILLTOPOS = 0x0004,
  901. IDLE_USEITEM = 0x0008,
  902. IDLE_ATTACK = 0x0010,
  903. IDLE_CHAT = 0x0020,
  904. IDLE_SIT = 0x0040,
  905. IDLE_EMOTION = 0x0080,
  906. IDLE_DROPITEM = 0x0100,
  907. IDLE_ATCOMMAND = 0x0200,
  908. IDLE_NPC_CLOSE = 0x0400,
  909. IDLE_NPC_INPUT = 0x0800,
  910. IDLE_NPC_MENU = 0x1000,
  911. IDLE_NPC_NEXT = 0x2000,
  912. IDLE_NPC_PROGRESS = 0x4000,
  913. };
  914. enum adopt_responses {
  915. ADOPT_ALLOWED = 0,
  916. ADOPT_ALREADY_ADOPTED,
  917. ADOPT_MARRIED_AND_PARTY,
  918. ADOPT_EQUIP_RINGS,
  919. ADOPT_NOT_NOVICE,
  920. ADOPT_CHARACTER_NOT_FOUND,
  921. ADOPT_MORE_CHILDREN,
  922. ADOPT_LEVEL_70,
  923. ADOPT_MARRIED,
  924. };
  925. enum item_check {
  926. ITMCHK_NONE = 0x0,
  927. ITMCHK_INVENTORY = 0x1,
  928. ITMCHK_CART = 0x2,
  929. ITMCHK_STORAGE = 0x4,
  930. ITMCHK_ALL = ITMCHK_INVENTORY|ITMCHK_CART|ITMCHK_STORAGE,
  931. };
  932. enum e_penalty_type : uint16{
  933. PENALTY_NONE,
  934. PENALTY_EXP,
  935. PENALTY_DROP,
  936. PENALTY_MVP_EXP,
  937. PENALTY_MVP_DROP,
  938. PENALTY_MAX
  939. };
  940. struct s_penalty{
  941. e_penalty_type type;
  942. uint16 rate[MAX_LEVEL * 2 - 1];
  943. };
  944. class PenaltyDatabase : public TypesafeYamlDatabase<uint16, s_penalty> {
  945. public:
  946. PenaltyDatabase() : TypesafeYamlDatabase( "PENALTY_DB", 1 ){
  947. }
  948. const std::string getDefaultLocation() override;
  949. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  950. void loadingFinished() override;
  951. };
  952. struct s_job_info {
  953. std::vector<uint32> base_hp, base_sp, base_ap; //Storage for the first calculation with hp/sp/ap factor and multiplicator
  954. uint32 hp_factor, hp_increase, sp_increase, max_weight_base;
  955. std::vector<std::array<uint16,PARAM_MAX>> job_bonus;
  956. std::vector<int16> aspd_base;
  957. t_exp base_exp[MAX_LEVEL], job_exp[MAX_LEVEL];
  958. uint16 max_base_level, max_job_level;
  959. uint16 max_param[PARAM_MAX];
  960. struct s_job_noenter_map {
  961. uint32 zone;
  962. uint8 group_lv;
  963. } noenter_map;
  964. };
  965. class JobDatabase : public TypesafeCachedYamlDatabase<uint16, s_job_info> {
  966. public:
  967. JobDatabase() : TypesafeCachedYamlDatabase("JOB_STATS", 2) {
  968. }
  969. const std::string getDefaultLocation() override;
  970. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  971. void loadingFinished() override;
  972. // Additional
  973. uint32 get_maxBaseLv(uint16 job_id);
  974. uint32 get_maxJobLv(uint16 job_id);
  975. t_exp get_baseExp(uint16 job_id, uint32 level);
  976. t_exp get_jobExp(uint16 job_id, uint32 level);
  977. int32 get_maxWeight(uint16 job_id);
  978. };
  979. extern JobDatabase job_db;
  980. #define EQP_WEAPON EQP_HAND_R
  981. #define EQP_SHIELD EQP_HAND_L
  982. #define EQP_ARMS (EQP_HAND_R|EQP_HAND_L)
  983. #define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
  984. #define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
  985. #define EQP_COSTUME (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW|EQP_COSTUME_GARMENT)
  986. #define EQP_COSTUME_HELM (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW)
  987. #define EQP_SHADOW_GEAR (EQP_SHADOW_ARMOR|EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD|EQP_SHADOW_SHOES|EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  988. #define EQP_SHADOW_ACC (EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  989. #define EQP_SHADOW_ARMS (EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD)
  990. /// Equip positions that use a visible sprite
  991. #if PACKETVER < 20110111
  992. #define EQP_VISIBLE EQP_HELM
  993. #else
  994. #define EQP_VISIBLE (EQP_HELM|EQP_GARMENT|EQP_COSTUME)
  995. #endif
  996. #define pc_setdead(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 1 )
  997. #define pc_setsit(sd) { pc_stop_walking((sd), 1|4); pc_stop_attack((sd)); (sd)->state.dead_sit = (sd)->vd.dead_sit = 2; }
  998. #define pc_isdead(sd) ( (sd)->state.dead_sit == 1 )
  999. #define pc_issit(sd) ( (sd)->vd.dead_sit == 2 )
  1000. #define pc_isidle_party(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
  1001. #define pc_isidle_hom(sd) ( (sd)->hd && ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime_hom) >= battle_config.hom_idle_no_share ) )
  1002. #define pc_isidle_mer(sd) ( (sd)->md && ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime_mer) >= battle_config.mer_idle_no_share ) )
  1003. #define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading )
  1004. static bool pc_cant_act2( map_session_data* sd ){
  1005. return sd->state.vending || sd->state.buyingstore || (sd->sc.opt1 && sd->sc.opt1 != OPT1_BURNING)
  1006. || sd->state.trading || sd->state.storage_flag || sd->state.prevend || sd->state.refineui_open
  1007. || sd->state.stylist_open || sd->state.inventory_expansion_confirmation || sd->npc_shopid
  1008. || sd->state.barter_open || sd->state.barter_extended_open
  1009. || sd->state.laphine_synthesis || sd->state.laphine_upgrade
  1010. || sd->state.roulette_open || sd->state.enchantgrade_open
  1011. || sd->state.item_reform || sd->state.item_enchant_index;
  1012. }
  1013. // equals pc_cant_act2 and additionally checks for chat rooms and npcs
  1014. static bool pc_cant_act( map_session_data* sd ){
  1015. return sd->npc_id || sd->chatID || pc_cant_act2( sd );
  1016. }
  1017. #define pc_setdir(sd,b,h) ( (sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
  1018. #define pc_setchatid(sd,n) ( (sd)->chatID = n )
  1019. #define pc_ishiding(sd) ( (sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) )
  1020. #define pc_iscloaking(sd) ( !((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK) )
  1021. #define pc_ischasewalk(sd) ( (sd)->sc.option&OPTION_CHASEWALK )
  1022. #ifdef VIP_ENABLE
  1023. #define pc_isvip(sd) ( (sd)->vip.enabled ? true : false )
  1024. #else
  1025. #define pc_isvip(sd) ( false )
  1026. #endif
  1027. #ifdef NEW_CARTS
  1028. #define pc_iscarton(sd) ( (sd)->sc.getSCE(SC_PUSH_CART) )
  1029. #else
  1030. #define pc_iscarton(sd) ( (sd)->sc.option&OPTION_CART )
  1031. #endif
  1032. #define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
  1033. #define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
  1034. #define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
  1035. #define pc_is50overweight(sd) ( (sd)->weight * 100 >= (sd)->max_weight * battle_config.natural_heal_weight_rate )
  1036. #define pc_is70overweight(sd) ( (sd)->weight * 100 >= (sd)->max_weight * battle_config.natural_heal_weight_rate_renewal )
  1037. #define pc_is90overweight(sd) ( (sd)->weight * 10 >= (sd)->max_weight * 9 )
  1038. static inline bool pc_hasprogress(map_session_data *sd, enum e_wip_block progress) {
  1039. return sd == nullptr || (sd->state.workinprogress&progress) == progress;
  1040. }
  1041. uint16 pc_maxparameter(map_session_data *sd, e_params param);
  1042. short pc_maxaspd(map_session_data *sd);
  1043. /**
  1044. * Ranger
  1045. **/
  1046. #define pc_iswug(sd) ( (sd)->sc.option&OPTION_WUG )
  1047. #define pc_isridingwug(sd) ( (sd)->sc.option&OPTION_WUGRIDER )
  1048. // Mechanic Magic Gear
  1049. enum e_mado_type : uint16 {
  1050. MADO_ROBOT = 0x00,
  1051. MADO_UNUSED,
  1052. MADO_SUIT,
  1053. MADO_MAX
  1054. };
  1055. #define pc_ismadogear(sd) ( (sd)->sc.option&OPTION_MADOGEAR )
  1056. // Rune Knight Dragon
  1057. #define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON )
  1058. #define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type)
  1059. #define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl)
  1060. //Weapon check considering dual wielding.
  1061. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
  1062. 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon)))
  1063. //Checks if the given class value corresponds to a player class. [Skotlex]
  1064. //JOB_NOVICE isn't checked for class_ is supposed to be unsigned
  1065. #define pcdb_checkid_sub(class_) ( \
  1066. ( (class_) < JOB_MAX_BASIC ) || \
  1067. ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) || \
  1068. ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) || \
  1069. ( (class_) >= JOB_BABY_RUNE_KNIGHT && (class_) <= JOB_BABY_MECHANIC2 ) || \
  1070. ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) || \
  1071. ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) || \
  1072. (class_) == JOB_REBELLION || (class_) == JOB_SUMMONER || \
  1073. (class_) == JOB_BABY_SUMMONER || \
  1074. ( (class_) >= JOB_BABY_NINJA && (class_) <= JOB_BABY_REBELLION ) || \
  1075. ( (class_) >= JOB_BABY_STAR_GLADIATOR2 && (class_) <= JOB_BABY_STAR_EMPEROR2 ) || \
  1076. ( (class_) >= JOB_DRAGON_KNIGHT && (class_) <= JOB_TROUVERE ) || \
  1077. ( (class_) >= JOB_WINDHAWK2 && (class_) <= JOB_IMPERIAL_GUARD2 ) || \
  1078. ( (class_) >= JOB_SKY_EMPEROR && (class_) <= JOB_SPIRIT_HANDLER ) || \
  1079. (class_) == JOB_SKY_EMPEROR2 \
  1080. )
  1081. #define pcdb_checkid(class_) pcdb_checkid_sub((uint32)class_)
  1082. // clientside display macros (values to the left/right of the "+")
  1083. #ifdef RENEWAL
  1084. #define pc_leftside_atk(sd) ((sd)->battle_status.batk)
  1085. #define pc_rightside_atk(sd) ((sd)->battle_status.watk + (sd)->battle_status.watk2 + (sd)->battle_status.eatk)
  1086. #define pc_leftside_def(sd) ((sd)->battle_status.def2)
  1087. #define pc_rightside_def(sd) ((sd)->battle_status.def)
  1088. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2)
  1089. #define pc_rightside_mdef(sd) ((sd)->battle_status.mdef)
  1090. #define pc_leftside_matk(sd) (status_base_matk_min(&(sd)->bl, status_get_status_data((sd)->bl), (sd)->status.base_level))
  1091. #define pc_rightside_matk(sd) \
  1092. (\
  1093. (sd)->battle_status.rhw.matk + \
  1094. (sd)->battle_status.lhw.matk + \
  1095. (sd)->bonus.ematk + \
  1096. status_calc_consumablematk(&(sd)->sc, 0) + \
  1097. status_calc_pseudobuff_matk((sd), &(sd)->sc, 0) \
  1098. )
  1099. #else
  1100. #define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk)
  1101. #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2)
  1102. #define pc_leftside_def(sd) ((sd)->battle_status.def)
  1103. #define pc_rightside_def(sd) ((sd)->battle_status.def2)
  1104. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef)
  1105. #define pc_rightside_mdef(sd) ( (sd)->battle_status.mdef2 - ((sd)->battle_status.vit / 2) )
  1106. #define pc_leftside_matk(sd) \
  1107. (\
  1108. ((sd)->sc.getSCE(SC_MAGICPOWER) && (sd)->sc.getSCE(SC_MAGICPOWER)->val4) \
  1109. ?((sd)->battle_status.matk_min * 100 + 50) / ((sd)->sc.getSCE(SC_MAGICPOWER)->val3+100) \
  1110. :(sd)->battle_status.matk_min \
  1111. )
  1112. #define pc_rightside_matk(sd) \
  1113. (\
  1114. ((sd)->sc.getSCE(SC_MAGICPOWER) && (sd)->sc.getSCE(SC_MAGICPOWER)->val4) \
  1115. ?((sd)->battle_status.matk_max * 100 + 50) / ((sd)->sc.getSCE(SC_MAGICPOWER)->val3+100) \
  1116. :(sd)->battle_status.matk_max \
  1117. )
  1118. #endif
  1119. struct s_attendance_reward {
  1120. t_itemid item_id;
  1121. uint16 amount;
  1122. };
  1123. struct s_attendance_period {
  1124. uint32 start;
  1125. uint32 end;
  1126. std::map<uint32, std::shared_ptr<struct s_attendance_reward>> rewards;
  1127. };
  1128. class AttendanceDatabase : public TypesafeYamlDatabase<uint32, s_attendance_period> {
  1129. public:
  1130. AttendanceDatabase() : TypesafeYamlDatabase("ATTENDANCE_DB", 1) {
  1131. }
  1132. const std::string getDefaultLocation() override;
  1133. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  1134. };
  1135. extern AttendanceDatabase attendance_db;
  1136. struct s_reputation{
  1137. int64 id;
  1138. std::string name;
  1139. std::string variable;
  1140. int64 minimum;
  1141. int64 maximum;
  1142. #ifdef MAP_GENERATOR
  1143. enum e_visibility {ALWAYS, NEVER, EXIST} visibility;
  1144. #endif
  1145. };
  1146. class ReputationDatabase : public TypesafeYamlDatabase<int64, s_reputation>{
  1147. public:
  1148. ReputationDatabase() : TypesafeYamlDatabase( "REPUTATION_DB", 1 ){
  1149. #ifdef MAP_GENERATOR
  1150. setGenerator(true);
  1151. #endif
  1152. }
  1153. const std::string getDefaultLocation() override;
  1154. uint64 parseBodyNode( const ryml::NodeRef& node ) override;
  1155. };
  1156. extern ReputationDatabase reputation_db;
  1157. struct s_reputationgroup {
  1158. int64 id;
  1159. std::string script_name;
  1160. std::string name;
  1161. std::vector<int64> reputations;
  1162. };
  1163. class ReputationGroupDatabase : public TypesafeYamlDatabase<int64, s_reputationgroup> {
  1164. public:
  1165. ReputationGroupDatabase() : TypesafeYamlDatabase("REPUTATION_GROUP_DB", 1) {
  1166. #ifdef MAP_GENERATOR
  1167. setGenerator(true);
  1168. #endif
  1169. }
  1170. const std::string getDefaultLocation() override;
  1171. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  1172. };
  1173. extern ReputationGroupDatabase reputationgroup_db;
  1174. struct s_statpoint_entry{
  1175. uint16 level;
  1176. uint32 statpoints;
  1177. uint32 traitpoints;
  1178. };
  1179. class PlayerStatPointDatabase : public TypesafeCachedYamlDatabase<uint16, s_statpoint_entry>{
  1180. public:
  1181. PlayerStatPointDatabase() : TypesafeCachedYamlDatabase("STATPOINT_DB", 2, 1) {
  1182. }
  1183. const std::string getDefaultLocation() override;
  1184. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  1185. void loadingFinished() override;
  1186. // Additional
  1187. uint32 pc_gets_status_point(uint16 level);
  1188. uint32 get_table_point(uint16 level);
  1189. uint32 pc_gets_trait_point(uint16 level);
  1190. uint32 get_trait_table_point(uint16 level);
  1191. };
  1192. extern PlayerStatPointDatabase statpoint_db;
  1193. /// Enum of Summoner Power of
  1194. enum e_summoner_power_type {
  1195. SUMMONER_POWER_LAND = 0,
  1196. SUMMONER_POWER_LIFE,
  1197. SUMMONER_POWER_SEA,
  1198. };
  1199. void pc_set_reg_load(bool val);
  1200. int32 pc_class2idx(int32 class_);
  1201. int32 pc_get_group_level(map_session_data *sd);
  1202. int32 pc_get_group_id(map_session_data *sd);
  1203. bool pc_can_sell_item(map_session_data* sd, struct item * item, enum npc_subtype shoptype);
  1204. bool pc_can_give_items(map_session_data *sd);
  1205. bool pc_can_give_bounded_items(map_session_data *sd);
  1206. bool pc_can_trade_item(map_session_data *sd, int32 index);
  1207. bool pc_can_use_command(map_session_data *sd, const char *command, AtCommandType type);
  1208. bool pc_has_permission( map_session_data* sd, e_pc_permission permission );
  1209. bool pc_should_log_commands(map_session_data *sd);
  1210. void pc_setrestartvalue(map_session_data *sd, char type);
  1211. void pc_makesavestatus(map_session_data *sd);
  1212. void pc_respawn(map_session_data* sd, clr_type clrtype);
  1213. void pc_setnewpc(map_session_data *sd, uint32 account_id, uint32 char_id, int32 login_id1, t_tick client_tick, int32 sex, int32 fd);
  1214. bool pc_authok(map_session_data *sd, uint32 login_id2, time_t expiration_time, int32 group_id, struct mmo_charstatus *st, bool changing_mapservers);
  1215. void pc_authfail(map_session_data *sd);
  1216. void pc_reg_received(map_session_data *sd);
  1217. void pc_close_npc(map_session_data *sd,int32 flag);
  1218. TIMER_FUNC(pc_close_npc_timer);
  1219. void pc_setequipindex(map_session_data *sd);
  1220. uint8 pc_isequip(map_session_data *sd,int32 n);
  1221. int32 pc_equippoint(map_session_data *sd,int32 n);
  1222. int32 pc_equippoint_sub(map_session_data *sd, struct item_data* id);
  1223. void pc_setinventorydata(map_session_data *sd);
  1224. int32 pc_get_skillcooldown(map_session_data *sd, uint16 skill_id, uint16 skill_lv);
  1225. uint8 pc_checkskill(map_session_data *sd,uint16 skill_id);
  1226. e_skill_flag pc_checkskill_flag(map_session_data &sd, uint16 skill_id);
  1227. uint8 pc_checkskill_summoner(map_session_data *sd, e_summoner_power_type type);
  1228. uint8 pc_checkskill_imperial_guard(map_session_data *sd, short flag);
  1229. short pc_checkequip(map_session_data *sd,int32 pos,bool checkall=false);
  1230. bool pc_checkequip2(map_session_data *sd, t_itemid nameid, int32 min, int32 max);
  1231. void pc_scdata_received(map_session_data *sd);
  1232. void pc_check_expiration(map_session_data *sd);
  1233. TIMER_FUNC(pc_expiration_timer);
  1234. TIMER_FUNC(pc_global_expiration_timer);
  1235. void pc_expire_check(map_session_data *sd);
  1236. void pc_calc_skilltree(map_session_data *sd);
  1237. uint64 pc_calc_skilltree_normalize_job(map_session_data *sd);
  1238. void pc_clean_skilltree(map_session_data *sd);
  1239. #define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
  1240. #define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
  1241. enum e_setpos{
  1242. SETPOS_OK = 0,
  1243. SETPOS_MAPINDEX = 1,
  1244. SETPOS_NO_MAPSERVER = 2,
  1245. SETPOS_AUTOTRADE = 3
  1246. };
  1247. enum e_setpos pc_setpos(map_session_data* sd, unsigned short mapindex, int32 x, int32 y, clr_type clrtype);
  1248. enum e_setpos pc_setpos_savepoint( map_session_data& sd, clr_type clrtype = CLR_TELEPORT );
  1249. void pc_setsavepoint(map_session_data *sd, short mapindex,int32 x,int32 y);
  1250. char pc_randomwarp(map_session_data *sd,clr_type type,bool ignore_mapflag = false);
  1251. bool pc_memo(map_session_data* sd, int32 pos);
  1252. char pc_checkadditem(map_session_data *sd, t_itemid nameid, int32 amount);
  1253. uint8 pc_inventoryblank(map_session_data *sd);
  1254. short pc_search_inventory(map_session_data *sd, t_itemid nameid);
  1255. char pc_payzeny(map_session_data *sd, int32 zeny, enum e_log_pick_type type, uint32 log_charid = 0);
  1256. enum e_additem_result pc_additem(map_session_data *sd, struct item *item, int32 amount, e_log_pick_type log_type);
  1257. char pc_getzeny(map_session_data *sd, int32 zeny, enum e_log_pick_type type, uint32 log_charid = 0);
  1258. char pc_delitem(map_session_data *sd, int32 n, int32 amount, int32 type, short reason, e_log_pick_type log_type);
  1259. uint64 pc_generate_unique_id(map_session_data *sd);
  1260. //Bound items
  1261. int32 pc_bound_chk(TBL_PC *sd,enum bound_type type,int32 *idxlist);
  1262. // Special Shop System
  1263. int32 pc_paycash( map_session_data *sd, int32 price, int32 points, e_log_pick_type type );
  1264. int32 pc_getcash( map_session_data *sd, int32 cash, int32 points, e_log_pick_type type );
  1265. enum e_additem_result pc_cart_additem(map_session_data *sd,struct item *item_data,int32 amount,e_log_pick_type log_type);
  1266. void pc_cart_delitem(map_session_data *sd,int32 n,int32 amount,int32 type,e_log_pick_type log_type);
  1267. void pc_putitemtocart(map_session_data *sd,int32 idx,int32 amount);
  1268. bool pc_getitemfromcart(map_session_data *sd,int32 idx,int32 amount);
  1269. int32 pc_cartitem_amount(map_session_data *sd,int32 idx,int32 amount);
  1270. bool pc_takeitem(map_session_data *sd,struct flooritem_data *fitem);
  1271. bool pc_dropitem(map_session_data *sd,int32 n,int32 amount);
  1272. bool pc_isequipped(map_session_data *sd, t_itemid nameid);
  1273. enum adopt_responses pc_try_adopt(map_session_data *p1_sd, map_session_data *p2_sd, map_session_data *b_sd);
  1274. bool pc_adoption(map_session_data *p1_sd, map_session_data *p2_sd, map_session_data *b_sd);
  1275. void pc_updateweightstatus(map_session_data *sd);
  1276. bool pc_addautobonus(std::vector<std::shared_ptr<s_autobonus>> &bonus, const char *script, short rate, uint32 dur, uint16 atk_type, const char *o_script, uint32 pos, bool onskill);
  1277. void pc_exeautobonus(map_session_data &sd, std::vector<std::shared_ptr<s_autobonus>> *bonus, std::shared_ptr<s_autobonus> autobonus);
  1278. TIMER_FUNC(pc_endautobonus);
  1279. void pc_delautobonus(map_session_data &sd, std::vector<std::shared_ptr<s_autobonus>> &bonus, bool restore);
  1280. void pc_bonus(map_session_data *sd, int32 type, int32 val);
  1281. void pc_bonus2(map_session_data *sd, int32 type, int32 type2, int32 val);
  1282. void pc_bonus3(map_session_data *sd, int32 type, int32 type2, int32 type3, int32 val);
  1283. void pc_bonus4(map_session_data *sd, int32 type, int32 type2, int32 type3, int32 type4, int32 val);
  1284. void pc_bonus5(map_session_data *sd, int32 type, int32 type2, int32 type3, int32 type4, int32 type5, int32 val);
  1285. enum e_addskill_type {
  1286. ADDSKILL_PERMANENT = 0, ///< Permanent skill. Remove the skill if level is 0
  1287. ADDSKILL_TEMP = 1, ///< Temporary skill. If player learned the skill and the given level is higher, level will be replaced and learned level will be palced in skill flag. `flag = learned + SKILL_FLAG_REPLACED_LV_0; learned_level = level;`
  1288. ADDSKILL_TEMP_ADDLEVEL = 2, ///< Like PCSKILL_TEMP, except the level will be stacked. `learned_level += level`. The flag is used to store original learned level
  1289. ADDSKILL_PERMANENT_GRANTED = 3, ///< Grant permanent skill, ignore skill tree and learned level
  1290. };
  1291. bool pc_skill(map_session_data *sd, uint16 skill_id, int32 level, enum e_addskill_type type);
  1292. bool pc_skill_plagiarism(map_session_data &sd, uint16 skill_id, uint16 skill_lv);
  1293. bool pc_skill_plagiarism_reset(map_session_data &sd, uint8 type);
  1294. int32 pc_insert_card(map_session_data *sd,int32 idx_card,int32 idx_equip);
  1295. int32 pc_identifyall(map_session_data *sd, bool identify_item);
  1296. bool pc_steal_item(map_session_data *sd,struct block_list *bl, uint16 skill_lv);
  1297. int32 pc_steal_coin(map_session_data *sd,struct block_list *bl);
  1298. int32 pc_modifybuyvalue(map_session_data*,int);
  1299. int32 pc_modifysellvalue(map_session_data*,int);
  1300. int32 pc_follow(map_session_data*, int); // [MouseJstr]
  1301. int32 pc_stop_following(map_session_data*);
  1302. uint32 pc_maxbaselv(map_session_data *sd);
  1303. uint32 pc_maxjoblv(map_session_data *sd);
  1304. bool pc_is_maxbaselv(map_session_data *sd);
  1305. bool pc_is_maxjoblv(map_session_data *sd);
  1306. int32 pc_checkbaselevelup(map_session_data *sd);
  1307. int32 pc_checkjoblevelup(map_session_data *sd);
  1308. void pc_gainexp(map_session_data *sd, struct block_list *src, t_exp base_exp, t_exp job_exp, uint8 exp_flag);
  1309. void pc_gainexp_disp(map_session_data *sd, t_exp base_exp, t_exp next_base_exp, t_exp job_exp, t_exp next_job_exp, bool lost);
  1310. void pc_lostexp(map_session_data *sd, t_exp base_exp, t_exp job_exp);
  1311. t_exp pc_nextbaseexp(map_session_data *sd);
  1312. t_exp pc_nextjobexp(map_session_data *sd);
  1313. int32 pc_need_status_point(map_session_data *,int,int);
  1314. int32 pc_maxparameterincrease(map_session_data*,int);
  1315. bool pc_statusup(map_session_data*,int,int);
  1316. int32 pc_statusup2(map_session_data*,int,int);
  1317. int32 pc_getstat(map_session_data *sd, int32 type);
  1318. int32 pc_setstat(map_session_data* sd, int32 type, int32 val);
  1319. int32 pc_need_trait_point(map_session_data *, int, int);
  1320. int32 pc_maxtraitparameterincrease(map_session_data*, int);
  1321. bool pc_traitstatusup(map_session_data*, int, int);
  1322. int32 pc_traitstatusup2(map_session_data*, int, int);
  1323. void pc_skillup(map_session_data*,uint16 skill_id);
  1324. int32 pc_allskillup(map_session_data*);
  1325. int32 pc_resetlvl(map_session_data*,int32 type);
  1326. int32 pc_resetstate(map_session_data*);
  1327. int32 pc_resetskill(map_session_data*, int);
  1328. int32 pc_resetfeel(map_session_data*);
  1329. int32 pc_resethate(map_session_data*);
  1330. bool pc_equipitem(map_session_data *sd, short n, int32 req_pos, bool equipswitch=false);
  1331. bool pc_unequipitem(map_session_data*,int,int);
  1332. int32 pc_equipswitch( map_session_data* sd, int32 index );
  1333. void pc_equipswitch_remove( map_session_data* sd, int32 index );
  1334. void pc_checkitem(map_session_data*);
  1335. void pc_check_available_item(map_session_data *sd, uint8 type);
  1336. int32 pc_useitem(map_session_data*,int);
  1337. int32 pc_skillatk_bonus(map_session_data *sd, uint16 skill_id);
  1338. int32 pc_sub_skillatk_bonus(map_session_data *sd, uint16 skill_id);
  1339. int32 pc_skillheal_bonus(map_session_data *sd, uint16 skill_id);
  1340. int32 pc_skillheal2_bonus(map_session_data *sd, uint16 skill_id);
  1341. void pc_damage(map_session_data *sd,struct block_list *src,uint32 hp, uint32 sp, uint32 ap);
  1342. int32 pc_dead(map_session_data *sd,struct block_list *src);
  1343. void pc_revive(map_session_data *sd,uint32 hp, uint32 sp, uint32 ap = 0);
  1344. bool pc_revive_item(map_session_data *sd);
  1345. void pc_heal(map_session_data *sd,uint32 hp,uint32 sp, uint32 ap, int32 type);
  1346. int32 pc_itemheal(map_session_data *sd, t_itemid itemid, int32 hp,int32 sp);
  1347. int32 pc_percentheal(map_session_data *sd,int,int);
  1348. bool pc_jobchange(map_session_data *sd, int32 job, char upper);
  1349. void pc_setoption(map_session_data *,int32 type, int32 subtype = 0);
  1350. bool pc_setcart(map_session_data* sd, int32 type);
  1351. void pc_setfalcon(map_session_data* sd, int32 flag);
  1352. void pc_setriding(map_session_data* sd, int32 flag);
  1353. void pc_setmadogear(map_session_data* sd, bool flag, e_mado_type type = MADO_ROBOT);
  1354. void pc_changelook(map_session_data *,int,int);
  1355. void pc_equiplookall(map_session_data *sd);
  1356. void pc_set_costume_view(map_session_data *sd);
  1357. int64 pc_readparam(map_session_data *sd, int64 type);
  1358. bool pc_setparam(map_session_data *sd, int64 type, int64 val);
  1359. int64 pc_readreg(map_session_data *sd, int64 reg);
  1360. bool pc_setreg(map_session_data *sd, int64 reg, int64 val);
  1361. char *pc_readregstr(map_session_data *sd, int64 reg);
  1362. bool pc_setregstr(map_session_data *sd, int64 reg, const char *str);
  1363. int64 pc_readregistry(map_session_data *sd, int64 reg);
  1364. bool pc_setregistry(map_session_data *sd, int64 reg, int64 val);
  1365. char *pc_readregistry_str(map_session_data *sd, int64 reg);
  1366. bool pc_setregistry_str(map_session_data *sd, int64 reg, const char *val);
  1367. #define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg)
  1368. #define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val)
  1369. #define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg)
  1370. #define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1371. #define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg)
  1372. #define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val)
  1373. #define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg)
  1374. #define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1375. #define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg)
  1376. #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val)
  1377. #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg)
  1378. #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1379. bool pc_setreg2(map_session_data *sd, const char *reg, int64 val);
  1380. int64 pc_readreg2(map_session_data *sd, const char *reg);
  1381. bool pc_addeventtimer(map_session_data *sd,int32 tick,const char *name);
  1382. bool pc_deleventtimer(map_session_data *sd,const char *name);
  1383. void pc_cleareventtimer(map_session_data *sd);
  1384. void pc_addeventtimercount(map_session_data *sd,const char *name,int32 tick);
  1385. int32 pc_calc_pvprank(map_session_data *sd);
  1386. TIMER_FUNC(pc_calc_pvprank_timer);
  1387. int32 pc_ismarried(map_session_data *sd);
  1388. bool pc_marriage(map_session_data *sd,map_session_data *dstsd);
  1389. bool pc_divorce(map_session_data *sd);
  1390. map_session_data *pc_get_partner(map_session_data *sd);
  1391. map_session_data *pc_get_father(map_session_data *sd);
  1392. map_session_data *pc_get_mother(map_session_data *sd);
  1393. map_session_data *pc_get_child(map_session_data *sd);
  1394. void pc_bleeding (map_session_data *sd, t_tick diff_tick);
  1395. void pc_regen (map_session_data *sd, t_tick diff_tick);
  1396. bool pc_setstand(map_session_data *sd, bool force);
  1397. bool pc_candrop(map_session_data *sd,struct item *item);
  1398. uint64 pc_jobid2mapid(unsigned short b_class); // Skotlex
  1399. int32 pc_mapid2jobid(uint64 class_, int32 sex); // Skotlex
  1400. const char * job_name(int32 class_);
  1401. struct s_skill_tree_entry {
  1402. uint16 skill_id, max_lv;
  1403. uint32 baselv, joblv;
  1404. std::unordered_map<uint16, uint16> need; /// skill_id, skill_lv
  1405. bool exclude_inherit; // exclude the skill from inherit when loading the table
  1406. };
  1407. struct s_skill_tree {
  1408. std::vector<uint16> inherit_job;
  1409. std::unordered_map<uint16, std::shared_ptr<s_skill_tree_entry>> skills; /// skill_id, entry
  1410. };
  1411. class SkillTreeDatabase : public TypesafeYamlDatabase<uint16, s_skill_tree> {
  1412. public:
  1413. SkillTreeDatabase() : TypesafeYamlDatabase("SKILL_TREE_DB", 1) {
  1414. }
  1415. const std::string getDefaultLocation() override;
  1416. uint64 parseBodyNode(const ryml::NodeRef& node) override;
  1417. void loadingFinished() override;
  1418. // Additional
  1419. std::shared_ptr<s_skill_tree_entry> get_skill_data(int32 class_, uint16 skill_id);
  1420. };
  1421. extern SkillTreeDatabase skill_tree_db;
  1422. struct sg_data {
  1423. short anger_id;
  1424. short bless_id;
  1425. short comfort_id;
  1426. char feel_var[NAME_LENGTH];
  1427. char hate_var[NAME_LENGTH];
  1428. bool (*day_func)(void);
  1429. };
  1430. extern const struct sg_data sg_info[MAX_PC_FEELHATE];
  1431. void pc_set_bg_queue_timer(map_session_data *sd);
  1432. void pc_delete_bg_queue_timer(map_session_data *sd);
  1433. void pc_setinvincibletimer(map_session_data* sd, int32 val);
  1434. void pc_delinvincibletimer(map_session_data* sd);
  1435. void pc_addspiritball(map_session_data *sd,int32 interval,int32 max);
  1436. void pc_delspiritball(map_session_data *sd,int32 count,int32 type);
  1437. void pc_addsoulball( map_session_data& sd, int32 number, int32 max = MAX_SOUL_BALL );
  1438. void pc_delsoulball( map_session_data& sd, int32 count, bool no_client_effect = false );
  1439. void pc_addservantball( map_session_data& sd, int32 count = 1 );
  1440. void pc_delservantball( map_session_data& sd, int32 count = 1 );
  1441. void pc_addabyssball( map_session_data& sd, int32 count = 1 );
  1442. void pc_delabyssball( map_session_data& sd, int32 count = 1 );
  1443. bool pc_addfame(map_session_data &sd, int32 count);
  1444. unsigned char pc_famerank(uint32 char_id, int32 job);
  1445. bool pc_set_hate_mob(map_session_data *sd, int32 pos, struct block_list *bl);
  1446. extern struct fame_list smith_fame_list[MAX_FAME_LIST];
  1447. extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
  1448. extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
  1449. void pc_readdb(void);
  1450. void do_init_pc(void);
  1451. void do_final_pc(void);
  1452. // timer for night.day
  1453. extern int32 day_timer_tid;
  1454. extern int32 night_timer_tid;
  1455. TIMER_FUNC(map_day_timer); // by [yor]
  1456. TIMER_FUNC(map_night_timer); // by [yor]
  1457. // Rental System
  1458. void pc_inventory_rentals(map_session_data *sd);
  1459. void pc_inventory_rental_clear(map_session_data *sd);
  1460. void pc_inventory_rental_add(map_session_data *sd, uint32 seconds);
  1461. int32 pc_read_motd(void); // [Valaris]
  1462. int32 pc_disguise(map_session_data *sd, int32 class_);
  1463. bool pc_isautolooting(map_session_data *sd, t_itemid nameid);
  1464. void pc_overheat(map_session_data &sd, int16 heat);
  1465. void pc_itemcd_do(map_session_data *sd, bool load);
  1466. uint8 pc_itemcd_add(map_session_data *sd, struct item_data *id, t_tick tick, unsigned short n);
  1467. uint8 pc_itemcd_check(map_session_data *sd, struct item_data *id, t_tick tick, unsigned short n);
  1468. int32 pc_load_combo(map_session_data *sd);
  1469. void pc_addspiritcharm(map_session_data *sd, int32 interval, int32 max, int32 type);
  1470. void pc_delspiritcharm(map_session_data *sd, int32 count, int32 type);
  1471. void pc_baselevelchanged(map_session_data *sd);
  1472. void pc_damage_log_add(map_session_data *sd, int32 id);
  1473. void pc_damage_log_clear(map_session_data *sd, int32 id);
  1474. enum e_BANKING_DEPOSIT_ACK : uint8;
  1475. enum e_BANKING_WITHDRAW_ACK : uint8;
  1476. enum e_BANKING_DEPOSIT_ACK pc_bank_deposit(map_session_data *sd, int32 money);
  1477. enum e_BANKING_WITHDRAW_ACK pc_bank_withdraw(map_session_data *sd, int32 money);
  1478. void pc_crimson_marker_clear(map_session_data *sd);
  1479. void pc_show_version(map_session_data *sd);
  1480. TIMER_FUNC(pc_bonus_script_timer);
  1481. void pc_bonus_script(map_session_data *sd);
  1482. struct s_bonus_script_entry *pc_bonus_script_add(map_session_data *sd, const char *script_str, t_tick dur, enum efst_type icon, uint16 flag, uint8 type);
  1483. void pc_bonus_script_clear(map_session_data *sd, uint32 flag);
  1484. void pc_cell_basilica(map_session_data *sd);
  1485. short pc_get_itemgroup_bonus(map_session_data* sd, t_itemid nameid, std::vector<s_item_bonus>& bonuses);
  1486. short pc_get_itemgroup_bonus_group(map_session_data* sd, uint16 group_id, std::vector<s_item_bonus>& bonuses);
  1487. bool pc_is_same_equip_index(enum equip_index eqi, short *equip_index, short index);
  1488. /// Check if player is Taekwon Ranker and the level is >= 90 (battle_config.taekwon_ranker_min_lv)
  1489. #define pc_is_taekwon_ranker(sd) (((sd)->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && (sd)->status.base_level >= battle_config.taekwon_ranker_min_lv && pc_famerank((sd)->status.char_id,MAPID_TAEKWON))
  1490. TIMER_FUNC(pc_autotrade_timer);
  1491. void pc_validate_skill(map_session_data *sd);
  1492. void pc_show_questinfo(map_session_data *sd);
  1493. void pc_show_questinfo_reinit(map_session_data *sd);
  1494. bool pc_job_can_entermap(enum e_job jobid, int32 m, int32 group_lv);
  1495. #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
  1496. uint16 pc_level_penalty_mod( map_session_data* sd, e_penalty_type type, std::shared_ptr<s_mob_db> mob, mob_data* md = nullptr );
  1497. #endif
  1498. bool pc_attendance_enabled();
  1499. int32 pc_attendance_counter( map_session_data* sd );
  1500. void pc_attendance_claim_reward( map_session_data* sd );
  1501. void pc_jail(map_session_data &sd, int32 duration = INT_MAX);
  1502. // Captcha Register
  1503. void pc_macro_captcha_register(map_session_data &sd, uint16 image_size, const char captcha_answer[CAPTCHA_ANSWER_SIZE]);
  1504. void pc_macro_captcha_register_upload(map_session_data & sd, uint16 upload_size, const char *upload_data);
  1505. // Macro Detector
  1506. TIMER_FUNC(pc_macro_detector_timeout);
  1507. void pc_macro_detector_process_answer(map_session_data &sd, const char captcha_answer[CAPTCHA_ANSWER_SIZE]);
  1508. void pc_macro_detector_disconnect(map_session_data &sd);
  1509. // Macro Reporter
  1510. void pc_macro_reporter_area_select(map_session_data &sd, const int16 x, const int16 y, const int8 radius);
  1511. void pc_macro_reporter_process(map_session_data &sd, int32 reporter_account_id = -1);
  1512. #ifdef MAP_GENERATOR
  1513. void pc_reputation_generate();
  1514. #endif
  1515. #endif /* PC_HPP */