pc.hpp 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef PC_HPP
  4. #define PC_HPP
  5. #include <memory>
  6. #include <vector>
  7. #include "../common/cbasetypes.hpp"
  8. #include "../common/database.hpp"
  9. #include "../common/mmo.hpp" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
  10. #include "../common/strlib.hpp"// StringBuf
  11. #include "../common/timer.hpp"
  12. #include "battleground.hpp"
  13. #include "buyingstore.hpp" // struct s_buyingstore
  14. #include "clif.hpp" //e_wip_block
  15. #include "itemdb.hpp" // MAX_ITEMGROUP
  16. #include "map.hpp" // RC_ALL
  17. #include "mob.hpp" //e_size
  18. #include "script.hpp" // struct script_reg, struct script_regstr
  19. #include "searchstore.hpp" // struct s_search_store_info
  20. #include "status.hpp" // unit_data
  21. #include "unit.hpp" // unit_data
  22. #include "vending.hpp" // struct s_vending
  23. enum AtCommandType : uint8;
  24. enum e_instance_mode : uint8;
  25. //enum e_log_chat_type : uint8;
  26. enum e_log_pick_type : uint32;
  27. enum sc_type : int16;
  28. #define MAX_PC_BONUS 50 /// Max bonus, usually used by item bonus
  29. #define MAX_PC_FEELHATE 3 /// Max feel hate info
  30. #define DAMAGELOG_SIZE_PC 100 /// Damage log
  31. #define MAX_SPIRITBALL 15 /// Max spirit balls
  32. #define MAX_DEVOTION 5 /// Max Devotion slots
  33. #define MAX_SPIRITCHARM 10 /// Max spirit charms
  34. #define MAX_SOUL_BALL 20 /// Max soul ball
  35. #define MAX_STELLAR_MARKS 5 /// Max stellar marks
  36. #define MAX_UNITED_SOULS 12 /// Max united souls
  37. #define MAX_SERVANTBALL 5 /// Max servant weapons
  38. #define MAX_SERVANT_SIGN 5 /// Max servant signs
  39. #define MAX_ABYSSBALL 5 /// Max abyss spheres
  40. #define LANGTYPE_VAR "#langtype"
  41. #define CASHPOINT_VAR "#CASHPOINTS"
  42. #define KAFRAPOINT_VAR "#KAFRAPOINTS"
  43. #define BANK_VAULT_VAR "#BANKVAULT"
  44. #define ROULETTE_BRONZE_VAR "RouletteBronze"
  45. #define ROULETTE_SILVER_VAR "RouletteSilver"
  46. #define ROULETTE_GOLD_VAR "RouletteGold"
  47. #define COOKMASTERY_VAR "COOK_MASTERY"
  48. #define PCDIECOUNTER_VAR "PC_DIE_COUNTER"
  49. #define JOBCHANGE2ND_VAR "jobchange_level"
  50. #define JOBCHANGE3RD_VAR "jobchange_level_3rd"
  51. #define JOBCHANGE4TH_VAR "jobchange_level_4th"
  52. #define TKMISSIONID_VAR "TK_MISSION_ID"
  53. #define TKMISSIONCOUNT_VAR "TK_MISSION_COUNT"
  54. #define ATTENDANCE_DATE_VAR "#AttendanceDate"
  55. #define ATTENDANCE_COUNT_VAR "#AttendanceCounter"
  56. #define ACHIEVEMENTLEVEL "AchievementLevel"
  57. //Total number of classes (for data storage)
  58. #define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
  59. //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
  60. //where the arrows are equipped)
  61. enum equip_index {
  62. EQI_COMPOUND_ON = -1,
  63. EQI_ACC_L = 0,
  64. EQI_ACC_R,
  65. EQI_SHOES,
  66. EQI_GARMENT,
  67. EQI_HEAD_LOW,
  68. EQI_HEAD_MID,
  69. EQI_HEAD_TOP,
  70. EQI_ARMOR,
  71. EQI_HAND_L,
  72. EQI_HAND_R,
  73. EQI_COSTUME_HEAD_TOP,
  74. EQI_COSTUME_HEAD_MID,
  75. EQI_COSTUME_HEAD_LOW,
  76. EQI_COSTUME_GARMENT,
  77. EQI_AMMO,
  78. EQI_SHADOW_ARMOR,
  79. EQI_SHADOW_WEAPON,
  80. EQI_SHADOW_SHIELD,
  81. EQI_SHADOW_SHOES,
  82. EQI_SHADOW_ACC_R,
  83. EQI_SHADOW_ACC_L,
  84. EQI_MAX
  85. };
  86. enum prevent_logout_trigger {
  87. PLT_NONE = 0,
  88. PLT_LOGIN = 1,
  89. PLT_ATTACK = 2,
  90. PLT_SKILL = 4,
  91. PLT_DAMAGE = 8
  92. };
  93. enum e_chkitem_result : uint8 {
  94. CHKADDITEM_EXIST,
  95. CHKADDITEM_NEW,
  96. CHKADDITEM_OVERAMOUNT
  97. };
  98. enum e_additem_result : uint8 {
  99. ADDITEM_SUCCESS,
  100. ADDITEM_INVALID,
  101. ADDITEM_OVERWEIGHT,
  102. ADDITEM_ITEM,
  103. ADDITEM_OVERITEM,
  104. ADDITEM_OVERAMOUNT,
  105. ADDITEM_REFUSED_TIME,
  106. ADDITEM_STACKLIMIT
  107. };
  108. struct skill_cooldown_entry {
  109. unsigned short skill_id;
  110. int timer;
  111. };
  112. #ifdef VIP_ENABLE
  113. struct vip_info {
  114. unsigned int enabled : 1;
  115. time_t time;
  116. bool disableshowrate; //State to disable clif_display_pinfo(). [Cydh]
  117. };
  118. #endif
  119. enum npc_timeout_type {
  120. NPCT_INPUT = 0,
  121. NPCT_MENU = 1,
  122. NPCT_WAIT = 2,
  123. };
  124. /// Enum of Player's Parameter
  125. enum e_params {
  126. PARAM_STR = 0,
  127. PARAM_AGI,
  128. PARAM_VIT,
  129. PARAM_INT,
  130. PARAM_DEX,
  131. PARAM_LUK,
  132. PARAM_POW,
  133. PARAM_STA,
  134. PARAM_WIS,
  135. PARAM_SPL,
  136. PARAM_CON,
  137. PARAM_CRT,
  138. PARAM_MAX
  139. };
  140. static const char* parameter_names[PARAM_MAX] = {
  141. "Str",
  142. "Agi",
  143. "Vit",
  144. "Int",
  145. "Dex",
  146. "Luk",
  147. "Pow",
  148. "Sta",
  149. "Wis",
  150. "Spl",
  151. "Con",
  152. "Crt"
  153. };
  154. extern unsigned int equip_bitmask[EQI_MAX];
  155. #define equip_index_check(i) ( (i) >= EQI_ACC_L && (i) < EQI_MAX )
  156. /// Miscellaneous item bonus struct
  157. struct s_item_bonus {
  158. uint16 id;
  159. int val;
  160. };
  161. /// AddEle bonus struct
  162. struct s_addele2 {
  163. short flag, rate;
  164. unsigned char ele;
  165. };
  166. /// AddRace bonus struct
  167. struct s_addrace2 {
  168. short flag, rate;
  169. unsigned char race;
  170. };
  171. struct weapon_data {
  172. int atkmods[SZ_ALL];
  173. // all the variables except atkmods get zero'ed in each call of status_calc_pc
  174. // NOTE: if you want to add a non-zeroed variable, you need to update the memset call
  175. // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex]
  176. int overrefine;
  177. int star;
  178. int ignore_def_ele;
  179. int ignore_def_race;
  180. int ignore_def_class;
  181. int def_ratio_atk_ele;
  182. int def_ratio_atk_race;
  183. int def_ratio_atk_class;
  184. int addele[ELE_MAX];
  185. int addrace[RC_MAX];
  186. int addclass[CLASS_MAX];
  187. int addrace2[RC2_MAX];
  188. int addsize[SZ_MAX];
  189. short hp_drain_race[RC_MAX];
  190. short sp_drain_race[RC_MAX];
  191. short hp_drain_class[CLASS_MAX];
  192. short sp_drain_class[CLASS_MAX];
  193. struct drain_data {
  194. short rate; ///< Success rate 10000 = 100%
  195. short per; ///< Drain value/rate per attack
  196. } hp_drain_rate, sp_drain_rate;
  197. std::vector<s_item_bonus> add_dmg;
  198. std::vector<s_addele2> addele2;
  199. std::vector<s_addrace2> addrace3;
  200. };
  201. enum e_autospell_flags{
  202. AUTOSPELL_FORCE_SELF = 0x0,
  203. AUTOSPELL_FORCE_TARGET = 0x1,
  204. AUTOSPELL_FORCE_RANDOM_LEVEL = 0x2,
  205. AUTOSPELL_FORCE_ALL = 0x3
  206. };
  207. /// AutoSpell bonus struct
  208. struct s_autospell {
  209. uint16 id, lv, trigger_skill;
  210. short rate, battle_flag;
  211. t_itemid card_id;
  212. uint8 flag;
  213. bool lock; // bAutoSpellOnSkill: blocks autospell from triggering again, while being executed
  214. };
  215. /// AddEff and AddEff2 bonus struct
  216. struct s_addeffect {
  217. enum sc_type sc; /// SC type/effect
  218. short rate, /// Rate
  219. arrow_rate; /// Arrow rate
  220. unsigned char flag; /// Flag
  221. unsigned int duration; /// Duration the effect applied
  222. };
  223. /// AddEffOnSkill bonus struct
  224. struct s_addeffectonskill {
  225. enum sc_type sc; /// SC type/effect
  226. short rate, /// Rate
  227. skill_id; /// Skill ID
  228. unsigned char target; /// Target
  229. unsigned int duration; /// Duration the effect applied
  230. };
  231. ///Struct of add drop item/group rate
  232. struct s_add_drop {
  233. t_itemid nameid; ///Item ID
  234. unsigned short group; ///Group ID
  235. int rate; ///Rate, 1 ~ 10000, -1 ~ -100000
  236. short race; ///Target Race, bitwise value of 1<<x. if < 0 means Monster ID
  237. unsigned short class_; ///Target Class, bitwise value of 1<<x
  238. };
  239. struct s_vanish_bonus {
  240. int16 rate; // 1000 = 100%
  241. int16 per; // 100 = 100%
  242. int flag;
  243. };
  244. /// AutoBonus bonus struct
  245. struct s_autobonus {
  246. short rate;
  247. uint16 atk_type;
  248. unsigned int duration;
  249. char *bonus_script, *other_script;
  250. int active;
  251. unsigned int pos;
  252. ~s_autobonus();
  253. };
  254. /// Timed bonus 'bonus_script' struct [Cydh]
  255. struct s_bonus_script_entry {
  256. struct script_code *script;
  257. StringBuf *script_buf; //Used for comparing and storing on table
  258. t_tick tick;
  259. uint16 flag;
  260. enum efst_types icon;
  261. uint8 type; //0 - Ignore; 1 - Buff; 2 - Debuff
  262. int tid;
  263. };
  264. /// HP/SP bonus struct
  265. struct s_regen {
  266. short value;
  267. int rate;
  268. int tick;
  269. };
  270. /// Item combo struct
  271. struct s_combos {
  272. script_code *bonus;
  273. uint32 id;
  274. uint32 pos;
  275. };
  276. struct s_qi_display {
  277. bool is_active;
  278. e_questinfo_types icon;
  279. e_questinfo_markcolor color;
  280. };
  281. struct map_session_data {
  282. struct block_list bl;
  283. struct unit_data ud;
  284. struct view_data vd;
  285. struct status_data base_status, battle_status;
  286. struct status_change sc;
  287. struct regen_data regen;
  288. struct regen_data_sub sregen, ssregen;
  289. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
  290. //status_calc_pc, while special_state is recalculated in each call. [Skotlex]
  291. struct s_state {
  292. unsigned int active : 1; //Marks active player (not active is logging in/out, or changing map servers)
  293. unsigned int menu_or_input : 1;// if a script is waiting for feedback from the player
  294. unsigned int dead_sit : 2;
  295. unsigned int lr_flag : 3;//1: left h. weapon; 2: arrow; 3: shield
  296. unsigned int connect_new : 1;
  297. unsigned int arrow_atk : 1;
  298. unsigned int gangsterparadise : 1;
  299. unsigned int rest : 1;
  300. unsigned int storage_flag : 3; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex], 3: Premium Storage
  301. unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
  302. unsigned int abra_flag : 2; // Abracadabra bugfix by Aru
  303. unsigned int autocast : 1; // Autospell flag [Inkfish]
  304. unsigned int autotrade : 3; //By Fantik. &2 Requested by vending autotrade; &4 Requested by buyingstore autotrade
  305. unsigned int showdelay :1;
  306. unsigned int showexp :1;
  307. unsigned int showzeny :1;
  308. unsigned int noask :1; // [LuzZza]
  309. unsigned int trading :1; //[Skotlex] is 1 only after a trade has started.
  310. unsigned int deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
  311. unsigned int size :2; // for tiny/large types
  312. unsigned int night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
  313. unsigned int using_fake_npc :1;
  314. unsigned int rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex]
  315. unsigned int killer : 1;
  316. unsigned int killable : 1;
  317. unsigned int doridori : 1;
  318. unsigned int ignoreAll : 1;
  319. unsigned int debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
  320. unsigned int buyingstore : 1;
  321. unsigned int lesseffect : 1;
  322. unsigned int vending : 1;
  323. unsigned int noks : 3; // [Zeph Kill Steal Protection]
  324. unsigned int changemap : 1;
  325. unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
  326. short pmap; // Previous map on Map Change
  327. unsigned short autoloot;
  328. t_itemid autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
  329. unsigned short autoloottype;
  330. unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
  331. unsigned int gmaster_flag : 1;
  332. unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
  333. unsigned int warping : 1;//states whether you're in the middle of a warp processing
  334. unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
  335. bool hold_recalc;
  336. unsigned int banking : 1; //1 when we using the banking system 0 when closed
  337. unsigned int hpmeter_visible : 1;
  338. unsigned disable_atcommand_on_npc : 1; //Prevent to use atcommand while talking with NPC [Kichi]
  339. uint8 isBoundTrading; // Player is currently add bound item to trade list [Cydh]
  340. bool ignoretimeout; // Prevent the SECURE_NPCTIMEOUT function from closing current script.
  341. unsigned int workinprogress : 2; // See clif.hpp::e_workinprogress
  342. bool pc_loaded; // Ensure inventory data and status data is loaded before we calculate player stats
  343. bool keepshop; // Whether shop data should be removed when the player disconnects
  344. bool mail_writing; // Whether the player is currently writing a mail in RODEX or not
  345. bool cashshop_open;
  346. bool sale_open;
  347. unsigned int block_action : 10;
  348. bool refineui_open;
  349. } state;
  350. struct {
  351. unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
  352. unsigned int restart_full_recover : 1;
  353. unsigned int no_castcancel : 1;
  354. unsigned int no_castcancel2 : 1;
  355. unsigned int no_sizefix : 1;
  356. unsigned int no_gemstone : 2;
  357. unsigned int intravision : 1; // Maya Purple Card effect [DracoRPG]
  358. unsigned int perfect_hiding : 1; // [Valaris]
  359. unsigned int no_knockback : 1;
  360. unsigned int bonus_coma : 1;
  361. unsigned int no_mado_fuel : 1; // Disable Magic_Gear_Fuel consumption [Secret]
  362. unsigned int no_walk_delay : 1;
  363. } special_state;
  364. uint32 login_id1, login_id2;
  365. uint64 class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
  366. int group_id, group_pos, group_level;
  367. unsigned int permissions;/* group permissions */
  368. int count_rewarp; //count how many time we being rewarped
  369. int langtype;
  370. struct mmo_charstatus status;
  371. // Item Storages
  372. struct s_storage storage, premiumStorage;
  373. struct s_storage inventory;
  374. struct s_storage cart;
  375. struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
  376. short equip_index[EQI_MAX];
  377. short equip_switch_index[EQI_MAX];
  378. unsigned int weight,max_weight,add_max_weight;
  379. int cart_weight,cart_num,cart_weight_max;
  380. int fd;
  381. unsigned short mapindex;
  382. unsigned char head_dir; //0: Look forward. 1: Look right, 2: Look left.
  383. t_tick client_tick;
  384. int npc_id,npc_shopid; //for script follow scriptoid; ,npcid
  385. std::vector<int> areanpc, npc_ontouch_; ///< Array of OnTouch and OnTouch_ NPC ID
  386. int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
  387. int npc_menu; // internal variable, used in npc menu handling
  388. int npc_amount;
  389. struct script_state *st;
  390. char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
  391. int npc_timer_id; //For player attached npc timers. [Skotlex]
  392. unsigned int chatID;
  393. time_t idletime;
  394. time_t idletime_hom;
  395. time_t idletime_mer;
  396. struct s_progressbar {
  397. int npc_id;
  398. t_tick timeout;
  399. } progressbar; //Progress Bar [Inkfish]
  400. struct s_ignore {
  401. char name[NAME_LENGTH];
  402. } ignore[MAX_IGNORE_LIST];
  403. int followtimer; // [MouseJstr]
  404. int followtarget;
  405. time_t emotionlasttime; // to limit flood with emotion packets
  406. short skillitem,skillitemlv;
  407. bool skillitem_keep_requirement;
  408. uint16 skill_id_old,skill_lv_old;
  409. uint16 skill_id_dance,skill_lv_dance;
  410. uint16 skill_id_song, skill_lv_song;
  411. short cook_mastery; // range: [0,1999] [Inkfish]
  412. struct skill_cooldown_entry * scd[MAX_SKILLCOOLDOWN]; // Skill Cooldown
  413. uint16 cloneskill_idx, ///Stores index of copied skill by Intimidate/Plagiarism
  414. reproduceskill_idx; ///Stores index of copied skill by Reproduce
  415. int menuskill_id, menuskill_val, menuskill_val2;
  416. int invincible_timer;
  417. t_tick canlog_tick;
  418. t_tick canuseitem_tick; // [Skotlex]
  419. t_tick canusecashfood_tick;
  420. t_tick canequip_tick; // [Inkfish]
  421. t_tick cantalk_tick;
  422. t_tick canskill_tick; // used to prevent abuse from no-delay ACT files
  423. t_tick cansendmail_tick; // [Mail System Flood Protection]
  424. t_tick ks_floodprotect_tick; // [Kill Steal Protection]
  425. t_tick equipswitch_tick; // Equip switch
  426. struct s_item_delay {
  427. t_itemid nameid;
  428. t_tick tick;
  429. } item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
  430. short weapontype1,weapontype2;
  431. short disguise; // [Valaris]
  432. struct weapon_data right_weapon, left_weapon;
  433. // here start arrays to be globally zeroed at the beginning of status_calc_pc()
  434. struct s_indexed_bonus {
  435. int param_bonus[PARAM_MAX], param_equip[PARAM_MAX]; //Stores card/equipment bonuses.
  436. int subele[ELE_MAX];
  437. int subele_script[ELE_MAX];
  438. int subdefele[ELE_MAX];
  439. int subrace[RC_MAX];
  440. int subclass[CLASS_MAX];
  441. int subrace2[RC2_MAX];
  442. int subsize[SZ_MAX];
  443. short coma_class[CLASS_MAX];
  444. short coma_race[RC_MAX];
  445. short weapon_coma_ele[ELE_MAX];
  446. short weapon_coma_race[RC_MAX];
  447. short weapon_coma_class[CLASS_MAX];
  448. int weapon_atk[16];
  449. int weapon_damage_rate[16];
  450. int arrow_addele[ELE_MAX];
  451. int arrow_addrace[RC_MAX];
  452. int arrow_addclass[CLASS_MAX];
  453. int arrow_addsize[SZ_MAX];
  454. int magic_addele[ELE_MAX];
  455. int magic_addele_script[ELE_MAX];
  456. int magic_addrace[RC_MAX];
  457. int magic_addclass[CLASS_MAX];
  458. int magic_addsize[SZ_MAX];
  459. int magic_atk_ele[ELE_MAX];
  460. int weapon_subsize[SZ_MAX];
  461. int magic_subsize[SZ_MAX];
  462. int critaddrace[RC_MAX];
  463. int expaddrace[RC_MAX];
  464. int expaddclass[CLASS_MAX];
  465. int ignore_mdef_by_race[RC_MAX];
  466. int ignore_mdef_by_class[CLASS_MAX];
  467. int ignore_def_by_race[RC_MAX];
  468. int ignore_def_by_class[CLASS_MAX];
  469. short sp_gain_race[RC_MAX];
  470. int magic_addrace2[RC2_MAX];
  471. int ignore_mdef_by_race2[RC2_MAX];
  472. int dropaddrace[RC_MAX];
  473. int dropaddclass[CLASS_MAX];
  474. int magic_subdefele[ELE_MAX];
  475. } indexed_bonus;
  476. // zeroed arrays end here.
  477. std::vector<s_autospell> autospell, autospell2, autospell3;
  478. std::vector<s_addeffect> addeff, addeff_atked;
  479. std::vector<s_addeffectonskill> addeff_onskill;
  480. std::vector<s_item_bonus> skillatk, skillusesprate, skillusesp, skillheal, skillheal2, skillblown, skillcastrate, skillfixcastrate, subskill, skillcooldown, skillfixcast,
  481. skillvarcast, skilldelay, itemhealrate, add_def, add_mdef, add_mdmg, reseff, itemgrouphealrate, itemsphealrate, itemgroupsphealrate;
  482. std::vector<s_add_drop> add_drop;
  483. std::vector<s_addele2> subele2;
  484. std::vector<s_vanish_bonus> sp_vanish, hp_vanish;
  485. std::vector<s_addrace2> subrace3;
  486. std::vector<std::shared_ptr<s_autobonus>> autobonus, autobonus2, autobonus3; //Auto script on attack, when attacked, on skill usage
  487. // zeroed structures start here
  488. struct s_regen {
  489. short value;
  490. int rate;
  491. t_tick tick;
  492. } hp_loss, sp_loss, hp_regen, sp_regen, percent_hp_regen, percent_sp_regen;
  493. struct {
  494. short value;
  495. int rate, tick;
  496. } def_set_race[RC_MAX], mdef_set_race[RC_MAX], norecover_state_race[RC_MAX];
  497. struct s_bonus_vanish_gain {
  498. short rate, ///< Success rate 0 - 1000 (100%)
  499. per; ///< % HP/SP vanished/gained
  500. } hp_vanish_race[RC_MAX], sp_vanish_race[RC_MAX];
  501. // zeroed structures end here
  502. // zeroed vars start here.
  503. struct s_bonus {
  504. int hp, sp, ap;
  505. int atk_rate;
  506. int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
  507. int nsshealhp,nsshealsp;
  508. int critical_def,double_rate;
  509. int short_attack_atk_rate; // Short range atk rate, not weapon based.
  510. int long_attack_atk_rate; //Long range atk rate, not weapon based. [Skotlex]
  511. int near_attack_def_rate,long_attack_def_rate,magic_def_rate,misc_def_rate;
  512. int ignore_mdef_ele;
  513. int ignore_mdef_race;
  514. int ignore_mdef_class;
  515. int perfect_hit;
  516. int perfect_hit_add;
  517. int get_zeny_rate;
  518. int get_zeny_num; //Added Get Zeny Rate [Skotlex]
  519. int double_add_rate;
  520. int short_weapon_damage_return,long_weapon_damage_return,reduce_damage_return;
  521. int magic_damage_return; // AppleGirl Was Here
  522. int break_weapon_rate,break_armor_rate;
  523. int crit_atk_rate;
  524. int crit_def_rate;
  525. int classchange; // [Valaris]
  526. int speed_rate, speed_add_rate, aspd_add;
  527. int itemhealrate2; // [Epoque] Increase heal rate of all healing items.
  528. int itemsphealrate2;
  529. int shieldmdef;//royal guard's
  530. unsigned int setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
  531. short splash_range, splash_add_range;
  532. short add_steal_rate;
  533. int add_heal_rate, add_heal2_rate;
  534. int sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value, long_sp_gain_value, long_hp_gain_value;
  535. unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
  536. unsigned short unbreakable_equip; //100% break resistance on certain equipment
  537. unsigned short unstripable_equip;
  538. int fixcastrate, varcastrate, delayrate; // n/100
  539. int add_fixcast, add_varcast; // in milliseconds
  540. int ematk; // matk bonus from equipment
  541. int eatk; // atk bonus from equipment
  542. uint8 absorb_dmg_maxhp; // [Cydh]
  543. short critical_rangeatk;
  544. short weapon_atk_rate, weapon_matk_rate;
  545. } bonus;
  546. // zeroed vars end here.
  547. int castrate,hprate,sprate,aprate,dsprate;
  548. int hprecov_rate,sprecov_rate;
  549. int matk_rate;
  550. int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
  551. int patk_rate,smatk_rate,res_rate,mres_rate,hplus_rate,crate_rate;
  552. t_itemid itemid;
  553. short itemindex; //Used item's index in sd->inventory [Skotlex]
  554. uint16 catch_target_class; // pet catching, stores a pet class to catch [zzo]
  555. int8 spiritball, spiritball_old;
  556. int spirit_timer[MAX_SPIRITBALL];
  557. short spiritcharm; //No. of spirit
  558. int spiritcharm_type; //Spirit type
  559. int spiritcharm_timer[MAX_SPIRITCHARM];
  560. int8 soulball, soulball_old;
  561. int8 servantball, servantball_old;
  562. int8 abyssball, abyssball_old;
  563. unsigned char potion_success_counter; //Potion successes in row counter
  564. unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
  565. short mission_mobid; //Stores the target mob_id for TK_MISSION
  566. int die_counter; //Total number of times you've died
  567. int devotion[MAX_DEVOTION]; //Stores the account IDs of chars devoted to.
  568. int stellar_mark[MAX_STELLAR_MARKS]; // Stores the account ID's of character's with a stellar mark.
  569. int united_soul[MAX_UNITED_SOULS]; // Stores the account ID's of character's who's soul is united.
  570. int servant_sign[MAX_SERVANT_SIGN]; // Stores the account ID's of character's with a servant sign.
  571. int trade_partner;
  572. struct s_deal {
  573. struct s_item {
  574. short index, amount;
  575. } item[10];
  576. int zeny, weight;
  577. } deal;
  578. bool party_creating; // whether the char is requesting party creation
  579. bool party_joining; // whether the char is accepting party invitation
  580. int party_invite, party_invite_account; // for handling party invitation (holds party id and account id)
  581. int adopt_invite; // Adoption
  582. struct guild *guild; // [Ind] speed everything up
  583. int guild_invite,guild_invite_account;
  584. int guild_emblem_id,guild_alliance,guild_alliance_account;
  585. short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo]
  586. int guildspy; // [Syrus22]
  587. int partyspy; // [Syrus22]
  588. int clanspy;
  589. struct clan *clan;
  590. int vended_id;
  591. int vender_id;
  592. int vend_num;
  593. uint16 vend_skill_lv;
  594. char message[MESSAGE_SIZE];
  595. struct s_vending vending[MAX_VENDING];
  596. unsigned int buyer_id; // uid of open buying store
  597. struct s_buyingstore buyingstore;
  598. struct s_search_store_info searchstore;
  599. struct pet_data *pd;
  600. struct homun_data *hd; // [blackhole89]
  601. s_mercenary_data *md;
  602. s_elemental_data *ed;
  603. struct s_hate_mob {
  604. int m; //-1 - none, other: map index corresponding to map name.
  605. unsigned short index; //map index
  606. } feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
  607. short hate_mob[3];
  608. int pvp_timer;
  609. short pvp_point;
  610. unsigned short pvp_rank, pvp_lastusers;
  611. unsigned short pvp_won, pvp_lost;
  612. char eventqueue[MAX_EVENTQUEUE][EVENT_NAME_LENGTH];
  613. int eventtimer[MAX_EVENTTIMER];
  614. unsigned short eventcount; // [celest]
  615. uint16 change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value]
  616. uint16 change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value]
  617. uint16 change_level_4th; // job level when changing from 3rd to 4th class [jobchange_level_4rd in global_reg_value]
  618. char fakename[NAME_LENGTH]; // fake names [Valaris]
  619. size_t duel_group; // duel vars [LuzZza]
  620. size_t duel_invite;
  621. int killerrid, killedrid, killedgid;
  622. int cashPoints, kafraPoints;
  623. int rental_timer;
  624. // Auction System [Zephyrus]
  625. struct s_auction{
  626. int index, amount;
  627. } auction;
  628. // Mail System [Zephyrus]
  629. struct s_mail {
  630. struct {
  631. t_itemid nameid;
  632. int index, amount;
  633. } item[MAIL_MAX_ITEM];
  634. int zeny;
  635. struct mail_data inbox;
  636. bool changed; // if true, should sync with charserver on next mailbox request
  637. uint32 pending_weight;
  638. uint32 pending_zeny;
  639. uint16 pending_slots;
  640. } mail;
  641. //Quest log system
  642. int num_quests; ///< Number of entries in quest_log
  643. int avail_quests; ///< Number of Q_ACTIVE and Q_INACTIVE entries in quest log (index of the first Q_COMPLETE entry)
  644. struct quest *quest_log; ///< Quest log entries (note: Q_COMPLETE quests follow the first <avail_quests>th enties
  645. bool save_quest; ///< Whether the quest_log entries were modified and are waitin to be saved
  646. // Achievement log system
  647. struct s_achievement_data {
  648. int total_score; ///< Total achievement points
  649. int level; ///< Achievement level
  650. bool save; ///< Flag to know if achievements need to be saved
  651. uint16 count; ///< Total achievements in log
  652. uint16 incompleteCount; ///< Total incomplete achievements in log
  653. struct achievement *achievements; ///< Achievement log entries
  654. } achievement_data;
  655. // Title system
  656. std::vector<int> titles;
  657. std::vector<int> cloaked_npc;
  658. /* ShowEvent Data Cache flags from map */
  659. std::vector<s_qi_display> qi_display;
  660. // temporary debug [flaviojs]
  661. const char* debug_file;
  662. int debug_line;
  663. const char* debug_func;
  664. // Battlegrounds queue system [MasterOfMuppets]
  665. int bg_id, bg_queue_id;
  666. int tid_queue_active; ///< Timer ID associated with players joining an active BG
  667. #ifdef SECURE_NPCTIMEOUT
  668. /**
  669. * ID of the timer
  670. * @info
  671. * - value is -1 (INVALID_TIMER constant) when not being used
  672. * - timer is cancelled upon closure of the current npc's instance
  673. **/
  674. int npc_idle_timer;
  675. /**
  676. * Tick on the last recorded NPC iteration (next/menu/whatever)
  677. * @info
  678. * - It is updated on every NPC iteration as mentioned above
  679. **/
  680. t_tick npc_idle_tick;
  681. /* */
  682. enum npc_timeout_type npc_idle_type;
  683. #endif
  684. std::vector<std::shared_ptr<s_combos>> combos;
  685. /**
  686. * Guarantees your friend request is legit (for bugreport:4629)
  687. **/
  688. int friend_req;
  689. int shadowform_id;
  690. /* Channel System [Ind] */
  691. struct Channel **channels;
  692. unsigned char channel_count;
  693. struct Channel *gcbind;
  694. bool stealth;
  695. unsigned char fontcolor;
  696. t_tick *channel_tick;
  697. /* [Ind] */
  698. struct sc_display_entry **sc_display;
  699. unsigned char sc_display_count;
  700. unsigned char delayed_damage; //[Ind]
  701. /**
  702. * Account/Char variables & array control of those variables
  703. **/
  704. struct reg_db regs;
  705. unsigned char vars_received; // char loading is only complete when you get it all.
  706. bool vars_ok;
  707. bool vars_dirty;
  708. uint16 dmglog[DAMAGELOG_SIZE_PC]; ///target ids
  709. int c_marker[MAX_SKILL_CRIMSON_MARKER]; /// Store target that marked by Crimson Marker [Cydh]
  710. bool flicker; /// Check RL_FLICKER usage status [Cydh]
  711. #ifdef VIP_ENABLE
  712. struct vip_info vip;
  713. #endif
  714. /// Bonus Script [Cydh]
  715. struct s_bonus_script_list {
  716. struct linkdb_node *head; ///< Bonus script head node. data: struct s_bonus_script_entry *entry, key: (intptr_t)entry
  717. uint16 count;
  718. } bonus_script;
  719. /* Expiration Timer ID */
  720. int expiration_tid;
  721. time_t expiration_time;
  722. short last_addeditem_index; /// Index of latest item added
  723. int autotrade_tid;
  724. int respawn_tid;
  725. int bank_vault; ///< Bank Vault
  726. #ifdef PACKET_OBFUSCATION
  727. unsigned int cryptKey; ///< Packet obfuscation key to be used for the next received packet
  728. #endif
  729. struct {
  730. int bronze, silver, gold; ///< Roulette Coin
  731. } roulette_point;
  732. struct {
  733. short stage;
  734. int8 prizeIdx;
  735. short prizeStage;
  736. bool claimPrize;
  737. t_tick tick;
  738. } roulette;
  739. int instance_id;
  740. e_instance_mode instance_mode; ///< Mode of instance player last leaves from (used for instance destruction button)
  741. short setlook_head_top, setlook_head_mid, setlook_head_bottom, setlook_robe; ///< Stores 'setlook' script command values.
  742. #if PACKETVER_MAIN_NUM >= 20150507 || PACKETVER_RE_NUM >= 20150429 || defined(PACKETVER_ZERO)
  743. std::vector<int16> hatEffects;
  744. #endif
  745. struct{
  746. int tid;
  747. uint16 skill_id;
  748. uint16 level;
  749. int target;
  750. } skill_keep_using;
  751. };
  752. extern struct eri *pc_sc_display_ers; /// Player's SC display table
  753. /**
  754. * ERS for the bulk of pc vars
  755. **/
  756. extern struct eri *num_reg_ers;
  757. extern struct eri *str_reg_ers;
  758. /* Global Expiration Timer ID */
  759. extern int pc_expiration_tid;
  760. enum weapon_type : uint8 {
  761. W_FIST, //Bare hands
  762. W_DAGGER, //1
  763. W_1HSWORD, //2
  764. W_2HSWORD, //3
  765. W_1HSPEAR, //4
  766. W_2HSPEAR, //5
  767. W_1HAXE, //6
  768. W_2HAXE, //7
  769. W_MACE, //8
  770. W_2HMACE, //9 (unused)
  771. W_STAFF, //10
  772. W_BOW, //11
  773. W_KNUCKLE, //12
  774. W_MUSICAL, //13
  775. W_WHIP, //14
  776. W_BOOK, //15
  777. W_KATAR, //16
  778. W_REVOLVER, //17
  779. W_RIFLE, //18
  780. W_GATLING, //19
  781. W_SHOTGUN, //20
  782. W_GRENADE, //21
  783. W_HUUMA, //22
  784. W_2HSTAFF, //23
  785. MAX_WEAPON_TYPE,
  786. // dual-wield constants
  787. W_DOUBLE_DD, // 2 daggers
  788. W_DOUBLE_SS, // 2 swords
  789. W_DOUBLE_AA, // 2 axes
  790. W_DOUBLE_DS, // dagger + sword
  791. W_DOUBLE_DA, // dagger + axe
  792. W_DOUBLE_SA, // sword + axe
  793. MAX_WEAPON_TYPE_ALL,
  794. W_SHIELD = MAX_WEAPON_TYPE,
  795. };
  796. #define WEAPON_TYPE_ALL ((1<<MAX_WEAPON_TYPE)-1)
  797. enum e_ammo_type : uint8 {
  798. AMMO_NONE = 0,
  799. AMMO_ARROW,
  800. AMMO_DAGGER,
  801. AMMO_BULLET,
  802. AMMO_SHELL,
  803. AMMO_GRENADE,
  804. AMMO_SHURIKEN,
  805. AMMO_KUNAI,
  806. AMMO_CANNONBALL,
  807. AMMO_THROWWEAPON,
  808. MAX_AMMO_TYPE
  809. };
  810. enum e_card_type : uint8 {
  811. CARD_NORMAL = 0,
  812. CARD_ENCHANT,
  813. MAX_CARD_TYPE
  814. };
  815. enum idletime_option {
  816. IDLE_WALK = 0x0001,
  817. IDLE_USESKILLTOID = 0x0002,
  818. IDLE_USESKILLTOPOS = 0x0004,
  819. IDLE_USEITEM = 0x0008,
  820. IDLE_ATTACK = 0x0010,
  821. IDLE_CHAT = 0x0020,
  822. IDLE_SIT = 0x0040,
  823. IDLE_EMOTION = 0x0080,
  824. IDLE_DROPITEM = 0x0100,
  825. IDLE_ATCOMMAND = 0x0200,
  826. IDLE_NPC_CLOSE = 0x0400,
  827. IDLE_NPC_INPUT = 0x0800,
  828. IDLE_NPC_MENU = 0x1000,
  829. IDLE_NPC_NEXT = 0x2000,
  830. IDLE_NPC_PROGRESS = 0x4000,
  831. };
  832. enum adopt_responses {
  833. ADOPT_ALLOWED = 0,
  834. ADOPT_ALREADY_ADOPTED,
  835. ADOPT_MARRIED_AND_PARTY,
  836. ADOPT_EQUIP_RINGS,
  837. ADOPT_NOT_NOVICE,
  838. ADOPT_CHARACTER_NOT_FOUND,
  839. ADOPT_MORE_CHILDREN,
  840. ADOPT_LEVEL_70,
  841. ADOPT_MARRIED,
  842. };
  843. enum item_check {
  844. ITMCHK_NONE = 0x0,
  845. ITMCHK_INVENTORY = 0x1,
  846. ITMCHK_CART = 0x2,
  847. ITMCHK_STORAGE = 0x4,
  848. ITMCHK_ALL = ITMCHK_INVENTORY|ITMCHK_CART|ITMCHK_STORAGE,
  849. };
  850. enum e_penalty_type : uint16{
  851. PENALTY_NONE,
  852. PENALTY_EXP,
  853. PENALTY_DROP,
  854. PENALTY_MVP_EXP,
  855. PENALTY_MVP_DROP,
  856. PENALTY_MAX
  857. };
  858. struct s_penalty{
  859. e_penalty_type type;
  860. uint16 rate[MAX_LEVEL * 2 - 1];
  861. };
  862. class PenaltyDatabase : public TypesafeYamlDatabase<uint16, s_penalty> {
  863. public:
  864. PenaltyDatabase() : TypesafeYamlDatabase( "PENALTY_DB", 1 ){
  865. }
  866. const std::string getDefaultLocation();
  867. uint64 parseBodyNode(const YAML::Node& node);
  868. void loadingFinished();
  869. };
  870. struct s_job_info {
  871. std::vector<uint32> base_hp, base_sp, base_ap; //Storage for the first calculation with hp/sp/ap factor and multiplicator
  872. uint32 hp_factor, hp_multiplicator, sp_factor, max_weight_base;
  873. std::vector<std::array<uint16,PARAM_MAX>> job_bonus;
  874. std::vector<int16> aspd_base;
  875. t_exp base_exp[MAX_LEVEL], job_exp[MAX_LEVEL];
  876. uint16 max_base_level, max_job_level;
  877. uint16 max_param[PARAM_MAX];
  878. struct s_job_noenter_map {
  879. uint32 zone;
  880. uint8 group_lv;
  881. } noenter_map;
  882. };
  883. class JobDatabase : public TypesafeCachedYamlDatabase<uint16, s_job_info> {
  884. public:
  885. JobDatabase() : TypesafeCachedYamlDatabase("JOB_STATS", 1) {
  886. }
  887. const std::string getDefaultLocation();
  888. uint64 parseBodyNode(const YAML::Node &node);
  889. void loadingFinished();
  890. // Extras
  891. uint32 get_maxBaseLv(uint16 job_id);
  892. uint32 get_maxJobLv(uint16 job_id);
  893. t_exp get_baseExp(uint16 job_id, uint32 level);
  894. t_exp get_jobExp(uint16 job_id, uint32 level);
  895. int32 get_maxWeight(uint16 job_id);
  896. };
  897. extern JobDatabase job_db;
  898. #define EQP_WEAPON EQP_HAND_R
  899. #define EQP_SHIELD EQP_HAND_L
  900. #define EQP_ARMS (EQP_HAND_R|EQP_HAND_L)
  901. #define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
  902. #define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
  903. #define EQP_COSTUME (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW|EQP_COSTUME_GARMENT)
  904. #define EQP_COSTUME_HELM (EQP_COSTUME_HEAD_TOP|EQP_COSTUME_HEAD_MID|EQP_COSTUME_HEAD_LOW)
  905. #define EQP_SHADOW_GEAR (EQP_SHADOW_ARMOR|EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD|EQP_SHADOW_SHOES|EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  906. #define EQP_SHADOW_ACC (EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L)
  907. #define EQP_SHADOW_ARMS (EQP_SHADOW_WEAPON|EQP_SHADOW_SHIELD)
  908. /// Equip positions that use a visible sprite
  909. #if PACKETVER < 20110111
  910. #define EQP_VISIBLE EQP_HELM
  911. #else
  912. #define EQP_VISIBLE (EQP_HELM|EQP_GARMENT|EQP_COSTUME)
  913. #endif
  914. #define pc_setdead(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 1 )
  915. #define pc_setsit(sd) { pc_stop_walking((sd), 1|4); pc_stop_attack((sd)); (sd)->state.dead_sit = (sd)->vd.dead_sit = 2; }
  916. #define pc_isdead(sd) ( (sd)->state.dead_sit == 1 )
  917. #define pc_issit(sd) ( (sd)->vd.dead_sit == 2 )
  918. #define pc_isidle_party(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime) >= battle_config.idle_no_share )
  919. #define pc_isidle_hom(sd) ( (sd)->hd && ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime_hom) >= battle_config.hom_idle_no_share ) )
  920. #define pc_isidle_mer(sd) ( (sd)->md && ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(last_tick, (sd)->idletime_mer) >= battle_config.mer_idle_no_share ) )
  921. #define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading )
  922. // equals pc_cant_act2 and additionally checks for chat rooms and npcs
  923. #define pc_cant_act(sd) ( (sd)->npc_id || (sd)->chatID || pc_cant_act2( (sd) ) )
  924. #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 || (sd)->state.refineui_open )
  925. #define pc_setdir(sd,b,h) ( (sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
  926. #define pc_setchatid(sd,n) ( (sd)->chatID = n )
  927. #define pc_ishiding(sd) ( (sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) )
  928. #define pc_iscloaking(sd) ( !((sd)->sc.option&OPTION_CHASEWALK) && ((sd)->sc.option&OPTION_CLOAK) )
  929. #define pc_ischasewalk(sd) ( (sd)->sc.option&OPTION_CHASEWALK )
  930. #ifdef VIP_ENABLE
  931. #define pc_isvip(sd) ( sd->vip.enabled ? true : false )
  932. #else
  933. #define pc_isvip(sd) ( false )
  934. #endif
  935. #ifdef NEW_CARTS
  936. #define pc_iscarton(sd) ( (sd)->sc.data[SC_PUSH_CART] )
  937. #else
  938. #define pc_iscarton(sd) ( (sd)->sc.option&OPTION_CART )
  939. #endif
  940. #define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
  941. #define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
  942. #define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
  943. #define pc_is50overweight(sd) ( (sd)->weight * 100 >= (sd)->max_weight * battle_config.natural_heal_weight_rate )
  944. #define pc_is70overweight(sd) ( (sd)->weight * 100 >= (sd)->max_weight * battle_config.natural_heal_weight_rate_renewal )
  945. #define pc_is90overweight(sd) ( (sd)->weight * 10 >= (sd)->max_weight * 9 )
  946. static inline bool pc_hasprogress(struct map_session_data *sd, enum e_wip_block progress) {
  947. return sd == NULL || (sd->state.workinprogress&progress) == progress;
  948. }
  949. uint16 pc_maxparameter(struct map_session_data *sd, e_params param);
  950. short pc_maxaspd(struct map_session_data *sd);
  951. /**
  952. * Ranger
  953. **/
  954. #define pc_iswug(sd) ( (sd)->sc.option&OPTION_WUG )
  955. #define pc_isridingwug(sd) ( (sd)->sc.option&OPTION_WUGRIDER )
  956. // Mechanic Magic Gear
  957. enum e_mado_type : uint16 {
  958. MADO_ROBOT = 0x00,
  959. MADO_UNUSED,
  960. MADO_SUIT,
  961. MADO_MAX
  962. };
  963. #define pc_ismadogear(sd) ( (sd)->sc.option&OPTION_MADOGEAR )
  964. // Rune Knight Dragon
  965. #define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON )
  966. #define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type)
  967. #define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl)
  968. //Weapon check considering dual wielding.
  969. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
  970. 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon)))
  971. //Checks if the given class value corresponds to a player class. [Skotlex]
  972. //JOB_NOVICE isn't checked for class_ is supposed to be unsigned
  973. #define pcdb_checkid_sub(class_) ( \
  974. ( (class_) < JOB_MAX_BASIC ) || \
  975. ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) || \
  976. ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) || \
  977. ( (class_) >= JOB_BABY_RUNE_KNIGHT && (class_) <= JOB_BABY_MECHANIC2 ) || \
  978. ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) || \
  979. ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) || \
  980. (class_) == JOB_REBELLION || (class_) == JOB_SUMMONER || \
  981. (class_) == JOB_BABY_SUMMONER || \
  982. ( (class_) >= JOB_BABY_NINJA && (class_) <= JOB_BABY_REBELLION ) || \
  983. ( (class_) >= JOB_BABY_STAR_GLADIATOR2 && (class_) <= JOB_BABY_STAR_EMPEROR2 ) || \
  984. ( (class_) >= JOB_DRAGON_KNIGHT && (class_) <= JOB_TROUVERE ) || \
  985. ( (class_) >= JOB_WINDHAWK2 && (class_) <= JOB_IMPERIAL_GUARD2 ) || \
  986. ( (class_) >= JOB_SKY_EMPEROR && (class_) <= JOB_SPIRIT_HANDLER ) || \
  987. (class_) == JOB_SKY_EMPEROR2 \
  988. )
  989. #define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_)
  990. // clientside display macros (values to the left/right of the "+")
  991. #ifdef RENEWAL
  992. #define pc_leftside_atk(sd) ((sd)->battle_status.batk)
  993. #define pc_rightside_atk(sd) ((sd)->battle_status.watk + (sd)->battle_status.watk2 + (sd)->battle_status.eatk)
  994. #define pc_leftside_def(sd) ((sd)->battle_status.def2)
  995. #define pc_rightside_def(sd) ((sd)->battle_status.def)
  996. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2)
  997. #define pc_rightside_mdef(sd) ((sd)->battle_status.mdef)
  998. #define pc_leftside_matk(sd) (status_base_matk_min(&(sd)->bl, status_get_status_data(&(sd)->bl), (sd)->status.base_level))
  999. #define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk)
  1000. #else
  1001. #define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk)
  1002. #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2)
  1003. #define pc_leftside_def(sd) ((sd)->battle_status.def)
  1004. #define pc_rightside_def(sd) ((sd)->battle_status.def2)
  1005. #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef)
  1006. #define pc_rightside_mdef(sd) ( (sd)->battle_status.mdef2 - ((sd)->battle_status.vit>>1) )
  1007. #define pc_leftside_matk(sd) \
  1008. (\
  1009. ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
  1010. ?((sd)->battle_status.matk_min * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
  1011. :(sd)->battle_status.matk_min \
  1012. )
  1013. #define pc_rightside_matk(sd) \
  1014. (\
  1015. ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \
  1016. ?((sd)->battle_status.matk_max * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \
  1017. :(sd)->battle_status.matk_max \
  1018. )
  1019. #endif
  1020. struct s_attendance_reward {
  1021. t_itemid item_id;
  1022. uint16 amount;
  1023. };
  1024. struct s_attendance_period {
  1025. uint32 start;
  1026. uint32 end;
  1027. std::map<uint32, std::shared_ptr<struct s_attendance_reward>> rewards;
  1028. };
  1029. class AttendanceDatabase : public TypesafeYamlDatabase<uint32, s_attendance_period> {
  1030. public:
  1031. AttendanceDatabase() : TypesafeYamlDatabase("ATTENDANCE_DB", 1) {
  1032. }
  1033. const std::string getDefaultLocation();
  1034. uint64 parseBodyNode(const YAML::Node &node);
  1035. };
  1036. extern AttendanceDatabase attendance_db;
  1037. struct s_statpoint_entry{
  1038. uint16 level;
  1039. uint32 statpoints;
  1040. uint32 traitpoints;
  1041. };
  1042. class PlayerStatPointDatabase : public TypesafeCachedYamlDatabase<uint16, s_statpoint_entry>{
  1043. public:
  1044. PlayerStatPointDatabase() : TypesafeCachedYamlDatabase("STATPOINT_DB", 2, 1) {
  1045. }
  1046. const std::string getDefaultLocation();
  1047. uint64 parseBodyNode(const YAML::Node& node);
  1048. void loadingFinished();
  1049. uint32 pc_gets_status_point(uint16 level);
  1050. uint32 get_table_point(uint16 level);
  1051. uint32 pc_gets_trait_point(uint16 level);
  1052. uint32 get_trait_table_point(uint16 level);
  1053. };
  1054. extern PlayerStatPointDatabase statpoint_db;
  1055. /// Enum of Summoner Power of
  1056. enum e_summoner_power_type {
  1057. SUMMONER_POWER_LAND = 0,
  1058. SUMMONER_POWER_LIFE,
  1059. SUMMONER_POWER_SEA,
  1060. };
  1061. void pc_set_reg_load(bool val);
  1062. int pc_class2idx(int class_);
  1063. int pc_get_group_level(struct map_session_data *sd);
  1064. int pc_get_group_id(struct map_session_data *sd);
  1065. bool pc_can_sell_item(struct map_session_data* sd, struct item * item, enum npc_subtype shoptype);
  1066. bool pc_can_give_items(struct map_session_data *sd);
  1067. bool pc_can_give_bounded_items(struct map_session_data *sd);
  1068. bool pc_can_trade_item(map_session_data *sd, int index);
  1069. bool pc_can_use_command(struct map_session_data *sd, const char *command, AtCommandType type);
  1070. #define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
  1071. bool pc_should_log_commands(struct map_session_data *sd);
  1072. void pc_setrestartvalue(struct map_session_data *sd, char type);
  1073. void pc_makesavestatus(struct map_session_data *sd);
  1074. void pc_respawn(struct map_session_data* sd, clr_type clrtype);
  1075. void pc_setnewpc(struct map_session_data *sd, uint32 account_id, uint32 char_id, int login_id1, t_tick client_tick, int sex, int fd);
  1076. bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers);
  1077. void pc_authfail(struct map_session_data *sd);
  1078. void pc_reg_received(struct map_session_data *sd);
  1079. void pc_close_npc(struct map_session_data *sd,int flag);
  1080. TIMER_FUNC(pc_close_npc_timer);
  1081. void pc_setequipindex(struct map_session_data *sd);
  1082. uint8 pc_isequip(struct map_session_data *sd,int n);
  1083. int pc_equippoint(struct map_session_data *sd,int n);
  1084. int pc_equippoint_sub(struct map_session_data *sd, struct item_data* id);
  1085. void pc_setinventorydata(struct map_session_data *sd);
  1086. int pc_get_skillcooldown(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
  1087. uint8 pc_checkskill(struct map_session_data *sd,uint16 skill_id);
  1088. uint8 pc_checkskill_summoner(map_session_data *sd, e_summoner_power_type type);
  1089. uint8 pc_checkskill_imperial_guard(struct map_session_data *sd, short flag);
  1090. short pc_checkequip(struct map_session_data *sd,int pos,bool checkall=false);
  1091. bool pc_checkequip2(struct map_session_data *sd, t_itemid nameid, int min, int max);
  1092. void pc_scdata_received(struct map_session_data *sd);
  1093. void pc_check_expiration(struct map_session_data *sd);
  1094. TIMER_FUNC(pc_expiration_timer);
  1095. TIMER_FUNC(pc_global_expiration_timer);
  1096. void pc_expire_check(struct map_session_data *sd);
  1097. void pc_calc_skilltree(struct map_session_data *sd);
  1098. uint64 pc_calc_skilltree_normalize_job(struct map_session_data *sd);
  1099. void pc_clean_skilltree(struct map_session_data *sd);
  1100. #define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
  1101. #define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
  1102. enum e_setpos{
  1103. SETPOS_OK = 0,
  1104. SETPOS_MAPINDEX = 1,
  1105. SETPOS_NO_MAPSERVER = 2,
  1106. SETPOS_AUTOTRADE = 3
  1107. };
  1108. enum e_setpos pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
  1109. void pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y);
  1110. char pc_randomwarp(struct map_session_data *sd,clr_type type,bool ignore_mapflag = false);
  1111. bool pc_memo(struct map_session_data* sd, int pos);
  1112. char pc_checkadditem(struct map_session_data *sd, t_itemid nameid, int amount);
  1113. uint8 pc_inventoryblank(struct map_session_data *sd);
  1114. short pc_search_inventory(struct map_session_data *sd, t_itemid nameid);
  1115. char pc_payzeny(struct map_session_data *sd, int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
  1116. enum e_additem_result pc_additem(struct map_session_data *sd, struct item *item, int amount, e_log_pick_type log_type);
  1117. char pc_getzeny(struct map_session_data *sd, int zeny, enum e_log_pick_type type, struct map_session_data *tsd);
  1118. char pc_delitem(struct map_session_data *sd, int n, int amount, int type, short reason, e_log_pick_type log_type);
  1119. uint64 pc_generate_unique_id(struct map_session_data *sd);
  1120. //Bound items
  1121. int pc_bound_chk(TBL_PC *sd,enum bound_type type,int *idxlist);
  1122. // Special Shop System
  1123. int pc_paycash( struct map_session_data *sd, int price, int points, e_log_pick_type type );
  1124. int pc_getcash( struct map_session_data *sd, int cash, int points, e_log_pick_type type );
  1125. enum e_additem_result pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
  1126. void pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
  1127. void pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
  1128. void pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
  1129. int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
  1130. bool pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem);
  1131. bool pc_dropitem(struct map_session_data *sd,int n,int amount);
  1132. bool pc_isequipped(struct map_session_data *sd, t_itemid nameid);
  1133. enum adopt_responses pc_try_adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
  1134. bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
  1135. void pc_updateweightstatus(struct map_session_data *sd);
  1136. bool pc_addautobonus(std::vector<std::shared_ptr<s_autobonus>> &bonus, const char *script, short rate, unsigned int dur, uint16 atk_type, const char *o_script, unsigned int pos, bool onskill);
  1137. void pc_exeautobonus(struct map_session_data &sd, std::vector<std::shared_ptr<s_autobonus>> *bonus, std::shared_ptr<s_autobonus> autobonus);
  1138. TIMER_FUNC(pc_endautobonus);
  1139. void pc_delautobonus(struct map_session_data &sd, std::vector<std::shared_ptr<s_autobonus>> &bonus, bool restore);
  1140. void pc_bonus(struct map_session_data *sd, int type, int val);
  1141. void pc_bonus2(struct map_session_data *sd, int type, int type2, int val);
  1142. void pc_bonus3(struct map_session_data *sd, int type, int type2, int type3, int val);
  1143. void pc_bonus4(struct map_session_data *sd, int type, int type2, int type3, int type4, int val);
  1144. void pc_bonus5(struct map_session_data *sd, int type, int type2, int type3, int type4, int type5, int val);
  1145. enum e_addskill_type {
  1146. ADDSKILL_PERMANENT = 0, ///< Permanent skill. Remove the skill if level is 0
  1147. ADDSKILL_TEMP = 1, ///< Temporary skill. If player learned the skill and the given level is higher, level will be replaced and learned level will be palced in skill flag. `flag = learned + SKILL_FLAG_REPLACED_LV_0; learned_level = level;`
  1148. ADDSKILL_TEMP_ADDLEVEL = 2, ///< Like PCSKILL_TEMP, except the level will be stacked. `learned_level += level`. The flag is used to store original learned level
  1149. ADDSKILL_PERMANENT_GRANTED = 3, ///< Grant permanent skill, ignore skill tree and learned level
  1150. };
  1151. bool pc_skill(struct map_session_data *sd, uint16 skill_id, int level, enum e_addskill_type type);
  1152. int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
  1153. int pc_identifyall(struct map_session_data *sd, bool identify_item);
  1154. bool pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv);
  1155. int pc_steal_coin(struct map_session_data *sd,struct block_list *bl);
  1156. int pc_modifybuyvalue(struct map_session_data*,int);
  1157. int pc_modifysellvalue(struct map_session_data*,int);
  1158. int pc_follow(struct map_session_data*, int); // [MouseJstr]
  1159. int pc_stop_following(struct map_session_data*);
  1160. unsigned int pc_maxbaselv(struct map_session_data *sd);
  1161. unsigned int pc_maxjoblv(struct map_session_data *sd);
  1162. bool pc_is_maxbaselv(struct map_session_data *sd);
  1163. bool pc_is_maxjoblv(struct map_session_data *sd);
  1164. int pc_checkbaselevelup(struct map_session_data *sd);
  1165. int pc_checkjoblevelup(struct map_session_data *sd);
  1166. void pc_gainexp(struct map_session_data *sd, struct block_list *src, t_exp base_exp, t_exp job_exp, uint8 exp_flag);
  1167. void pc_gainexp_disp(struct map_session_data *sd, t_exp base_exp, t_exp next_base_exp, t_exp job_exp, t_exp next_job_exp, bool lost);
  1168. void pc_lostexp(struct map_session_data *sd, t_exp base_exp, t_exp job_exp);
  1169. t_exp pc_nextbaseexp(struct map_session_data *sd);
  1170. t_exp pc_nextjobexp(struct map_session_data *sd);
  1171. int pc_need_status_point(struct map_session_data *,int,int);
  1172. int pc_maxparameterincrease(struct map_session_data*,int);
  1173. bool pc_statusup(struct map_session_data*,int,int);
  1174. int pc_statusup2(struct map_session_data*,int,int);
  1175. int pc_getstat(map_session_data *sd, int type);
  1176. int pc_setstat(struct map_session_data* sd, int type, int val);
  1177. int pc_need_trait_point(struct map_session_data *, int, int);
  1178. int pc_maxtraitparameterincrease(struct map_session_data*, int);
  1179. bool pc_traitstatusup(struct map_session_data*, int, int);
  1180. int pc_traitstatusup2(struct map_session_data*, int, int);
  1181. void pc_skillup(struct map_session_data*,uint16 skill_id);
  1182. int pc_allskillup(struct map_session_data*);
  1183. int pc_resetlvl(struct map_session_data*,int type);
  1184. int pc_resetstate(struct map_session_data*);
  1185. int pc_resetskill(struct map_session_data*, int);
  1186. int pc_resetfeel(struct map_session_data*);
  1187. int pc_resethate(struct map_session_data*);
  1188. bool pc_equipitem(struct map_session_data *sd, short n, int req_pos, bool equipswitch=false);
  1189. bool pc_unequipitem(struct map_session_data*,int,int);
  1190. int pc_equipswitch( struct map_session_data* sd, int index );
  1191. void pc_equipswitch_remove( struct map_session_data* sd, int index );
  1192. void pc_checkitem(struct map_session_data*);
  1193. void pc_check_available_item(struct map_session_data *sd, uint8 type);
  1194. int pc_useitem(struct map_session_data*,int);
  1195. int pc_skillatk_bonus(struct map_session_data *sd, uint16 skill_id);
  1196. int pc_sub_skillatk_bonus(struct map_session_data *sd, uint16 skill_id);
  1197. int pc_skillheal_bonus(struct map_session_data *sd, uint16 skill_id);
  1198. int pc_skillheal2_bonus(struct map_session_data *sd, uint16 skill_id);
  1199. void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp, unsigned int ap);
  1200. int pc_dead(struct map_session_data *sd,struct block_list *src);
  1201. void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp, unsigned int ap = 0);
  1202. bool pc_revive_item(struct map_session_data *sd);
  1203. void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, unsigned int ap, int type);
  1204. int pc_itemheal(struct map_session_data *sd, t_itemid itemid, int hp,int sp);
  1205. int pc_percentheal(struct map_session_data *sd,int,int);
  1206. bool pc_jobchange(struct map_session_data *sd, int job, char upper);
  1207. void pc_setoption(struct map_session_data *,int type, int subtype = 0);
  1208. bool pc_setcart(struct map_session_data* sd, int type);
  1209. void pc_setfalcon(struct map_session_data* sd, int flag);
  1210. void pc_setriding(struct map_session_data* sd, int flag);
  1211. void pc_setmadogear(struct map_session_data* sd, bool flag, e_mado_type type = MADO_ROBOT);
  1212. void pc_changelook(struct map_session_data *,int,int);
  1213. void pc_equiplookall(struct map_session_data *sd);
  1214. void pc_set_costume_view(struct map_session_data *sd);
  1215. int64 pc_readparam(struct map_session_data *sd, int64 type);
  1216. bool pc_setparam(struct map_session_data *sd, int64 type, int64 val);
  1217. int64 pc_readreg(struct map_session_data *sd, int64 reg);
  1218. bool pc_setreg(struct map_session_data *sd, int64 reg, int64 val);
  1219. char *pc_readregstr(struct map_session_data *sd, int64 reg);
  1220. bool pc_setregstr(struct map_session_data *sd, int64 reg, const char *str);
  1221. int64 pc_readregistry(struct map_session_data *sd, int64 reg);
  1222. bool pc_setregistry(struct map_session_data *sd, int64 reg, int64 val);
  1223. char *pc_readregistry_str(struct map_session_data *sd, int64 reg);
  1224. bool pc_setregistry_str(struct map_session_data *sd, int64 reg, const char *val);
  1225. #define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg)
  1226. #define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val)
  1227. #define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg)
  1228. #define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1229. #define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg)
  1230. #define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val)
  1231. #define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg)
  1232. #define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1233. #define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg)
  1234. #define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val)
  1235. #define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg)
  1236. #define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val)
  1237. bool pc_setreg2(struct map_session_data *sd, const char *reg, int64 val);
  1238. int64 pc_readreg2(struct map_session_data *sd, const char *reg);
  1239. bool pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
  1240. bool pc_deleventtimer(struct map_session_data *sd,const char *name);
  1241. void pc_cleareventtimer(struct map_session_data *sd);
  1242. void pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick);
  1243. int pc_calc_pvprank(struct map_session_data *sd);
  1244. TIMER_FUNC(pc_calc_pvprank_timer);
  1245. int pc_ismarried(struct map_session_data *sd);
  1246. bool pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd);
  1247. bool pc_divorce(struct map_session_data *sd);
  1248. struct map_session_data *pc_get_partner(struct map_session_data *sd);
  1249. struct map_session_data *pc_get_father(struct map_session_data *sd);
  1250. struct map_session_data *pc_get_mother(struct map_session_data *sd);
  1251. struct map_session_data *pc_get_child(struct map_session_data *sd);
  1252. void pc_bleeding (struct map_session_data *sd, t_tick diff_tick);
  1253. void pc_regen (struct map_session_data *sd, t_tick diff_tick);
  1254. bool pc_setstand(struct map_session_data *sd, bool force);
  1255. bool pc_candrop(struct map_session_data *sd,struct item *item);
  1256. bool pc_can_attack(struct map_session_data *sd, int target_id);
  1257. uint64 pc_jobid2mapid(unsigned short b_class); // Skotlex
  1258. int pc_mapid2jobid(uint64 class_, int sex); // Skotlex
  1259. const char * job_name(int class_);
  1260. struct s_skill_tree_entry {
  1261. uint16 skill_id, max_lv;
  1262. uint32 baselv, joblv;
  1263. std::unordered_map<uint16, uint16> need; /// skill_id, skill_lv
  1264. bool exclude_inherit; // exclude the skill from inherit when loading the table
  1265. };
  1266. struct s_skill_tree {
  1267. std::vector<uint16> inherit_job;
  1268. std::unordered_map<uint16, std::shared_ptr<s_skill_tree_entry>> skills; /// skill_id, entry
  1269. };
  1270. class SkillTreeDatabase : public TypesafeYamlDatabase<uint16, s_skill_tree> {
  1271. public:
  1272. SkillTreeDatabase() : TypesafeYamlDatabase("SKILL_TREE_DB", 1) {
  1273. }
  1274. const std::string getDefaultLocation();
  1275. uint64 parseBodyNode(const YAML::Node& node);
  1276. void loadingFinished();
  1277. // Additional
  1278. std::shared_ptr<s_skill_tree_entry> get_skill_data(int class_, uint16 skill_id);
  1279. };
  1280. extern SkillTreeDatabase skill_tree_db;
  1281. struct sg_data {
  1282. short anger_id;
  1283. short bless_id;
  1284. short comfort_id;
  1285. char feel_var[NAME_LENGTH];
  1286. char hate_var[NAME_LENGTH];
  1287. bool (*day_func)(void);
  1288. };
  1289. extern const struct sg_data sg_info[MAX_PC_FEELHATE];
  1290. void pc_set_bg_queue_timer(map_session_data *sd);
  1291. void pc_delete_bg_queue_timer(map_session_data *sd);
  1292. void pc_setinvincibletimer(struct map_session_data* sd, int val);
  1293. void pc_delinvincibletimer(struct map_session_data* sd);
  1294. void pc_addspiritball(struct map_session_data *sd,int interval,int max);
  1295. void pc_delspiritball(struct map_session_data *sd,int count,int type);
  1296. int pc_addsoulball(map_session_data *sd, int max);
  1297. int pc_delsoulball(map_session_data *sd, int count, bool type);
  1298. void pc_addservantball( struct map_session_data& sd, int count = 1 );
  1299. void pc_delservantball( struct map_session_data& sd, int count = 1 );
  1300. void pc_addabyssball( struct map_session_data& sd, int count = 1 );
  1301. void pc_delabyssball( struct map_session_data& sd, int count = 1 );
  1302. void pc_addfame(struct map_session_data *sd,int count);
  1303. unsigned char pc_famerank(uint32 char_id, int job);
  1304. bool pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl);
  1305. extern struct fame_list smith_fame_list[MAX_FAME_LIST];
  1306. extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
  1307. extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
  1308. void pc_readdb(void);
  1309. void do_init_pc(void);
  1310. void do_final_pc(void);
  1311. // timer for night.day
  1312. extern int day_timer_tid;
  1313. extern int night_timer_tid;
  1314. TIMER_FUNC(map_day_timer); // by [yor]
  1315. TIMER_FUNC(map_night_timer); // by [yor]
  1316. // Rental System
  1317. void pc_inventory_rentals(struct map_session_data *sd);
  1318. void pc_inventory_rental_clear(struct map_session_data *sd);
  1319. void pc_inventory_rental_add(struct map_session_data *sd, unsigned int seconds);
  1320. int pc_read_motd(void); // [Valaris]
  1321. int pc_disguise(struct map_session_data *sd, int class_);
  1322. bool pc_isautolooting(struct map_session_data *sd, t_itemid nameid);
  1323. void pc_overheat(struct map_session_data *sd, int16 heat);
  1324. void pc_itemcd_do(struct map_session_data *sd, bool load);
  1325. uint8 pc_itemcd_add(struct map_session_data *sd, struct item_data *id, t_tick tick, unsigned short n);
  1326. uint8 pc_itemcd_check(struct map_session_data *sd, struct item_data *id, t_tick tick, unsigned short n);
  1327. int pc_load_combo(struct map_session_data *sd);
  1328. void pc_addspiritcharm(struct map_session_data *sd, int interval, int max, int type);
  1329. void pc_delspiritcharm(struct map_session_data *sd, int count, int type);
  1330. void pc_baselevelchanged(struct map_session_data *sd);
  1331. void pc_damage_log_add(struct map_session_data *sd, int id);
  1332. void pc_damage_log_clear(struct map_session_data *sd, int id);
  1333. enum e_BANKING_DEPOSIT_ACK : uint8;
  1334. enum e_BANKING_WITHDRAW_ACK : uint8;
  1335. enum e_BANKING_DEPOSIT_ACK pc_bank_deposit(struct map_session_data *sd, int money);
  1336. enum e_BANKING_WITHDRAW_ACK pc_bank_withdraw(struct map_session_data *sd, int money);
  1337. void pc_crimson_marker_clear(struct map_session_data *sd);
  1338. void pc_show_version(struct map_session_data *sd);
  1339. TIMER_FUNC(pc_bonus_script_timer);
  1340. void pc_bonus_script(struct map_session_data *sd);
  1341. struct s_bonus_script_entry *pc_bonus_script_add(struct map_session_data *sd, const char *script_str, t_tick dur, enum efst_types icon, uint16 flag, uint8 type);
  1342. void pc_bonus_script_clear(struct map_session_data *sd, uint16 flag);
  1343. void pc_cell_basilica(struct map_session_data *sd);
  1344. short pc_get_itemgroup_bonus(struct map_session_data* sd, t_itemid nameid, std::vector<s_item_bonus>& bonuses);
  1345. short pc_get_itemgroup_bonus_group(struct map_session_data* sd, uint16 group_id, std::vector<s_item_bonus>& bonuses);
  1346. bool pc_is_same_equip_index(enum equip_index eqi, short *equip_index, short index);
  1347. /// Check if player is Taekwon Ranker and the level is >= 90 (battle_config.taekwon_ranker_min_lv)
  1348. #define pc_is_taekwon_ranker(sd) (((sd)->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && (sd)->status.base_level >= battle_config.taekwon_ranker_min_lv && pc_famerank((sd)->status.char_id,MAPID_TAEKWON))
  1349. TIMER_FUNC(pc_autotrade_timer);
  1350. void pc_validate_skill(struct map_session_data *sd);
  1351. void pc_show_questinfo(struct map_session_data *sd);
  1352. void pc_show_questinfo_reinit(struct map_session_data *sd);
  1353. bool pc_job_can_entermap(enum e_job jobid, int m, int group_lv);
  1354. #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
  1355. uint16 pc_level_penalty_mod( struct map_session_data* sd, e_penalty_type type, std::shared_ptr<s_mob_db> mob, mob_data* md = nullptr );
  1356. #endif
  1357. bool pc_attendance_enabled();
  1358. int32 pc_attendance_counter( struct map_session_data* sd );
  1359. void pc_attendance_claim_reward( struct map_session_data* sd );
  1360. #endif /* PC_HPP */