pc.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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 "map.h" // MAX_PC_CLASS, struct map_session_data
  9. #include "status.h" // OPTION_*
  10. #include "unit.h" // unit_stop_attack(), unit_stop_walking()
  11. //Update this max as necessary. 53 is the value needed for Super Baby currently
  12. #define MAX_SKILL_TREE 53
  13. enum {
  14. W_FIST, //Bare hands
  15. W_DAGGER, //1
  16. W_1HSWORD, //2
  17. W_2HSWORD, //3
  18. W_1HSPEAR, //4
  19. W_2HSPEAR, //5
  20. W_1HAXE, //6
  21. W_2HAXE, //7
  22. W_MACE, //8
  23. W_UNKNOWN, //View 9 seems unused anywhere
  24. W_STAFF, //10
  25. W_BOW, //11
  26. W_KNUCKLE, //12
  27. W_MUSICAL, //13
  28. W_WHIP, //14
  29. W_BOOK, //15
  30. W_KATAR, //16
  31. W_REVOLVER, //17
  32. W_RIFLE, //18
  33. W_SHOTGUN, //19
  34. W_GATLING, //20
  35. W_GRENADE, //21
  36. W_HUUMA, //22
  37. MAX_WEAPON_TYPE
  38. } weapon_type;
  39. enum {
  40. A_ARROW = 1,
  41. A_DAGGER, //2
  42. A_BULLET, //3
  43. A_SHELL, //4
  44. A_GRENADE, //5
  45. A_SHURIKEN, //6
  46. A_KUNAI //7
  47. } ammo_type;
  48. //Equip position constants
  49. enum {
  50. EQP_HEAD_LOW = 0x0001,
  51. EQP_HEAD_MID = 0x0200, //512
  52. EQP_HEAD_TOP = 0x0100, //256
  53. EQP_HAND_R = 0x0002,
  54. EQP_HAND_L = 0x0020, //32
  55. EQP_ARMOR = 0x0010, //16
  56. EQP_SHOES = 0x0040, //64
  57. EQP_GARMENT = 0x0004,
  58. EQP_ACC_L = 0x0008,
  59. EQP_ACC_R = 0x0080, //128
  60. EQP_AMMO = 0x8000, //32768
  61. } equip_pos_enum;
  62. #define EQP_WEAPON EQP_HAND_R
  63. #define EQP_SHIELD EQP_HAND_L
  64. #define EQP_ARMS (EQP_HAND_R|EQP_HAND_L)
  65. #define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
  66. #define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
  67. //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
  68. //where the arrows are equipped)
  69. enum {
  70. EQI_ACC_L = 0,
  71. EQI_ACC_R,
  72. EQI_SHOES,
  73. EQI_GARMENT,
  74. EQI_HEAD_LOW,
  75. EQI_HEAD_MID,
  76. EQI_HEAD_TOP,
  77. EQI_ARMOR,
  78. EQI_HAND_L,
  79. EQI_HAND_R,
  80. EQI_AMMO,
  81. EQI_MAX
  82. } equip_index_enum;
  83. #define pc_setdead(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 1)
  84. #define pc_setsit(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 2)
  85. #define pc_isdead(sd) ((sd)->state.dead_sit == 1)
  86. #define pc_issit(sd) ((sd)->vd.dead_sit == 2)
  87. #define pc_isidle(sd) ((sd)->chatID || (sd)->vender_id || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share)
  88. #define pc_setdir(sd,b,h) ((sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
  89. #define pc_setchatid(sd,n) ((sd)->chatID = n)
  90. #define pc_ishiding(sd) ((sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK))
  91. #define pc_iscloaking(sd) (!((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK))
  92. #define pc_ischasewalk(sd) ((sd)->sc.option&OPTION_CHASEWALK)
  93. #define pc_iscarton(sd) ((sd)->sc.option&OPTION_CART)
  94. #define pc_isfalcon(sd) ((sd)->sc.option&OPTION_FALCON)
  95. #define pc_isriding(sd) ((sd)->sc.option&OPTION_RIDING)
  96. #define pc_isinvisible(sd) ((sd)->sc.option&OPTION_INVISIBLE)
  97. #define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle_config.natural_heal_weight_rate )
  98. #define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 )
  99. #define pc_maxparameter(sd) ((sd->class_&JOBL_BABY) ? battle_config.max_baby_parameter : battle_config.max_parameter)
  100. #define pc_stop_attack(sd) { if (sd->ud.attacktimer!=-1) { unit_stop_attack(&sd->bl); sd->ud.target = 0; } }
  101. #define pc_stop_walking(sd, type) { if (sd->ud.walktimer!=-1) unit_stop_walking(&sd->bl, type); }
  102. //Weapon check considering dual wielding.
  103. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
  104. 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)))
  105. //Checks if the given class value corresponds to a player class. [Skotlex]
  106. #define pcdb_checkid(class_) (class_ <= JOB_XMAS || (class_ >= JOB_NOVICE_HIGH && class_ <= JOB_SOUL_LINKER))
  107. int pc_isGM(struct map_session_data *sd);
  108. int pc_getrefinebonus(int lv,int type);
  109. int pc_can_give_items(int level); //[Lupus]
  110. int pc_setrestartvalue(struct map_session_data *sd,int type);
  111. int pc_makesavestatus(struct map_session_data *);
  112. int pc_setnewpc(struct map_session_data*,int,int,int,unsigned int,int,int);
  113. int pc_authok(struct map_session_data*, int, time_t, struct mmo_charstatus *);
  114. int pc_authfail(struct map_session_data *);
  115. int pc_reg_received(struct map_session_data *sd);
  116. int pc_isequip(struct map_session_data *sd,int n);
  117. int pc_equippoint(struct map_session_data *sd,int n);
  118. int pc_checkskill(struct map_session_data *sd,int skill_id);
  119. int pc_checkallowskill(struct map_session_data *sd);
  120. int pc_checkequip(struct map_session_data *sd,int pos);
  121. int pc_calc_skilltree(struct map_session_data *sd);
  122. int pc_calc_skilltree_normalize_job(struct map_session_data *sd);
  123. int pc_clean_skilltree(struct map_session_data *sd);
  124. #define pc_checkoverhp(sd) (sd->battle_status.hp == sd->battle_status.max_hp)
  125. #define pc_checkoversp(sd) (sd->battle_status.sp == sd->battle_status.max_sp)
  126. int pc_setpos(struct map_session_data*,unsigned short,int,int,int);
  127. int pc_setsavepoint(struct map_session_data*,short,int,int);
  128. int pc_randomwarp(struct map_session_data *sd,int type);
  129. int pc_memo(struct map_session_data *sd,int i);
  130. int pc_remove_map(struct map_session_data *sd,int clrtype);
  131. int pc_checkadditem(struct map_session_data*,int,int);
  132. int pc_inventoryblank(struct map_session_data*);
  133. int pc_search_inventory(struct map_session_data *sd,int item_id);
  134. int pc_payzeny(struct map_session_data*,int);
  135. int pc_additem(struct map_session_data*,struct item*,int);
  136. int pc_getzeny(struct map_session_data*,int);
  137. int pc_delitem(struct map_session_data*,int,int,int);
  138. int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount);
  139. int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type);
  140. int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
  141. int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
  142. int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
  143. int pc_takeitem(struct map_session_data*,struct flooritem_data*);
  144. int pc_dropitem(struct map_session_data*,int,int);
  145. int pc_updateweightstatus(struct map_session_data *sd);
  146. int pc_bonus(struct map_session_data*,int,int);
  147. int pc_bonus2(struct map_session_data *sd,int,int,int);
  148. int pc_bonus3(struct map_session_data *sd,int,int,int,int);
  149. int pc_bonus4(struct map_session_data *sd,int,int,int,int,int);
  150. int pc_bonus5(struct map_session_data *sd,int,int,int,int,int,int);
  151. int pc_skill(struct map_session_data* sd, int id, int level, int flag);
  152. int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
  153. int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int skilllv);
  154. int pc_steal_coin(struct map_session_data *sd,struct block_list *bl);
  155. int pc_modifybuyvalue(struct map_session_data*,int);
  156. int pc_modifysellvalue(struct map_session_data*,int);
  157. int pc_follow(struct map_session_data*, int); // [MouseJstr]
  158. int pc_stop_following(struct map_session_data*);
  159. unsigned int pc_maxbaselv(struct map_session_data *sd);
  160. unsigned int pc_maxjoblv(struct map_session_data *sd);
  161. int pc_checkbaselevelup(struct map_session_data *sd);
  162. int pc_checkjoblevelup(struct map_session_data *sd);
  163. int pc_gainexp(struct map_session_data*,struct block_list*,unsigned int,unsigned int);
  164. unsigned int pc_nextbaseexp(struct map_session_data *);
  165. unsigned int pc_nextjobexp(struct map_session_data *);
  166. int pc_need_status_point(struct map_session_data *,int);
  167. int pc_statusup(struct map_session_data*,int);
  168. int pc_statusup2(struct map_session_data*,int,int);
  169. int pc_skillup(struct map_session_data*,int);
  170. int pc_allskillup(struct map_session_data*);
  171. int pc_resetlvl(struct map_session_data*,int type);
  172. int pc_resetstate(struct map_session_data*);
  173. int pc_resetskill(struct map_session_data*, int);
  174. int pc_resetfeel(struct map_session_data*);
  175. int pc_resethate(struct map_session_data*);
  176. int pc_equipitem(struct map_session_data*,int,int);
  177. int pc_unequipitem(struct map_session_data*,int,int);
  178. int pc_checkitem(struct map_session_data*);
  179. int pc_useitem(struct map_session_data*,int);
  180. int pc_skillatk_bonus(struct map_session_data *sd, int skill_num);
  181. int pc_skillheal_bonus(struct map_session_data *sd, int skill_num);
  182. void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp);
  183. int pc_dead(struct map_session_data *sd,struct block_list *src);
  184. void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp);
  185. void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int type);
  186. int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp);
  187. int pc_percentheal(struct map_session_data *sd,int,int);
  188. int pc_jobchange(struct map_session_data *,int, int);
  189. int pc_setoption(struct map_session_data *,int);
  190. int pc_setcart(struct map_session_data* sd, int type);
  191. int pc_setfalcon(struct map_session_data* sd, int flag);
  192. int pc_setriding(struct map_session_data* sd, int flag);
  193. int pc_changelook(struct map_session_data *,int,int);
  194. int pc_equiplookall(struct map_session_data *sd);
  195. int pc_readparam(struct map_session_data*,int);
  196. int pc_setparam(struct map_session_data*,int,int);
  197. int pc_readreg(struct map_session_data*,int);
  198. int pc_setreg(struct map_session_data*,int,int);
  199. char *pc_readregstr(struct map_session_data *sd,int reg);
  200. int pc_setregstr(struct map_session_data *sd,int reg,char *str);
  201. #define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg,3)
  202. #define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val,3)
  203. #define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg,3)
  204. #define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val,3)
  205. #define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg,2)
  206. #define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val,2)
  207. #define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg,2)
  208. #define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val,2)
  209. #define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg,1)
  210. #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val,1)
  211. #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg,1)
  212. #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val,1)
  213. int pc_readregistry(struct map_session_data*,const char*,int);
  214. int pc_setregistry(struct map_session_data*,const char*,int,int);
  215. char *pc_readregistry_str(struct map_session_data*,char*,int);
  216. int pc_setregistry_str(struct map_session_data*,char*,char*,int);
  217. int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
  218. int pc_deleventtimer(struct map_session_data *sd,const char *name);
  219. int pc_cleareventtimer(struct map_session_data *sd);
  220. int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick);
  221. int pc_calc_pvprank(struct map_session_data *sd);
  222. int pc_calc_pvprank_timer(int tid,unsigned int tick,int id,int data);
  223. int pc_ismarried(struct map_session_data *sd);
  224. int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd);
  225. int pc_divorce(struct map_session_data *sd);
  226. int pc_adoption(struct map_session_data *sd,struct map_session_data *dstsd,struct map_session_data *jasd);
  227. struct map_session_data *pc_get_partner(struct map_session_data *sd);
  228. struct map_session_data *pc_get_father(struct map_session_data *sd);
  229. struct map_session_data *pc_get_mother(struct map_session_data *sd);
  230. struct map_session_data *pc_get_child(struct map_session_data *sd);
  231. void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick);
  232. void pc_regen (struct map_session_data *sd, unsigned int diff_tick, int flag);
  233. int pc_set_gm_level(int account_id, int level);
  234. void pc_setstand(struct map_session_data *sd);
  235. int pc_candrop(struct map_session_data *sd,struct item *item);
  236. int pc_jobid2mapid(unsigned short b_class); // Skotlex
  237. int pc_mapid2jobid(unsigned short class_, int sex); // Skotlex
  238. char * job_name(int class_);
  239. struct skill_tree_entry {
  240. short id;
  241. unsigned char max;
  242. unsigned char joblv;
  243. struct {
  244. short id;
  245. unsigned char lv;
  246. } need[5];
  247. }; // Celest
  248. extern struct skill_tree_entry skill_tree[MAX_PC_CLASS][MAX_SKILL_TREE];
  249. int pc_read_gm_account(int fd);
  250. int pc_setinvincibletimer(struct map_session_data *sd,int);
  251. void pc_delinvincibletimer_sub(struct map_session_data *sd);
  252. #define pc_delinvincibletimer(sd) if ((sd)->invincible_timer != INVALID_TIMER) pc_delinvincibletimer_sub(sd)
  253. int pc_addspiritball(struct map_session_data *sd,int,int);
  254. int pc_delspiritball(struct map_session_data *sd,int,int);
  255. void pc_addfame(struct map_session_data *sd,int count);
  256. unsigned char pc_famerank(int char_id, int job);
  257. int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl);
  258. extern struct fame_list smith_fame_list[MAX_FAME_LIST];
  259. extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
  260. extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
  261. int pc_readdb(void);
  262. int do_init_pc(void);
  263. void do_final_pc(void);
  264. enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT};
  265. // timer for night.day
  266. extern int day_timer_tid;
  267. extern int night_timer_tid;
  268. int map_day_timer(int,unsigned int,int,int); // by [yor]
  269. int map_night_timer(int,unsigned int,int,int); // by [yor]
  270. //Duel functions // [LuzZza]
  271. int duel_create(struct map_session_data* sd, const unsigned int maxpl);
  272. int duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd);
  273. int duel_accept(const unsigned int did, struct map_session_data* sd);
  274. int duel_reject(const unsigned int did, struct map_session_data* sd);
  275. int duel_leave(const unsigned int did, struct map_session_data* sd);
  276. int duel_showinfo(const unsigned int did, struct map_session_data* sd);
  277. int duel_checktime(struct map_session_data* sd);
  278. int pc_read_motd(void); // [Valaris]
  279. int pc_disguise(struct map_session_data *sd, int class_);
  280. #endif /* _PC_H_ */