/src/map/pc.hpp

https://bitbucket.org/teededung/mmm · C++ Header · 1470 lines · 1164 code · 216 blank · 90 comment · 65 complexity · c2e35cd162520ac4c4eea183564c396b MD5 · raw file

Large files are truncated click here to view the full file

  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 <memory>
  6. #include <vector>
  7. #include "../common/mmo.hpp" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
  8. #include "../common/strlib.hpp"// StringBuf
  9. #include "../common/timer.hpp"
  10. #include "battleground.hpp"
  11. #include "buyingstore.hpp" // struct s_buyingstore
  12. #include "clif.hpp" //e_wip_block
  13. #include "itemdb.hpp" // MAX_ITEMGROUP
  14. #include "map.hpp" // RC_ALL
  15. #include "mob.hpp" //e_size
  16. #include "script.hpp" // struct script_reg, struct script_regstr
  17. #include "searchstore.hpp" // struct s_search_store_info
  18. #include "status.hpp" // unit_data
  19. #include "unit.hpp" // unit_data
  20. #include "vending.hpp" // struct s_vending
  21. enum AtCommandType : uint8;
  22. //enum e_log_chat_type : uint8;
  23. enum e_log_pick_type : uint32;
  24. enum sc_type : int16;
  25. #define MAX_PC_BONUS 50 /// Max bonus, usually used by item bonus
  26. #define MAX_PC_SKILL_REQUIRE 5 /// Max skill tree requirement
  27. #define MAX_PC_FEELHATE 3 /// Max feel hate info
  28. #define DAMAGELOG_SIZE_PC 100 /// Damage log
  29. #define MAX_SPIRITBALL 15 /// Max spirit balls
  30. #define MAX_DEVOTION 5 /// Max Devotion slots
  31. #define MAX_SPIRITCHARM 10 /// Max spirit charms
  32. #define MAX_SOUL_BALL 20 /// Max soul ball
  33. #define MAX_STELLAR_MARKS 5 /// Max stellar marks
  34. #define MAX_UNITED_SOULS 12 /// Max united souls
  35. #define MAX_SHIELD_BALL 4 /// Max shield ball
  36. #define LANGTYPE_VAR "#langtype"
  37. #define CASHPOINT_VAR "#CASHPOINTS"
  38. #define KAFRAPOINT_VAR "#KAFRAPOINTS"
  39. #define BANK_VAULT_VAR "#BANKVAULT"
  40. #define ROULETTE_BRONZE_VAR "RouletteBronze"
  41. #define ROULETTE_SILVER_VAR "RouletteSilver"
  42. #define ROULETTE_GOLD_VAR "RouletteGold"
  43. #define COOKMASTERY_VAR "COOK_MASTERY"
  44. #define PCDIECOUNTER_VAR "PC_DIE_COUNTER"
  45. #define JOBCHANGE2ND_VAR "jobchange_level"
  46. #define JOBCHANGE3RD_VAR "jobchange_level_3rd"
  47. #define TKMISSIONID_VAR "TK_MISSION_ID"
  48. #define TKMISSIONCOUNT_VAR "TK_MISSION_COUNT"
  49. #define ATTENDANCE_DATE_VAR "#AttendanceDate"
  50. #define ATTENDANCE_COUNT_VAR "#AttendanceCounter"
  51. #define ACHIEVEMENTLEVEL "AchievementLevel"
  52. //Update this max as necessary. 55 is the value needed for Super Baby currently
  53. //Raised to 105 since Expanded Super Baby needs it.
  54. #define MAX_SKILL_TREE 105
  55. //Total number of classes (for data storage)
  56. #define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
  57. //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
  58. //where the arrows are equipped)
  59. enum equip_index {
  60. EQI_COMPOUND_ON = -1,
  61. EQI_ACC_L = 0,
  62. EQI_ACC_R,
  63. EQI_SHOES,
  64. EQI_GARMENT,
  65. EQI_HEAD_LOW,
  66. EQI_HEAD_MID,
  67. EQI_HEAD_TOP,
  68. EQI_ARMOR,
  69. EQI_HAND_L,
  70. EQI_HAND_R,
  71. EQI_COSTUME_HEAD_TOP,
  72. EQI_COSTUME_HEAD_MID,
  73. EQI_COSTUME_HEAD_LOW,
  74. EQI_COSTUME_GARMENT,
  75. EQI_AMMO,
  76. EQI_SHADOW_ARMOR,
  77. EQI_SHADOW_WEAPON,
  78. EQI_SHADOW_SHIELD,
  79. EQI_SHADOW_SHOES,
  80. EQI_SHADOW_ACC_R,
  81. EQI_SHADOW_ACC_L,
  82. EQI_MAX
  83. };
  84. enum prevent_logout_trigger {
  85. PLT_NONE = 0,
  86. PLT_LOGIN = 1,
  87. PLT_ATTACK = 2,
  88. PLT_SKILL = 4,
  89. PLT_DAMAGE = 8
  90. };
  91. enum e_chkitem_result : uint8 {
  92. CHKADDITEM_EXIST,
  93. CHKADDITEM_NEW,
  94. CHKADDITEM_OVERAMOUNT
  95. };
  96. enum e_additem_result : uint8 {
  97. ADDITEM_SUCCESS,
  98. ADDITEM_INVALID,
  99. ADDITEM_OVERWEIGHT,
  100. ADDITEM_ITEM,
  101. ADDITEM_OVERITEM,
  102. ADDITEM_OVERAMOUNT,
  103. ADDITEM_REFUSED_TIME,
  104. ADDITEM_STACKLIMIT
  105. };
  106. struct skill_cooldown_entry {
  107. unsigned short skill_id;
  108. int timer;
  109. };
  110. #ifdef VIP_ENABLE
  111. struct vip_info {
  112. unsigned int enabled : 1;
  113. time_t time;
  114. bool disableshowrate; //State to disable clif_display_pinfo(). [Cydh]
  115. };
  116. #endif
  117. enum npc_timeout_type {
  118. NPCT_INPUT = 0,
  119. NPCT_MENU = 1,
  120. NPCT_WAIT = 2,
  121. };
  122. extern unsigned int equip_bitmask[EQI_MAX];
  123. #define equip_index_check(i) ( (i) >= EQI_ACC_L && (i) < EQI_MAX )
  124. /// Miscellaneous item bonus struct
  125. struct s_item_bonus {
  126. uint16 id;
  127. int val;
  128. };
  129. /// AddEle bonus struct
  130. struct s_addele2 {
  131. short flag, rate;
  132. unsigned char ele;
  133. };
  134. /// AddRace bonus struct
  135. struct s_addrace2 {
  136. short flag, rate;
  137. unsigned char race;
  138. };
  139. struct weapon_data {
  140. int atkmods[SZ_ALL];
  141. // all the variables except atkmods get zero'ed in each call of status_calc_pc
  142. // NOTE: if you want to add a non-zeroed variable, you need to update the memset call
  143. // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex]
  144. int overrefine;
  145. int star;
  146. int ignore_def_ele;
  147. int ignore_def_race;
  148. int ignore_def_class;
  149. int def_ratio_atk_ele;
  150. int def_ratio_atk_race;
  151. int def_ratio_atk_class;
  152. int addele[ELE_MAX];
  153. int addrace[RC_MAX];
  154. int addclass[CLASS_MAX];
  155. int addrace2[RC2_MAX];
  156. int addsize[SZ_MAX];
  157. short hp_drain_race[RC_MAX];
  158. short sp_drain_race[RC_MAX];
  159. short hp_drain_class[CLASS_MAX];
  160. short sp_drain_class[CLASS_MAX];
  161. struct drain_data {
  162. short rate; ///< Success rate 10000 = 100%
  163. short per; ///< Drain value/rate per attack
  164. } hp_drain_rate, sp_drain_rate;
  165. std::vector<s_item_bonus> add_dmg;
  166. std::vector<s_addele2> addele2;
  167. std::vector<s_addrace2> addrace3;
  168. };
  169. /// AutoSpell bonus struct
  170. struct s_autospell {
  171. short id, lv, rate, flag;
  172. unsigned short card_id;
  173. bool lock; // bAutoSpellOnSkill: blocks autospell from triggering again, while being executed
  174. };
  175. /// AddEff and AddEff2 bonus struct
  176. struct s_addeffect {
  177. enum sc_type sc; /// SC type/effect
  178. short rate, /// Rate
  179. arrow_rate; /// Arrow rate
  180. unsigned char flag; /// Flag
  181. unsigned int duration; /// Duration the effect applied
  182. };
  183. /// AddEffOnSkill bonus struct
  184. struct s_addeffectonskill {
  185. enum sc_type sc; /// SC type/effect
  186. short rate, /// Rate
  187. skill_id; /// Skill ID
  188. unsigned char target; /// Target
  189. unsigned int duration; /// Duration the effect applied
  190. };
  191. ///Struct of add drop item/group rate
  192. struct s_add_drop {
  193. unsigned short nameid, ///Item ID
  194. group; ///Group ID
  195. int rate; ///Rate, 1 ~ 10000, -1 ~ -100000
  196. short race; ///Target Race, bitwise value of 1<<x. if < 0 means Monster ID
  197. unsigned short class_; ///Target Class, bitwise value of 1<<x
  198. };
  199. struct s_vanish_bonus {
  200. int16 rate; // 1000 = 100%
  201. int16 per; // 100 = 100%
  202. int flag;
  203. };
  204. /// AutoBonus bonus struct
  205. struct s_autobonus {
  206. short rate;
  207. uint16 atk_type;
  208. unsigned int duration;
  209. char *bonus_script, *other_script;
  210. int active;
  211. unsigned int pos;
  212. };
  213. /// bResSC struct
  214. struct s_pc_resSC {
  215. sc_type sc;
  216. short rate;
  217. };
  218. /// Timed bonus 'bonus_script' struct [Cydh]
  219. struct s_bonus_script_entry {
  220. struct script_code *script;
  221. StringBuf *script_buf; //Used for comparing and storing on table
  222. t_tick tick;
  223. uint16 flag;
  224. enum efst_types icon;
  225. uint8 type; //0 - Ignore; 1 - Buff; 2 - Debuff
  226. int tid;
  227. };
  228. /// HP/SP bonus struct
  229. struct s_regen {
  230. short value;
  231. int rate;
  232. int tick;
  233. };
  234. struct map_session_data {
  235. struct block_list bl;
  236. struct unit_data ud;
  237. struct view_data vd;
  238. struct status_data base_status, battle_status;
  239. struct status_change sc;
  240. struct regen_data regen;
  241. struct regen_data_sub sregen, ssregen;
  242. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
  243. //status_calc_pc, while special_state is recalculated in each call. [Skotlex]
  244. struct s_state {
  245. unsigned int active : 1; //Marks active player (not active is logging in/out, or changing map servers)
  246. unsigned int menu_or_input : 1;// if a script is waiting for feedback from the player
  247. unsigned int dead_sit : 2;
  248. unsigned int lr_flag : 3;//1: left h. weapon; 2: arrow; 3: shield
  249. unsigned int connect_new : 1;
  250. unsigned int arrow_atk : 1;
  251. unsigned int gangsterparadise : 1;
  252. unsigned int rest : 1;
  253. unsigned int storage_flag : 3; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex], 3: Premium Storage
  254. unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
  255. unsigned int abra_flag : 2; // Abracadabra bugfix by Aru
  256. unsigned int autocast : 1; // Autospell flag [Inkfish]
  257. unsigned int autotrade : 3; //By Fantik. &2 Requested by vending autotrade; &4 Requested by buyingstore autotrade
  258. unsigned int showdelay :1;
  259. unsigned int showexp :1;
  260. unsigned int showzeny :1;
  261. unsigned int noask :1; // [LuzZza]
  262. unsigned int trading :1; //[Skotlex] is 1 only after a trade has started.
  263. unsigned int deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
  264. unsigned int size :2; // for tiny/large types
  265. unsigned int night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
  266. unsigned int using_fake_npc :1;
  267. unsigned int rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex]
  268. unsigned int killer : 1;
  269. unsigned int killable : 1;
  270. unsigned int doridori : 1;
  271. unsigned int ignoreAll : 1;
  272. unsigned int debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
  273. unsigned int buyingstore : 1;
  274. unsigned int lesseffect : 1;
  275. unsigned int vending : 1;
  276. unsigned int noks : 3; // [Zeph Kill Steal Protection]
  277. unsigned int changemap : 1;
  278. unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
  279. short pmap; // Previous map on Map Change
  280. unsigned short autoloot;
  281. unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
  282. unsigned short autoloottype;
  283. unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
  284. unsigned int autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
  285. unsigned int gmaster_flag : 1;
  286. unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
  287. unsigned int warping : 1;//states whether you're in the middle of a warp processing
  288. // (^~_~^) Auras Start
  289. unsigned int show_auras : 2;
  290. // (^~_~^) Auras End
  291. unsigned int no_skill_scale : 1; // when 1, show skill scale from MvP
  292. unsigned int hide_cart : 1; // when 1, hide cart
  293. unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
  294. bool hold_recalc;
  295. unsigned int banking : 1; //1 when we using the banking system 0 when closed
  296. unsigned int hpmeter_visible : 1;
  297. unsigned disable_atcommand_on_npc : 1; //Prevent to use atcommand while talking with NPC [Kichi]
  298. uint8 isBoundTrading; // Player is currently add bound item to trade list [Cydh]
  299. bool ignoretimeout; // Prevent the SECURE_NPCTIMEOUT function from closing current script.
  300. unsigned int workinprogress : 2; // See clif.hpp::e_workinprogress
  301. bool pc_loaded; // Ensure inventory data and status data is loaded before we calculate player stats
  302. bool keepshop; // Whether shop data should be removed when the player disconnects
  303. bool mail_writing; // Whether the player is currently writing a mail in RODEX or not
  304. bool cashshop_open;
  305. bool sale_open;
  306. unsigned int lapine_ui : 3; // Lapine Synthesis/Upgrade UI is opened
  307. unsigned int block_action : 10;
  308. bool refineui_open;
  309. } state;
  310. struct {
  311. unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
  312. unsigned int restart_full_recover : 1;
  313. unsigned int no_castcancel : 1;
  314. unsigned int no_castcancel2 : 1;
  315. unsigned int no_sizefix : 1;
  316. unsigned int no_gemstone : 2;
  317. unsigned int intravision : 1; // Maya Purple Card effect [DracoRPG]
  318. unsigned int perfect_hiding : 1; // [Valaris]
  319. unsigned int no_knockback : 1;
  320. unsigned int bonus_coma : 1;
  321. unsigned int no_mado_fuel : 1; // Disable Magic_Gear_Fuel consumption [Secret]
  322. unsigned int no_walk_delay : 1;
  323. unsigned int no_receive_reflect : 1; // No Receive Reflected Dame [teededung]
  324. } special_state;
  325. uint32 login_id1, login_id2;
  326. unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
  327. int group_id, group_pos, group_level;
  328. unsigned int permissions;/* group permissions */
  329. int count_rewarp; //count how many time we being rewarped
  330. int langtype;
  331. struct mmo_charstatus status;
  332. // Item Storages
  333. struct s_storage storage, premiumStorage;
  334. struct s_storage inventory;
  335. struct s_storage cart;
  336. struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
  337. short equip_index[EQI_MAX];
  338. short equip_switch_index[EQI_MAX];
  339. unsigned int weight,max_weight,add_max_weight;
  340. int cart_weight,cart_num,cart_weight_max;
  341. int fd;
  342. unsigned short mapindex;
  343. unsigned char head_dir; //0: Look forward. 1: Look right, 2: Look left.
  344. t_tick client_tick;
  345. int npc_id,npc_shopid; //for script follow scriptoid; ,npcid
  346. std::vector<int> areanpc, npc_ontouch_; ///< Array of OnTouch and OnTouch_ NPC ID
  347. int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
  348. int npc_menu; // internal variable, used in npc menu handling
  349. int npc_amount;
  350. struct script_state *st;
  351. char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
  352. int npc_timer_id; //For player attached npc timers. [Skotlex]
  353. unsigned int chatID;
  354. time_t idletime;
  355. time_t idletime_hom;
  356. struct s_progressbar {
  357. int npc_id;
  358. t_tick timeout;
  359. } progressbar; //Progress Bar [Inkfish]
  360. struct s_ignore {
  361. char name[NAME_LENGTH];
  362. } ignore[MAX_IGNORE_LIST];
  363. int followtimer; // [MouseJstr]
  364. int followtarget;
  365. time_t emotionlasttime; // to limit flood with emotion packets
  366. short skillitem,skillitemlv;
  367. bool skillitem_keep_requirement;
  368. uint16 skill_id_old,skill_lv_old;
  369. uint16 skill_id_dance,skill_lv_dance;
  370. short cook_mastery; // range: [0,1999] [Inkfish]
  371. struct skill_cooldown_entry * scd[MAX_SKILLCOOLDOWN]; // Skill Cooldown
  372. uint16 cloneskill_idx, ///Stores index of copied skill by Intimidate/Plagiarism
  373. reproduceskill_idx; ///Stores index of copied skill by Reproduce
  374. int menuskill_id, menuskill_val, menuskill_val2;
  375. int invincible_timer;
  376. t_tick canlog_tick;
  377. t_tick canuseitem_tick; // [Skotlex]
  378. t_tick canusecashfood_tick;
  379. t_tick request_delay_tick;
  380. t_tick canequip_tick; // [Inkfish]
  381. t_tick cantalk_tick;
  382. t_tick canskill_tick; // used to prevent abuse from no-delay ACT files
  383. t_tick cansendmail_tick; // [Mail System Flood Protection]
  384. t_tick ks_floodprotect_tick; // [Kill Steal Protection]
  385. t_tick equipswitch_tick; // Equip switch
  386. struct s_item_delay {
  387. unsigned short nameid;
  388. t_tick tick;
  389. } item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
  390. short weapontype1,weapontype2;
  391. short disguise; // [Valaris]
  392. struct weapon_data right_weapon, left_weapon;
  393. // here start arrays to be globally zeroed at the beginning of status_calc_pc()
  394. int param_bonus[6],param_equip[6]; //Stores card/equipment bonuses.
  395. int subele[ELE_MAX];
  396. int subele_script[ELE_MAX];
  397. int subdefele[ELE_MAX];
  398. int subrace[RC_MAX];
  399. int subclass[CLASS_MAX];
  400. int subrace2[RC2_MAX];
  401. int subsize[SZ_MAX];
  402. short coma_class[CLASS_MAX];
  403. short coma_race[RC_MAX];
  404. short weapon_coma_ele[ELE_MAX];
  405. short weapon_coma_race[RC_MAX];
  406. short weapon_coma_class[CLASS_MAX];
  407. int weapon_atk[16];
  408. int weapon_damage_rate[16];
  409. int arrow_addele[ELE_MAX];
  410. int arrow_addrace[RC_MAX];
  411. int arrow_addclass[CLASS_MAX];
  412. int arrow_addsize[SZ_MAX];
  413. int magic_addele[ELE_MAX];
  414. int magic_addele_script[ELE_MAX];
  415. int magic_addrace[RC_MAX];
  416. int magic_addclass[CLASS_MAX];
  417. int magic_addsize[SZ_MAX];
  418. int magic_atk_ele[ELE_MAX];
  419. int magic_subsize[SZ_MAX];
  420. int critaddrace[RC_MAX];
  421. int expaddrace[RC_MAX];
  422. int expaddclass[CLASS_MAX];
  423. int ignore_mdef_by_race[RC_MAX];
  424. int ignore_mdef_by_class[CLASS_MAX];
  425. int ignore_def_by_race[RC_MAX];
  426. int ignore_def_by_class[CLASS_MAX];
  427. short sp_gain_race[RC_MAX];
  428. int magic_addrace2[RC2_MAX];
  429. int ignore_mdef_by_race2[RC2_MAX];
  430. int dropaddrace[RC_MAX];
  431. int dropaddclass[CLASS_MAX];
  432. // zeroed arrays end here.
  433. std::vector<s_autospell> autospell, autospell2, autospell3;
  434. std::vector<s_addeffect> addeff, addeff_atked;
  435. std::vector<s_addeffectonskill> addeff_onskill;
  436. std::vector<s_item_bonus> skillatk, skillusesprate, skillusesp, skillheal, skillheal2, skillblown, skillcastrate, skillfixcastrate, subskill, skillcooldown, skillfixcast,
  437. skillvarcast, skilldelay, itemhealrate, add_def, add_mdef, add_mdmg, reseff, itemgrouphealrate;
  438. std::vector<s_add_drop> add_drop;
  439. std::vector<s_addele2> subele2;
  440. std::vector<s_vanish_bonus> sp_vanish, hp_vanish;
  441. std::vector<s_addrace2> subrace3;
  442. std::vector<s_autobonus> autobonus, autobonus2, autobonus3; //Auto script on attack, when attacked, on skill usage
  443. // zeroed structures start here
  444. struct s_regen {
  445. short value;
  446. int rate;
  447. t_tick tick;
  448. } hp_loss, sp_loss, hp_regen, sp_regen, percent_hp_regen, percent_sp_regen;
  449. struct {
  450. short value;
  451. int rate, tick;
  452. } def_set_race[RC_MAX], mdef_set_race[RC_MAX], norecover_state_race[RC_MAX];
  453. struct s_bonus_vanish_gain {
  454. short rate, ///< Success rate 0 - 1000 (100%)
  455. per; ///< % HP/SP vanished/gained
  456. } hp_vanish_race[RC_MAX], sp_vanish_race[RC_MAX];
  457. // zeroed structures end here
  458. // zeroed vars start here.
  459. struct s_bonus {
  460. int hp, sp;
  461. int atk_rate;
  462. int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
  463. int nsshealhp,nsshealsp;
  464. int critical_def,double_rate;
  465. int short_attack_atk_rate; // Short range atk rate, not weapon based.
  466. int long_attack_atk_rate; //Long range atk rate, not weapon based. [Skotlex]
  467. int near_attack_def_rate,long_attack_def_rate,magic_def_rate,misc_def_rate;
  468. int ignore_mdef_ele;
  469. int ignore_mdef_race;
  470. int ignore_mdef_class;
  471. int perfect_hit;
  472. int perfect_hit_add;
  473. int get_zeny_rate;
  474. int get_zeny_num; //Added Get Zeny Rate [Skotlex]
  475. int double_add_rate;
  476. int short_weapon_damage_return,long_weapon_damage_return;
  477. int magic_damage_return; // AppleGirl Was Here
  478. int break_weapon_rate,break_armor_rate;
  479. int crit_atk_rate;
  480. int crit_def_rate;
  481. int classchange; // [Valaris]
  482. int speed_rate, speed_add_rate, aspd_add;
  483. int itemhealrate2; // [Epoque] Increase heal rate of all healing items.
  484. int shieldmdef;//royal guard's
  485. unsigned int setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
  486. short splash_range, splash_add_range;
  487. short add_steal_rate;
  488. int add_heal_rate, add_heal2_rate;
  489. int sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value, long_sp_gain_value, long_hp_gain_value;
  490. unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
  491. unsigned short unbreakable_equip; //100% break resistance on certain equipment
  492. unsigned short unstripable_equip;
  493. int fixcastrate, varcastrate; // n/100
  494. int add_fixcast, add_varcast; // in milliseconds
  495. int ematk; // matk bonus from equipment
  496. int eatk; // atk bonus from equipment
  497. uint8 absorb_dmg_maxhp; // [Cydh]
  498. short critical_rangeatk;
  499. short weapon_atk_rate, weapon_matk_rate;
  500. } bonus;
  501. // zeroed vars end here.
  502. // (^~_~^) Color Nicks Start
  503. unsigned int color_nicks_group_id;
  504. // (^~_~^) Color Nicks End
  505. int castrate,delayrate,hprate,sprate,dsprate;
  506. int hprecov_rate,sprecov_rate;
  507. int matk_rate;
  508. int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
  509. int itemid;
  510. short itemindex; //Used item's index in sd->inventory [Skotlex]
  511. uint16 catch_target_class; // pet catching, stores a pet class to catch [zzo]
  512. int8 spiritball, spiritball_old;
  513. int spirit_timer[MAX_SPIRITBALL];
  514. short spiritcharm; //No. of spirit
  515. int spiritcharm_type; //Spirit type
  516. int spiritcharm_timer[MAX_SPIRITCHARM];
  517. int8 soulball, soulball_old;
  518. short shieldball, shieldball_old;
  519. int shield_timer[MAX_SHIELD_BALL];
  520. int shieldball_health, shieldball_set_health;
  521. unsigned char potion_success_counter; //Potion successes in row counter
  522. unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
  523. short mission_mobid; //Stores the target mob_id for TK_MISSION
  524. int die_counter; //Total number of times you've died
  525. int devotion[MAX_DEVOTION]; //Stores the account IDs of chars devoted to.
  526. int stellar_mark[MAX_STELLAR_MARKS]; // Stores the account ID's of character's with a stellar mark.
  527. int united_soul[MAX_UNITED_SOULS]; // Stores the account ID's of character's who's soul is united.
  528. int trade_partner;
  529. struct s_deal {
  530. struct s_item {
  531. short index, amount;
  532. } item[10];
  533. int zeny, weight;
  534. } deal;
  535. bool party_creating; // whether the char is requesting party creation
  536. bool party_joining; // whether the char is accepting party invitation
  537. int party_invite, party_invite_account; // for handling party invitation (holds party id and account id)
  538. int adopt_invite; // Adoption
  539. // (^~_~^) Auras Start
  540. union
  541. { // Auras by Functor
  542. struct
  543. {
  544. unsigned char part_3;
  545. unsigned char part_2;
  546. unsigned char part_1;
  547. unsigned char option;
  548. } aura;
  549. unsigned int aura_data;
  550. };
  551. // (^~_~^) Auras End
  552. struct guild *guild; // [Ind] speed everything up
  553. int guild_invite,guild_invite_account;
  554. int guild_emblem_id,guild_alliance,guild_alliance_account;
  555. short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo]
  556. int guildspy; // [Syrus22]
  557. int partyspy; // [Syrus22]
  558. int clanspy;
  559. struct clan *clan;
  560. int vended_id;
  561. int vender_id;
  562. int vend_num;
  563. uint16 vend_skill_lv;
  564. char message[MESSAGE_SIZE];
  565. struct s_vending vending[MAX_VENDING];
  566. unsigned int buyer_id; // uid of open buying store
  567. struct s_buyingstore buyingstore;
  568. struct s_search_store_info searchstore;
  569. struct pet_data *pd;
  570. struct homun_data *hd; // [blackhole89]
  571. struct mercenary_data *md;
  572. struct elemental_data *ed;
  573. struct s_hate_mob {
  574. int m; //-1 - none, other: map index corresponding to map name.
  575. unsigned short index; //map index
  576. } feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
  577. short hate_mob[3];
  578. int pvp_timer;
  579. short pvp_point;
  580. unsigned short pvp_rank, pvp_lastusers;
  581. unsigned short pvp_won, pvp_lost;
  582. char eventqueue[MAX_EVENTQUEUE][EVENT_NAME_LENGTH];
  583. int eventtimer[MAX_EVENTTIMER];
  584. unsigned short eventcount; // [celest]
  585. unsigned char change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value]
  586. unsigned char change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value]
  587. char fakename[NAME_LENGTH]; // fake names [Valaris]
  588. size_t duel_group; // duel vars [LuzZza]
  589. size_t duel_invite;
  590. int killerrid, killedrid, killedgid;
  591. int cashPoints, kafraPoints;
  592. int rental_timer;
  593. // Auction System [Zephyrus]
  594. struct s_auction{
  595. int index, amount;
  596. } auction;
  597. // Mail System [Zephyrus]
  598. struct s_mail {
  599. struct {
  600. unsigned short nameid;
  601. int index, amount;
  602. } item[MAIL_MAX_ITEM];
  603. int zeny;
  604. struct mail_data inbox;
  605. bool changed; // if true, should sync with charserver on next mailbox request
  606. } mail;
  607. // Battlegrounds queue system [MasterOfMuppets]
  608. std::shared_ptr<s_battleground_queue> bg_queue;
  609. bool bg_queue_accept_state; // Set this to true when someone has accepted the invite to join BGs
  610. //Quest log system
  611. int num_quests; ///< Number of entries in quest_log
  612. int avail_quests; ///< Number of Q_ACTIVE and Q_INACTIVE entries in quest log (index of the first Q_COMPLETE entry)
  613. struct quest *quest_log; ///< Quest log entries (note: Q_COMPLETE quests follow the first <avail_quests>th enties
  614. bool save_quest; ///< Whether the quest_log entries were modified and are waitin to be saved
  615. // Achievement log system
  616. struct s_achievement_data {
  617. int total_score; ///< Total achievement points
  618. int level; ///< Achievement level
  619. bool save; ///< Flag to know if achievements need to be saved
  620. uint16 count; ///< Total achievements in log
  621. uint16 incompleteCount; ///< Total incomplete achievements in log
  622. struct achievement *achievements; ///< Achievement log entries
  623. } achievement_data;
  624. // Title system
  625. std::vector<int> titles;
  626. std::vector<int> cloaked_npc;
  627. /* ShowEvent Data Cache flags from map */
  628. bool *qi_display;
  629. int qi_count;
  630. // temporary debug [flaviojs]
  631. const char* debug_file;
  632. int debug_line;
  633. const char* debug_func;
  634. int bg_id;
  635. #ifdef SECURE_NPCTIMEOUT
  636. /**
  637. * ID of the timer
  638. * @info
  639. * - value is -1 (INVALID_TIMER constant) when not being used
  640. * - timer is cancelled upon closure of the current npc's instance
  641. **/
  642. int npc_idle_timer;
  643. /**
  644. * Tick on the last recorded NPC iteration (next/menu/whatever)
  645. * @info
  646. * - It is updated on every NPC iteration as mentioned above
  647. **/
  648. t_tick npc_idle_tick;
  649. /* */
  650. enum npc_timeout_type npc_idle_type;
  651. #endif
  652. struct s_combos {
  653. struct script_code **bonus;/* the script */
  654. unsigned short *id;/* array of combo ids */
  655. unsigned int *pos;/* array of positions*/
  656. unsigned char count;
  657. } combos;
  658. /**
  659. * Guarantees your friend request is legit (for bugreport:4629)
  660. **/
  661. int friend_req;
  662. int shadowform_id;
  663. /* Channel System [Ind] */
  664. struct Channel **channels;
  665. unsigned char channel_count;
  666. struct Channel *gcbind;
  667. bool stealth;
  668. unsigned char fontcolor;
  669. t_tick *channel_tick;
  670. /* [Ind] */
  671. struct sc_display_entry **sc_display;
  672. unsigned char sc_display_count;
  673. unsigned char delayed_damage; //[Ind]
  674. /**
  675. * Account/Char variables & array control of those variables
  676. **/
  677. struct reg_db regs;
  678. unsigned char vars_received; // char loading is only complete when you get it all.
  679. bool vars_ok;
  680. bool vars_dirty;
  681. uint16 dmglog[DAMAGELOG_SIZE_PC]; ///target ids
  682. int c_marker[MAX_SKILL_CRIMSON_MARKER]; /// Store target that marked by Crimson Marker [Cydh]
  683. bool flicker; /// Check RL_FLICKER usage status [Cydh]
  684. #ifdef VIP_ENABLE
  685. struct vip_info vip;
  686. #endif
  687. /// Bonus Script [Cydh]
  688. struct s_bonus_script_list {
  689. struct linkdb_node *head; ///< Bonus script head node. data: struct s_bonus_script_entry *entry, key: (intptr_t)entry
  690. uint16 count;
  691. } bonus_script;
  692. struct s_pc_resSC **resSC;
  693. unsigned short resSC_count;
  694. /* Expiration Timer ID */
  695. int expiration_tid;
  696. time_t expiration_time;
  697. short last_addeditem_index; /// Index of latest item added
  698. int autotrade_tid;
  699. int respawn_tid;
  700. int bank_vault; ///< Bank Vault
  701. #ifdef PACKET_OBFUSCATION
  702. unsigned int cryptKey; ///< Packet obfuscation key to be used for the next received packet
  703. #endif
  704. struct {
  705. int bronze, silver, gold; ///< Roulette Coin
  706. } roulette_point;
  707. struct {
  708. short stage;
  709. int8 prizeIdx;
  710. short prizeStage;
  711. bool claimPrize;
  712. t_tick tick;
  713. } roulette;
  714. unsigned short instance_id;
  715. short setlook_head_top, setlook_head_mid, setlook_head_bottom, setlook_robe; ///< Stores 'setlook' script command values.
  716. unsigned int last_lapine_box;
  717. bool pet_auto_feed;
  718. #if PACKETVER >= 20150513
  719. uint32* hatEffectIDs;
  720. uint8 hatEffectCount;
  721. #endif
  722. };
  723. extern struct eri *pc_sc_display_ers; /// Player's SC display table
  724. extern struct eri *pc_resSC_ers; /// Player's bResSC table
  725. /**
  726. * ERS for the bulk of pc vars
  727. **/
  728. extern struct eri *num_reg_ers;
  729. extern struct eri *str_reg_ers;
  730. /* Global Expiration Timer ID */
  731. extern int pc_expiration_tid;
  732. enum weapon_type {
  733. W_FIST, //Bare hands
  734. W_DAGGER, //1
  735. W_1HSWORD, //2
  736. W_2HSWORD, //3
  737. W_1HSPEAR, //4
  738. W_2HSPEAR, //5
  739. W_1HAXE, //6
  740. W_2HAXE, //7
  741. W_MACE, //8
  742. W_2HMACE, //9 (unused)
  743. W_STAFF, //10
  744. W_BOW, //11
  745. W_KNUCKLE, //12
  746. W_MUSICAL, //13
  747. W_WHIP, //14
  748. W_BOOK, //15
  749. W_KATAR, //16
  750. W_REVOLVER, //17
  751. W_RIFLE, //18
  752. W_GATLING, //19
  753. W_SHOTGUN, //20
  754. W_GRENADE, //21
  755. W_HUUMA, //22
  756. W_2HSTAFF, //23
  757. MAX_WEAPON_TYPE,
  758. // dual-wield constants
  759. W_DOUBLE_DD, // 2 daggers
  760. W_DOUBLE_SS, // 2 swords
  761. W_DOUBLE_AA, // 2 axes
  762. W_DOUBLE_DS, // dagger + sword
  763. W_DOUBLE_DA, // dagger + axe
  764. W_DOUBLE_SA, // sword + axe
  765. MAX_WEAPON_TYPE_ALL,
  766. };
  767. #define WEAPON_TYPE_ALL ((1<<MAX_WEAPON_TYPE)-1)
  768. enum ammo_type {
  769. A_ARROW = 1,
  770. A_DAGGER, //2
  771. A_BULLET, //3
  772. A_SHELL, //4
  773. A_GRENADE, //5
  774. A_SHURIKEN, //6
  775. A_KUNAI, //7
  776. A_CANNONBALL, //8
  777. A_THROWWEAPON //9
  778. };
  779. enum idletime_option {
  780. IDLE_WALK = 0x001,
  781. IDLE_USESKILLTOID = 0x002,
  782. IDLE_USESKILLTOPOS = 0x004,
  783. IDLE_USEITEM = 0x008,
  784. IDLE_ATTACK = 0x010,
  785. IDLE_CHAT = 0x020,
  786. IDLE_SIT = 0x040,
  787. IDLE_EMOTION = 0x080,
  788. IDLE_DROPITEM = 0x100,
  789. IDLE_ATCOMMAND = 0x200,
  790. };
  791. enum adopt_responses {
  792. ADOPT_ALLOWED = 0,
  793. ADOPT_ALREADY_ADOPTED,
  794. ADOPT_MARRIED_AND_PARTY,
  795. ADOPT_EQUIP_RINGS,
  796. ADOPT_NOT_NOVICE,
  797. ADOPT_CHARACTER_NOT_FOUND,
  798. ADOPT_MORE_CHILDREN,
  799. ADOPT_LEVEL_70,
  800. ADOPT_MARRIED,
  801. };
  802. enum item_check {
  803. ITMCHK_NONE = 0x0,
  804. ITMCHK_INVENTORY = 0x1,
  805. ITMCHK_CART = 0x2,
  806. ITMCHK_STORAGE = 0x4,
  807. ITMCHK_ALL = ITMCHK_INVENTORY|ITMCHK_CART|ITMCHK_STORAGE,
  808. };
  809. struct s_job_info {
  810. unsigned int base_hp[MAX_LEVEL], base_sp[MAX_LEVEL]; //Storage for the first calculation with hp/sp factor and multiplicator
  811. int hp_factor, hp_multiplicator, sp_factor;
  812. int max_weight_base;
  813. char job_bonus[MAX_LEVEL];
  814. #ifdef RENEWAL_ASPD
  815. int aspd_base[MAX_WEAPON_TYPE+1];
  816. #else
  817. int aspd_base[MAX_WEAPON_TYPE]; //[blackhole89]
  818. #endif
  819. uint64 exp_table[2][MAX_LEVEL];
  820. uint32 max_level[2];
  821. struct s_params {
  822. uint16 str, agi, vit, int_, dex, luk;
  823. } max_param;
  824. struct s_job_noenter_map {
  825. uint32 zone;
  826. uint8 group_lv;
  827. } noenter_map;
  828. };
  829. extern struct s_job_info job_info[CLASS_COUNT];
  830. #define EQP_WEAPON EQP_HAND_R
  831. #define EQP_SHIELD EQP_HAND_L
  832. #define EQP_ARMS (EQP_HAND_R|EQP_HAND_L)
  833. #define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
  834. #define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
  835. #define EQP_COSTUME (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW|EQP_COSTUME_GARMENT)
  836. #define EQP_COSTUME_HELM (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW)
  837. #define EQP_SHADOW_GEAR (EQP_SHADOW_ARMOR|EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD|EQP_SHADOW_SHOES|EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  838. #define EQP_SHADOW_ACC (EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  839. #define EQP_SHADOW_ARMS (EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD)
  840. /// Equip positions that use a visible sprite
  841. #if PACKETVER < 20110111
  842. #define EQP_VISIBLE EQP_HELM
  843. #else
  844. #define EQP_VISIBLE (EQP_HELM|EQP_GARMENT|EQP_COSTUME)
  845. #endif
  846. #define pc_setdead(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 1 )
  847. #define pc_setsit(sd) { pc_stop_walking((sd), 1|4); pc_stop_attack((sd)); (sd)->state.dead_sit = (sd)->vd.dead_sit = 2; }
  848. #define pc_isdead(sd) ( (sd)->state.dead_sit == 1 )
  849. #define pc_issit(sd) ( (sd)->vd.dead_sit == 2 )
  850. #define pc_isidle_party(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
  851. #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 ) )
  852. #define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading )
  853. #define pc_cant_act(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chatID || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend || (sd)->state.refineui_open || (sd)->state.lapine_ui )
  854. /* equals pc_cant_act except it doesn't check for chat rooms or npcs */
  855. #define pc_cant_act2(sd) ( (sd)->state.vending || (sd)->state.buyingstore || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend || (sd)->state.lapine_ui )
  856. #define pc_setdir(sd,b,h) ( (sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
  857. #define pc_setchatid(sd,n) ( (sd)->chatID = n )
  858. #define pc_ishiding(sd) ( (sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) )
  859. #define pc_iscloaking(sd) ( !((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK) )
  860. #define pc_ischasewalk(sd) ( (sd)->sc.option&OPTION_CHASEWALK )
  861. #ifdef VIP_ENABLE
  862. #define pc_isvip(sd) ( sd->vip.enabled ? true : false )
  863. #else
  864. #define pc_isvip(sd) ( false )
  865. #endif
  866. #ifdef NEW_CARTS
  867. #define pc_iscarton(sd) ( (sd)->sc.data[SC_PUSH_CART] )
  868. #else
  869. #define pc_iscarton(sd) ( (sd)->sc.option&OPTION_CART )
  870. #endif
  871. #define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
  872. #define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
  873. #define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
  874. #define pc_is50overweight(sd) ( (sd)->weight * 100 >= (sd)->max_weight * battle_config.natural_heal_weight_rate )
  875. #define pc_is70overweight(sd) ( (sd)->weight * 100 >= (sd)->max_weight * battle_config.natural_heal_weight_rate_renewal )
  876. #define pc_is90overweight(sd) ( (sd)->weight * 10 >= (sd)->max_weight * 9 )
  877. static inline bool pc_hasprogress(struct map_session_data *sd, enum e_wip_block progress) {
  878. return sd == NULL || (sd->state.workinprogress&progress) == progress;
  879. }
  880. /// Enum of Player's Parameter
  881. enum e_params {
  882. PARAM_STR = 0,
  883. PARAM_AGI,
  884. PARAM_VIT,
  885. PARAM_INT,
  886. PARAM_DEX,
  887. PARAM_LUK,
  888. PARAM_MAX
  889. };
  890. short pc_maxparameter(struct map_session_data *sd, enum e_params param);
  891. short pc_maxaspd(struct map_session_data *sd);
  892. /**
  893. * Ranger
  894. **/
  895. #define pc_iswug(sd) ( (sd)->sc.option&OPTION_WUG )
  896. #define pc_isridingwug(sd) ( (sd)->sc.option&OPTION_WUGRIDER )
  897. // Mechanic Magic Gear
  898. #define pc_ismadogear(sd) ( (sd)->sc.option&OPTION_MADOGEAR )
  899. // Rune Knight Dragon
  900. #define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON )
  901. #define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type)
  902. #define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl)
  903. //Weapon check considering dual wielding.
  904. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
  905. 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon)))
  906. //Checks if the given class value corresponds to a player class. [Skotlex]
  907. //JOB_NOVICE isn't checked for class_ is supposed to be unsigned
  908. #define pcdb_checkid_sub(class_) ( \
  909. ( (class_) < JOB_MAX_BASIC ) || \
  910. ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) || \
  911. ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) || \
  912. ( (class_) >= JOB_BABY_RUNE_KNIGHT && (class_) <= JOB_BABY_MECHANIC2 ) || \
  913. ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) || \
  914. ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) || \
  915. (class_) == JOB_REBELLION || (class_) == JOB_SUMMONER || \
  916. (class_) == JOB_BABY_SUMMONER || \
  917. ( (class_) >= JOB_BABY_NINJA && (class_) <= JOB_BABY_REBELLION ) || \
  918. ( (class_) >= JOB_BABY_STAR_GLADIATOR2 && (class_) <= JOB_BABY_STAR_EMPEROR2 ) \
  919. )
  920. #define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_)
  921. // clientside display macros (values to the left/right of the "+")
  922. #ifdef RENEWAL
  923. #define pc_leftside_atk(sd) ((sd)->battle_status.batk)
  924. #define pc_rightside_atk(sd) ((sd)->battle_status.watk + (sd)->battle_status.watk2 + (sd)->battle_status.eatk)
  925. #define pc_leftside_def(sd) ((sd)->battle_status.def2)
  926. #define pc_rightside_def(sd) ((sd)->battle_status.def)
  927. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2)
  928. #define pc_rightside_mdef(sd) ((sd)->battle_status.mdef)
  929. #define pc_leftside_matk(sd) (status_base_matk_min(&(sd)->bl, status_get_status_data(&(sd)->bl), (sd)->status.base_level))
  930. #define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk)
  931. #else
  932. #define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk)
  933. #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2)
  934. #define pc_leftside_def(sd) ((sd)->battle_status.def)
  935. #define pc_rightside_def(sd) ((sd)->battle_status.def2)
  936. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef)
  937. #define pc_rightside_mdef(sd) ( (sd)->battle_status.mdef2 - ((sd)->battle_status.vit>>1) )
  938. #define pc_leftside_matk(sd) \
  939. (\
  940. ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
  941. ?((sd)->battle_status.matk_min * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
  942. :(sd)->battle_status.matk_min \
  943. )
  944. #define pc_rightside_matk(sd) \
  945. (\
  946. ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
  947. ?((sd)->battle_status.matk_max * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
  948. :(sd)->battle_status.matk_max \
  949. )
  950. #endif
  951. struct s_attendance_reward {
  952. uint16 item_id;
  953. uint16 amount;
  954. };
  955. struct s_attendance_period {
  956. uint32 start;
  957. uint32 end;
  958. std::map<uint32, std::shared_ptr<struct s_attendance_reward>> rewards;
  959. };
  960. class AttendanceDatabase : public TypesafeYamlDatabase<uint32, s_attendance_period> {
  961. public:
  962. AttendanceDatabase() : TypesafeYamlDatabase("ATTENDANCE_DB", 1) {
  963. }
  964. const std::string getDefaultLocation();
  965. uint64 parseBodyNode(const YAML::Node &node);
  966. };
  967. extern AttendanceDatabase attendance_db;
  968. /// Enum of Summoner Power of
  969. enum e_summoner_power_type {
  970. SUMMONER_POWER_LAND = 0,
  971. SUMMONER_POWER_LIFE,
  972. SUMMONER_POWER_SEA,
  973. };
  974. void pc_set_reg_load(bool val);
  975. int pc_split_atoi(char* str, int* val, char sep, int max);
  976. int pc_class2idx(int class_);
  977. int pc_get_group_level(struct map_session_data *sd);
  978. int pc_get_group_id(struct map_session_data *sd);
  979. bool pc_can_sell_item(struct map_session_data* sd, struct item * item, enum npc_subtype shoptype);
  980. bool pc_can_give_items(struct map_session_data *sd);
  981. bool pc_can_give_bounded_items(struct map_session_data *sd);
  982. bool pc_can_trade_item(map_session_data *sd, int index);
  983. bool pc_can_use_command(struct map_session_data *sd, const char *command, AtCommandType type);
  984. #define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
  985. bool pc_should_log_commands(struct map_session_data *sd);
  986. void pc_setrestartvalue(struct map_session_data *sd, char type);
  987. void pc_makesavestatus(struct map_session_data *sd);
  988. void pc_respawn(struct map_session_data* sd, clr_type clrtype);
  989. 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);
  990. 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);
  991. void pc_authfail(struct map_session_data *sd);
  992. void pc_reg_received(struct map_session_data *sd);
  993. void pc_close_npc(struct map_session_data *sd,int flag);
  994. TIMER_FUNC(pc_close_npc_timer);
  995. void pc_setequipindex(struct map_session_data *sd);
  996. uint8 pc_isequip(struct map_session_data *sd,int n);
  997. int pc_equippoint(struct map_session_data *sd,int n);
  998. int pc_equippoint_sub(struct map_session_data *sd, struct item_data* id);
  999. void pc_setinventorydata(struct map_session_data *sd);
  1000. int pc_get_skillcooldown(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
  1001. uint8 pc_checkskill(struct map_session_data *sd,uint16 skill_id);
  1002. uint8 pc_checkskill_summoner(map_session_data *sd, e_summoner_power_type type);
  1003. short pc_checkequip(struct map_session_data *sd,int pos,bool checkall=false);
  1004. bool pc_checkequip2(struct map_session_data *sd, unsigned short nameid, int min, int max);
  1005. void pc_scdata_received(struct map_session_data *sd);
  1006. void pc_check_expiration(struct map_session_data *sd);
  1007. TIMER_FUNC(pc_expiration_timer);
  1008. TIMER_FUNC(pc_global_expiration_timer);
  1009. void pc_expire_check(struct map_session_data *sd);
  1010. void pc_calc_skilltree(struct map_session_data *sd);
  1011. int pc_calc_skilltree_normalize_job(struct map_session_data *sd);
  1012. void pc_clean_skilltree(struct map_session_data *sd);
  1013. #define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
  1014. #define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
  1015. enum e_setpos{
  1016. SETPOS_OK = 0,
  1017. SETPOS_MAPINDEX = 1,
  1018. SETPOS_NO_MAPSERVER = 2,
  1019. SETPOS_AUTOTRADE = 3
  1020. };
  1021. enum e_setpos pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
  1022. void pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y);
  1023. char pc_randomwarp(struct map_session_data *sd,clr_type type);
  1024. bool pc_memo(struct map_session_data* sd, int pos);
  1025. char pc_checkadditem(struct map_session_data *sd, unsigned short nameid, int amount);
  1026. uint8 pc_inventoryblank(struct map_session_data *sd);
  1027. short pc_search_inventory(struct map_session_data *sd, unsigned short nameid);
  1028. char pc_payzeny(struct map_session_data *sd, int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
  1029. enum e_additem_result pc_additem(struct map_session_data *sd, struct item *item, int amount, e_log_pick_type log_type);
  1030. char pc_getzeny(struct map_session_data *sd, int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
  1031. char pc_delitem(struct map_session_data *sd, int n, int amount, int type, short reason, e_log_pick_type log_type);
  1032. uint64 pc_generate_unique_id(struct map_session_data *sd);
  1033. //Bound items
  1034. int pc_bound_chk(TBL_PC *sd,enum bound_type type,int *idxlist);
  1035. // Special Shop System
  1036. int pc_paycash( struct map_session_data *sd, int price, int points, e_log_pick_type type );
  1037. int pc_getcash( struct map_session_data *sd, int cash, int points, e_log_pick_type type );
  1038. enum e_additem_result pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
  1039. void pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
  1040. void pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
  1041. void pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
  1042. int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
  1043. bool pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem);
  1044. bool pc_dropitem(struct map_session_data *sd,int n,int amount);
  1045. void pc_lootevent(struct map_session_data *sd, struct item *vitem);
  1046. bool pc_isequipped(struct map_session_data *sd, unsigned short nameid);
  1047. enum adopt_responses pc_try_adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
  1048. bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
  1049. void pc_updateweightstatus(struct map_session_data *sd);
  1050. bool pc_addautobonus(std::vector<s_autobonus> &bonus, const char *script, short rate, unsigned int dur, uint16 atk_type, const char *o_script, unsigned int pos, bool onskill);
  1051. void pc_exeautobonus(struct map_session_data* sd, std::vector<s_autobonus> *bonus, struct s_autobonus *autobonus);
  1052. TIMER_FUNC(pc_endautobonus);
  1053. void pc_delautobonus(struct map_session_data* sd, std::vector<s_autobonus> &bonus, bool restore);
  1054. void pc_bonus(struct map_session_data *sd, int type, int val);
  1055. void pc_bonus2(struct map_session_data *sd, int type, int type2, int val);
  1056. void pc_bonus3(struct map_session_data *sd, int type, int type2, int type3, int val);
  1057. void pc_bonus4(struct map_session_data *sd, int type, int type2, int type3, int type4, int val);
  1058. void pc_bonus5(struct map_session_data *sd, int type, int type2, int type3, int type4, int type5, int val);
  1059. enum e_addskill_type {
  1060. ADDSKILL_PERMANENT = 0, ///< Permanent skill. Remove the skill if level is 0
  1061. 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;`
  1062. 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
  1063. ADDSKILL_PERMANENT_GRANTED = 3, ///< Grant permanent skill, ignore skill tree and learned level
  1064. };
  1065. bool pc_skill(struct map_session_data *sd, uint16 skill_id, int level, enum e_addskill_type type);
  1066. int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
  1067. int pc_identifyall(struct map_session_data *sd, bool identify_item);
  1068. bool pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv);
  1069. int pc_steal_coin(struct map_session_data *sd,struct block_list *bl);
  1070. int pc_modifybuyvalue(struct map_session_data*,int);
  1071. int pc_modifysellvalue(struct map_session_data*,int);
  1072. int pc_follow(struct map_session_data*, int); // [MouseJstr]
  1073. int pc_stop_following(struct map_session_data*);
  1074. unsigned int pc_maxbaselv(struct map_session_data *sd);
  1075. unsigned int pc_maxjoblv(struct map_session_data *sd);
  1076. bool pc_is_maxbaselv(struct map_session_data *sd);
  1077. bool pc_is_maxjoblv(struct map_session_data *sd);
  1078. int pc_checkbaselevelup(struct map_session_data *sd);
  1079. int pc_checkjoblevelup(struct map_session_data *sd);
  1080. void pc_gainexp(struct map_session_data *sd, struct block_list *src, uint64 base_exp, uint64 job_exp, uint8 exp_flag);
  1081. void pc_gainexp_disp(struct map_session_data *sd, uint64 base_exp, uint64 next_base_exp, uint64 job_exp, uint64 next_job_exp, bool lost);
  1082. void pc_lostexp(struct map_session_data *sd, uint64 base_exp, uint64 job_exp);
  1083. uint64 pc_nextbaseexp(struct map_session_data *sd);
  1084. uint64 pc_nextjobexp(struct map_session_data *sd);
  1085. int pc_gets_status_point(int);
  1086. int pc_need_status_point(struct map_session_data *,int,int);
  1087. int pc_maxparameterincrease(struct map_session_data*,int);
  1088. bool pc_statusup(struct map_session_data*,int,int);
  1089. int pc_statusup2(struct map_session_data*,int,int);
  1090. void pc_skillup(struct map_session_data*,uint16 skill_id);
  1091. int pc_allskillup(struct map_session_data*);
  1092. int pc_resetlvl(struct map_session_data*,int type);
  1093. int pc_resetstate(struct map_session_data*);
  1094. int pc_resetskill(struct map_session_data*, int);
  1095. int pc_resetfeel(struct map_session_data*);
  1096. int pc_resethate(struct map_session_data*);
  1097. bool pc_equipitem(struct map_session_data *sd, short n, int req_pos, bool equipswitch=false);
  1098. bool pc_unequipitem(struct map_session_data*,int,int);
  1099. int pc_equipswitch( struct map_session_data* sd, int index );
  1100. void pc_equipswitch_remove( struct map_session_data* sd, int index );
  1101. void pc_checkitem(struct map_session_data*);
  1102. void pc_check_available_item(struct map_session_data *sd, uint8 type);
  1103. int pc_useitem(struct map_session_data*,int);
  1104. int pc_skillatk_bonus(struct map_session_data *sd, uint16 skill_id);
  1105. int pc_sub_skillatk_bonus(struct map_session_data *sd, uint16 skill_id);
  1106. int pc_skillheal_bonus(struct map_session_data *sd, uint16 skill_id);
  1107. int pc_skillheal2_bonus(struct map_session_data *sd, uint16 skill_id);
  1108. void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp);
  1109. int pc_dead(struct map_session_data *sd,struct block_list *src);
  1110. void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp);
  1111. bool pc_revive_item(struct map_session_data *sd);
  1112. void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int type);
  1113. int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp);
  1114. int pc_percentheal(struct map_session_data *sd,int,int);
  1115. bool pc_jobchange(struct map_session_data *sd, int job, char upper);
  1116. void pc_setoption(struct map_session_data *,int);
  1117. bool pc_setcart(struct map_session_data* sd, int type);
  1118. void pc_setfalcon(struct map_session_data* sd, int flag);
  1119. void pc_setriding(struct map_session_data* sd, int flag);
  1120. void pc_setmadogear(struct map_session_data* sd, int flag);
  1121. void pc_changelook(struct map_session_data *,int,int);
  1122. void pc_equiplookall(struct map_session_data *sd);
  1123. void pc_set_costume_view(struct map_session_data *sd);
  1124. int64 pc_readparam(struct map_session_data *sd, int64 type);
  1125. bool pc_setparam(struct map_session_data *sd, int64 type, int64 val);
  1126. int64 pc_readreg(struct map_session_data *sd, int64 reg);
  1127. bool pc_setreg(struct map_session_data *sd, int64 reg, int64 val);
  1128. char *pc_readregstr(struct map_session_data *sd, int64 reg);
  1129. bool pc_setregstr(struct map_session_data *sd, int64 reg, const char *str);
  1130. int64 pc_readregistry(struct map_session_data *sd, int64 reg);
  1131. bool pc_setregistry(struct map_session_data *sd, int64 reg, int64 val);
  1132. char *pc_readregistry_str(struct map_session_data *sd, int64 reg);
  1133. bool pc_setregistry_str(struct map_session_data *sd, int64 reg, const char *val);
  1134. #define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg)
  1135. #define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val)
  1136. #define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg)
  1137. #define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1138. #define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg)
  1139. #define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val)
  1140. #define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg)
  1141. #define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1142. #define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg)
  1143. #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val)
  1144. #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg)
  1145. #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1146. bool pc_setreg2(struct map_session_data *sd, const char *reg, int64 val);
  1147. int64 pc_readreg2(struct map_session_data *sd, const char *reg);
  1148. bool pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
  1149. bool pc_deleventtimer(struct map_session_data *sd,const char *name);
  1150. void pc_cleareventtimer(struct map_session_data *sd);
  1151. void pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick);
  1152. int pc_calc_pvprank(struct map_session_data *sd);
  1153. TIMER_FUNC(pc_calc_pvprank_timer);
  1154. int pc_ismarried(struct map_session_data *sd);
  1155. bool pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd);
  1156. bool pc_divorce(struct map_session_data *sd);
  1157. struct map_session_data *pc_get_partner(struct map_session_data *sd);
  1158. struct map_session_data *pc_get_father(struct map_session_data *sd);
  1159. struct map_session_data *pc_get_mother(struct map_session_data *sd);
  1160. struct map_session_data *pc_get_child(struct map_session_data *sd);
  1161. void pc_bleeding (struct map_session_data *sd, t_tick diff_tick);
  1162. void pc_regen (struct map_session_data *sd, t_tick diff_tick);
  1163. bool pc_setstand(struct map_session_data *sd, bool force);
  1164. bool pc_candrop(struct map_session_data *sd,struct item *item);
  1165. bool pc_can_attack(struct map_session_data *sd, int target_id);
  1166. int pc_jobid2mapid(unsigned short b_class); // Skotlex
  1167. int pc_mapid2jobid(unsigned short class_, int sex); // Skotlex
  1168. const char * job_name(int class_);
  1169. struct skill_tree_entry {
  1170. uint16 skill_id, skill_lv;
  1171. uint32 baselv, joblv;
  1172. struct {
  1173. uint16 skill_i