pc.hpp 58 KB

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