pc.hpp 60 KB

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