pc.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. #define OPTION_MASK 0xd7b8
  7. #define CART_MASK 0x788
  8. //Update this max as necessary. 53 is the value needed for Super Baby currently
  9. #define MAX_SKILL_TREE 53
  10. #define pc_setdead(sd) ((sd)->state.dead_sit = 1)
  11. #define pc_setsit(sd) ((sd)->state.dead_sit = 2)
  12. #define pc_isdead(sd) ((sd)->state.dead_sit == 1)
  13. #define pc_issit(sd) ((sd)->state.dead_sit == 2)
  14. #define pc_setdir(sd,b,h) ((sd)->dir = (b) ,(sd)->head_dir = (h) )
  15. #define pc_setchatid(sd,n) ((sd)->chatID = n)
  16. #define pc_ishiding(sd) ((sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK))
  17. #define pc_iscloaking(sd) (!((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK))
  18. #define pc_ischasewalk(sd) ((sd)->sc.option&OPTION_CHASEWALK)
  19. #define pc_iscarton(sd) ((sd)->sc.option&CART_MASK)
  20. #define pc_isfalcon(sd) ((sd)->sc.option&OPTION_FALCON)
  21. #define pc_isriding(sd) ((sd)->sc.option&OPTION_RIDING)
  22. #define pc_isinvisible(sd) ((sd)->sc.option&OPTION_INVISIBLE)
  23. #define pc_is50overweight(sd) (sd->weight*2 >= sd->max_weight)
  24. #define pc_is90overweight(sd) (sd->weight*10 >= sd->max_weight*9)
  25. #define pc_maxparameter(sd) ((sd->class_&JOBL_BABY) ? battle_config.max_baby_parameter : battle_config.max_parameter)
  26. //Checks if the given class value corresponds to a player class. [Skotlex]
  27. #define pcdb_checkid(class_) ((class_ >= JOB_NOVICE && class_ <= JOB_XMAS) || (class_ >= JOB_NOVICE_HIGH && class_ <= JOB_SOUL_LINKER))
  28. int pc_isGM(struct map_session_data *sd);
  29. int pc_iskiller(struct map_session_data *src, struct map_session_data *target); // [MouseJstr]
  30. int pc_getrefinebonus(int lv,int type);
  31. int pc_can_move(struct map_session_data *sd); //[Skotlex]
  32. int pc_can_give_items(int level); //[Lupus]
  33. int pc_setrestartvalue(struct map_session_data *sd,int type);
  34. int pc_makesavestatus(struct map_session_data *);
  35. int pc_setnewpc(struct map_session_data*,int,int,int,unsigned int,int,int);
  36. int pc_authok(struct map_session_data*, int, time_t, struct mmo_charstatus *);
  37. int pc_authfail(struct map_session_data *);
  38. int pc_reg_received(struct map_session_data *sd);
  39. int pc_isequip(struct map_session_data *sd,int n);
  40. int pc_equippoint(struct map_session_data *sd,int n);
  41. int pc_break_equip(struct map_session_data *, unsigned short);
  42. #define pc_breakweapon(sd) (pc_break_equip(sd, EQP_WEAPON))
  43. #define pc_breakarmor(sd) (pc_break_equip(sd, EQP_ARMOR))
  44. #define pc_breakshield(sd) (pc_break_equip(sd, EQP_SHIELD))
  45. #define pc_breakhelm(sd) (pc_break_equip(sd, EQP_HELM))
  46. int pc_checkskill(struct map_session_data *sd,int skill_id);
  47. int pc_checkallowskill(struct map_session_data *sd);
  48. int pc_checkequip(struct map_session_data *sd,int pos);
  49. int pc_calc_skilltree(struct map_session_data *sd);
  50. int pc_calc_skilltree_normalize_job(struct map_session_data *sd);
  51. int pc_clean_skilltree(struct map_session_data *sd);
  52. int pc_checkoverhp(struct map_session_data*);
  53. int pc_checkoversp(struct map_session_data*);
  54. int pc_can_reach(struct map_session_data*,int,int);
  55. int pc_walktoxy(struct map_session_data*,int,int);
  56. int pc_stop_walking(struct map_session_data*,int);
  57. int pc_movepos(struct map_session_data*,int,int,int);
  58. int pc_setpos(struct map_session_data*,unsigned short,int,int,int);
  59. int pc_setsavepoint(struct map_session_data*,short,int,int);
  60. int pc_randomwarp(struct map_session_data *sd,int type);
  61. int pc_memo(struct map_session_data *sd,int i);
  62. int pc_remove_map(struct map_session_data *sd,int clrtype);
  63. int pc_checkadditem(struct map_session_data*,int,int);
  64. int pc_inventoryblank(struct map_session_data*);
  65. int pc_search_inventory(struct map_session_data *sd,int item_id);
  66. int pc_payzeny(struct map_session_data*,int);
  67. int pc_additem(struct map_session_data*,struct item*,int);
  68. int pc_getzeny(struct map_session_data*,int);
  69. int pc_delitem(struct map_session_data*,int,int,int);
  70. int pc_checkitem(struct map_session_data*);
  71. int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount);
  72. int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type);
  73. int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
  74. int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
  75. int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
  76. int pc_takeitem(struct map_session_data*,struct flooritem_data*);
  77. int pc_dropitem(struct map_session_data*,int,int);
  78. int pc_checkweighticon(struct map_session_data *sd);
  79. int pc_bonus(struct map_session_data*,int,int);
  80. int pc_bonus2(struct map_session_data *sd,int,int,int);
  81. int pc_bonus3(struct map_session_data *sd,int,int,int,int);
  82. int pc_bonus4(struct map_session_data *sd,int,int,int,int,int);
  83. int pc_skill(struct map_session_data*,int,int,int);
  84. int pc_blockskill_start (struct map_session_data*,int,int); // [celest]
  85. int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
  86. int pc_steal_item(struct map_session_data *sd,struct block_list *bl);
  87. int pc_steal_coin(struct map_session_data *sd,struct block_list *bl);
  88. int pc_modifybuyvalue(struct map_session_data*,int);
  89. int pc_modifysellvalue(struct map_session_data*,int);
  90. int pc_attack(struct map_session_data*,int,int);
  91. int pc_stopattack(struct map_session_data*);
  92. int pc_follow(struct map_session_data*, int); // [MouseJstr]
  93. int pc_stop_following(struct map_session_data*);
  94. unsigned int pc_maxbaselv(struct map_session_data *sd);
  95. unsigned int pc_maxjoblv(struct map_session_data *sd);
  96. int pc_checkbaselevelup(struct map_session_data *sd);
  97. int pc_checkjoblevelup(struct map_session_data *sd);
  98. int pc_gainexp(struct map_session_data*,unsigned int,unsigned int);
  99. unsigned int pc_nextbaseexp(struct map_session_data *);
  100. unsigned int pc_nextjobexp(struct map_session_data *);
  101. int pc_need_status_point(struct map_session_data *,int);
  102. int pc_statusup(struct map_session_data*,int);
  103. int pc_statusup2(struct map_session_data*,int,int);
  104. int pc_skillup(struct map_session_data*,int);
  105. int pc_allskillup(struct map_session_data*);
  106. int pc_resetlvl(struct map_session_data*,int type);
  107. int pc_resetstate(struct map_session_data*);
  108. int pc_resetskill(struct map_session_data*, int);
  109. int pc_resetfeel(struct map_session_data*);
  110. int pc_equipitem(struct map_session_data*,int,int);
  111. int pc_unequipitem(struct map_session_data*,int,int);
  112. int pc_checkitem(struct map_session_data*);
  113. int pc_useitem(struct map_session_data*,int);
  114. int pc_damage_sp(struct map_session_data *, int, int);
  115. int pc_damage(struct block_list *,struct map_session_data*,int);
  116. int pc_heal(struct map_session_data *,int,int);
  117. int pc_itemheal(struct map_session_data *sd,int hp,int sp);
  118. int pc_percentheal(struct map_session_data *sd,int,int);
  119. int pc_jobchange(struct map_session_data *,int, int);
  120. int pc_setoption(struct map_session_data *,int);
  121. int pc_setcart(struct map_session_data *sd,int type);
  122. int pc_setfalcon(struct map_session_data *sd);
  123. int pc_setriding(struct map_session_data *sd);
  124. int pc_changelook(struct map_session_data *,int,int);
  125. int pc_equiplookall(struct map_session_data *sd);
  126. int pc_readparam(struct map_session_data*,int);
  127. int pc_setparam(struct map_session_data*,int,int);
  128. int pc_readreg(struct map_session_data*,int);
  129. int pc_setreg(struct map_session_data*,int,int);
  130. char *pc_readregstr(struct map_session_data *sd,int reg);
  131. int pc_setregstr(struct map_session_data *sd,int reg,char *str);
  132. #define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg,3)
  133. #define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val,3)
  134. #define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg,3)
  135. #define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val,3)
  136. #define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg,2)
  137. #define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val,2)
  138. #define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg,2)
  139. #define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val,2)
  140. #define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg,1)
  141. #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val,1)
  142. #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg,1)
  143. #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val,1)
  144. int pc_readregistry(struct map_session_data*,char*,int);
  145. int pc_setregistry(struct map_session_data*,char*,int,int);
  146. char *pc_readregistry_str(struct map_session_data*,char*,int);
  147. int pc_setregistry_str(struct map_session_data*,char*,char*,int);
  148. int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
  149. int pc_deleventtimer(struct map_session_data *sd,const char *name);
  150. int pc_cleareventtimer(struct map_session_data *sd);
  151. int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick);
  152. int pc_calc_pvprank(struct map_session_data *sd);
  153. int pc_calc_pvprank_timer(int tid,unsigned int tick,int id,int data);
  154. int pc_ismarried(struct map_session_data *sd);
  155. int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd);
  156. int pc_divorce(struct map_session_data *sd);
  157. int pc_adoption(struct map_session_data *sd,struct map_session_data *dstsd,struct map_session_data *jasd);
  158. struct map_session_data *pc_get_partner(struct map_session_data *sd);
  159. struct map_session_data *pc_get_father(struct map_session_data *sd);
  160. struct map_session_data *pc_get_mother(struct map_session_data *sd);
  161. struct map_session_data *pc_get_child(struct map_session_data *sd);
  162. int pc_set_gm_level(int account_id, int level);
  163. void pc_setstand(struct map_session_data *sd);
  164. int pc_break_equip(struct map_session_data *sd, unsigned short where);
  165. int pc_candrop(struct map_session_data *sd,int item_id);
  166. struct pc_base_job{
  167. int job; //職業、ただし転生職や養子職の場合は元の職業を返す(廃プリ→プリ)
  168. int type; //ノビ 0, 一次職 1, 二次職 2, スパノビ 3
  169. int upper; //通常 0, 転生 1, 養子 2
  170. };
  171. struct pc_base_job pc_calc_base_job(int b_class);//転生や養子職の元の職業を返す
  172. int pc_calc_base_job2(int b_class); // Celest
  173. unsigned short pc_jobid2mapid(unsigned short b_class); // Skotlex
  174. unsigned short pc_mapid2jobid(unsigned short class_, int sex); // Skotlex
  175. char * job_name(int class_);
  176. struct skill_tree_entry {
  177. short id;
  178. unsigned char max;
  179. unsigned char joblv;
  180. struct {
  181. short id;
  182. unsigned char lv;
  183. } need[5];
  184. }; // Celest
  185. extern struct skill_tree_entry skill_tree[MAX_PC_CLASS][MAX_SKILL_TREE];
  186. int pc_read_gm_account(int fd);
  187. int pc_setinvincibletimer(struct map_session_data *sd,int);
  188. int pc_delinvincibletimer(struct map_session_data *sd);
  189. int pc_addspiritball(struct map_session_data *sd,int,int);
  190. int pc_delspiritball(struct map_session_data *sd,int,int);
  191. void pc_addfame(struct map_session_data *sd,int count);
  192. int pc_istop10fame(int char_id, int job);
  193. int pc_eventtimer(int tid,unsigned int tick,int id,int data); // for npc_dequeue
  194. int pc_run(struct map_session_data *sd, int skilllv, int dir);
  195. extern struct fame_list smith_fame_list[10];
  196. extern struct fame_list chemist_fame_list[10];
  197. extern struct fame_list taekwon_fame_list[10];
  198. int pc_readdb(void);
  199. int do_init_pc(void);
  200. void do_final_pc(void);
  201. enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT};
  202. // timer for night.day
  203. extern int day_timer_tid;
  204. extern int night_timer_tid;
  205. int map_day_timer(int,unsigned int,int,int); // by [yor]
  206. int map_night_timer(int,unsigned int,int,int); // by [yor]
  207. int pc_read_motd(void); // [Valaris]
  208. #endif