pc.h 12 KB

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