pc.h 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef _PC_H_
  4. #define _PC_H_
  5. #include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
  6. #include "../common/timer.h" // INVALID_TIMER
  7. #include "map.h" // RC_ALL
  8. #include "atcommand.h" // AtCommandType
  9. #include "battle.h" // battle_config
  10. #include "buyingstore.h" // struct s_buyingstore
  11. #include "itemdb.h" // MAX_ITEMGROUP
  12. #include "script.h" // struct script_reg, struct script_regstr
  13. #include "searchstore.h" // struct s_search_store_info
  14. #include "status.h" // OPTION_*, struct weapon_atk
  15. #include "unit.h" // unit_stop_attack(), unit_stop_walking()
  16. #include "vending.h" // struct s_vending
  17. #include "mob.h"
  18. #include "log.h"
  19. #include "pc_groups.h"
  20. #define MAX_PC_BONUS 10
  21. #define MAX_PC_SKILL_REQUIRE 5
  22. #define MAX_PC_FEELHATE 3
  23. #define DAMAGELOG_SIZE_PC 100 // Any idea for this value?
  24. #define MAX_PC_BONUS_SCRIPT 20
  25. //Update this max as necessary. 55 is the value needed for Super Baby currently
  26. //Raised to 84 since Expanded Super Novice needs it.
  27. #define MAX_SKILL_TREE 84
  28. //Total number of classes (for data storage)
  29. #define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
  30. //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
  31. //where the arrows are equipped)
  32. enum equip_index {
  33. EQI_ACC_L = 0,
  34. EQI_ACC_R,
  35. EQI_SHOES,
  36. EQI_GARMENT,
  37. EQI_HEAD_LOW,
  38. EQI_HEAD_MID,
  39. EQI_HEAD_TOP,
  40. EQI_ARMOR,
  41. EQI_HAND_L,
  42. EQI_HAND_R,
  43. EQI_COSTUME_TOP,
  44. EQI_COSTUME_MID,
  45. EQI_COSTUME_LOW,
  46. EQI_COSTUME_GARMENT,
  47. EQI_AMMO,
  48. EQI_SHADOW_ARMOR,
  49. EQI_SHADOW_WEAPON,
  50. EQI_SHADOW_SHIELD,
  51. EQI_SHADOW_SHOES,
  52. EQI_SHADOW_ACC_R,
  53. EQI_SHADOW_ACC_L,
  54. EQI_MAX
  55. };
  56. struct weapon_data {
  57. int atkmods[3];
  58. // all the variables except atkmods get zero'ed in each call of status_calc_pc
  59. // NOTE: if you want to add a non-zeroed variable, you need to update the memset call
  60. // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex]
  61. int overrefine;
  62. int star;
  63. int ignore_def_ele;
  64. int ignore_def_race;
  65. int ignore_def_class;
  66. int def_ratio_atk_ele;
  67. int def_ratio_atk_race;
  68. int def_ratio_atk_class;
  69. int addele[ELE_NONE];
  70. int addrace[RC_MAX];
  71. int addclass[CLASS_MAX];
  72. int addrace2[RC2_MAX];
  73. int addsize[SZ_MAX];
  74. struct drain_data {
  75. short rate;
  76. short per;
  77. short value;
  78. unsigned type:1;
  79. } hp_drain_race[RC_MAX], sp_drain_race[RC_MAX], hp_drain_class[CLASS_MAX], sp_drain_class[CLASS_MAX];
  80. struct {
  81. short class_, rate;
  82. } add_dmg[MAX_PC_BONUS];
  83. struct {
  84. short flag, rate;
  85. unsigned char ele;
  86. } addele2[MAX_PC_BONUS];
  87. };
  88. struct s_autospell {
  89. short id, lv, rate, card_id, flag;
  90. bool lock; // bAutoSpellOnSkill: blocks autospell from triggering again, while being executed
  91. };
  92. struct s_addeffect {
  93. enum sc_type id;
  94. short rate, arrow_rate;
  95. unsigned char flag;
  96. };
  97. struct s_addeffectonskill {
  98. enum sc_type id;
  99. short rate, skill;
  100. unsigned char target;
  101. };
  102. ///Struct of add drop item/group rate
  103. struct s_add_drop {
  104. uint16 nameid, ///Item ID
  105. group; ///Group ID
  106. int rate; ///Rate, 1 ~ 10000, -1 ~ -100000
  107. char race, ///Target Race, bitwise value of 1<<x. if < 0 means Monster ID
  108. class_; ///Target Class, bitwise value of 1<<x
  109. };
  110. struct s_autobonus {
  111. short rate,atk_type;
  112. unsigned int duration;
  113. char *bonus_script, *other_script;
  114. int active;
  115. unsigned short pos;
  116. };
  117. struct skill_cooldown_entry {
  118. unsigned short skill_id;
  119. int timer;
  120. };
  121. #ifdef VIP_ENABLE
  122. struct vip_info {
  123. unsigned int enabled : 1;
  124. time_t time;
  125. };
  126. #endif
  127. enum npc_timeout_type {
  128. NPCT_INPUT = 0,
  129. NPCT_MENU = 1,
  130. NPCT_WAIT = 2,
  131. };
  132. struct map_session_data {
  133. struct block_list bl;
  134. struct unit_data ud;
  135. struct view_data vd;
  136. struct status_data base_status, battle_status;
  137. struct status_change sc;
  138. struct regen_data regen;
  139. struct regen_data_sub sregen, ssregen;
  140. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
  141. //status_calc_pc, while special_state is recalculated in each call. [Skotlex]
  142. struct s_state {
  143. unsigned int active : 1; //Marks active player (not active is logging in/out, or changing map servers)
  144. unsigned int menu_or_input : 1;// if a script is waiting for feedback from the player
  145. unsigned int dead_sit : 2;
  146. unsigned int lr_flag : 3;//1: left h. weapon; 2: arrow; 3: shield
  147. unsigned int connect_new : 1;
  148. unsigned int arrow_atk : 1;
  149. unsigned int gangsterparadise : 1;
  150. unsigned int rest : 1;
  151. unsigned int storage_flag : 2; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex]
  152. unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
  153. unsigned int abra_flag : 2; // Abracadabra bugfix by Aru
  154. unsigned int autocast : 1; // Autospell flag [Inkfish]
  155. unsigned int autotrade : 1; //By Fantik
  156. unsigned int reg_dirty : 4; //By Skotlex (marks whether registry variables have been saved or not yet)
  157. unsigned int showdelay :1;
  158. unsigned int showexp :1;
  159. unsigned int showzeny :1;
  160. unsigned int noask :1; // [LuzZza]
  161. unsigned int trading :1; //[Skotlex] is 1 only after a trade has started.
  162. unsigned int deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
  163. unsigned int monster_ignore :1; // for monsters to ignore a character [Valaris] [zzo]
  164. unsigned int size :2; // for tiny/large types
  165. unsigned int night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
  166. unsigned int blockedmove :1;
  167. unsigned int using_fake_npc :1;
  168. unsigned int rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex]
  169. unsigned int killer : 1;
  170. unsigned int killable : 1;
  171. unsigned int doridori : 1;
  172. unsigned int ignoreAll : 1;
  173. unsigned int debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
  174. unsigned int buyingstore : 1;
  175. unsigned int lesseffect : 1;
  176. unsigned int vending : 1;
  177. unsigned int noks : 3; // [Zeph Kill Steal Protection]
  178. unsigned int changemap : 1;
  179. unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
  180. short pmap; // Previous map on Map Change
  181. unsigned short autoloot;
  182. unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
  183. unsigned short autoloottype;
  184. unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
  185. unsigned int autolootingtype : 1; //performance-saver, autolooting state for @autoloottype
  186. unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
  187. struct guild *gmaster_flag;
  188. unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
  189. unsigned int warping : 1;//states whether you're in the middle of a warp processing
  190. unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
  191. unsigned int banking : 1; //1 when we using the banking system 0 when closed
  192. unsigned int hpmeter_visible : 1;
  193. bool disable_atcommand_on_npc; //Prevent to use atcommand while talking with NPC [Kichi]
  194. } state;
  195. struct {
  196. unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
  197. unsigned int restart_full_recover : 1;
  198. unsigned int no_castcancel : 1;
  199. unsigned int no_castcancel2 : 1;
  200. unsigned int no_sizefix : 1;
  201. unsigned int no_gemstone : 2;
  202. unsigned int intravision : 1; // Maya Purple Card effect [DracoRPG]
  203. unsigned int perfect_hiding : 1; // [Valaris]
  204. unsigned int no_knockback : 1;
  205. unsigned int bonus_coma : 1;
  206. } special_state;
  207. int login_id1, login_id2;
  208. unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
  209. int group_id, group_pos, group_level;
  210. unsigned int permissions;/* group permissions */
  211. int langtype;
  212. uint32 packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 ... 18
  213. struct mmo_charstatus status;
  214. struct registry save_reg;
  215. struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
  216. int equip_index[EQI_MAX];
  217. unsigned int weight,max_weight;
  218. int cart_weight,cart_num,cart_weight_max;
  219. int fd;
  220. unsigned short mapindex;
  221. unsigned char head_dir; //0: Look forward. 1: Look right, 2: Look left.
  222. unsigned int client_tick;
  223. int npc_id,areanpc_id,npc_shopid,touching_id; //for script follow scriptoid; ,npcid
  224. int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
  225. int npc_menu; // internal variable, used in npc menu handling
  226. int npc_amount;
  227. struct script_state *st;
  228. char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
  229. int npc_timer_id; //For player attached npc timers. [Skotlex]
  230. unsigned int chatID;
  231. time_t idletime;
  232. struct s_progressbar {
  233. int npc_id;
  234. unsigned int timeout;
  235. } progressbar; //Progress Bar [Inkfish]
  236. struct s_ignore {
  237. char name[NAME_LENGTH];
  238. } ignore[MAX_IGNORE_LIST];
  239. int followtimer; // [MouseJstr]
  240. int followtarget;
  241. time_t emotionlasttime; // to limit flood with emotion packets
  242. short skillitem,skillitemlv;
  243. uint16 skill_id_old,skill_lv_old;
  244. uint16 skill_id_dance,skill_lv_dance;
  245. short cook_mastery; // range: [0,1999] [Inkfish]
  246. struct skill_cooldown_entry * scd[MAX_SKILLCOOLDOWN]; // Skill Cooldown
  247. short cloneskill_idx, ///Stores index of copied skill by Intimidate/Plagiarism
  248. reproduceskill_idx; ///Stores index of copied skill by Reproduce
  249. int menuskill_id, menuskill_val, menuskill_val2;
  250. int invincible_timer;
  251. unsigned int canlog_tick;
  252. unsigned int canuseitem_tick; // [Skotlex]
  253. unsigned int canusecashfood_tick;
  254. unsigned int canequip_tick; // [Inkfish]
  255. unsigned int cantalk_tick;
  256. unsigned int canskill_tick; // used to prevent abuse from no-delay ACT files
  257. unsigned int cansendmail_tick; // [Mail System Flood Protection]
  258. unsigned int ks_floodprotect_tick; // [Kill Steal Protection]
  259. struct s_item_delay {
  260. short nameid;
  261. unsigned int tick;
  262. } item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
  263. short weapontype1,weapontype2;
  264. short disguise; // [Valaris]
  265. struct weapon_data right_weapon, left_weapon;
  266. // here start arrays to be globally zeroed at the beginning of status_calc_pc()
  267. int param_bonus[6],param_equip[6]; //Stores card/equipment bonuses.
  268. int subele[ELE_NONE];
  269. int subrace[RC_MAX];
  270. int subclass[CLASS_MAX];
  271. int subrace2[RC2_MAX];
  272. int subsize[SZ_MAX];
  273. int reseff[SC_COMMON_MAX-SC_COMMON_MIN+1];
  274. int weapon_coma_ele[ELE_NONE];
  275. int weapon_coma_race[RC_MAX];
  276. int weapon_coma_class[CLASS_MAX];
  277. int weapon_atk[16];
  278. int weapon_atk_rate[16];
  279. int arrow_addele[ELE_NONE];
  280. int arrow_addrace[RC_MAX];
  281. int arrow_addclass[CLASS_MAX];
  282. int arrow_addsize[SZ_MAX];
  283. int magic_addele[ELE_NONE];
  284. int magic_addrace[RC_MAX];
  285. int magic_addclass[CLASS_MAX];
  286. int magic_addsize[SZ_MAX];
  287. int magic_atk_ele[ELE_NONE];
  288. int critaddrace[RC_MAX];
  289. int expaddrace[RC_MAX];
  290. int expaddclass[CLASS_MAX];
  291. int ignore_mdef_by_race[RC_MAX];
  292. int ignore_mdef_by_class[CLASS_MAX];
  293. int ignore_def_by_race[RC_MAX];
  294. int itemgrouphealrate[MAX_ITEMGROUP];
  295. short sp_gain_race[RC_MAX];
  296. short sp_gain_race_attack[RC_MAX];
  297. short hp_gain_race_attack[RC_MAX];
  298. // zeroed arrays end here.
  299. // zeroed structures start here
  300. struct s_autospell autospell[15], autospell2[15], autospell3[15];
  301. struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
  302. struct s_addeffectonskill addeff3[MAX_PC_BONUS];
  303. struct s_skill_bonus { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills.
  304. unsigned short id;
  305. short val;
  306. } skillatk[MAX_PC_BONUS], skillusesprate[MAX_PC_BONUS], skillusesp[MAX_PC_BONUS], skillheal[5], skillheal2[5], skillblown[MAX_PC_BONUS], skillcast[MAX_PC_BONUS], skillcooldown[MAX_PC_BONUS], skillfixcast[MAX_PC_BONUS], skillvarcast[MAX_PC_BONUS], skillfixcastrate[MAX_PC_BONUS];
  307. struct s_regen {
  308. short value;
  309. int rate;
  310. int tick;
  311. } hp_loss, sp_loss, hp_regen, sp_regen;
  312. struct {
  313. short class_, rate;
  314. } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
  315. struct s_add_drop add_drop[MAX_PC_BONUS];
  316. struct s_healrate {
  317. int nameid;
  318. int rate;
  319. } itemhealrate[MAX_PC_BONUS];
  320. struct s_subele2 {
  321. short flag, rate;
  322. unsigned char ele;
  323. } subele2[MAX_PC_BONUS];
  324. struct {
  325. short value;
  326. int rate, tick;
  327. } def_set_race[RC_MAX], mdef_set_race[RC_MAX];
  328. // zeroed structures end here
  329. // manually zeroed structures start here.
  330. struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage
  331. // manually zeroed structures end here.
  332. // zeroed vars start here.
  333. struct s_bonus {
  334. int hp, sp;
  335. int atk_rate;
  336. int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
  337. int nsshealhp,nsshealsp;
  338. int critical_def,double_rate;
  339. int long_attack_atk_rate; //Long range atk rate, not weapon based. [Skotlex]
  340. int near_attack_def_rate,long_attack_def_rate,magic_def_rate,misc_def_rate;
  341. int ignore_mdef_ele;
  342. int ignore_mdef_race;
  343. int ignore_mdef_class;
  344. int perfect_hit;
  345. int perfect_hit_add;
  346. int get_zeny_rate;
  347. int get_zeny_num; //Added Get Zeny Rate [Skotlex]
  348. int double_add_rate;
  349. int short_weapon_damage_return,long_weapon_damage_return;
  350. int magic_damage_return; // AppleGirl Was Here
  351. int break_weapon_rate,break_armor_rate;
  352. int crit_atk_rate;
  353. int classchange; // [Valaris]
  354. int speed_rate, speed_add_rate, aspd_add;
  355. int itemhealrate2; // [Epoque] Increase heal rate of all healing items.
  356. int shieldmdef;//royal guard's
  357. unsigned int setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
  358. short splash_range, splash_add_range;
  359. short add_steal_rate;
  360. short add_heal_rate, add_heal2_rate;
  361. short sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value;
  362. short sp_vanish_rate, hp_vanish_rate;
  363. short sp_vanish_per, hp_vanish_per;
  364. unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
  365. unsigned short unbreakable_equip; //100% break resistance on certain equipment
  366. unsigned short unstripable_equip;
  367. int fixcastrate,varcastrate;
  368. int add_fixcast,add_varcast;
  369. int ematk; // matk bonus from equipment
  370. int eatk; // atk bonus from equipment
  371. } bonus;
  372. // zeroed vars end here.
  373. int castrate,delayrate,hprate,sprate,dsprate;
  374. int hprecov_rate,sprecov_rate;
  375. int matk_rate;
  376. int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
  377. int itemid;
  378. short itemindex; //Used item's index in sd->inventory [Skotlex]
  379. short catch_target_class; // pet catching, stores a pet class to catch (short now) [zzo]
  380. short spiritball, spiritball_old;
  381. int spirit_timer[MAX_SKILL_LEVEL];
  382. short talisman[ELE_POISON+1]; // There are actually 5 talisman Fire, Ice, Wind, Earth & Poison maybe because its color violet.
  383. int talisman_timer[ELE_POISON+1][10];
  384. unsigned char potion_success_counter; //Potion successes in row counter
  385. unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
  386. short mission_mobid; //Stores the target mob_id for TK_MISSION
  387. int die_counter; //Total number of times you've died
  388. int devotion[5]; //Stores the account IDs of chars devoted to.
  389. int reg_num; //Number of registries (type numeric)
  390. int regstr_num; //Number of registries (type string)
  391. struct script_reg *reg;
  392. struct script_regstr *regstr;
  393. int trade_partner;
  394. struct s_deal {
  395. struct s_item {
  396. short index, amount;
  397. } item[10];
  398. int zeny, weight;
  399. } deal;
  400. bool party_creating; // whether the char is requesting party creation
  401. bool party_joining; // whether the char is accepting party invitation
  402. int party_invite, party_invite_account; // for handling party invitation (holds party id and account id)
  403. int adopt_invite; // Adoption
  404. struct guild *guild; // [Ind] speed everything up
  405. int guild_invite,guild_invite_account;
  406. int guild_emblem_id,guild_alliance,guild_alliance_account;
  407. short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo]
  408. int guildspy; // [Syrus22]
  409. int partyspy; // [Syrus22]
  410. int vended_id;
  411. int vender_id;
  412. int vend_num;
  413. char message[MESSAGE_SIZE];
  414. struct s_vending vending[MAX_VENDING];
  415. unsigned int buyer_id; // uid of open buying store
  416. struct s_buyingstore buyingstore;
  417. struct s_search_store_info searchstore;
  418. struct pet_data *pd;
  419. struct homun_data *hd; // [blackhole89]
  420. struct mercenary_data *md;
  421. struct elemental_data *ed;
  422. struct s_hate_mob {
  423. int m; //-1 - none, other: map index corresponding to map name.
  424. unsigned short index; //map index
  425. } feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
  426. short hate_mob[3];
  427. int pvp_timer;
  428. short pvp_point;
  429. unsigned short pvp_rank, pvp_lastusers;
  430. unsigned short pvp_won, pvp_lost;
  431. char eventqueue[MAX_EVENTQUEUE][EVENT_NAME_LENGTH];
  432. int eventtimer[MAX_EVENTTIMER];
  433. unsigned short eventcount; // [celest]
  434. unsigned char change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value]
  435. unsigned char change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value]
  436. char fakename[NAME_LENGTH]; // fake names [Valaris]
  437. int duel_group; // duel vars [LuzZza]
  438. int duel_invite;
  439. int killerrid, killedrid;
  440. int cashPoints, kafraPoints;
  441. int rental_timer;
  442. // Auction System [Zephyrus]
  443. struct s_auction{
  444. int index, amount;
  445. } auction;
  446. // Mail System [Zephyrus]
  447. struct s_mail {
  448. short nameid;
  449. int index, amount, zeny;
  450. struct mail_data inbox;
  451. bool changed; // if true, should sync with charserver on next mailbox request
  452. } mail;
  453. //Quest log system [Kevin] [Inkfish]
  454. int num_quests;
  455. int avail_quests;
  456. int quest_index[MAX_QUEST_DB];
  457. struct quest quest_log[MAX_QUEST_DB];
  458. bool save_quest;
  459. // temporary debug [flaviojs]
  460. const char* debug_file;
  461. int debug_line;
  462. const char* debug_func;
  463. unsigned int bg_id;
  464. unsigned short user_font;
  465. #ifdef SECURE_NPCTIMEOUT
  466. /**
  467. * ID of the timer
  468. * @info
  469. * - value is -1 (INVALID_TIMER constant) when not being used
  470. * - timer is cancelled upon closure of the current npc's instance
  471. **/
  472. int npc_idle_timer;
  473. /**
  474. * Tick on the last recorded NPC iteration (next/menu/whatever)
  475. * @info
  476. * - It is updated on every NPC iteration as mentioned above
  477. **/
  478. unsigned int npc_idle_tick;
  479. /* */
  480. enum npc_timeout_type npc_idle_type;
  481. #endif
  482. struct s_combos {
  483. struct script_code **bonus;/* the script */
  484. unsigned short *id;/* array of combo ids */
  485. unsigned char count;
  486. } combos;
  487. /**
  488. * Guarantees your friend request is legit (for bugreport:4629)
  489. **/
  490. int friend_req;
  491. int shadowform_id;
  492. /* Channel System [Ind] */
  493. struct Channel **channels;
  494. unsigned char channel_count;
  495. struct Channel *gcbind;
  496. bool stealth;
  497. unsigned char fontcolor; /* debug-only */
  498. unsigned int channel_tick;
  499. // temporary debugging of bug #3504
  500. const char* delunit_prevfile;
  501. int delunit_prevline;
  502. uint16 dmglog[DAMAGELOG_SIZE_PC]; ///target ids
  503. struct s_crimson_marker { ///Store target that marked by Crimson Marker [Cydh]
  504. int target[MAX_SKILL_CRIMSON_MARKER]; //Target id storage
  505. uint8 count; //Count of target for skill like RL_D_TAIL
  506. } c_marker;
  507. bool flicker; ///Is Flicker Skill skill as player's last action? [Cydh]
  508. int storage_size; /// Holds player storage size (VIP system).
  509. #ifdef VIP_ENABLE
  510. struct vip_info vip;
  511. bool disableshowrate; //State to disable clif_display_pinfo(). [Cydh]
  512. #endif
  513. ///Timed bonus 'bonus_script' struct [Cydh]
  514. struct s_script {
  515. struct script_code *script;
  516. char script_str[MAX_BONUS_SCRIPT_LENGTH]; //Used for comparing and storing on table
  517. uint32 tick;
  518. uint8 flag;
  519. char type; //0 - Ignore; 1 - Buff; 2 - Debuff
  520. int16 icon;
  521. int tid;
  522. } bonus_script[MAX_PC_BONUS_SCRIPT];
  523. };
  524. enum weapon_type {
  525. W_FIST, //Bare hands
  526. W_DAGGER, //1
  527. W_1HSWORD, //2
  528. W_2HSWORD, //3
  529. W_1HSPEAR, //4
  530. W_2HSPEAR, //5
  531. W_1HAXE, //6
  532. W_2HAXE, //7
  533. W_MACE, //8
  534. W_2HMACE, //9 (unused)
  535. W_STAFF, //10
  536. W_BOW, //11
  537. W_KNUCKLE, //12
  538. W_MUSICAL, //13
  539. W_WHIP, //14
  540. W_BOOK, //15
  541. W_KATAR, //16
  542. W_REVOLVER, //17
  543. W_RIFLE, //18
  544. W_GATLING, //19
  545. W_SHOTGUN, //20
  546. W_GRENADE, //21
  547. W_HUUMA, //22
  548. W_2HSTAFF, //23
  549. MAX_WEAPON_TYPE,
  550. // dual-wield constants
  551. W_DOUBLE_DD, // 2 daggers
  552. W_DOUBLE_SS, // 2 swords
  553. W_DOUBLE_AA, // 2 axes
  554. W_DOUBLE_DS, // dagger + sword
  555. W_DOUBLE_DA, // dagger + axe
  556. W_DOUBLE_SA, // sword + axe
  557. };
  558. enum ammo_type {
  559. A_ARROW = 1,
  560. A_DAGGER, //2
  561. A_BULLET, //3
  562. A_SHELL, //4
  563. A_GRENADE, //5
  564. A_SHURIKEN, //6
  565. A_KUNAI, //7
  566. A_CANNONBALL, //8
  567. A_THROWWEAPON //9
  568. };
  569. //Equip position constants
  570. enum equip_pos {
  571. EQP_HEAD_LOW = 0x000001,
  572. EQP_HEAD_MID = 0x000200, // 512
  573. EQP_HEAD_TOP = 0x000100, // 256
  574. EQP_HAND_R = 0x000002, // 2
  575. EQP_HAND_L = 0x000020, // 32
  576. EQP_ARMOR = 0x000010, // 16
  577. EQP_SHOES = 0x000040, // 64
  578. EQP_GARMENT = 0x000004, // 4
  579. EQP_ACC_L = 0x000008, // 8
  580. EQP_ACC_R = 0x000080, // 128
  581. EQP_COSTUME_HEAD_TOP = 0x000400, // 1024
  582. EQP_COSTUME_HEAD_MID = 0x000800, // 2048
  583. EQP_COSTUME_HEAD_LOW = 0x001000, // 4096
  584. EQP_COSTUME_GARMENT = 0x002000, // 8192
  585. //EQP_COSTUME_FLOOR = 0x004000, // 16384
  586. EQP_AMMO = 0x008000, // 32768
  587. EQP_SHADOW_ARMOR = 0x010000, // 65536
  588. EQP_SHADOW_WEAPON = 0x020000, // 131072
  589. EQP_SHADOW_SHIELD = 0x040000, // 262144
  590. EQP_SHADOW_SHOES = 0x080000, // 524288
  591. EQP_SHADOW_ACC_R = 0x100000, // 1048576
  592. EQP_SHADOW_ACC_L = 0x200000, // 2097152
  593. };
  594. struct {
  595. unsigned int base_hp[MAX_LEVEL], base_sp[MAX_LEVEL]; //Storage for the first calculation with hp/sp factor and multiplicator
  596. int hp_factor, hp_multiplicator, sp_factor;
  597. int max_weight_base;
  598. char job_bonus[MAX_LEVEL];
  599. #ifdef RENEWAL_ASPD
  600. int aspd_base[MAX_WEAPON_TYPE+1];
  601. #else
  602. int aspd_base[MAX_WEAPON_TYPE]; //[blackhole89]
  603. #endif
  604. uint32 exp_table[2][MAX_LEVEL];
  605. uint32 max_level[2];
  606. struct s_params {
  607. uint16 str, agi, vit, int_, dex, luk;
  608. } max_param;
  609. } job_info[CLASS_COUNT];
  610. #define EQP_WEAPON EQP_HAND_R
  611. #define EQP_SHIELD EQP_HAND_L
  612. #define EQP_ARMS (EQP_HAND_R|EQP_HAND_L)
  613. #define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
  614. #define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
  615. #define EQP_COSTUME (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW|EQP_COSTUME_GARMENT)
  616. #define EQP_SHADOW_GEAR (EQP_SHADOW_ARMOR|EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD|EQP_SHADOW_SHOES|EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  617. #define EQP_SHADOW_ACC (EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  618. /// Equip positions that use a visible sprite
  619. #if PACKETVER < 20110111
  620. #define EQP_VISIBLE EQP_HELM
  621. #else
  622. #define EQP_VISIBLE (EQP_HELM|EQP_GARMENT|EQP_COSTUME)
  623. #endif
  624. #define pc_setdead(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 1 )
  625. #define pc_setsit(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 2 )
  626. #define pc_isdead(sd) ( (sd)->state.dead_sit == 1 )
  627. #define pc_issit(sd) ( (sd)->vd.dead_sit == 2 )
  628. #define pc_isidle(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
  629. #define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading )
  630. #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 )
  631. /* equals pc_cant_act except it doesn't check for chat rooms or npcs */
  632. #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 )
  633. #define pc_setdir(sd,b,h) ( (sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
  634. #define pc_setchatid(sd,n) ( (sd)->chatID = n )
  635. #define pc_ishiding(sd) ( (sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) )
  636. #define pc_iscloaking(sd) ( !((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK) )
  637. #define pc_ischasewalk(sd) ( (sd)->sc.option&OPTION_CHASEWALK )
  638. #ifdef VIP_ENABLE
  639. #define pc_isvip(sd) ( sd->vip.enabled ? 1 : 0 )
  640. #else
  641. #define pc_isvip(sd) ( 0 )
  642. #endif
  643. #ifdef NEW_CARTS
  644. #define pc_iscarton(sd) ( (sd)->sc.data[SC_PUSH_CART] )
  645. #else
  646. #define pc_iscarton(sd) ( (sd)->sc.option&OPTION_CART )
  647. #endif
  648. #define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
  649. #define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
  650. #define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
  651. #define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle_config.natural_heal_weight_rate )
  652. #define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 )
  653. /// Enum of Player's Parameter
  654. enum e_params {
  655. PARAM_STR = 0,
  656. PARAM_AGI,
  657. PARAM_VIT,
  658. PARAM_INT,
  659. PARAM_DEX,
  660. PARAM_LUK,
  661. PARAM_MAX
  662. };
  663. short pc_maxparameter(struct map_session_data *sd, enum e_params param);
  664. /**
  665. * Ranger
  666. **/
  667. #define pc_iswug(sd) ( (sd)->sc.option&OPTION_WUG )
  668. #define pc_isridingwug(sd) ( (sd)->sc.option&OPTION_WUGRIDER )
  669. // Mechanic Magic Gear
  670. #define pc_ismadogear(sd) ( (sd)->sc.option&OPTION_MADOGEAR )
  671. // Rune Knight Dragon
  672. #define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON )
  673. #define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type)
  674. #define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl)
  675. //Weapon check considering dual wielding.
  676. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
  677. 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon)))
  678. //Checks if the given class value corresponds to a player class. [Skotlex]
  679. //JOB_NOVICE isn't checked for class_ is supposed to be unsigned
  680. #define pcdb_checkid_sub(class_) ( \
  681. ( (class_) < JOB_MAX_BASIC ) || \
  682. ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) || \
  683. ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) || \
  684. ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) || \
  685. ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) || \
  686. ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) || \
  687. ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \
  688. )
  689. #define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_)
  690. // clientside display macros (values to the left/right of the "+")
  691. #ifdef RENEWAL
  692. #define pc_leftside_atk(sd) ((sd)->battle_status.batk)
  693. #define pc_rightside_atk(sd) ((sd)->battle_status.watk + (sd)->battle_status.watk2 + (sd)->battle_status.eatk)
  694. #define pc_leftside_def(sd) ((sd)->battle_status.def2)
  695. #define pc_rightside_def(sd) ((sd)->battle_status.def)
  696. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2)
  697. #define pc_rightside_mdef(sd) ((sd)->battle_status.mdef)
  698. #define pc_leftside_matk(sd) (status_base_matk(status_get_status_data(&(sd)->bl), (sd)->status.base_level))
  699. #define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk)
  700. #else
  701. #define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk)
  702. #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2)
  703. #define pc_leftside_def(sd) ((sd)->battle_status.def)
  704. #define pc_rightside_def(sd) ((sd)->battle_status.def2)
  705. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef)
  706. #define pc_rightside_mdef(sd) ( (sd)->battle_status.mdef2 - ((sd)->battle_status.vit>>1) )
  707. #define pc_leftside_matk(sd) \
  708. (\
  709. ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
  710. ?((sd)->battle_status.matk_min * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
  711. :(sd)->battle_status.matk_min \
  712. )
  713. #define pc_rightside_matk(sd) \
  714. (\
  715. ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
  716. ?((sd)->battle_status.matk_max * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
  717. :(sd)->battle_status.matk_max \
  718. )
  719. #endif
  720. int pc_split_atoi(char* str, int* val, char sep, int max);
  721. int pc_class2idx(int class_);
  722. int pc_get_group_level(struct map_session_data *sd);
  723. int pc_get_group_id(struct map_session_data *sd);
  724. int pc_getrefinebonus(int lv,int type);
  725. bool pc_can_give_items(struct map_session_data *sd);
  726. bool pc_can_give_bounded_items(struct map_session_data *sd);
  727. bool pc_can_use_command(struct map_session_data *sd, const char *command, AtCommandType type);
  728. #define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
  729. bool pc_should_log_commands(struct map_session_data *sd);
  730. int pc_setrestartvalue(struct map_session_data *sd,int type);
  731. int pc_makesavestatus(struct map_session_data *);
  732. void pc_respawn(struct map_session_data* sd, clr_type clrtype);
  733. int pc_setnewpc(struct map_session_data*,int,int,int,unsigned int,int,int);
  734. bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers);
  735. void pc_authfail(struct map_session_data *);
  736. int pc_reg_received(struct map_session_data *sd);
  737. void pc_close_npc(struct map_session_data *sd,int flag);
  738. int pc_close_npc_timer(int tid, unsigned int tick, int id, intptr_t data);
  739. int pc_isequip(struct map_session_data *sd,int n);
  740. int pc_equippoint(struct map_session_data *sd,int n);
  741. int pc_setinventorydata(struct map_session_data *sd);
  742. int pc_checkskill(struct map_session_data *sd,uint16 skill_id);
  743. short pc_checkequip(struct map_session_data *sd,int pos);
  744. bool pc_checkequip2(struct map_session_data *sd,int nameid,int min, int max);
  745. int pc_calc_skilltree(struct map_session_data *sd);
  746. int pc_calc_skilltree_normalize_job(struct map_session_data *sd);
  747. void pc_clean_skilltree(struct map_session_data *sd);
  748. #define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
  749. #define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
  750. int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
  751. void pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y);
  752. int pc_randomwarp(struct map_session_data *sd,clr_type type);
  753. int pc_memo(struct map_session_data* sd, int pos);
  754. int pc_checkadditem(struct map_session_data*,int,int);
  755. int pc_inventoryblank(struct map_session_data*);
  756. int pc_search_inventory(struct map_session_data *sd,int item_id);
  757. int pc_payzeny(struct map_session_data*,int, enum e_log_pick_type type, struct map_session_data*);
  758. char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_pick_type log_type);
  759. int pc_getzeny(struct map_session_data*,int, enum e_log_pick_type, struct map_session_data*);
  760. int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type);
  761. //Bound items
  762. int pc_bound_chk(TBL_PC *sd,int type,int *idxlist);
  763. // Special Shop System
  764. int pc_paycash( struct map_session_data *sd, int price, int points, e_log_pick_type type );
  765. int pc_getcash( struct map_session_data *sd, int cash, int points, e_log_pick_type type );
  766. int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
  767. int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
  768. int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
  769. int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
  770. int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
  771. int pc_takeitem(struct map_session_data*,struct flooritem_data*);
  772. int pc_dropitem(struct map_session_data*,int,int);
  773. bool pc_isequipped(struct map_session_data *sd, int nameid);
  774. bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd );
  775. bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
  776. int pc_updateweightstatus(struct map_session_data *sd);
  777. 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 short pos,bool onskill);
  778. void pc_exeautobonus(struct map_session_data* sd,struct s_autobonus *bonus);
  779. int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data);
  780. void pc_delautobonus(struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);
  781. int pc_bonus(struct map_session_data*,int,int);
  782. int pc_bonus2(struct map_session_data *sd,int,int,int);
  783. int pc_bonus3(struct map_session_data *sd,int,int,int,int);
  784. int pc_bonus4(struct map_session_data *sd,int,int,int,int,int);
  785. int pc_bonus5(struct map_session_data *sd,int,int,int,int,int,int);
  786. int pc_skill(struct map_session_data* sd, int id, int level, int flag);
  787. int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
  788. int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv);
  789. int pc_steal_coin(struct map_session_data *sd,struct block_list *bl);
  790. int pc_modifybuyvalue(struct map_session_data*,int);
  791. int pc_modifysellvalue(struct map_session_data*,int);
  792. int pc_follow(struct map_session_data*, int); // [MouseJstr]
  793. int pc_stop_following(struct map_session_data*);
  794. unsigned int pc_maxbaselv(struct map_session_data *sd);
  795. unsigned int pc_maxjoblv(struct map_session_data *sd);
  796. int pc_checkbaselevelup(struct map_session_data *sd);
  797. int pc_checkjoblevelup(struct map_session_data *sd);
  798. int pc_gainexp(struct map_session_data*,struct block_list*,unsigned int,unsigned int, bool);
  799. unsigned int pc_nextbaseexp(struct map_session_data *);
  800. unsigned int pc_thisbaseexp(struct map_session_data *);
  801. unsigned int pc_nextjobexp(struct map_session_data *);
  802. unsigned int pc_thisjobexp(struct map_session_data *);
  803. int pc_gets_status_point(int);
  804. int pc_need_status_point(struct map_session_data *,int,int);
  805. int pc_statusup(struct map_session_data*,int);
  806. int pc_statusup2(struct map_session_data*,int,int);
  807. int pc_skillup(struct map_session_data*,uint16 skill_id);
  808. int pc_allskillup(struct map_session_data*);
  809. int pc_resetlvl(struct map_session_data*,int type);
  810. int pc_resetstate(struct map_session_data*);
  811. int pc_resetskill(struct map_session_data*, int);
  812. int pc_resetfeel(struct map_session_data*);
  813. int pc_resethate(struct map_session_data*);
  814. bool pc_equipitem(struct map_session_data*,int,int);
  815. bool pc_unequipitem(struct map_session_data*,int,int);
  816. void pc_checkitem(struct map_session_data*);
  817. void pc_check_available_item(struct map_session_data *sd);
  818. int pc_useitem(struct map_session_data*,int);
  819. int pc_skillatk_bonus(struct map_session_data *sd, uint16 skill_id);
  820. int pc_skillheal_bonus(struct map_session_data *sd, uint16 skill_id);
  821. int pc_skillheal2_bonus(struct map_session_data *sd, uint16 skill_id);
  822. void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp);
  823. int pc_dead(struct map_session_data *sd,struct block_list *src);
  824. void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp);
  825. void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int type);
  826. int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp);
  827. int pc_percentheal(struct map_session_data *sd,int,int);
  828. int pc_jobchange(struct map_session_data *,int, int);
  829. void pc_setoption(struct map_session_data *,int);
  830. bool pc_setcart(struct map_session_data* sd, int type);
  831. void pc_setfalcon(struct map_session_data* sd, int flag);
  832. void pc_setriding(struct map_session_data* sd, int flag);
  833. void pc_setmadogear(struct map_session_data* sd, int flag);
  834. void pc_changelook(struct map_session_data *,int,int);
  835. void pc_equiplookall(struct map_session_data *sd);
  836. int pc_readparam(struct map_session_data*,int);
  837. bool pc_setparam(struct map_session_data*,int,int);
  838. int pc_readreg(struct map_session_data*,int);
  839. bool pc_setreg(struct map_session_data*,int,int);
  840. char *pc_readregstr(struct map_session_data *sd,int reg);
  841. bool pc_setregstr(struct map_session_data *sd,int reg,const char *str);
  842. #define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg,3)
  843. #define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val,3)
  844. #define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg,3)
  845. #define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val,3)
  846. #define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg,2)
  847. #define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val,2)
  848. #define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg,2)
  849. #define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val,2)
  850. #define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg,1)
  851. #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val,1)
  852. #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg,1)
  853. #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val,1)
  854. int pc_readregistry(struct map_session_data*,const char*,int);
  855. bool pc_setregistry(struct map_session_data*,const char*,int,int);
  856. char *pc_readregistry_str(struct map_session_data*,const char*,int);
  857. bool pc_setregistry_str(struct map_session_data*,const char*,const char*,int);
  858. bool pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
  859. bool pc_deleventtimer(struct map_session_data *sd,const char *name);
  860. void pc_cleareventtimer(struct map_session_data *sd);
  861. void pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick);
  862. int pc_calc_pvprank(struct map_session_data *sd);
  863. int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data);
  864. int pc_ismarried(struct map_session_data *sd);
  865. bool pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd);
  866. bool pc_divorce(struct map_session_data *sd);
  867. struct map_session_data *pc_get_partner(struct map_session_data *sd);
  868. struct map_session_data *pc_get_father(struct map_session_data *sd);
  869. struct map_session_data *pc_get_mother(struct map_session_data *sd);
  870. struct map_session_data *pc_get_child(struct map_session_data *sd);
  871. void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick);
  872. void pc_regen (struct map_session_data *sd, unsigned int diff_tick);
  873. void pc_setstand(struct map_session_data *sd);
  874. bool pc_candrop(struct map_session_data *sd,struct item *item);
  875. int pc_jobid2mapid(unsigned short b_class); // Skotlex
  876. int pc_mapid2jobid(unsigned short class_, int sex); // Skotlex
  877. const char * job_name(int class_);
  878. struct skill_tree_entry {
  879. short id;
  880. unsigned char max;
  881. unsigned char joblv;
  882. struct {
  883. short id;
  884. unsigned char lv;
  885. } need[MAX_PC_SKILL_REQUIRE];
  886. }; // Celest
  887. extern struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE];
  888. struct sg_data {
  889. short anger_id;
  890. short bless_id;
  891. short comfort_id;
  892. char feel_var[NAME_LENGTH];
  893. char hate_var[NAME_LENGTH];
  894. int (*day_func)(void);
  895. };
  896. extern const struct sg_data sg_info[MAX_PC_FEELHATE];
  897. void pc_setinvincibletimer(struct map_session_data* sd, int val);
  898. void pc_delinvincibletimer(struct map_session_data* sd);
  899. int pc_addspiritball(struct map_session_data *sd,int,int);
  900. int pc_delspiritball(struct map_session_data *sd,int,int);
  901. void pc_addfame(struct map_session_data *sd,int count);
  902. unsigned char pc_famerank(int char_id, int job);
  903. bool pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl);
  904. extern struct fame_list smith_fame_list[MAX_FAME_LIST];
  905. extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
  906. extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
  907. int pc_readdb(void);
  908. int do_init_pc(void);
  909. void do_final_pc(void);
  910. enum {CHKADDITEM_EXIST,CHKADDITEM_NEW,CHKADDITEM_OVERAMOUNT};
  911. enum {
  912. ADDITEM_SUCCESS,
  913. ADDITEM_INVALID,
  914. ADDITEM_OVERWEIGHT,
  915. ADDITEM_OVERITEM=4,
  916. ADDITEM_OVERAMOUNT,
  917. ADDITEM_STACKLIMIT=7
  918. };
  919. // timer for night.day
  920. extern int day_timer_tid;
  921. extern int night_timer_tid;
  922. int map_day_timer(int tid, unsigned int tick, int id, intptr_t data); // by [yor]
  923. int map_night_timer(int tid, unsigned int tick, int id, intptr_t data); // by [yor]
  924. // Rental System
  925. void pc_inventory_rentals(struct map_session_data *sd);
  926. int pc_inventory_rental_clear(struct map_session_data *sd);
  927. void pc_inventory_rental_add(struct map_session_data *sd, int seconds);
  928. int pc_read_motd(void); // [Valaris]
  929. int pc_disguise(struct map_session_data *sd, int class_);
  930. bool pc_isautolooting(struct map_session_data *sd, int nameid);
  931. void pc_overheat(struct map_session_data *sd, int val);
  932. int pc_banding(struct map_session_data *sd, uint16 skill_lv);
  933. void pc_itemcd_do(struct map_session_data *sd, bool load);
  934. int pc_load_combo(struct map_session_data *sd);
  935. int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type);
  936. int pc_del_talisman(struct map_session_data *sd,int count,int type);
  937. void pc_baselevelchanged(struct map_session_data *sd);
  938. void pc_damage_log_add(struct map_session_data *sd, int id);
  939. void pc_damage_log_clear(struct map_session_data *sd, int id);
  940. enum e_BANKING_DEPOSIT_ACK pc_bank_deposit(struct map_session_data *sd, int money);
  941. enum e_BANKING_WITHDRAW_ACK pc_bank_withdraw(struct map_session_data *sd, int money);
  942. void pc_crimson_marker_clear(struct map_session_data *sd);
  943. void pc_show_version(struct map_session_data *sd);
  944. int pc_bonus_script_timer(int tid, unsigned int tick, int id, intptr_t data);
  945. void pc_bonus_script_remove(struct map_session_data *sd, uint8 i);
  946. void pc_bonus_script_clear(struct map_session_data *sd, uint16 flag);
  947. void pc_cell_basilica(struct map_session_data *sd);
  948. #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
  949. int pc_level_penalty_mod(struct map_session_data *sd, int mob_level, uint32 mob_class, int type);
  950. #endif
  951. #endif /* _PC_H_ */