mmo.hpp 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef MMO_HPP
  4. #define MMO_HPP
  5. #include <time.h>
  6. #include "../config/core.hpp"
  7. #include "cbasetypes.hpp"
  8. #include "db.hpp"
  9. #include "timer.hpp" // t_tick
  10. #ifndef PACKETVER
  11. #error Please define PACKETVER in src/config/packets.hpp
  12. #endif
  13. ///Remove/Comment this line to disable sc_data saving. [Skotlex]
  14. #define ENABLE_SC_SAVING
  15. /** Remove/Comment this line to disable server-side hot-key saving support [Skotlex]
  16. * Note that newer clients no longer save hotkeys in the registry! */
  17. #define HOTKEY_SAVING
  18. #if PACKETVER < 20090603
  19. // (27 = 9 skills x 3 bars) (0x02b9,191)
  20. #define MAX_HOTKEYS 27
  21. #elif PACKETVER < 20090617
  22. // (36 = 9 skills x 4 bars) (0x07d9,254)
  23. #define MAX_HOTKEYS 36
  24. #else
  25. // (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268)
  26. #define MAX_HOTKEYS 38
  27. #endif
  28. #if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190508 || PACKETVER_ZERO_NUM >= 20190605
  29. #define MAX_HOTKEYS_DB ((MAX_HOTKEYS) * 2)
  30. #else
  31. #define MAX_HOTKEYS_DB MAX_HOTKEYS
  32. #endif
  33. #define MAX_MAP_PER_SERVER 1500 /// Maximum amount of maps available on a server
  34. #ifndef INVENTORY_BASE_SIZE
  35. #define INVENTORY_BASE_SIZE 100 // Amount of inventory slots each player has
  36. #endif
  37. #ifndef INVENTORY_EXPANSION_SIZE
  38. #if PACKETVER_MAIN_NUM >= 20181031 || PACKETVER_RE_NUM >= 20181031 || PACKETVER_ZERO_NUM >= 20181114
  39. #define INVENTORY_EXPANSION_SIZE 100 // Amount of additional inventory slots a player can have
  40. #else
  41. #define INVENTORY_EXPANSION_SIZE 0
  42. #endif
  43. #endif
  44. #ifndef MAX_INVENTORY
  45. #define MAX_INVENTORY ( INVENTORY_BASE_SIZE + INVENTORY_EXPANSION_SIZE ) // Maximum items in player inventory (in total)
  46. #else
  47. #if MAX_INVENTORY < ( INVENTORY_BASE_SIZE + INVENTORY_EXPANSION_SIZE )
  48. #error Your custom MAX_INVENTORY define is too low
  49. #endif
  50. #endif
  51. /** Max number of characters per account. Note that changing this setting alone is not enough if the client is not hexed to support more characters as well.
  52. * Max value tested was 265 */
  53. #ifndef MAX_CHARS
  54. #if PACKETVER >= 20180124
  55. #define MAX_CHARS 15
  56. #elif PACKETVER >= 20100413
  57. #define MAX_CHARS 12
  58. #else
  59. #define MAX_CHARS 9
  60. #endif
  61. #endif
  62. typedef uint32 t_itemid;
  63. /** Number of slots carded equipment can have. Never set to less than 4 as they are also used to keep the data of forged items/equipment. [Skotlex]
  64. * Note: The client seems unable to receive data for more than 4 slots due to all related packets having a fixed size. */
  65. #define MAX_SLOTS 4
  66. #define MAX_AMOUNT 30000 ////Max amount of a single stacked item
  67. #define MAX_ZENY INT_MAX ///Max zeny
  68. #define MAX_BANK_ZENY SINT32_MAX ///Max zeny in Bank
  69. #define MAX_FAME 1000000000 ///Max fame points
  70. #define MAX_CART 100 ///Maximum item in cart
  71. #define MAX_SKILL 1454 ///Maximum skill can be hold by Player, Homunculus, & Mercenary (skill list) AND skill_db limit
  72. #define DEFAULT_WALK_SPEED 150 ///Default walk speed
  73. #define MIN_WALK_SPEED 20 ///Min walk speed
  74. #define MAX_WALK_SPEED 1000 ///Max walk speed
  75. #define MAX_STORAGE 600 ///Max number of storage slots a player can have
  76. #define MAX_GUILD_STORAGE 600 ///Max number of storage slots a guild
  77. #define MAX_PARTY 12 ///Max party member
  78. #define MAX_GUILD 16+10*6 ///Increased max guild members +6 per 1 extension levels [Lupus]
  79. #define MAX_GUILDPOSITION 20 ///Increased max guild positions to accomodate for all members [Valaris] (removed) [PoW]
  80. #define MAX_GUILDEXPULSION 32 ///Max Guild expulsion
  81. #define MAX_GUILDALLIANCE 16 ///Max Guild alliance
  82. #ifdef RENEWAL
  83. #define MAX_GUILDSKILL 20 ///Max Guild skills
  84. #else
  85. #define MAX_GUILDSKILL 15 ///Max Guild skills
  86. #endif
  87. #define MAX_GUILDLEVEL 50 ///Max Guild level
  88. #define MAX_GUARDIANS 8 ///Local max per castle. If this value is increased, need to add more fields on MySQL `guild_castle` table [Skotlex]
  89. #define MAX_QUEST_OBJECTIVES 3 ///Max quest objectives for a quest
  90. #define MAX_PC_BONUS_SCRIPT 50 ///Max bonus script can be fetched from `bonus_script` table on player load [Cydh]
  91. #define MAX_ITEM_RDM_OPT 5 /// Max item random option [Napster]
  92. #define DB_NAME_LEN 256 //max len of dbs
  93. #define MAX_CLAN 500
  94. #define MAX_CLANALLIANCE 6
  95. #ifndef MAX_BARTER_REQUIREMENTS
  96. #define MAX_BARTER_REQUIREMENTS 5
  97. #endif
  98. #ifdef RENEWAL
  99. #define MAX_WEAPON_LEVEL 5
  100. #define MAX_ARMOR_LEVEL 2
  101. #else
  102. #define MAX_WEAPON_LEVEL 4
  103. #define MAX_ARMOR_LEVEL 1
  104. #endif
  105. // for produce
  106. #define MIN_ATTRIBUTE 0
  107. #define MAX_ATTRIBUTE 4
  108. #define ATTRIBUTE_NORMAL 0
  109. #define MIN_STAR 0
  110. #define MAX_STAR 3
  111. const t_itemid WEDDING_RING_M = 2634;
  112. const t_itemid WEDDING_RING_F = 2635;
  113. //For character names, title names, guilds, maps, etc.
  114. //Includes null-terminator as it is the length of the array.
  115. #define NAME_LENGTH (23 + 1)
  116. #define PASSWD_LENGTH (32+1)
  117. //NPC names can be longer than it's displayed on client (NAME_LENGTH).
  118. #define NPC_NAME_LENGTH 50
  119. // <NPC_NAME_LENGTH> for npc name + 2 for a "::" + <NAME_LENGTH> for label + 1 for EOS
  120. #define EVENT_NAME_LENGTH ( NPC_NAME_LENGTH + 2 + NAME_LENGTH + 1 )
  121. //For item names, which tend to have much longer names.
  122. #define ITEM_NAME_LENGTH 50
  123. //For Map Names, which the client considers to be 16 in length including the .gat extension
  124. #define MAP_NAME_LENGTH (11 + 1)
  125. #define MAP_NAME_LENGTH_EXT (MAP_NAME_LENGTH + 4)
  126. //Pincode Length
  127. #define PINCODE_LENGTH 4
  128. #define MAX_FRIENDS 40
  129. #define MAX_MEMOPOINTS 3
  130. #define MAX_SKILLCOOLDOWN 20
  131. //Size of the fame list arrays.
  132. #define MAX_FAME_LIST 10
  133. //Limits to avoid ID collision with other game objects
  134. #define START_ACCOUNT_NUM 2000000
  135. #define END_ACCOUNT_NUM 100000000
  136. #define START_CHAR_NUM 150000
  137. //Guilds
  138. #define MAX_GUILDMES1 60
  139. #define MAX_GUILDMES2 120
  140. //Base Homun skill.
  141. #define HM_SKILLBASE 8001
  142. #define MAX_HOMUNSKILL 43
  143. #define MAX_HOMUNCULUS_CLASS 52 //[orn], Increased to 60 from 16 to allow new Homun-S.
  144. #define HM_CLASS_BASE 6001
  145. #define HM_CLASS_MAX (HM_CLASS_BASE+MAX_HOMUNCULUS_CLASS-1)
  146. //Mail System
  147. #define MAIL_MAX_INBOX 30
  148. #define MAIL_TITLE_LENGTH 40
  149. #if PACKETVER < 20150513
  150. #define MAIL_BODY_LENGTH 200
  151. #define MAIL_MAX_ITEM 1
  152. #else
  153. #define MAIL_BODY_LENGTH 500
  154. #define MAIL_MAX_ITEM 5
  155. #define MAIL_PAGE_SIZE 7
  156. #endif
  157. #ifndef MAIL_ITERATION_SIZE
  158. #define MAIL_ITERATION_SIZE 100
  159. #endif
  160. //Mercenary System
  161. #define MC_SKILLBASE 8201
  162. #define MAX_MERCSKILL 41
  163. //Elemental System
  164. #define MAX_ELEMENTALSKILL 57
  165. #define EL_SKILLBASE 8401
  166. //Automated Battle Robot System
  167. #define ABR_SKILLBASE 8601
  168. #define MAX_ABRSKILL 5
  169. //Achievement System
  170. #define MAX_ACHIEVEMENT_OBJECTIVES 10 /// Maximum different objectives in achievement_db.yml
  171. #define MAX_ACHIEVEMENT_DEPENDENTS 20 /// Maximum different dependents in achievement_db.yml
  172. #define ACHIEVEMENT_NAME_LENGTH 50 /// Max Achievement Name length
  173. enum item_types {
  174. IT_HEALING = 0,
  175. IT_UNKNOWN, //1
  176. IT_USABLE, //2
  177. IT_ETC, //3
  178. IT_ARMOR, //4
  179. IT_WEAPON, //5
  180. IT_CARD, //6
  181. IT_PETEGG, //7
  182. IT_PETARMOR,//8
  183. IT_UNKNOWN2,//9
  184. IT_AMMO, //10
  185. IT_DELAYCONSUME,//11
  186. IT_SHADOWGEAR, //12
  187. IT_CASH = 18,
  188. IT_MAX
  189. };
  190. /// Monster mode definitions to clear up code reading. [Skotlex]
  191. enum e_mode {
  192. MD_NONE = 0x0000000,
  193. MD_CANMOVE = 0x0000001,
  194. MD_LOOTER = 0x0000002,
  195. MD_AGGRESSIVE = 0x0000004,
  196. MD_ASSIST = 0x0000008,
  197. MD_CASTSENSORIDLE = 0x0000010,
  198. MD_NORANDOMWALK = 0x0000020,
  199. MD_NOCAST = 0x0000040,
  200. MD_CANATTACK = 0x0000080,
  201. //FREE = 0x0000100,
  202. MD_CASTSENSORCHASE = 0x0000200,
  203. MD_CHANGECHASE = 0x0000400,
  204. MD_ANGRY = 0x0000800,
  205. MD_CHANGETARGETMELEE = 0x0001000,
  206. MD_CHANGETARGETCHASE = 0x0002000,
  207. MD_TARGETWEAK = 0x0004000,
  208. MD_RANDOMTARGET = 0x0008000,
  209. MD_IGNOREMELEE = 0x0010000,
  210. MD_IGNOREMAGIC = 0x0020000,
  211. MD_IGNORERANGED = 0x0040000,
  212. MD_MVP = 0x0080000,
  213. MD_IGNOREMISC = 0x0100000,
  214. MD_KNOCKBACKIMMUNE = 0x0200000,
  215. MD_TELEPORTBLOCK = 0x0400000,
  216. //FREE = 0x0800000,
  217. MD_FIXEDITEMDROP = 0x1000000,
  218. MD_DETECTOR = 0x2000000,
  219. MD_STATUSIMMUNE = 0x4000000,
  220. MD_SKILLIMMUNE = 0x8000000,
  221. };
  222. #define MD_MASK 0x000FFFF
  223. #define ATR_MASK 0x0FF0000
  224. #define CL_MASK 0xF000000
  225. // Questlog states
  226. enum e_quest_state : uint8 {
  227. Q_INACTIVE, ///< Inactive quest (the user can toggle between active and inactive quests)
  228. Q_ACTIVE, ///< Active quest
  229. Q_COMPLETE, ///< Completed quest
  230. };
  231. /// Questlog entry
  232. struct quest {
  233. int quest_id; ///< Quest ID
  234. uint32 time; ///< Expiration time
  235. int count[MAX_QUEST_OBJECTIVES]; ///< Kill counters of each quest objective
  236. e_quest_state state; ///< Current quest state
  237. };
  238. /// Achievement log entry
  239. struct achievement {
  240. int achievement_id; ///< Achievement ID
  241. int count[MAX_ACHIEVEMENT_OBJECTIVES]; ///< Counters of each achievement objective
  242. time_t completed; ///< Date completed
  243. time_t rewarded; ///< Received reward?
  244. int score; ///< Amount of points achievement is worth
  245. };
  246. // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
  247. #if !defined( sun ) && ( !defined( __NETBSD__ ) || __NetBSD_Version__ >= 600000000 )
  248. #pragma pack( push, 1 )
  249. #endif
  250. struct s_item_randomoption {
  251. short id;
  252. short value;
  253. char param;
  254. } __attribute__((packed));
  255. struct item {
  256. int id;
  257. t_itemid nameid;
  258. short amount;
  259. unsigned int equip; // location(s) where item is equipped (using enum equip_pos for bitmasking)
  260. char identify;
  261. char refine;
  262. char attribute;
  263. t_itemid card[MAX_SLOTS];
  264. struct s_item_randomoption option[MAX_ITEM_RDM_OPT]; // max of 5 random options can be supported.
  265. unsigned int expire_time;
  266. char favorite, bound;
  267. uint64 unique_id;
  268. unsigned int equipSwitch; // location(s) where item is equipped for equip switching (using enum equip_pos for bitmasking)
  269. uint8 enchantgrade;
  270. } __attribute__((packed));
  271. // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
  272. #if !defined( sun ) && ( !defined( __NETBSD__ ) || __NetBSD_Version__ >= 600000000 )
  273. #pragma pack( pop )
  274. #endif
  275. //Equip position constants
  276. enum equip_pos : uint32 {
  277. EQP_HEAD_LOW = 0x000001,
  278. EQP_HEAD_MID = 0x000200, // 512
  279. EQP_HEAD_TOP = 0x000100, // 256
  280. EQP_HAND_R = 0x000002, // 2
  281. EQP_HAND_L = 0x000020, // 32
  282. EQP_ARMOR = 0x000010, // 16
  283. EQP_SHOES = 0x000040, // 64
  284. EQP_GARMENT = 0x000004, // 4
  285. EQP_ACC_R = 0x000008, // 8
  286. EQP_ACC_L = 0x000080, // 128
  287. EQP_COSTUME_HEAD_TOP = 0x000400, // 1024
  288. EQP_COSTUME_HEAD_MID = 0x000800, // 2048
  289. EQP_COSTUME_HEAD_LOW = 0x001000, // 4096
  290. EQP_COSTUME_GARMENT = 0x002000, // 8192
  291. //EQP_COSTUME_FLOOR = 0x004000, // 16384
  292. EQP_AMMO = 0x008000, // 32768
  293. EQP_SHADOW_ARMOR = 0x010000, // 65536
  294. EQP_SHADOW_WEAPON = 0x020000, // 131072
  295. EQP_SHADOW_SHIELD = 0x040000, // 262144
  296. EQP_SHADOW_SHOES = 0x080000, // 524288
  297. EQP_SHADOW_ACC_R = 0x100000, // 1048576
  298. EQP_SHADOW_ACC_L = 0x200000, // 2097152
  299. // Combined
  300. EQP_ACC_RL = EQP_ACC_R|EQP_ACC_L,
  301. EQP_SHADOW_ACC_RL = EQP_SHADOW_ACC_R|EQP_SHADOW_ACC_L,
  302. };
  303. struct point {
  304. unsigned short map;
  305. short x,y;
  306. };
  307. struct startitem {
  308. t_itemid nameid;
  309. unsigned short amount;
  310. uint32 pos;
  311. };
  312. enum e_skill_flag
  313. {
  314. SKILL_FLAG_PERMANENT,
  315. SKILL_FLAG_TEMPORARY,
  316. SKILL_FLAG_PLAGIARIZED,
  317. SKILL_FLAG_PERM_GRANTED, // Permanent, granted through someway e.g. script
  318. SKILL_FLAG_TMP_COMBO, //@FIXME for homunculus combo atm
  319. //! NOTE: This flag be the last flag, and don't change the value if not needed!
  320. SKILL_FLAG_REPLACED_LV_0 = 10, // temporary skill overshadowing permanent skill of level 'N - SKILL_FLAG_REPLACED_LV_0',
  321. };
  322. struct s_skill {
  323. uint16 id;
  324. uint8 lv;
  325. uint8 flag; // see enum e_skill_flag
  326. };
  327. struct script_reg_state {
  328. unsigned int type : 1; // because I'm a memory hoarder and having them in the same struct would be a 8-byte/instance waste while ints outnumber str on a 10000-to-1 ratio.
  329. unsigned int update : 1; // whether it needs to be sent to char server for insertion/update/delete
  330. };
  331. struct script_reg_num {
  332. struct script_reg_state flag;
  333. int64 value;
  334. };
  335. struct script_reg_str {
  336. struct script_reg_state flag;
  337. char *value;
  338. };
  339. //For saving status changes across sessions. [Skotlex]
  340. struct status_change_data {
  341. unsigned short type; //SC_type
  342. long val1, val2, val3, val4;
  343. t_tick tick; //Remaining duration.
  344. };
  345. #define MAX_BONUS_SCRIPT_LENGTH 512
  346. struct bonus_script_data {
  347. char script_str[MAX_BONUS_SCRIPT_LENGTH]; //< Script string
  348. t_tick tick; ///< Tick
  349. uint16 flag; ///< Flags @see enum e_bonus_script_flags
  350. int16 icon; ///< Icon SI
  351. uint8 type; ///< 0 - None, 1 - Buff, 2 - Debuff
  352. };
  353. struct skill_cooldown_data {
  354. unsigned short skill_id;
  355. t_tick tick;
  356. };
  357. enum storage_type {
  358. TABLE_INVENTORY = 1,
  359. TABLE_CART,
  360. TABLE_STORAGE,
  361. TABLE_GUILD_STORAGE,
  362. };
  363. enum e_storage_mode {
  364. STOR_MODE_NONE = 0x0,
  365. STOR_MODE_GET = 0x1,
  366. STOR_MODE_PUT = 0x2,
  367. STOR_MODE_ALL = 0x3,
  368. };
  369. struct s_storage {
  370. bool dirty; ///< Dirty status, data needs to be saved
  371. bool status; ///< Current status of storage (opened or closed)
  372. uint16 amount; ///< Amount of items in storage
  373. bool lock; ///< If locked, can't use storage when item bound retrieval
  374. uint32 id; ///< Account ID / Character ID / Guild ID (owner of storage)
  375. enum storage_type type; ///< Type of storage (inventory, cart, storage, guild storage)
  376. uint16 max_amount; ///< Maximum amount of items in storage
  377. uint8 stor_id; ///< Storage ID
  378. struct {
  379. unsigned get : 1;
  380. unsigned put : 1;
  381. } state;
  382. union { // Max for inventory, storage, cart, and guild storage are 818 each without changing this struct and struct item [2016/08/14]
  383. struct item items_inventory[MAX_INVENTORY];
  384. struct item items_storage[MAX_STORAGE];
  385. struct item items_cart[MAX_CART];
  386. struct item items_guild[MAX_GUILD_STORAGE];
  387. } u;
  388. };
  389. struct s_storage_table {
  390. char name[NAME_LENGTH];
  391. char table[DB_NAME_LEN];
  392. uint16 max_num;
  393. uint8 id;
  394. };
  395. struct s_pet {
  396. uint32 account_id;
  397. uint32 char_id;
  398. int pet_id;
  399. short class_;
  400. short level;
  401. t_itemid egg_id;//pet egg id
  402. t_itemid equip;//pet equip name_id
  403. short intimate;//pet friendly
  404. short hungry;//pet hungry
  405. char name[NAME_LENGTH];
  406. char rename_flag;
  407. char incubate;
  408. bool autofeed;
  409. };
  410. struct s_homunculus { //[orn]
  411. char name[NAME_LENGTH];
  412. int hom_id;
  413. uint32 char_id;
  414. short class_;
  415. short prev_class;
  416. int hp,max_hp,sp,max_sp;
  417. unsigned int intimacy; //[orn]
  418. short hunger;
  419. struct s_skill hskill[MAX_HOMUNSKILL]; //albator
  420. short skillpts;
  421. short level;
  422. t_exp exp;
  423. short rename_flag;
  424. short vaporize; //albator
  425. int str;
  426. int agi;
  427. int vit;
  428. int int_;
  429. int dex;
  430. int luk;
  431. int str_value;
  432. int agi_value;
  433. int vit_value;
  434. int int_value;
  435. int dex_value;
  436. int luk_value;
  437. char spiritball; //for homun S [lighta]
  438. bool autofeed;
  439. };
  440. struct s_mercenary {
  441. int mercenary_id;
  442. uint32 char_id;
  443. short class_;
  444. int hp, sp;
  445. unsigned int kill_count;
  446. t_tick life_time;
  447. };
  448. struct s_elemental {
  449. int elemental_id;
  450. uint32 char_id;
  451. short class_;
  452. int mode;
  453. int hp, sp, max_hp, max_sp, matk, atk, atk2;
  454. short hit, flee, amotion, def, mdef;
  455. t_tick life_time;
  456. };
  457. struct s_friend {
  458. uint32 account_id;
  459. uint32 char_id;
  460. char name[NAME_LENGTH];
  461. };
  462. #ifdef HOTKEY_SAVING
  463. struct hotkey {
  464. unsigned int id;
  465. unsigned short lv;
  466. unsigned char type; // 0: item, 1: skill
  467. };
  468. #endif
  469. struct mmo_charstatus {
  470. uint32 char_id;
  471. uint32 account_id;
  472. uint32 partner_id;
  473. uint32 father;
  474. uint32 mother;
  475. uint32 child;
  476. t_exp base_exp,job_exp;
  477. int zeny;
  478. short class_; ///< Player's JobID
  479. unsigned int status_point,skill_point,trait_point;
  480. int hp,max_hp,sp,max_sp,ap,max_ap;
  481. unsigned int option;
  482. short manner; // Defines how many minutes a char will be muted, each negative point is equivalent to a minute.
  483. unsigned char karma;
  484. short hair,hair_color,clothes_color,body;
  485. int party_id,guild_id,pet_id,hom_id,mer_id,ele_id,clan_id;
  486. int fame;
  487. // Mercenary Guilds Rank
  488. int arch_faith, arch_calls;
  489. int spear_faith, spear_calls;
  490. int sword_faith, sword_calls;
  491. short weapon; // enum weapon_type
  492. short shield; // view-id
  493. short head_top,head_mid,head_bottom;
  494. short robe;
  495. char name[NAME_LENGTH];
  496. unsigned int base_level,job_level;
  497. unsigned short str,agi,vit,int_,dex,luk;
  498. unsigned short pow,sta,wis,spl,con,crt;
  499. unsigned char slot,sex;
  500. uint32 mapip;
  501. uint16 mapport;
  502. struct point last_point,save_point,memo_point[MAX_MEMOPOINTS];
  503. struct s_skill skill[MAX_SKILL];
  504. struct s_friend friends[MAX_FRIENDS]; //New friend system [Skotlex]
  505. #ifdef HOTKEY_SAVING
  506. struct hotkey hotkeys[MAX_HOTKEYS_DB];
  507. #endif
  508. bool show_equip,allow_party;
  509. short rename;
  510. time_t delete_date;
  511. time_t unban_time;
  512. // Char server addon system
  513. unsigned int character_moves;
  514. unsigned char font;
  515. bool cashshop_sent; // Whether the player has received the CashShop list
  516. uint32 uniqueitem_counter;
  517. unsigned char hotkey_rowshift;
  518. unsigned char hotkey_rowshift2;
  519. unsigned long title_id;
  520. uint16 inventory_slots;
  521. };
  522. typedef enum mail_status {
  523. MAIL_NEW,
  524. MAIL_UNREAD,
  525. MAIL_READ,
  526. } mail_status;
  527. enum mail_inbox_type {
  528. MAIL_INBOX_NORMAL = 0,
  529. MAIL_INBOX_ACCOUNT,
  530. MAIL_INBOX_RETURNED
  531. };
  532. enum mail_attachment_type {
  533. MAIL_ATT_NONE = 0,
  534. MAIL_ATT_ZENY = 1,
  535. MAIL_ATT_ITEM = 2,
  536. MAIL_ATT_ALL = MAIL_ATT_ZENY | MAIL_ATT_ITEM
  537. };
  538. struct mail_message {
  539. int id;
  540. uint32 send_id; //hold char_id of sender
  541. char send_name[NAME_LENGTH]; //sender nickname
  542. uint32 dest_id; //hold char_id of receiver
  543. char dest_name[NAME_LENGTH]; //receiver nickname
  544. char title[MAIL_TITLE_LENGTH];
  545. char body[MAIL_BODY_LENGTH];
  546. enum mail_inbox_type type;
  547. time_t scheduled_deletion;
  548. mail_status status;
  549. time_t timestamp; // marks when the message was sent
  550. uint32 zeny;
  551. struct item item[MAIL_MAX_ITEM];
  552. };
  553. struct mail_data {
  554. short amount;
  555. bool full;
  556. short unchecked, unread;
  557. struct mail_message msg[MAIL_MAX_INBOX];
  558. };
  559. struct auction_data {
  560. unsigned int auction_id;
  561. int seller_id;
  562. char seller_name[NAME_LENGTH];
  563. int buyer_id;
  564. char buyer_name[NAME_LENGTH];
  565. struct item item;
  566. // This data is required for searching, as itemdb is not read by char server
  567. char item_name[ITEM_NAME_LENGTH];
  568. short type;
  569. unsigned short hours;
  570. int price, buynow;
  571. time_t timestamp; // auction's end time
  572. int auction_end_timer;
  573. };
  574. struct party_member {
  575. uint32 account_id;
  576. uint32 char_id;
  577. char name[NAME_LENGTH];
  578. unsigned short class_;
  579. unsigned short map;
  580. unsigned short lv;
  581. unsigned leader : 1,
  582. online : 1;
  583. };
  584. struct party {
  585. int party_id;
  586. char name[NAME_LENGTH];
  587. unsigned char count; //Count of online characters.
  588. unsigned exp : 1,
  589. item : 2; //&1: Party-Share (round-robin), &2: pickup style: shared.
  590. struct party_member member[MAX_PARTY];
  591. };
  592. struct map_session_data;
  593. struct guild_member {
  594. uint32 account_id, char_id;
  595. short hair,hair_color,gender,class_,lv;
  596. t_exp exp;
  597. short online,position;
  598. char name[NAME_LENGTH];
  599. struct map_session_data *sd;
  600. unsigned char modified;
  601. uint32 last_login;
  602. };
  603. struct guild_position {
  604. char name[NAME_LENGTH];
  605. int mode;
  606. int exp_mode;
  607. unsigned char modified;
  608. };
  609. struct guild_alliance {
  610. int opposition;
  611. int guild_id;
  612. char name[NAME_LENGTH];
  613. };
  614. struct guild_expulsion {
  615. char name[NAME_LENGTH];
  616. char mes[40];
  617. uint32 account_id;
  618. };
  619. struct guild_skill {
  620. int id,lv;
  621. };
  622. struct Channel;
  623. struct guild {
  624. int guild_id;
  625. short guild_lv, connect_member, max_member, average_lv;
  626. t_exp exp;
  627. t_exp next_exp;
  628. int skill_point;
  629. char name[NAME_LENGTH],master[NAME_LENGTH];
  630. struct guild_member member[MAX_GUILD];
  631. struct guild_position position[MAX_GUILDPOSITION];
  632. char mes1[MAX_GUILDMES1],mes2[MAX_GUILDMES2];
  633. int emblem_len,emblem_id;
  634. char emblem_data[2048];
  635. struct guild_alliance alliance[MAX_GUILDALLIANCE];
  636. struct guild_expulsion expulsion[MAX_GUILDEXPULSION];
  637. struct guild_skill skill[MAX_GUILDSKILL];
  638. struct Channel *channel;
  639. int instance_id;
  640. time_t last_leader_change;
  641. /* Used by char-server to save events for guilds */
  642. unsigned short save_flag;
  643. int32 chargeshout_flag_id;
  644. };
  645. struct guild_castle {
  646. int castle_id;
  647. int mapindex;
  648. char castle_name[NAME_LENGTH];
  649. char castle_event[NPC_NAME_LENGTH];
  650. int guild_id;
  651. int economy;
  652. int defense;
  653. int triggerE;
  654. int triggerD;
  655. int nextTime;
  656. int payTime;
  657. int createTime;
  658. int visibleC;
  659. struct {
  660. unsigned visible : 1;
  661. int id; // object id
  662. } guardian[MAX_GUARDIANS];
  663. int* temp_guardians; // ids of temporary guardians (mobs)
  664. int temp_guardians_max;
  665. };
  666. /// Enum for guild castle data script commands
  667. enum e_castle_data : uint8 {
  668. CD_NONE = 0,
  669. CD_GUILD_ID, ///< Guild ID
  670. CD_CURRENT_ECONOMY, ///< Castle Economy score
  671. CD_CURRENT_DEFENSE, ///< Castle Defense score
  672. CD_INVESTED_ECONOMY, ///< Number of times the economy was invested in today
  673. CD_INVESTED_DEFENSE, ///< Number of times the defense was invested in today
  674. CD_NEXT_TIME, ///< unused
  675. CD_PAY_TIME, ///< unused
  676. CD_CREATE_TIME, ///< unused
  677. CD_ENABLED_KAFRA, ///< Is 1 if a Kafra was hired for this castle, 0 otherwise
  678. CD_ENABLED_GUARDIAN00, ///< Is 1 if the 1st guardian is present (Soldier Guardian)
  679. // The others in between are not needed in src, but are exported for the script engine
  680. CD_MAX = CD_ENABLED_GUARDIAN00 + MAX_GUARDIANS
  681. };
  682. /// Guild Permissions
  683. enum e_guild_permission {
  684. GUILD_PERM_INVITE = 0x001,
  685. GUILD_PERM_EXPEL = 0x010,
  686. GUILD_PERM_STORAGE = 0x100,
  687. #if PACKETVER >= 20140205
  688. GUILD_PERM_ALL = GUILD_PERM_INVITE|GUILD_PERM_EXPEL|GUILD_PERM_STORAGE,
  689. #else
  690. GUILD_PERM_ALL = GUILD_PERM_INVITE|GUILD_PERM_EXPEL,
  691. #endif
  692. GUILD_PERM_DEFAULT = GUILD_PERM_ALL,
  693. };
  694. struct fame_list {
  695. int id;
  696. int fame;
  697. char name[NAME_LENGTH];
  698. };
  699. enum e_guild_info { //Change Guild Infos
  700. GBI_EXP =1, // Guild Experience (EXP)
  701. GBI_GUILDLV, // Guild level
  702. GBI_SKILLPOINT, // Guild skillpoints
  703. GBI_SKILLLV, // Guild skill_lv ?? seem unused
  704. };
  705. enum e_guild_member_info { //Change Member Infos
  706. GMI_POSITION =0,
  707. GMI_EXP,
  708. GMI_HAIR,
  709. GMI_HAIR_COLOR,
  710. GMI_GENDER,
  711. GMI_CLASS,
  712. GMI_LEVEL,
  713. };
  714. enum e_guild_skill {
  715. GD_SKILLBASE = 10000,
  716. GD_APPROVAL = 10000,
  717. GD_KAFRACONTRACT,
  718. GD_GUARDRESEARCH,
  719. GD_GUARDUP,
  720. GD_EXTENSION,
  721. GD_GLORYGUILD,
  722. GD_LEADERSHIP,
  723. GD_GLORYWOUNDS,
  724. GD_SOULCOLD,
  725. GD_HAWKEYES,
  726. GD_BATTLEORDER,
  727. GD_REGENERATION,
  728. GD_RESTORE,
  729. GD_EMERGENCYCALL,
  730. GD_DEVELOPMENT,
  731. GD_ITEMEMERGENCYCALL,
  732. GD_GUILD_STORAGE,
  733. GD_CHARGESHOUT_FLAG,
  734. GD_CHARGESHOUT_BEATING,
  735. GD_EMERGENCY_MOVE,
  736. GD_MAX,
  737. };
  738. #define MAX_SKILL_ID GD_MAX
  739. //These mark the ID of the jobs, as expected by the client. [Skotlex]
  740. enum e_job {
  741. JOB_NOVICE,
  742. JOB_SWORDMAN,
  743. JOB_MAGE,
  744. JOB_ARCHER,
  745. JOB_ACOLYTE,
  746. JOB_MERCHANT,
  747. JOB_THIEF,
  748. JOB_KNIGHT,
  749. JOB_PRIEST,
  750. JOB_WIZARD,
  751. JOB_BLACKSMITH,
  752. JOB_HUNTER,
  753. JOB_ASSASSIN,
  754. JOB_KNIGHT2,
  755. JOB_CRUSADER,
  756. JOB_MONK,
  757. JOB_SAGE,
  758. JOB_ROGUE,
  759. JOB_ALCHEMIST,
  760. JOB_BARD,
  761. JOB_DANCER,
  762. JOB_CRUSADER2,
  763. JOB_WEDDING,
  764. JOB_SUPER_NOVICE,
  765. JOB_GUNSLINGER,
  766. JOB_NINJA,
  767. JOB_XMAS,
  768. JOB_SUMMER,
  769. JOB_HANBOK,
  770. JOB_OKTOBERFEST,
  771. JOB_SUMMER2,
  772. JOB_MAX_BASIC,
  773. JOB_NOVICE_HIGH = 4001,
  774. JOB_SWORDMAN_HIGH,
  775. JOB_MAGE_HIGH,
  776. JOB_ARCHER_HIGH,
  777. JOB_ACOLYTE_HIGH,
  778. JOB_MERCHANT_HIGH,
  779. JOB_THIEF_HIGH,
  780. JOB_LORD_KNIGHT,
  781. JOB_HIGH_PRIEST,
  782. JOB_HIGH_WIZARD,
  783. JOB_WHITESMITH,
  784. JOB_SNIPER,
  785. JOB_ASSASSIN_CROSS,
  786. JOB_LORD_KNIGHT2,
  787. JOB_PALADIN,
  788. JOB_CHAMPION,
  789. JOB_PROFESSOR,
  790. JOB_STALKER,
  791. JOB_CREATOR,
  792. JOB_CLOWN,
  793. JOB_GYPSY,
  794. JOB_PALADIN2,
  795. JOB_BABY,
  796. JOB_BABY_SWORDMAN,
  797. JOB_BABY_MAGE,
  798. JOB_BABY_ARCHER,
  799. JOB_BABY_ACOLYTE,
  800. JOB_BABY_MERCHANT,
  801. JOB_BABY_THIEF,
  802. JOB_BABY_KNIGHT,
  803. JOB_BABY_PRIEST,
  804. JOB_BABY_WIZARD,
  805. JOB_BABY_BLACKSMITH,
  806. JOB_BABY_HUNTER,
  807. JOB_BABY_ASSASSIN,
  808. JOB_BABY_KNIGHT2,
  809. JOB_BABY_CRUSADER,
  810. JOB_BABY_MONK,
  811. JOB_BABY_SAGE,
  812. JOB_BABY_ROGUE,
  813. JOB_BABY_ALCHEMIST,
  814. JOB_BABY_BARD,
  815. JOB_BABY_DANCER,
  816. JOB_BABY_CRUSADER2,
  817. JOB_SUPER_BABY,
  818. JOB_TAEKWON,
  819. JOB_STAR_GLADIATOR,
  820. JOB_STAR_GLADIATOR2,
  821. JOB_SOUL_LINKER,
  822. JOB_GANGSI,
  823. JOB_DEATH_KNIGHT,
  824. JOB_DARK_COLLECTOR,
  825. JOB_RUNE_KNIGHT = 4054,
  826. JOB_WARLOCK,
  827. JOB_RANGER,
  828. JOB_ARCH_BISHOP,
  829. JOB_MECHANIC,
  830. JOB_GUILLOTINE_CROSS,
  831. JOB_RUNE_KNIGHT_T,
  832. JOB_WARLOCK_T,
  833. JOB_RANGER_T,
  834. JOB_ARCH_BISHOP_T,
  835. JOB_MECHANIC_T,
  836. JOB_GUILLOTINE_CROSS_T,
  837. JOB_ROYAL_GUARD,
  838. JOB_SORCERER,
  839. JOB_MINSTREL,
  840. JOB_WANDERER,
  841. JOB_SURA,
  842. JOB_GENETIC,
  843. JOB_SHADOW_CHASER,
  844. JOB_ROYAL_GUARD_T,
  845. JOB_SORCERER_T,
  846. JOB_MINSTREL_T,
  847. JOB_WANDERER_T,
  848. JOB_SURA_T,
  849. JOB_GENETIC_T,
  850. JOB_SHADOW_CHASER_T,
  851. JOB_RUNE_KNIGHT2,
  852. JOB_RUNE_KNIGHT_T2,
  853. JOB_ROYAL_GUARD2,
  854. JOB_ROYAL_GUARD_T2,
  855. JOB_RANGER2,
  856. JOB_RANGER_T2,
  857. JOB_MECHANIC2,
  858. JOB_MECHANIC_T2,
  859. JOB_BABY_RUNE_KNIGHT = 4096,
  860. JOB_BABY_WARLOCK,
  861. JOB_BABY_RANGER,
  862. JOB_BABY_ARCH_BISHOP,
  863. JOB_BABY_MECHANIC,
  864. JOB_BABY_GUILLOTINE_CROSS,
  865. JOB_BABY_ROYAL_GUARD,
  866. JOB_BABY_SORCERER,
  867. JOB_BABY_MINSTREL,
  868. JOB_BABY_WANDERER,
  869. JOB_BABY_SURA,
  870. JOB_BABY_GENETIC,
  871. JOB_BABY_SHADOW_CHASER,
  872. JOB_BABY_RUNE_KNIGHT2,
  873. JOB_BABY_ROYAL_GUARD2,
  874. JOB_BABY_RANGER2,
  875. JOB_BABY_MECHANIC2,
  876. JOB_SUPER_NOVICE_E = 4190,
  877. JOB_SUPER_BABY_E,
  878. JOB_KAGEROU = 4211,
  879. JOB_OBORO,
  880. JOB_REBELLION = 4215,
  881. JOB_SUMMONER = 4218,
  882. JOB_BABY_SUMMONER = 4220,
  883. JOB_BABY_NINJA = 4222,
  884. JOB_BABY_KAGEROU,
  885. JOB_BABY_OBORO,
  886. JOB_BABY_TAEKWON,
  887. JOB_BABY_STAR_GLADIATOR,
  888. JOB_BABY_SOUL_LINKER,
  889. JOB_BABY_GUNSLINGER,
  890. JOB_BABY_REBELLION,
  891. JOB_BABY_STAR_GLADIATOR2 = 4238,
  892. JOB_STAR_EMPEROR,
  893. JOB_SOUL_REAPER,
  894. JOB_BABY_STAR_EMPEROR,
  895. JOB_BABY_SOUL_REAPER,
  896. JOB_STAR_EMPEROR2,
  897. JOB_BABY_STAR_EMPEROR2,
  898. JOB_DRAGON_KNIGHT = 4252,
  899. JOB_MEISTER,
  900. JOB_SHADOW_CROSS,
  901. JOB_ARCH_MAGE,
  902. JOB_CARDINAL,
  903. JOB_WINDHAWK,
  904. JOB_IMPERIAL_GUARD,
  905. JOB_BIOLO,
  906. JOB_ABYSS_CHASER,
  907. JOB_ELEMENTAL_MASTER,
  908. JOB_INQUISITOR,
  909. JOB_TROUBADOUR,
  910. JOB_TROUVERE,
  911. JOB_WINDHAWK2 = 4278,
  912. JOB_MEISTER2,
  913. JOB_DRAGON_KNIGHT2,
  914. JOB_IMPERIAL_GUARD2,
  915. JOB_SKY_EMPEROR = 4302,
  916. JOB_SOUL_ASCETIC,
  917. JOB_SHINKIRO,
  918. JOB_SHIRANUI,
  919. JOB_NIGHT_WATCH,
  920. JOB_HYPER_NOVICE,
  921. JOB_SPIRIT_HANDLER,
  922. JOB_SKY_EMPEROR2 = 4316,
  923. JOB_MAX,
  924. };
  925. enum e_sex : uint8 {
  926. SEX_FEMALE = 0,
  927. SEX_MALE,
  928. SEX_BOTH,
  929. SEX_SERVER
  930. };
  931. /// Item Bound Type
  932. enum bound_type {
  933. BOUND_NONE = 0, /// No bound
  934. BOUND_ACCOUNT, /// 1- Account Bound
  935. BOUND_GUILD, /// 2 - Guild Bound
  936. BOUND_PARTY, /// 3 - Party Bound
  937. BOUND_CHAR, /// 4 - Character Bound
  938. BOUND_MAX,
  939. BOUND_ONEQUIP = 1, ///< Show notification when item will be bound on equip
  940. BOUND_DISPYELLOW = 2, /// Shows the item name in yellow color
  941. };
  942. enum e_pc_reg_loading {
  943. PRL_NONE = 0x0,
  944. PRL_CHAR = 0x1,
  945. PRL_ACCL = 0x2, // local
  946. PRL_ACCG = 0x4, // global
  947. PRL_ALL = 0xFF,
  948. };
  949. enum e_party_member_withdraw {
  950. PARTY_MEMBER_WITHDRAW_LEAVE, ///< /leave
  951. PARTY_MEMBER_WITHDRAW_EXPEL, ///< Kicked
  952. PARTY_MEMBER_WITHDRAW_CANT_LEAVE, ///< TODO: Cannot /leave
  953. PARTY_MEMBER_WITHDRAW_CANT_EXPEL, ///< TODO: Cannot be kicked
  954. };
  955. enum e_rank {
  956. RANK_BLACKSMITH = 0,
  957. RANK_ALCHEMIST = 1,
  958. RANK_TAEKWON = 2,
  959. RANK_KILLER = 3
  960. };
  961. struct clan_alliance {
  962. int opposition;
  963. int clan_id;
  964. char name[NAME_LENGTH];
  965. };
  966. struct clan{
  967. int id;
  968. char name[NAME_LENGTH];
  969. char master[NAME_LENGTH];
  970. char map[MAP_NAME_LENGTH_EXT];
  971. short max_member, connect_member;
  972. struct map_session_data *members[MAX_CLAN];
  973. struct clan_alliance alliance[MAX_CLANALLIANCE];
  974. unsigned short instance_id;
  975. };
  976. // Sanity checks...
  977. #if MAX_ZENY > INT_MAX
  978. #error MAX_ZENY is too big
  979. #endif
  980. // This sanity check is required, because some other places(like skill.cpp) rely on this
  981. #if MAX_PARTY < 2
  982. #error MAX_PARTY is too small, you need at least 2 players for a party
  983. #endif
  984. #ifndef VIP_ENABLE
  985. #define MIN_STORAGE MAX_STORAGE // If the VIP system is disabled the min = max.
  986. #define MIN_CHARS MAX_CHARS // Default number of characters per account.
  987. #define MAX_CHAR_BILLING 0
  988. #define MAX_CHAR_VIP 0
  989. #endif
  990. #if (MIN_CHARS + MAX_CHAR_VIP + MAX_CHAR_BILLING) > MAX_CHARS
  991. #error Config of MAX_CHARS is invalid
  992. #endif
  993. #if MIN_STORAGE > MAX_STORAGE
  994. #error Config of MIN_STORAGE is invalid
  995. #endif
  996. #ifdef PACKET_OBFUSCATION
  997. #if PACKETVER < 20110817
  998. #undef PACKET_OBFUSCATION
  999. #endif
  1000. #endif
  1001. /* Feb 1st 2012 */
  1002. #if PACKETVER >= 20120201
  1003. #define NEW_CARTS
  1004. #ifndef ENABLE_SC_SAVING
  1005. #warning "Cart won't be able to be saved for relog"
  1006. #endif
  1007. #if PACKETVER >= 20191106
  1008. #define MAX_CARTS 13 // used for another new cart design
  1009. #elif PACKETVER >= 20150826
  1010. #define MAX_CARTS 12 // used for 3 new cart design
  1011. #else
  1012. #define MAX_CARTS 9
  1013. #endif
  1014. #else
  1015. #define MAX_CARTS 5
  1016. #endif
  1017. #endif /* MMO_HPP */