pc.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  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 "battle.h" // battle_config
  8. #include "itemdb.h" // MAX_ITEMGROUP
  9. #include "map.h" // RC_MAX
  10. #include "pc.h" // struct map_session_data
  11. #include "script.h" // struct script_reg, struct script_regstr
  12. #include "status.h" // OPTION_*, struct weapon_atk
  13. #include "unit.h" // unit_stop_attack(), unit_stop_walking()
  14. #include "vending.h" // struct s_vending
  15. #include "mob.h"
  16. #define MAX_PC_BONUS 10
  17. struct weapon_data {
  18. int atkmods[3];
  19. // all the variables except atkmods get zero'ed in each call of status_calc_pc
  20. // NOTE: if you want to add a non-zeroed variable, you need to update the memset call
  21. // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex]
  22. int overrefine;
  23. int star;
  24. int ignore_def_ele;
  25. int ignore_def_race;
  26. int def_ratio_atk_ele;
  27. int def_ratio_atk_race;
  28. int addele[ELE_MAX];
  29. int addrace[RC_MAX];
  30. int addrace2[RC_MAX];
  31. int addsize[3];
  32. struct drain_data {
  33. short rate;
  34. short per;
  35. short value;
  36. unsigned type:1;
  37. } hp_drain[RC_MAX], sp_drain[RC_MAX];
  38. struct {
  39. short class_, rate;
  40. } add_dmg[MAX_PC_BONUS];
  41. };
  42. struct s_autospell {
  43. short id, lv, rate, card_id, flag;
  44. };
  45. struct s_addeffect {
  46. enum sc_type id;
  47. short rate, arrow_rate;
  48. unsigned char flag;
  49. };
  50. struct s_addeffectonskill {
  51. enum sc_type id;
  52. short rate, skill;
  53. unsigned char target;
  54. };
  55. struct s_add_drop {
  56. short id, group;
  57. int race, rate;
  58. };
  59. struct s_autobonus {
  60. short rate,atk_type;
  61. unsigned int duration;
  62. struct script_code *bonus_script;
  63. struct script_code *other_script;
  64. int active;
  65. unsigned short pos;
  66. };
  67. struct map_session_data {
  68. struct block_list bl;
  69. struct unit_data ud;
  70. struct view_data vd;
  71. struct status_data base_status, battle_status;
  72. struct status_change sc;
  73. struct regen_data regen;
  74. struct regen_data_sub sregen, ssregen;
  75. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
  76. //status_calc_pc, while special_state is recalculated in each call. [Skotlex]
  77. struct {
  78. unsigned active : 1; //Marks active player (not active is logging in/out, or changing map servers)
  79. unsigned menu_or_input : 1;// if a script is waiting for feedback from the player
  80. unsigned dead_sit : 2;
  81. unsigned lr_flag : 2;
  82. unsigned connect_new : 1;
  83. unsigned arrow_atk : 1;
  84. unsigned combo : 2; // 1:Asura, 2:Kick [Inkfish]
  85. unsigned gangsterparadise : 1;
  86. unsigned rest : 1;
  87. unsigned storage_flag : 2; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex]
  88. unsigned snovice_call_flag : 2; //Summon Angel (stage 1~3)
  89. unsigned snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
  90. unsigned abra_flag : 1; // Abracadabra bugfix by Aru
  91. unsigned autocast : 1; // Autospell flag [Inkfish]
  92. unsigned autotrade : 1; //By Fantik
  93. unsigned reg_dirty : 3; //By Skotlex (marks whether registry variables have been saved or not yet)
  94. unsigned showdelay :1;
  95. unsigned showexp :1;
  96. unsigned showzeny :1;
  97. unsigned mainchat :1; //[LuzZza]
  98. unsigned noask :1; // [LuzZza]
  99. unsigned trading :1; //[Skotlex] is 1 only after a trade has started.
  100. unsigned deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
  101. unsigned monster_ignore :1; // for monsters to ignore a character [Valaris] [zzo]
  102. unsigned size :2; // for tiny/large types
  103. unsigned night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
  104. unsigned blockedmove :1;
  105. unsigned using_fake_npc :1;
  106. unsigned rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex]
  107. unsigned killer : 1;
  108. unsigned killable : 1;
  109. unsigned doridori : 1;
  110. unsigned ignoreAll : 1;
  111. unsigned debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
  112. unsigned short autoloot;
  113. unsigned short autolootid; // [Zephyrus]
  114. unsigned noks : 3; // [Zeph Kill Steal Protection]
  115. bool changemap;
  116. short pmap; // Previous map on Map Change
  117. struct guild *gmaster_flag;
  118. unsigned int bg_id;
  119. unsigned skillonskill : 1;
  120. unsigned short user_font;
  121. unsigned short autobonus;
  122. } state;
  123. struct {
  124. unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
  125. unsigned restart_full_recover : 1;
  126. unsigned no_castcancel : 1;
  127. unsigned no_castcancel2 : 1;
  128. unsigned no_sizefix : 1;
  129. unsigned no_gemstone : 1;
  130. unsigned intravision : 1; // Maya Purple Card effect [DracoRPG]
  131. unsigned perfect_hiding : 1; // [Valaris]
  132. unsigned no_knockback : 1;
  133. unsigned bonus_coma : 1;
  134. } special_state;
  135. int login_id1, login_id2;
  136. unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
  137. int gmlevel;
  138. int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 ... 18
  139. struct mmo_charstatus status;
  140. struct registry save_reg;
  141. struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
  142. short equip_index[11];
  143. unsigned int weight,max_weight;
  144. int cart_weight,cart_num;
  145. int fd;
  146. unsigned short mapindex;
  147. unsigned char head_dir; //0: Look forward. 1: Look right, 2: Look left.
  148. unsigned int client_tick;
  149. int npc_id,areanpc_id,npc_shopid;
  150. struct {
  151. int npc_id;
  152. short x,y;
  153. } ontouch;
  154. int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
  155. int npc_menu; // internal variable, used in npc menu handling
  156. int npc_amount;
  157. struct script_state *st;
  158. char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
  159. int npc_timer_id; //For player attached npc timers. [Skotlex]
  160. unsigned int chatID;
  161. time_t idletime;
  162. struct{
  163. int npc_id;
  164. unsigned int timeout;
  165. } progressbar; //Progress Bar [Inkfish]
  166. struct{
  167. char name[NAME_LENGTH];
  168. } ignore[MAX_IGNORE_LIST];
  169. int followtimer; // [MouseJstr]
  170. int followtarget;
  171. time_t emotionlasttime; // to limit flood with emotion packets
  172. short skillitem,skillitemlv;
  173. short skillid_old,skilllv_old;
  174. short skillid_dance,skilllv_dance;
  175. short cook_mastery; // range: [0,1999] [Inkfish]
  176. unsigned char blockskill[MAX_SKILL];
  177. int cloneskill_id;
  178. int menuskill_id, menuskill_val;
  179. int invincible_timer;
  180. unsigned int canlog_tick;
  181. unsigned int canuseitem_tick; // [Skotlex]
  182. unsigned int canequip_tick; // [Inkfish]
  183. unsigned int cantalk_tick;
  184. unsigned int cansendmail_tick; // [Mail System Flood Protection]
  185. unsigned int ks_floodprotect_tick; // [Kill Steal Protection]
  186. short weapontype1,weapontype2;
  187. short disguise; // [Valaris]
  188. struct weapon_data right_weapon, left_weapon;
  189. // here start arrays to be globally zeroed at the beginning of status_calc_pc()
  190. int param_bonus[6],param_equip[6]; //Stores card/equipment bonuses.
  191. int subele[ELE_MAX];
  192. int subrace[RC_MAX];
  193. int subrace2[RC_MAX];
  194. int subsize[3];
  195. int reseff[SC_COMMON_MAX-SC_COMMON_MIN+1];
  196. int weapon_coma_ele[ELE_MAX];
  197. int weapon_coma_race[RC_MAX];
  198. int weapon_atk[16];
  199. int weapon_atk_rate[16];
  200. int arrow_addele[ELE_MAX];
  201. int arrow_addrace[RC_MAX];
  202. int arrow_addsize[3];
  203. int magic_addele[ELE_MAX];
  204. int magic_addrace[RC_MAX];
  205. int magic_addsize[3];
  206. int critaddrace[RC_MAX];
  207. int expaddrace[RC_MAX];
  208. int ignore_mdef[RC_MAX];
  209. int ignore_def[RC_MAX];
  210. int itemgrouphealrate[MAX_ITEMGROUP];
  211. short sp_gain_race[RC_MAX];
  212. // zeroed arrays end here.
  213. // zeroed structures start here
  214. struct s_autospell autospell[15], autospell2[15], autospell3[15];
  215. struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
  216. struct s_addeffectonskill addeff3[MAX_PC_BONUS];
  217. struct { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills.
  218. unsigned short id;
  219. short val;
  220. } skillatk[MAX_PC_BONUS], skillheal[5], skillheal2[5], skillblown[MAX_PC_BONUS], skillcast[MAX_PC_BONUS];
  221. struct {
  222. short value;
  223. int rate;
  224. int tick;
  225. } hp_loss, sp_loss, hp_regen, sp_regen;
  226. struct {
  227. short class_, rate;
  228. } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
  229. struct s_add_drop add_drop[MAX_PC_BONUS];
  230. struct {
  231. int nameid;
  232. int rate;
  233. } itemhealrate[MAX_PC_BONUS];
  234. // zeroed structures end here
  235. // manually zeroed structures start here.
  236. struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage
  237. // manually zeroed structures end here.
  238. // zeroed vars start here.
  239. int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
  240. int nsshealhp,nsshealsp;
  241. int critical_def,double_rate;
  242. int long_attack_atk_rate; //Long range atk rate, not weapon based. [Skotlex]
  243. int near_attack_def_rate,long_attack_def_rate,magic_def_rate,misc_def_rate;
  244. int ignore_mdef_ele;
  245. int ignore_mdef_race;
  246. int perfect_hit;
  247. int perfect_hit_add;
  248. int get_zeny_rate;
  249. int get_zeny_num; //Added Get Zeny Rate [Skotlex]
  250. int double_add_rate;
  251. int short_weapon_damage_return,long_weapon_damage_return;
  252. int magic_damage_return; // AppleGirl Was Here
  253. int random_attack_increase_add,random_attack_increase_per; // [Valaris]
  254. int break_weapon_rate,break_armor_rate;
  255. int crit_atk_rate;
  256. int classchange; // [Valaris]
  257. int speed_rate, speed_add_rate, aspd_add;
  258. unsigned int setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
  259. short splash_range, splash_add_range;
  260. short add_steal_rate;
  261. short add_heal_rate, add_heal2_rate;
  262. short sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value;
  263. short sp_vanish_rate;
  264. short sp_vanish_per;
  265. unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
  266. unsigned short unbreakable_equip; //100% break resistance on certain equipment
  267. unsigned short unstripable_equip;
  268. // zeroed vars end here.
  269. int castrate,delayrate,hprate,sprate,dsprate;
  270. int atk_rate;
  271. int hprecov_rate,sprecov_rate;
  272. int matk_rate;
  273. int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
  274. int itemid;
  275. short itemindex; //Used item's index in sd->inventory [Skotlex]
  276. short catch_target_class; // pet catching, stores a pet class to catch (short now) [zzo]
  277. short spiritball, spiritball_old;
  278. int spirit_timer[MAX_SKILL_LEVEL];
  279. unsigned char potion_success_counter; //Potion successes in row counter
  280. unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
  281. short mission_mobid; //Stores the target mob_id for TK_MISSION
  282. int die_counter; //Total number of times you've died
  283. int devotion[5]; //Stores the account IDs of chars devoted to.
  284. int reg_num; //Number of registries (type numeric)
  285. int regstr_num; //Number of registries (type string)
  286. struct script_reg *reg;
  287. struct script_regstr *regstr;
  288. int trade_partner;
  289. struct {
  290. struct {
  291. short index, amount;
  292. } item[10];
  293. int zeny, weight;
  294. } deal;
  295. bool party_creating; // whether the char is requesting party creation
  296. bool party_joining; // whether the char is accepting party invitation
  297. int party_invite, party_invite_account; // for handling party invitation (holds party id and account id)
  298. int adopt_invite; // Adoption
  299. int guild_invite,guild_invite_account;
  300. int guild_emblem_id,guild_alliance,guild_alliance_account;
  301. short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo]
  302. int guildspy; // [Syrus22]
  303. int partyspy; // [Syrus22]
  304. int vender_id;
  305. int vend_num;
  306. char message[MESSAGE_SIZE];
  307. struct s_vending vending[MAX_VENDING];
  308. struct pet_data *pd;
  309. struct homun_data *hd; // [blackhole89]
  310. struct mercenary_data *md;
  311. struct{
  312. int m; //-1 - none, other: map index corresponding to map name.
  313. unsigned short index; //map index
  314. }feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
  315. short hate_mob[3];
  316. int pvp_timer;
  317. short pvp_point;
  318. unsigned short pvp_rank, pvp_lastusers;
  319. unsigned short pvp_won, pvp_lost;
  320. char eventqueue[MAX_EVENTQUEUE][50];
  321. int eventtimer[MAX_EVENTTIMER];
  322. unsigned short eventcount; // [celest]
  323. unsigned char change_level; // [celest]
  324. char fakename[NAME_LENGTH]; // fake names [Valaris]
  325. int duel_group; // duel vars [LuzZza]
  326. int duel_invite;
  327. char away_message[128]; // [LuzZza]
  328. int cashPoints, kafraPoints;
  329. int rental_timer;
  330. // Auction System [Zephyrus]
  331. struct {
  332. int index, amount;
  333. } auction;
  334. // Mail System [Zephyrus]
  335. struct {
  336. short nameid;
  337. int index, amount, zeny;
  338. struct mail_data inbox;
  339. bool changed; // if true, should sync with charserver on next mailbox request
  340. } mail;
  341. //Quest log system [Kevin] [Inkfish]
  342. int num_quests;
  343. int avail_quests;
  344. int quest_index[MAX_QUEST_DB];
  345. struct quest quest_log[MAX_QUEST_DB];
  346. // temporary debug [flaviojs]
  347. const char* debug_file;
  348. int debug_line;
  349. const char* debug_func;
  350. };
  351. //Update this max as necessary. 54 is the value needed for Super Baby currently
  352. #define MAX_SKILL_TREE 54
  353. //Total number of classes (for data storage)
  354. #define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
  355. enum weapon_type {
  356. W_FIST, //Bare hands
  357. W_DAGGER, //1
  358. W_1HSWORD, //2
  359. W_2HSWORD, //3
  360. W_1HSPEAR, //4
  361. W_2HSPEAR, //5
  362. W_1HAXE, //6
  363. W_2HAXE, //7
  364. W_MACE, //8
  365. W_2HMACE, //9 (unused)
  366. W_STAFF, //10
  367. W_BOW, //11
  368. W_KNUCKLE, //12
  369. W_MUSICAL, //13
  370. W_WHIP, //14
  371. W_BOOK, //15
  372. W_KATAR, //16
  373. W_REVOLVER, //17
  374. W_RIFLE, //18
  375. W_GATLING, //19
  376. W_SHOTGUN, //20
  377. W_GRENADE, //21
  378. W_HUUMA, //22
  379. W_2HSTAFF, //23
  380. MAX_WEAPON_TYPE,
  381. // dual-wield constants
  382. W_DOUBLE_DD, // 2 daggers
  383. W_DOUBLE_SS, // 2 swords
  384. W_DOUBLE_AA, // 2 axes
  385. W_DOUBLE_DS, // dagger + sword
  386. W_DOUBLE_DA, // dagger + axe
  387. W_DOUBLE_SA, // sword + axe
  388. };
  389. enum ammo_type {
  390. A_ARROW = 1,
  391. A_DAGGER, //2
  392. A_BULLET, //3
  393. A_SHELL, //4
  394. A_GRENADE, //5
  395. A_SHURIKEN, //6
  396. A_KUNAI //7
  397. };
  398. //Equip position constants
  399. enum equip_pos {
  400. EQP_HEAD_LOW = 0x0001,
  401. EQP_HEAD_MID = 0x0200, //512
  402. EQP_HEAD_TOP = 0x0100, //256
  403. EQP_HAND_R = 0x0002,
  404. EQP_HAND_L = 0x0020, //32
  405. EQP_ARMOR = 0x0010, //16
  406. EQP_SHOES = 0x0040, //64
  407. EQP_GARMENT = 0x0004,
  408. EQP_ACC_L = 0x0008,
  409. EQP_ACC_R = 0x0080, //128
  410. EQP_AMMO = 0x8000, //32768
  411. };
  412. #define EQP_WEAPON EQP_HAND_R
  413. #define EQP_SHIELD EQP_HAND_L
  414. #define EQP_ARMS (EQP_HAND_R|EQP_HAND_L)
  415. #define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
  416. #define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
  417. //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
  418. //where the arrows are equipped)
  419. enum equip_index {
  420. EQI_ACC_L = 0,
  421. EQI_ACC_R,
  422. EQI_SHOES,
  423. EQI_GARMENT,
  424. EQI_HEAD_LOW,
  425. EQI_HEAD_MID,
  426. EQI_HEAD_TOP,
  427. EQI_ARMOR,
  428. EQI_HAND_L,
  429. EQI_HAND_R,
  430. EQI_AMMO,
  431. EQI_MAX
  432. };
  433. struct duel {
  434. int members_count;
  435. int invites_count;
  436. int max_players_limit;
  437. };
  438. #define MAX_DUEL 1024
  439. extern struct duel duel_list[MAX_DUEL];
  440. extern int duel_count;
  441. #define pc_setdead(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 1 )
  442. #define pc_setsit(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 2 )
  443. #define pc_isdead(sd) ( (sd)->state.dead_sit == 1 )
  444. #define pc_issit(sd) ( (sd)->vd.dead_sit == 2 )
  445. #define pc_isidle(sd) ( (sd)->chatID || (sd)->vender_id || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
  446. #define pc_istrading(sd) ( (sd)->npc_id || (sd)->vender_id || (sd)->state.trading )
  447. #define pc_cant_act(sd) ( (sd)->npc_id || (sd)->vender_id || (sd)->chatID || (sd)->sc.opt1 || (sd)->state.trading || (sd)->state.storage_flag )
  448. #define pc_setdir(sd,b,h) ( (sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
  449. #define pc_setchatid(sd,n) ( (sd)->chatID = n )
  450. #define pc_ishiding(sd) ( (sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) )
  451. #define pc_iscloaking(sd) ( !((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK) )
  452. #define pc_ischasewalk(sd) ( (sd)->sc.option&OPTION_CHASEWALK )
  453. #define pc_iscarton(sd) ( (sd)->sc.option&OPTION_CART )
  454. #define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
  455. #define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
  456. #define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
  457. #define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle_config.natural_heal_weight_rate )
  458. #define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 )
  459. #define pc_maxparameter(sd) ( (sd)->class_&JOBL_BABY ? battle_config.max_baby_parameter : battle_config.max_parameter )
  460. #define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type)
  461. #define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl)
  462. //Weapon check considering dual wielding.
  463. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
  464. 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)))
  465. //Checks if the given class value corresponds to a player class. [Skotlex]
  466. #define pcdb_checkid(class_) (class_ < JOB_MAX_BASIC || (class_ >= JOB_NOVICE_HIGH && class_ < JOB_MAX))
  467. int pc_class2idx(int class_);
  468. int pc_isGM(struct map_session_data *sd);
  469. int pc_getrefinebonus(int lv,int type);
  470. bool pc_can_give_items(int level);
  471. int pc_setrestartvalue(struct map_session_data *sd,int type);
  472. int pc_makesavestatus(struct map_session_data *);
  473. void pc_respawn(struct map_session_data* sd, uint8 clrtype);
  474. int pc_setnewpc(struct map_session_data*,int,int,int,unsigned int,int,int);
  475. bool pc_authok(struct map_session_data* sd, int, time_t, int gmlevel, struct mmo_charstatus* status);
  476. void pc_authfail(struct map_session_data *);
  477. int pc_reg_received(struct map_session_data *sd);
  478. int pc_isequip(struct map_session_data *sd,int n);
  479. int pc_equippoint(struct map_session_data *sd,int n);
  480. int pc_setinventorydata(struct map_session_data *sd);
  481. int pc_checkskill(struct map_session_data *sd,int skill_id);
  482. int pc_checkallowskill(struct map_session_data *sd);
  483. int pc_checkequip(struct map_session_data *sd,int pos);
  484. int pc_calc_skilltree(struct map_session_data *sd);
  485. int pc_calc_skilltree_normalize_job(struct map_session_data *sd);
  486. int pc_clean_skilltree(struct map_session_data *sd);
  487. #define pc_checkoverhp(sd) (sd->battle_status.hp == sd->battle_status.max_hp)
  488. #define pc_checkoversp(sd) (sd->battle_status.sp == sd->battle_status.max_sp)
  489. int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, uint8 clrtype);
  490. int pc_setsavepoint(struct map_session_data*,short,int,int);
  491. int pc_randomwarp(struct map_session_data *sd,int type);
  492. int pc_memo(struct map_session_data* sd, int pos);
  493. int pc_remove_map(struct map_session_data *sd,int clrtype);
  494. int pc_checkadditem(struct map_session_data*,int,int);
  495. int pc_inventoryblank(struct map_session_data*);
  496. int pc_search_inventory(struct map_session_data *sd,int item_id);
  497. int pc_payzeny(struct map_session_data*,int);
  498. int pc_additem(struct map_session_data*,struct item*,int);
  499. int pc_getzeny(struct map_session_data*,int);
  500. int pc_delitem(struct map_session_data*,int,int,int);
  501. // Special Shop System
  502. void pc_paycash(struct map_session_data *sd, int price, int points);
  503. void pc_getcash(struct map_session_data *sd, int cash, int points);
  504. int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount);
  505. int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type);
  506. int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
  507. int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
  508. int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
  509. int pc_takeitem(struct map_session_data*,struct flooritem_data*);
  510. int pc_dropitem(struct map_session_data*,int,int);
  511. bool pc_isequipped(struct map_session_data *sd, int nameid);
  512. bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd );
  513. bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
  514. int pc_updateweightstatus(struct map_session_data *sd);
  515. int pc_addautobonus(struct s_autobonus *bonus,char max,struct script_code *script,short rate,unsigned int dur,short atk_type,struct script_code *other_script,unsigned short pos,bool onskill);
  516. int pc_exeautobonus(struct map_session_data* sd,struct s_autobonus *bonus);
  517. int pc_endautobonus(int tid, unsigned int tick, int id, intptr data);
  518. int pc_delautobonus(struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);
  519. int pc_bonus(struct map_session_data*,int,int);
  520. int pc_bonus2(struct map_session_data *sd,int,int,int);
  521. int pc_bonus3(struct map_session_data *sd,int,int,int,int);
  522. int pc_bonus4(struct map_session_data *sd,int,int,int,int,int);
  523. int pc_bonus5(struct map_session_data *sd,int,int,int,int,int,int);
  524. int pc_skill(struct map_session_data* sd, int id, int level, int flag);
  525. int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
  526. int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int skilllv);
  527. int pc_steal_coin(struct map_session_data *sd,struct block_list *bl);
  528. int pc_modifybuyvalue(struct map_session_data*,int);
  529. int pc_modifysellvalue(struct map_session_data*,int);
  530. int pc_follow(struct map_session_data*, int); // [MouseJstr]
  531. int pc_stop_following(struct map_session_data*);
  532. unsigned int pc_maxbaselv(struct map_session_data *sd);
  533. unsigned int pc_maxjoblv(struct map_session_data *sd);
  534. int pc_checkbaselevelup(struct map_session_data *sd);
  535. int pc_checkjoblevelup(struct map_session_data *sd);
  536. int pc_gainexp(struct map_session_data*,struct block_list*,unsigned int,unsigned int);
  537. unsigned int pc_nextbaseexp(struct map_session_data *);
  538. unsigned int pc_thisbaseexp(struct map_session_data *);
  539. unsigned int pc_nextjobexp(struct map_session_data *);
  540. unsigned int pc_thisjobexp(struct map_session_data *);
  541. int pc_need_status_point(struct map_session_data *,int);
  542. int pc_statusup(struct map_session_data*,int);
  543. int pc_statusup2(struct map_session_data*,int,int);
  544. int pc_skillup(struct map_session_data*,int);
  545. int pc_allskillup(struct map_session_data*);
  546. int pc_resetlvl(struct map_session_data*,int type);
  547. int pc_resetstate(struct map_session_data*);
  548. int pc_resetskill(struct map_session_data*, int);
  549. int pc_resetfeel(struct map_session_data*);
  550. int pc_resethate(struct map_session_data*);
  551. int pc_equipitem(struct map_session_data*,int,int);
  552. int pc_unequipitem(struct map_session_data*,int,int);
  553. int pc_checkitem(struct map_session_data*);
  554. int pc_useitem(struct map_session_data*,int);
  555. int pc_skillatk_bonus(struct map_session_data *sd, int skill_num);
  556. int pc_skillheal_bonus(struct map_session_data *sd, int skill_num);
  557. int pc_skillheal2_bonus(struct map_session_data *sd, int skill_num);
  558. void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp);
  559. int pc_dead(struct map_session_data *sd,struct block_list *src);
  560. void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp);
  561. void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int type);
  562. int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp);
  563. int pc_percentheal(struct map_session_data *sd,int,int);
  564. int pc_jobchange(struct map_session_data *,int, int);
  565. int pc_setoption(struct map_session_data *,int);
  566. int pc_setcart(struct map_session_data* sd, int type);
  567. int pc_setfalcon(struct map_session_data* sd, int flag);
  568. int pc_setriding(struct map_session_data* sd, int flag);
  569. int pc_changelook(struct map_session_data *,int,int);
  570. int pc_equiplookall(struct map_session_data *sd);
  571. int pc_readparam(struct map_session_data*,int);
  572. int pc_setparam(struct map_session_data*,int,int);
  573. int pc_readreg(struct map_session_data*,int);
  574. int pc_setreg(struct map_session_data*,int,int);
  575. char *pc_readregstr(struct map_session_data *sd,int reg);
  576. int pc_setregstr(struct map_session_data *sd,int reg,const char *str);
  577. #define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg,3)
  578. #define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val,3)
  579. #define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg,3)
  580. #define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val,3)
  581. #define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg,2)
  582. #define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val,2)
  583. #define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg,2)
  584. #define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val,2)
  585. #define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg,1)
  586. #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val,1)
  587. #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg,1)
  588. #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val,1)
  589. int pc_readregistry(struct map_session_data*,const char*,int);
  590. int pc_setregistry(struct map_session_data*,const char*,int,int);
  591. char *pc_readregistry_str(struct map_session_data*,const char*,int);
  592. int pc_setregistry_str(struct map_session_data*,const char*,const char*,int);
  593. int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
  594. int pc_deleventtimer(struct map_session_data *sd,const char *name);
  595. int pc_cleareventtimer(struct map_session_data *sd);
  596. int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick);
  597. int pc_calc_pvprank(struct map_session_data *sd);
  598. int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr data);
  599. int pc_ismarried(struct map_session_data *sd);
  600. int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd);
  601. int pc_divorce(struct map_session_data *sd);
  602. struct map_session_data *pc_get_partner(struct map_session_data *sd);
  603. struct map_session_data *pc_get_father(struct map_session_data *sd);
  604. struct map_session_data *pc_get_mother(struct map_session_data *sd);
  605. struct map_session_data *pc_get_child(struct map_session_data *sd);
  606. void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick);
  607. void pc_regen (struct map_session_data *sd, unsigned int diff_tick);
  608. void pc_setstand(struct map_session_data *sd);
  609. int pc_candrop(struct map_session_data *sd,struct item *item);
  610. int pc_jobid2mapid(unsigned short b_class); // Skotlex
  611. int pc_mapid2jobid(unsigned short class_, int sex); // Skotlex
  612. char * job_name(int class_);
  613. struct skill_tree_entry {
  614. short id;
  615. unsigned char max;
  616. unsigned char joblv;
  617. struct {
  618. short id;
  619. unsigned char lv;
  620. } need[5];
  621. }; // Celest
  622. extern struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE];
  623. struct sg_data {
  624. short anger_id;
  625. short bless_id;
  626. short comfort_id;
  627. char feel_var[NAME_LENGTH];
  628. char hate_var[NAME_LENGTH];
  629. int (*day_func)(void);
  630. };
  631. extern const struct sg_data sg_info[3];
  632. void pc_setinvincibletimer(struct map_session_data* sd, int val);
  633. void pc_delinvincibletimer(struct map_session_data* sd);
  634. int pc_addspiritball(struct map_session_data *sd,int,int);
  635. int pc_delspiritball(struct map_session_data *sd,int,int);
  636. void pc_addfame(struct map_session_data *sd,int count);
  637. unsigned char pc_famerank(int char_id, int job);
  638. int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl);
  639. extern struct fame_list smith_fame_list[MAX_FAME_LIST];
  640. extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
  641. extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
  642. int pc_readdb(void);
  643. int do_init_pc(void);
  644. void do_final_pc(void);
  645. enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT};
  646. // timer for night.day
  647. extern int day_timer_tid;
  648. extern int night_timer_tid;
  649. int map_day_timer(int tid, unsigned int tick, int id, intptr data); // by [yor]
  650. int map_night_timer(int tid, unsigned int tick, int id, intptr data); // by [yor]
  651. // Rental System
  652. void pc_inventory_rentals(struct map_session_data *sd);
  653. int pc_inventory_rental_clear(struct map_session_data *sd);
  654. void pc_inventory_rental_add(struct map_session_data *sd, int seconds);
  655. //Duel functions // [LuzZza]
  656. int duel_create(struct map_session_data* sd, const unsigned int maxpl);
  657. int duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd);
  658. int duel_accept(const unsigned int did, struct map_session_data* sd);
  659. int duel_reject(const unsigned int did, struct map_session_data* sd);
  660. int duel_leave(const unsigned int did, struct map_session_data* sd);
  661. int duel_showinfo(const unsigned int did, struct map_session_data* sd);
  662. int duel_checktime(struct map_session_data* sd);
  663. int pc_read_motd(void); // [Valaris]
  664. int pc_disguise(struct map_session_data *sd, int class_);
  665. #endif /* _PC_H_ */