pc.hpp 50 KB

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