pc.hpp 60 KB

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