pc.hpp 50 KB

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