map.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef _MAP_H_
  4. #define _MAP_H_
  5. #include <stdarg.h>
  6. #include "../common/mmo.h"
  7. #include "../common/mapindex.h"
  8. #include "../common/db.h"
  9. //Uncomment to enable the Cell Stack Limit mod. (EXPERIMENTAL)
  10. //It's only config is the battle_config cell_stack_limit.
  11. //Only chars affected are those defined in BL_CHAR (mobs and players currently)
  12. //#define CELL_NOSTACK
  13. #define MAX_PC_CLASS 4050
  14. #define PC_CLASS_BASE 0
  15. #define PC_CLASS_BASE2 (PC_CLASS_BASE + 4001)
  16. #define PC_CLASS_BASE3 (PC_CLASS_BASE2 + 22)
  17. #define MAX_NPC_PER_MAP 512
  18. #define BLOCK_SIZE 8
  19. #define AREA_SIZE battle_config.area_size
  20. #define LIFETIME_FLOORITEM 60
  21. #define DAMAGELOG_SIZE 30
  22. #define LOOTITEM_SIZE 10
  23. #define MAX_STATUSCHANGE 250
  24. //Quick defines to know which are the min-max common ailments. [Skotlex]
  25. //Because of the way the headers are included.. these must be replaced for actual values.
  26. //Remember to update as needed! Min is SC_STONE and max is SC_DPOISON currently.
  27. #define SC_COMMON_MIN 0
  28. #define SC_COMMON_MAX 10
  29. #define MAX_SKILL_LEVEL 100
  30. #define MAX_SKILLUNITGROUP 25
  31. #define MAX_SKILLUNITGROUPTICKSET 25
  32. #define MAX_SKILLTIMERSKILL 15
  33. #define MAX_MOBSKILL 50
  34. #define MAX_MOB_LIST_PER_MAP 128
  35. #define MAX_EVENTQUEUE 2
  36. #define MAX_EVENTTIMER 32
  37. #define NATURAL_HEAL_INTERVAL 500
  38. #define MAX_FLOORITEM 500000
  39. #define MAX_LEVEL 1000
  40. #define MAX_WALKPATH 32
  41. #define MAX_DROP_PER_MAP 48
  42. #define MAX_IGNORE_LIST 80
  43. #define MAX_VENDING 12
  44. #define MOBID_EMPERIUM 1288
  45. #define MAX_PC_BONUS 10
  46. //Designed for search functions, species max number of matches to display.
  47. #define MAX_SEARCH 5
  48. #define MAX_DUEL 1024
  49. //These mark the ID of the jobs, as expected by the client. [Skotlex]
  50. enum {
  51. JOB_NOVICE,
  52. JOB_SWORDMAN,
  53. JOB_MAGE,
  54. JOB_ARCHER,
  55. JOB_ACOLYTE,
  56. JOB_MERCHANT,
  57. JOB_THIEF,
  58. JOB_KNIGHT,
  59. JOB_PRIEST,
  60. JOB_WIZARD,
  61. JOB_BLACKSMITH,
  62. JOB_HUNTER,
  63. JOB_ASSASSIN,
  64. JOB_KNIGHT2,
  65. JOB_CRUSADER,
  66. JOB_MONK,
  67. JOB_SAGE,
  68. JOB_ROGUE,
  69. JOB_ALCHEMIST,
  70. JOB_BARD,
  71. JOB_DANCER,
  72. JOB_CRUSADER2,
  73. JOB_WEDDING,
  74. JOB_SUPER_NOVICE,
  75. JOB_GUNSLINGER,
  76. JOB_NINJA,
  77. JOB_XMAS,
  78. JOB_NOVICE_HIGH = 4001,
  79. JOB_SWORDMAN_HIGH,
  80. JOB_MAGE_HIGH,
  81. JOB_ARCHER_HIGH,
  82. JOB_ACOLYTE_HIGH,
  83. JOB_MERCHANT_HIGH,
  84. JOB_THIEF_HIGH,
  85. JOB_LORD_KNIGHT,
  86. JOB_HIGH_PRIEST,
  87. JOB_HIGH_WIZARD,
  88. JOB_WHITESMITH,
  89. JOB_SNIPER,
  90. JOB_ASSASSIN_CROSS,
  91. JOB_LORD_KNIGHT2,
  92. JOB_PALADIN,
  93. JOB_CHAMPION,
  94. JOB_PROFESSOR,
  95. JOB_STALKER,
  96. JOB_CREATOR,
  97. JOB_CLOWN,
  98. JOB_GYPSY,
  99. JOB_PALADIN2,
  100. JOB_BABY,
  101. JOB_BABY_SWORDMAN,
  102. JOB_BABY_MAGE,
  103. JOB_BABY_ARCHER,
  104. JOB_BABY_ACOLYTE,
  105. JOB_BABY_MERCHANT,
  106. JOB_BABY_THIEF,
  107. JOB_BABY_KNIGHT,
  108. JOB_BABY_PRIEST,
  109. JOB_BABY_WIZARD,
  110. JOB_BABY_BLACKSMITH,
  111. JOB_BABY_HUNTER,
  112. JOB_BABY_ASSASSIN,
  113. JOB_BABY_KNIGHT2,
  114. JOB_BABY_CRUSADER,
  115. JOB_BABY_MONK,
  116. JOB_BABY_SAGE,
  117. JOB_BABY_ROGUE,
  118. JOB_BABY_ALCHEMIST,
  119. JOB_BABY_BARD,
  120. JOB_BABY_DANCER,
  121. JOB_BABY_CRUSADER2,
  122. JOB_SUPER_BABY,
  123. JOB_TAEKWON,
  124. JOB_STAR_GLADIATOR,
  125. JOB_STAR_GLADIATOR2,
  126. JOB_SOUL_LINKER,
  127. };
  128. //The following system marks a different job ID system used by the map server,
  129. //which makes a lot more sense than the normal one. [Skotlex]
  130. //
  131. //These marks the "level" of the job.
  132. #define JOBL_2_1 0x100 //256
  133. #define JOBL_2_2 0x200 //512
  134. #define JOBL_2 0x300
  135. #define JOBL_UPPER 0x1000 //4096
  136. #define JOBL_BABY 0x2000 //8192
  137. //for filtering and quick checking.
  138. #define MAPID_UPPERMASK 0x0fff
  139. #define MAPID_BASEMASK 0x00ff
  140. //First Jobs
  141. //Note the oddity of the novice:
  142. //Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type, too...
  143. enum {
  144. MAPID_NOVICE = 0x0,
  145. MAPID_SWORDMAN,
  146. MAPID_MAGE,
  147. MAPID_ARCHER,
  148. MAPID_ACOLYTE,
  149. MAPID_MERCHANT,
  150. MAPID_THIEF,
  151. MAPID_TAEKWON,
  152. MAPID_WEDDING,
  153. MAPID_GUNSLINGER,
  154. MAPID_NINJA,
  155. MAPID_XMAS, // [Valaris]
  156. //2_1 classes
  157. MAPID_SUPER_NOVICE = JOBL_2_1|0x0,
  158. MAPID_KNIGHT,
  159. MAPID_WIZARD,
  160. MAPID_HUNTER,
  161. MAPID_PRIEST,
  162. MAPID_BLACKSMITH,
  163. MAPID_ASSASSIN,
  164. MAPID_STAR_GLADIATOR,
  165. //2_2 classes
  166. MAPID_CRUSADER = JOBL_2_2|0x1,
  167. MAPID_SAGE,
  168. MAPID_BARDDANCER,
  169. MAPID_MONK,
  170. MAPID_ALCHEMIST,
  171. MAPID_ROGUE,
  172. MAPID_SOUL_LINKER,
  173. //1-1, advanced
  174. MAPID_NOVICE_HIGH = JOBL_UPPER|0x0,
  175. MAPID_SWORDMAN_HIGH,
  176. MAPID_MAGE_HIGH,
  177. MAPID_ARCHER_HIGH,
  178. MAPID_ACOLYTE_HIGH,
  179. MAPID_MERCHANT_HIGH,
  180. MAPID_THIEF_HIGH,
  181. //2_1 advanced
  182. MAPID_LORD_KNIGHT = JOBL_UPPER|JOBL_2_1|0x1,
  183. MAPID_HIGH_WIZARD,
  184. MAPID_SNIPER,
  185. MAPID_HIGH_PRIEST,
  186. MAPID_WHITESMITH,
  187. MAPID_ASSASSIN_CROSS,
  188. //2_2 advanced
  189. MAPID_PALADIN = JOBL_UPPER|JOBL_2_2|0x1,
  190. MAPID_PROFESSOR,
  191. MAPID_CLOWNGYPSY,
  192. MAPID_CHAMPION,
  193. MAPID_CREATOR,
  194. MAPID_STALKER,
  195. //1-1 baby
  196. MAPID_BABY = JOBL_BABY|0x0,
  197. MAPID_BABY_SWORDMAN,
  198. MAPID_BABY_MAGE,
  199. MAPID_BABY_ARCHER,
  200. MAPID_BABY_ACOLYTE,
  201. MAPID_BABY_MERCHANT,
  202. MAPID_BABY_THIEF,
  203. MAPID_BABY_TAEKWON,
  204. //2_1 baby
  205. MAPID_SUPER_BABY = JOBL_BABY|JOBL_2_1|0x0,
  206. MAPID_BABY_KNIGHT,
  207. MAPID_BABY_WIZARD,
  208. MAPID_BABY_HUNTER,
  209. MAPID_BABY_PRIEST,
  210. MAPID_BABY_BLACKSMITH,
  211. MAPID_BABY_ASSASSIN,
  212. MAPID_BABY_STAR_GLADIATOR,
  213. //2_2 baby
  214. MAPID_BABY_CRUSADER = JOBL_BABY|JOBL_2_2|0x1,
  215. MAPID_BABY_SAGE,
  216. MAPID_BABY_BARDDANCER,
  217. MAPID_BABY_MONK,
  218. MAPID_BABY_ALCHEMIST,
  219. MAPID_BABY_ROGUE,
  220. MAPID_BABY_SOUL_LINKER,
  221. };
  222. //Don't change this, as the client seems to always send/receive 80 characters as it currently is. [Skotlex]
  223. #define MESSAGE_SIZE 80
  224. #define DEFAULT_AUTOSAVE_INTERVAL 60*1000
  225. #define OPTION_SIGHT 0x0001
  226. #define OPTION_HIDE 0x0002
  227. #define OPTION_CLOAK 0x0004
  228. #define OPTION_CART1 0x0008
  229. #define OPTION_FALCON 0x0010
  230. #define OPTION_RIDING 0x0020
  231. #define OPTION_INVISIBLE 0x0040
  232. #define OPTION_CART2 0x0080
  233. #define OPTION_CART3 0x0100
  234. #define OPTION_CART4 0x0200
  235. #define OPTION_CART5 0x0400
  236. #define OPTION_ORCISH 0x0800
  237. #define OPTION_WEDDING 0x1000
  238. #define OPTION_RUWACH 0x2000
  239. #define OPTION_CHASEWALK 0x4000
  240. #define OPTION_FLYING 0x8000
  241. //TODO: Get these Missing options...
  242. #define OPTION_SIGHTTRASHER 0x0001
  243. //Specifies maps where players may hit each other
  244. #define map_flag_vs(m) (map[m].flag.pvp || map[m].flag.gvg_dungeon || map[m].flag.gvg || (agit_flag && map[m].flag.gvg_castle))
  245. //Specifies maps that have special GvG/WoE restrictions
  246. #define map_flag_gvg(m) (map[m].flag.gvg || (agit_flag && map[m].flag.gvg_castle))
  247. //This stackable implementation does not means a BL can be more than one type at a time, but it's
  248. //meant to make it easier to check for multiple types at a time on invocations such as
  249. // map_foreach* calls [Skotlex]
  250. enum {
  251. BL_NUL = 0x000,
  252. BL_PC = 0x001,
  253. BL_MOB = 0x002,
  254. BL_PET = 0x004,
  255. BL_HOMUNCULUS = 0x008, //[blackhole89]
  256. BL_ITEM = 0x010,
  257. BL_SKILL = 0x020,
  258. BL_NPC = 0x040,
  259. BL_CHAT = 0x080,
  260. };
  261. //For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
  262. #define BL_CHAR (BL_PC|BL_MOB|BL_HOMUNCULUS)
  263. #define BL_ALL 0xfff
  264. enum { WARP, SHOP, SCRIPT, MONS };
  265. enum {
  266. RC_FORMLESS=0,
  267. RC_UNDEAD,
  268. RC_BRUTE,
  269. RC_PLANT,
  270. RC_INSECT,
  271. RC_FISH,
  272. RC_DEMON,
  273. RC_DEMIHUMAN,
  274. RC_ANGEL,
  275. RC_DRAGON,
  276. RC_BOSS,
  277. RC_NONBOSS,
  278. RC_MAX
  279. };
  280. struct block_list {
  281. struct block_list *next,*prev;
  282. int id;
  283. short m,x,y;
  284. unsigned char type;
  285. unsigned char subtype;
  286. };
  287. struct walkpath_data {
  288. unsigned char path_len,path_pos,path_half;
  289. unsigned char path[MAX_WALKPATH];
  290. };
  291. struct shootpath_data {
  292. int rx,ry,len;
  293. int x[MAX_WALKPATH];
  294. int y[MAX_WALKPATH];
  295. };
  296. struct skill_timerskill {
  297. int timer;
  298. int src_id;
  299. int target_id;
  300. int map;
  301. short x,y;
  302. short skill_id,skill_lv;
  303. int type;
  304. int flag;
  305. };
  306. struct skill_unit_group;
  307. struct skill_unit {
  308. struct block_list bl;
  309. struct skill_unit_group *group;
  310. int limit;
  311. int val1,val2;
  312. short alive,range;
  313. };
  314. struct skill_unit_group {
  315. int src_id;
  316. int party_id;
  317. int guild_id;
  318. int map;
  319. int target_flag; //Holds BCT_* flag for battle_check_target
  320. int bl_flag; //Holds BL_* flag for map_foreachin* functions
  321. unsigned int tick;
  322. int limit,interval;
  323. int skill_id,skill_lv;
  324. int val1,val2,val3;
  325. char *valstr;
  326. int unit_id;
  327. int group_id;
  328. int unit_count,alive_count;
  329. struct skill_unit *unit;
  330. struct {
  331. unsigned ammo_consume : 1;
  332. unsigned magic_power : 1;
  333. unsigned into_abyss : 1;
  334. } state;
  335. };
  336. struct skill_unit_group_tickset {
  337. unsigned int tick;
  338. int id;
  339. };
  340. struct unit_data {
  341. struct block_list *bl;
  342. struct walkpath_data walkpath;
  343. struct skill_timerskill *skilltimerskill[MAX_SKILLTIMERSKILL];
  344. struct skill_unit_group *skillunit[MAX_SKILLUNITGROUP];
  345. struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
  346. short attacktarget_lv;
  347. short to_x,to_y;
  348. short skillx,skilly;
  349. short skillid,skilllv;
  350. int skilltarget;
  351. int skilltimer;
  352. int target;
  353. int attacktimer;
  354. int walktimer;
  355. int chaserange;
  356. unsigned int attackabletime;
  357. unsigned int canact_tick;
  358. unsigned int canmove_tick;
  359. unsigned char dir;
  360. unsigned char walk_count;
  361. struct {
  362. unsigned change_walk_target : 1 ;
  363. unsigned skillcastcancel : 1 ;
  364. unsigned attack_continue : 1 ;
  365. unsigned walk_easy : 1 ;
  366. unsigned running : 1;
  367. } state;
  368. };
  369. struct script_reg {
  370. int index;
  371. int data;
  372. };
  373. struct script_regstr {
  374. int index;
  375. char data[256];
  376. };
  377. struct status_change_entry {
  378. int timer;
  379. int val1,val2,val3,val4;
  380. };
  381. struct status_change {
  382. struct status_change_entry data[MAX_STATUSCHANGE];
  383. short count;
  384. short opt1,opt2,opt3;
  385. unsigned short option;
  386. };
  387. struct vending {
  388. short index;
  389. unsigned short amount;
  390. unsigned int value;
  391. };
  392. struct weapon_data {
  393. int atkmods[3];
  394. // all the variables except atkmods get zero'ed in each call of status_calc_pc
  395. // NOTE: if you want to add a non-zeroed variable, you need to update the memset call
  396. // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex]
  397. int watk;
  398. int watk2;
  399. int atk_ele;
  400. int overrefine;
  401. int star;
  402. int ignore_def_ele;
  403. int ignore_def_race;
  404. int def_ratio_atk_ele;
  405. int def_ratio_atk_race;
  406. int addele[10];
  407. int addrace[RC_MAX];
  408. int addrace2[RC_MAX];
  409. int addsize[3];
  410. short ignore_def_mob;
  411. struct drain_data {
  412. short rate;
  413. short per;
  414. short value;
  415. unsigned type:1;
  416. } hp_drain[RC_MAX], sp_drain[RC_MAX];
  417. short add_damage_classid[MAX_PC_BONUS];
  418. int add_damage_classrate[MAX_PC_BONUS];
  419. int add_damage_class_count;
  420. };
  421. struct view_data {
  422. short class_;
  423. short weapon;
  424. short shield; //Or left-hand weapon.
  425. short head_top;
  426. short head_mid;
  427. short head_bottom;
  428. short hair_style;
  429. short hair_color;
  430. short cloth_color;
  431. char sex;
  432. unsigned dead_sit : 2;
  433. };
  434. struct npc_data;
  435. struct pet_db;
  436. struct item_data;
  437. struct square;
  438. struct map_session_data {
  439. struct block_list bl;
  440. struct unit_data ud;
  441. struct view_data vd;
  442. struct status_change sc;
  443. //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
  444. //status_calc_pc, while special_state is recalculated in each call. [Skotlex]
  445. struct {
  446. unsigned auth : 1;
  447. unsigned menu_or_input : 1;
  448. unsigned dead_sit : 2;
  449. unsigned waitingdisconnect : 1;
  450. unsigned lr_flag : 2;
  451. unsigned connect_new : 1;
  452. unsigned arrow_atk : 1;
  453. unsigned skill_flag : 1;
  454. unsigned gangsterparadise : 1;
  455. unsigned rest : 1;
  456. unsigned storage_flag : 2; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex]
  457. unsigned snovice_flag : 4;
  458. // originally by Qamera, adapted by celest
  459. unsigned event_death : 1;
  460. unsigned event_kill_pc : 1;
  461. unsigned event_disconnect : 1;
  462. unsigned event_kill_mob : 1;
  463. // Abracadabra bugfix by Aru
  464. unsigned abra_flag : 1;
  465. unsigned autotrade : 1; //By Fantik
  466. unsigned perfect_hiding : 1; // [Valaris]
  467. unsigned reg_dirty : 3; //By Skotlex (marks whether registry variables have been saved or not yet)
  468. unsigned showdelay :1;
  469. unsigned showexp :1;
  470. unsigned showzeny :1;
  471. unsigned mainchat :1; //[LuzZza]
  472. unsigned noask :1; // [LuzZza]
  473. unsigned trading :1; //[Skotlex] is 1 only after a trade has started.
  474. unsigned deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
  475. unsigned party_sent :1;
  476. unsigned guild_sent :1;
  477. unsigned monster_ignore :1; // for monsters to ignore a character [Valaris] [zzo]
  478. unsigned size :2; // for tiny/large types
  479. unsigned night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
  480. unsigned finalsave :1; //Signals whether the final save for the char was done or not yet. Meant to prevent exploits and the like. [Skotlex]
  481. unsigned blockedmove :1;
  482. unsigned using_fake_npc :1;
  483. unsigned short autoloot;
  484. struct guild *gmaster_flag;
  485. } state;
  486. struct {
  487. unsigned killer : 1;
  488. unsigned killable : 1;
  489. unsigned restart_full_recover : 1;
  490. unsigned no_castcancel : 1;
  491. unsigned no_castcancel2 : 1;
  492. unsigned no_sizefix : 1;
  493. unsigned no_magic_damage : 1;
  494. unsigned no_weapon_damage : 1;
  495. unsigned no_gemstone : 1;
  496. unsigned infinite_endure : 1;
  497. unsigned intravision : 1; // Maya Purple Card effect allowing to see Hiding/Cloaking people [DracoRPG]
  498. } special_state;
  499. int char_id, login_id1, login_id2, sex;
  500. unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
  501. int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 ... 18
  502. struct mmo_charstatus status;
  503. struct registry save_reg;
  504. struct item_data *inventory_data[MAX_INVENTORY];
  505. short equip_index[11];
  506. unsigned int weight,max_weight;
  507. int cart_weight,cart_max_weight,cart_num,cart_max_num;
  508. int fd;
  509. unsigned short mapindex;
  510. short speed,prev_speed;
  511. unsigned char head_dir;
  512. unsigned int client_tick,server_tick;
  513. int npc_id,areanpc_id,npc_shopid;
  514. int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
  515. int npc_pos;
  516. int npc_menu;
  517. int npc_amount;
  518. struct script_stack *stack;
  519. unsigned char *npc_script,*npc_scriptroot;
  520. int npc_scriptstate;
  521. char npc_str[256];
  522. int npc_timer_id; //For player attached npc timers. [Skotlex]
  523. unsigned int chatID;
  524. time_t idletime;
  525. struct{
  526. char name[NAME_LENGTH];
  527. } ignore[MAX_IGNORE_LIST];
  528. int ignoreAll;
  529. int followtimer; // [MouseJstr]
  530. int followtarget;
  531. time_t emotionlasttime; // to limit flood with emotion packets
  532. short skillitem,skillitemlv;
  533. short skillid_old,skilllv_old;
  534. short skillid_dance,skilllv_dance;
  535. char blockskill[MAX_SKILL]; // [celest]
  536. int cloneskill_id;
  537. int menuskill_id, menuskill_lv;
  538. int invincible_timer;
  539. unsigned int canlog_tick;
  540. unsigned int canregen_tick;
  541. unsigned int canuseitem_tick; // [Skotlex]
  542. int hp_sub,sp_sub;
  543. int inchealhptick,inchealsptick,inchealspirithptick,inchealspiritsptick;
  544. short weapontype1,weapontype2;
  545. short disguise; // [Valaris]
  546. struct weapon_data right_weapon;
  547. struct weapon_data left_weapon;
  548. int paramc[6],paramcard[6];
  549. // here start arrays to be globally zeroed at the beginning of status_calc_pc()
  550. int paramb[6];
  551. int parame[6];
  552. int subele[10];
  553. int subrace[RC_MAX];
  554. int subrace2[RC_MAX];
  555. int subsize[3];
  556. int addeff[SC_COMMON_MAX-SC_COMMON_MIN+1];
  557. int addeff2[SC_COMMON_MAX-SC_COMMON_MIN+1];
  558. int reseff[SC_COMMON_MAX-SC_COMMON_MIN+1];
  559. int weapon_coma_ele[10];
  560. int weapon_coma_race[RC_MAX];
  561. int weapon_atk[16];
  562. int weapon_atk_rate[16];
  563. int arrow_addele[10];
  564. int arrow_addrace[RC_MAX];
  565. int arrow_addsize[3];
  566. int arrow_addeff[SC_COMMON_MAX-SC_COMMON_MIN+1];
  567. int arrow_addeff2[SC_COMMON_MAX-SC_COMMON_MIN+1];
  568. int magic_addele[10];
  569. int magic_addrace[RC_MAX];
  570. int magic_addsize[3];
  571. int critaddrace[RC_MAX];
  572. int expaddrace[RC_MAX];
  573. int itemhealrate[7];
  574. int addeff3[SC_COMMON_MAX-SC_COMMON_MIN+1];
  575. short addeff3_type[SC_COMMON_MAX-SC_COMMON_MIN+1];
  576. short sp_gain_race[RC_MAX];
  577. // zeroed arrays end here.
  578. // zeroed structures start here
  579. struct s_autospell{
  580. short id, lv, rate, card_id;
  581. } autospell[MAX_PC_BONUS], autospell2[MAX_PC_BONUS];
  582. struct { //skillatk raises bonus dmg% of skills, skillblown increases bonus blewcount for some skills.
  583. short id, val;
  584. } skillatk[MAX_PC_BONUS], skillblown[MAX_PC_BONUS];
  585. struct {
  586. short class_, rate;
  587. } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS],
  588. add_dmg[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
  589. struct s_add_drop {
  590. short id, group;
  591. int race, rate;
  592. } add_drop[MAX_PC_BONUS];
  593. // zeroed structures end here
  594. // zeroed vars start here.
  595. int hit;
  596. int flee, flee2;
  597. int critical;
  598. int aspd;
  599. int def, def2;
  600. int mdef, mdef2;
  601. int def_ele;
  602. int matk1, matk2;
  603. int base_atk;
  604. int arrow_atk,arrow_ele,arrow_cri,arrow_hit,arrow_range;
  605. int nhealhp,nhealsp,nshealhp,nshealsp,nsshealhp,nsshealsp;
  606. int critical_def,double_rate;
  607. int long_attack_atk_rate; //Long range atk rate, not weapon based. [Skotlex]
  608. int near_attack_def_rate,long_attack_def_rate,magic_def_rate,misc_def_rate;
  609. int ignore_mdef_ele;
  610. int ignore_mdef_race;
  611. int perfect_hit;
  612. int perfect_hit_add;
  613. int get_zeny_rate;
  614. int get_zeny_num; //Added Get Zeny Rate [Skotlex]
  615. int double_add_rate;
  616. int short_weapon_damage_return,long_weapon_damage_return;
  617. int magic_damage_return; // AppleGirl Was Here
  618. int random_attack_increase_add,random_attack_increase_per; // [Valaris]
  619. int break_weapon_rate,break_armor_rate;
  620. int crit_atk_rate;
  621. int hp_loss_rate;
  622. int sp_loss_rate;
  623. int classchange; // [Valaris]
  624. unsigned int setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
  625. short attackrange,attackrange_;
  626. short splash_range, splash_add_range;
  627. short add_steal_rate;
  628. short hp_loss_value;
  629. short sp_loss_value;
  630. short hp_loss_type;
  631. short sp_gain_value, hp_gain_value;
  632. short sp_vanish_rate;
  633. short sp_vanish_per;
  634. short add_drop_count;
  635. unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest]
  636. unsigned short unbreakable_equip; //100% break resistance on certain equipment
  637. unsigned short unstripable_equip;
  638. short no_regen;
  639. short add_def_count,add_mdef_count;
  640. short add_dmg_count,add_mdmg_count;
  641. // zeroed vars end here.
  642. int amotion,dmotion;
  643. int castrate,delayrate,hprate,sprate,dsprate;
  644. int atk_rate;
  645. int aspd_rate,speed_rate,hprecov_rate,sprecov_rate;
  646. int matk_rate;
  647. int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
  648. int speed_add_rate, aspd_add_rate;
  649. int hp_loss_tick;
  650. int sp_loss_tick;
  651. int itemid;
  652. short itemindex; //Used item's index in sd->inventory [Skotlex]
  653. short catch_target_class; // pet catching, stores a pet class to catch (short now) [zzo]
  654. short spiritball, spiritball_old;
  655. int spirit_timer[MAX_SKILL_LEVEL];
  656. int die_counter;
  657. short doridori_counter;
  658. char potion_success_counter;
  659. int reg_num;
  660. struct script_reg *reg;
  661. int regstr_num;
  662. struct script_regstr *regstr;
  663. short mission_mobid; //Stores the target mob_id for TK_MISSION
  664. short mission_count; //Stores the bounty kill count for TK_MISSION
  665. int devotion[5]; //Stores the char IDs of chars devoted to.
  666. int trade_partner;
  667. struct {
  668. struct {
  669. int index, amount;
  670. } item[10];
  671. int zeny, weight;
  672. } deal;
  673. int party_invite,party_invite_account;
  674. short party_x,party_y; // should be short [zzo]
  675. int guild_invite,guild_invite_account;
  676. int guild_emblem_id,guild_alliance,guild_alliance_account;
  677. short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo]
  678. int guildspy; // [Syrus22]
  679. int partyspy; // [Syrus22]
  680. int vender_id;
  681. int vend_num;
  682. char message[MESSAGE_SIZE];
  683. struct vending vending[MAX_VENDING];
  684. struct s_pet pet;
  685. struct pet_db *petDB;
  686. struct pet_data *pd;
  687. int pet_hungry_timer;
  688. struct{
  689. int m; //-1 - none, other: map index corresponding to map name.
  690. unsigned short index; //map index
  691. }feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
  692. short hate_mob[3];
  693. unsigned int pvp_timer;
  694. short pvp_point;
  695. unsigned short pvp_rank, pvp_lastusers;
  696. unsigned short pvp_won, pvp_lost;
  697. char eventqueue[MAX_EVENTQUEUE][50];
  698. int eventtimer[MAX_EVENTTIMER];
  699. unsigned short eventcount; // [celest]
  700. unsigned char change_level; // [celest]
  701. char fakename[NAME_LENGTH]; // fake names [Valaris]
  702. #ifndef TXT_ONLY
  703. int mail_counter; // mail counter for mail system [Valaris]
  704. #endif
  705. int duel_group; // duel vars [LuzZza]
  706. int duel_invite;
  707. char away_message[128]; // [LuzZza]
  708. };
  709. struct {
  710. int members_count;
  711. int invites_count;
  712. int max_players_limit;
  713. } duel_list[MAX_DUEL];
  714. int duel_count;
  715. struct npc_timerevent_list {
  716. int timer,pos;
  717. };
  718. struct npc_label_list {
  719. char name[NAME_LENGTH];
  720. int pos;
  721. };
  722. struct npc_item_list {
  723. unsigned int nameid,value;
  724. };
  725. struct npc_data {
  726. struct block_list bl;
  727. struct unit_data ud; //Because they need to be able to move....
  728. struct view_data *vd;
  729. struct status_change sc; //They can't have status changes, but.. they want the visual opt values.
  730. short n;
  731. short class_;
  732. short speed;
  733. unsigned char name[NAME_LENGTH];
  734. unsigned char exname[NAME_LENGTH];
  735. int chat_id;
  736. unsigned int next_walktime;
  737. char eventqueue[MAX_EVENTQUEUE][50];
  738. int eventtimer[MAX_EVENTTIMER];
  739. short arenaflag;
  740. void *chatdb;
  741. struct npc_data *master_nd;
  742. union {
  743. struct {
  744. unsigned char *script;
  745. short xs,ys;
  746. int guild_id;
  747. int timer,timerid,timeramount,rid;
  748. unsigned int timertick;
  749. struct npc_timerevent_list *timer_event;
  750. int label_list_num;
  751. struct npc_label_list *label_list;
  752. int src_id;
  753. } scr;
  754. struct npc_item_list shop_item[1];
  755. struct {
  756. short xs,ys;
  757. short x,y;
  758. unsigned short mapindex;
  759. } warp;
  760. } u;
  761. //Do NOT place anything afterwards... shop data NPC will override any variables from here and on! [Skotlex]
  762. };
  763. //For quick linking to a guardian's info. [Skotlex]
  764. struct guardian_data {
  765. int number; //0-MAX_GUARDIANS-1 = Guardians. MAX_GUARDIANS = Emperium.
  766. int guild_id;
  767. int emblem_id;
  768. int guardup_lv; //Level of GD_GUARDUP skill.
  769. char guild_name[NAME_LENGTH];
  770. struct guild_castle* castle;
  771. };
  772. // Mob List Held in memory for Dynamic Mobs [Wizputer]
  773. // Expanded to specify all mob-related spawn data by [Skotlex]
  774. struct spawn_data {
  775. short class_; //Class, used because a mob can change it's class
  776. unsigned short m,x,y,xs,ys; //Spawn information (map, point, spawn-area around point)
  777. unsigned short num; //Number of mobs using this structure.
  778. unsigned int level; //Custom level.
  779. unsigned int delay1,delay2; //Min delay before respawning after spawn/death
  780. struct {
  781. unsigned size :2; //Holds if mob has to be tiny/large
  782. unsigned ai :1; //Holds if mob is special ai.
  783. } state;
  784. char name[NAME_LENGTH],eventname[50]; //Name/event
  785. };
  786. struct mob_data {
  787. struct block_list bl;
  788. struct unit_data ud;
  789. struct view_data *vd;
  790. struct status_change sc;
  791. struct mob_db *db; //For quick data access (saves doing mob_db(md->class_) all the time) [Skotlex]
  792. char name[NAME_LENGTH];
  793. struct {
  794. unsigned size : 2; //Small/Big monsters.
  795. unsigned cached : 1; //Cached mobs for dynamic mob unloading [Skotlex]
  796. unsigned ai : 3; //Special ai for summoned monsters.
  797. } special_state; //Special mob information that does not needs to be zero'ed on mob respawn.
  798. struct {
  799. unsigned skillstate : 8;
  800. unsigned aggressive : 1; //Signals whether the mob AI is in aggressive mode or reactive mode. [Skotlex]
  801. unsigned char steal_flag; //number of steal tries (to prevent steal exploit on mobs with few items) [Lupus]
  802. unsigned steal_coin_flag : 1;
  803. unsigned soul_change_flag : 1; // Celest
  804. unsigned alchemist: 1;
  805. int provoke_flag; // Celest
  806. } state;
  807. struct guardian_data* guardian_data;
  808. struct {
  809. int id;
  810. int dmg;
  811. } dmglog[DAMAGELOG_SIZE];
  812. struct spawn_data *spawn; //Spawn data.
  813. struct item *lootitem;
  814. short spawn_n; //Spawn data index on the map server.
  815. short class_,mode;
  816. short speed;
  817. short attacked_count;
  818. unsigned short level;
  819. unsigned short attacked_players;
  820. unsigned int tdmg; //Stores total damage given to the mob, for exp calculations. [Skotlex]
  821. int hp, max_hp;
  822. int target_id,attacked_id;
  823. unsigned int next_walktime;
  824. unsigned int last_deadtime,last_spawntime,last_thinktime,last_linktime;
  825. short move_fail_count;
  826. short lootitem_count;
  827. short min_chase;
  828. int deletetimer;
  829. int def_ele;
  830. int master_id,master_dist;
  831. struct npc_data *nd;
  832. short skillidx;
  833. unsigned int skilldelay[MAX_MOBSKILL];
  834. char npc_event[50];
  835. };
  836. struct pet_data {
  837. struct block_list bl;
  838. struct unit_data ud;
  839. struct view_data vd;
  840. struct mob_db *db;
  841. int target_id;
  842. short n;
  843. short class_;
  844. short speed;
  845. char name[NAME_LENGTH];
  846. struct {
  847. unsigned skillstate : 8 ;
  848. short skillbonus;
  849. } state;
  850. short equip;
  851. int move_fail_count;
  852. unsigned int next_walktime,last_thinktime;
  853. short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex]
  854. struct pet_status { //Pet Status data
  855. short level;
  856. short atk1,atk2;
  857. short str,agi,vit,int_,dex,luk;
  858. } *status; //[Skotlex]
  859. struct pet_recovery { //Stat recovery
  860. unsigned short type; //Status Change id
  861. unsigned short delay; //How long before curing (secs).
  862. int timer;
  863. } *recovery; //[Valaris] / Reimplemented by [Skotlex]
  864. struct pet_bonus {
  865. unsigned short type; //bStr, bVit?
  866. unsigned short val; //Qty
  867. unsigned short duration; //in secs
  868. unsigned short delay; //Time before recasting (secs)
  869. int timer;
  870. } *bonus; //[Valaris] / Reimplemented by [Skotlex]
  871. struct pet_skill_attack { //Attack Skill
  872. unsigned short id;
  873. unsigned short lv;
  874. unsigned short div_; //0 = Normal skill. >0 = Fixed damage (lv), fixed div_.
  875. unsigned short rate; //Base chance of skill ocurrance (10 = 10% of attacks)
  876. unsigned short bonusrate; //How being 100% loyal affects cast rate (10 = At 1000 intimacy->rate+10%
  877. } *a_skill; //[Skotlex]
  878. struct pet_skill_support { //Support Skill
  879. unsigned short id;
  880. unsigned short lv;
  881. unsigned short hp; //Max HP% for skill to trigger (50 -> 50% for Magnificat)
  882. unsigned short sp; //Max SP% for skill to trigger (100 = no check)
  883. unsigned short delay; //Time (secs) between being able to recast.
  884. int timer;
  885. } *s_skill; //[Skotlex]
  886. struct pet_loot {
  887. struct item *item;
  888. unsigned short count;
  889. unsigned short weight;
  890. unsigned short max;
  891. } *loot; //[Valaris] / Rewritten by [Skotlex]
  892. struct map_session_data *msd;
  893. };
  894. enum { ATK_LUCKY=1,ATK_FLEE,ATK_DEF}; // 囲まれペナルティ計算用
  895. // For equipment breaking/stripping effects
  896. enum {
  897. EQP_WEAPON = 1, // Both weapons
  898. EQP_ARMOR = 2, // Armor
  899. EQP_SHIELD = 4, // Shield
  900. EQP_HELM = 8, // Top-head headgear
  901. };
  902. struct map_data {
  903. char name[MAP_NAME_LENGTH];
  904. unsigned short index; //Index is the map index used by the mapindex* functions.
  905. unsigned char *gat; // NULLなら下のmap_data_other_serverとして扱う
  906. unsigned char *cell; //Contains temporary cell data that is set/unset on tiles.
  907. #ifdef CELL_NOSTACK
  908. unsigned char *cell_bl; //Holds amount of bls in any given cell.
  909. #endif
  910. char *alias; // [MouseJstr]
  911. struct block_list **block;
  912. struct block_list **block_mob;
  913. int *block_count,*block_mob_count;
  914. int m;
  915. short xs,ys;
  916. short bxs,bys;
  917. int water_height;
  918. int npc_num;
  919. int users;
  920. struct {
  921. unsigned alias : 1;
  922. unsigned nomemo : 1;
  923. unsigned noteleport : 1;
  924. unsigned noreturn : 1;
  925. unsigned monster_noteleport : 1;
  926. unsigned nosave : 1;
  927. unsigned nobranch : 1;
  928. unsigned nopenalty : 1;
  929. unsigned pvp : 1;
  930. unsigned pvp_noparty : 1;
  931. unsigned pvp_noguild : 1;
  932. unsigned pvp_nightmaredrop :1;
  933. unsigned pvp_nocalcrank : 1;
  934. unsigned gvg_castle : 1;
  935. unsigned gvg : 1; // Now it identifies gvg versus maps that are active 24/7
  936. unsigned gvg_dungeon : 1; // Celest
  937. unsigned gvg_noparty : 1;
  938. unsigned nozenypenalty : 1;
  939. unsigned notrade : 1;
  940. unsigned noskill : 1;
  941. unsigned nowarp : 1;
  942. unsigned nowarpto : 1;
  943. unsigned noicewall : 1; // [Valaris]
  944. unsigned snow : 1; // [Valaris]
  945. unsigned clouds : 1;
  946. unsigned clouds2 : 1; // [Valaris]
  947. unsigned fog : 1; // [Valaris]
  948. unsigned fireworks : 1;
  949. unsigned sakura : 1; // [Valaris]
  950. unsigned leaves : 1; // [Valaris]
  951. unsigned rain : 1; // [Valaris]
  952. unsigned indoors : 1; // celest
  953. unsigned nogo : 1; // [Valaris]
  954. unsigned nobaseexp : 1; // [Lorky] added by Lupus
  955. unsigned nojobexp : 1; // [Lorky]
  956. unsigned nomobloot : 1; // [Lorky]
  957. unsigned nomvploot : 1; // [Lorky]
  958. unsigned nightenabled :1; //For night display. [Skotlex]
  959. unsigned restricted : 1; // [Komurka]
  960. unsigned nocommand : 1; //Blocks @/# commands for non-gms. [Skotlex]
  961. unsigned nodrop : 1;
  962. } flag;
  963. struct point save;
  964. struct npc_data *npc[MAX_NPC_PER_MAP];
  965. struct {
  966. int drop_id;
  967. int drop_type;
  968. int drop_per;
  969. } drop_list[MAX_DROP_PER_MAP];
  970. struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
  971. int mob_delete_timer; // [Skotlex]
  972. int zone; // [Komurka]
  973. int jexp; // map experience multiplicator
  974. int bexp; // map experience multiplicator
  975. };
  976. struct map_data_other_server {
  977. char name[MAP_NAME_LENGTH];
  978. unsigned short index; //Index is the map index used by the mapindex* functions.
  979. unsigned char *gat; // NULL固定にして判断
  980. unsigned long ip;
  981. unsigned int port;
  982. };
  983. struct flooritem_data {
  984. struct block_list bl;
  985. unsigned char subx,suby;
  986. int cleartimer;
  987. int first_get_id,second_get_id,third_get_id;
  988. unsigned int first_get_tick,second_get_tick,third_get_tick;
  989. struct item item_data;
  990. };
  991. enum {
  992. SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7
  993. SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15
  994. SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23
  995. SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31
  996. SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39
  997. SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47
  998. SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55
  999. SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60
  1000. SP_CARTINFO=99, // 99
  1001. SP_BASEJOB=119, // 100+19 - celest
  1002. SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex]
  1003. // original 1000-
  1004. SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002
  1005. SP_CASTRATE, SP_MAXHPRATE, SP_MAXSPRATE, SP_SPRATE, // 1003-1006
  1006. SP_ADDELE, SP_ADDRACE, SP_ADDSIZE, SP_SUBELE, SP_SUBRACE, // 1007-1011
  1007. SP_ADDEFF, SP_RESEFF, // 1012-1013
  1008. SP_BASE_ATK,SP_ASPD_RATE,SP_HP_RECOV_RATE,SP_SP_RECOV_RATE,SP_SPEED_RATE, // 1014-1018
  1009. SP_CRITICAL_DEF,SP_NEAR_ATK_DEF,SP_LONG_ATK_DEF, // 1019-1021
  1010. SP_DOUBLE_RATE, SP_DOUBLE_ADD_RATE, SP_MATK, SP_MATK_RATE, // 1022-1025
  1011. SP_IGNORE_DEF_ELE,SP_IGNORE_DEF_RACE, // 1026-1027
  1012. SP_ATK_RATE,SP_SPEED_ADDRATE,SP_ASPD_ADDRATE, // 1028-1030
  1013. SP_MAGIC_ATK_DEF,SP_MISC_ATK_DEF, // 1031-1032
  1014. SP_IGNORE_MDEF_ELE,SP_IGNORE_MDEF_RACE, // 1033-1034
  1015. SP_MAGIC_ADDELE,SP_MAGIC_ADDRACE,SP_MAGIC_ADDSIZE, // 1035-1037
  1016. SP_PERFECT_HIT_RATE,SP_PERFECT_HIT_ADD_RATE,SP_CRITICAL_RATE,SP_GET_ZENY_NUM,SP_ADD_GET_ZENY_NUM, // 1038-1042
  1017. SP_ADD_DAMAGE_CLASS,SP_ADD_MAGIC_DAMAGE_CLASS,SP_ADD_DEF_CLASS,SP_ADD_MDEF_CLASS, // 1043-1046
  1018. SP_ADD_MONSTER_DROP_ITEM,SP_DEF_RATIO_ATK_ELE,SP_DEF_RATIO_ATK_RACE,SP_ADD_SPEED, // 1047-1050
  1019. SP_HIT_RATE,SP_FLEE_RATE,SP_FLEE2_RATE,SP_DEF_RATE,SP_DEF2_RATE,SP_MDEF_RATE,SP_MDEF2_RATE, // 1051-1057
  1020. SP_SPLASH_RANGE,SP_SPLASH_ADD_RANGE,SP_AUTOSPELL,SP_HP_DRAIN_RATE,SP_SP_DRAIN_RATE, // 1058-1062
  1021. SP_SHORT_WEAPON_DAMAGE_RETURN,SP_LONG_WEAPON_DAMAGE_RETURN,SP_WEAPON_COMA_ELE,SP_WEAPON_COMA_RACE, // 1063-1066
  1022. SP_ADDEFF2,SP_BREAK_WEAPON_RATE,SP_BREAK_ARMOR_RATE,SP_ADD_STEAL_RATE, // 1067-1070
  1023. SP_MAGIC_DAMAGE_RETURN,SP_RANDOM_ATTACK_INCREASE,SP_ALL_STATS,SP_AGI_VIT,SP_AGI_DEX_STR,SP_PERFECT_HIDE, // 1071-1076
  1024. SP_DISGUISE,SP_CLASSCHANGE, // 1077-1078
  1025. SP_HP_DRAIN_VALUE,SP_SP_DRAIN_VALUE, // 1079-1080
  1026. SP_WEAPON_ATK,SP_WEAPON_ATK_RATE, // 1081-1082
  1027. SP_DELAYRATE,SP_HP_DRAIN_RATE_RACE,SP_SP_DRAIN_RATE_RACE, // 1083-1085
  1028. SP_RESTART_FULL_RECOVER=2000,SP_NO_CASTCANCEL,SP_NO_SIZEFIX,SP_NO_MAGIC_DAMAGE,SP_NO_WEAPON_DAMAGE,SP_NO_GEMSTONE, // 2000-2005
  1029. SP_NO_CASTCANCEL2,SP_INFINITE_ENDURE,SP_UNBREAKABLE_WEAPON,SP_UNBREAKABLE_ARMOR, SP_UNBREAKABLE_HELM, // 2006-2010
  1030. SP_UNBREAKABLE_SHIELD, SP_LONG_ATK_RATE, // 2011-2012
  1031. SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017
  1032. SP_SKILL_ATK, SP_UNSTRIPABLE, SP_ADD_DAMAGE_BY_CLASS, // 2018-2020
  1033. SP_SP_GAIN_VALUE, SP_IGNORE_DEF_MOB, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025
  1034. SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030
  1035. SP_SP_GAIN_RACE, SP_SUBRACE2, SP_ADDEFF_WHENHIT_SHORT, // 2031-2033
  1036. SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037
  1037. SP_INTRAVISION, SP_ADD_MONSTER_DROP_ITEMGROUP, SP_SP_LOSS_RATE, // 2038-2040
  1038. SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE //2041
  1039. };
  1040. enum {
  1041. LOOK_BASE,LOOK_HAIR,LOOK_WEAPON,LOOK_HEAD_BOTTOM,LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HAIR_COLOR,LOOK_CLOTHES_COLOR,LOOK_SHIELD,LOOK_SHOES
  1042. };
  1043. // CELLs for non-permanent cell-based effects (Pneuma, Basilica, Npcs, etc)
  1044. #define CELL_NPC 0x1
  1045. #define CELL_REGEN 0x2
  1046. #define CELL_PNEUMA 0x4
  1047. #define CELL_SAFETYWALL 0x8
  1048. #define CELL_LANDPROTECTOR 0x10
  1049. #define CELL_BASILICA 0x20
  1050. #define CELL_MOONLIT 0x40
  1051. #define CELL_ICEWALL 0x80
  1052. /*
  1053. * map_getcell()で使用されるフラグ
  1054. */
  1055. typedef enum {
  1056. CELL_CHKWALL=0, // 壁(セルタイプ1)
  1057. CELL_CHKWATER, // 水場(セルタイプ3)
  1058. CELL_CHKGROUND, // 地面障害物(セルタイプ5)
  1059. CELL_CHKPASS, // 通過可能(セルタイプ1,5以外)
  1060. CELL_CHKREACH, // Same as PASS, but ignores the cell-stacking mod.
  1061. CELL_CHKNOPASS, // 通過不可(セルタイプ1,5)
  1062. CELL_CHKNOREACH, // Same as NOPASS, but ignores the cell-stacking mod.
  1063. CELL_GETTYPE, // セルタイプを返す
  1064. CELL_GETCELLTYPE,
  1065. CELL_CHKNPC=0x10, // タッチタイプのNPC(セルタイプ0x80フラグ)
  1066. CELL_CHKREGEN, // cells that improve regeneration
  1067. CELL_CHKPNEUMA,
  1068. CELL_CHKSAFETYWALL,
  1069. CELL_CHKBASILICA, // バジリカ(セルタイプ0x40フラグ)
  1070. CELL_CHKLANDPROTECTOR,
  1071. CELL_CHKMOONLIT,
  1072. CELL_CHKICEWALL,
  1073. CELL_CHKSTACK,
  1074. } cell_t;
  1075. // map_setcell()で使用されるフラグ
  1076. enum {
  1077. CELL_SETNPC=0x10, // タッチタイプのNPCをセット
  1078. CELL_CLRNPC,
  1079. CELL_SETBASILICA, // バジリカをセット
  1080. CELL_CLRBASILICA, // バジリカをクリア
  1081. CELL_SETREGEN, // set regen cell
  1082. CELL_SETLANDPROTECTOR, //Set/Clear Magnetic Earth
  1083. CELL_CLRLANDPROTECTOR,
  1084. CELL_SETPNEUMA,
  1085. CELL_CLRPNEUMA,
  1086. CELL_SETSAFETYWALL,
  1087. CELL_CLRSAFETYWALL,
  1088. CELL_SETMOONLIT,
  1089. CELL_CLRMOONLIT,
  1090. CELL_SETICEWALL,
  1091. CELL_CLRICEWALL,
  1092. };
  1093. struct chat_data {
  1094. struct block_list bl;
  1095. unsigned char pass[8]; /* password */
  1096. unsigned char title[61]; /* room title MAX 60 */
  1097. unsigned char limit; /* join limit */
  1098. unsigned char trigger;
  1099. unsigned char users; /* current users */
  1100. unsigned char pub; /* room attribute */
  1101. struct map_session_data *usersd[20];
  1102. struct block_list *owner_;
  1103. struct block_list **owner;
  1104. char npc_event[50];
  1105. };
  1106. extern struct map_data map[];
  1107. extern int map_num;
  1108. extern int autosave_interval;
  1109. extern int agit_flag;
  1110. extern int night_flag; // 0=day, 1=night [Yor]
  1111. extern int kick_on_disconnect; //To allow inter-server reconnections without kicking players out [Skotlex]
  1112. extern int enable_spy; //Determines if @spy commands are active.
  1113. extern char db_path[256];
  1114. // gat?ヨァ
  1115. int map_getcell(int,int,int,cell_t);
  1116. int map_getcellp(struct map_data*,int,int,cell_t);
  1117. void map_setcell(int,int,int,int);
  1118. extern int map_read_flag; // 0: grfォユォ。ォ、ォ・1: ォュォ罩テォキォ・2: ォュォ罩テォキォ・?�)
  1119. enum {
  1120. READ_FROM_GAT, READ_FROM_AFM,
  1121. READ_FROM_BITMAP, CREATE_BITMAP,
  1122. READ_FROM_BITMAP_COMPRESSED, CREATE_BITMAP_COMPRESSED
  1123. };
  1124. extern char motd_txt[];
  1125. extern char help_txt[];
  1126. extern char help2_txt[];
  1127. extern char charhelp_txt[];
  1128. extern char talkie_mes[];
  1129. extern char wisp_server_name[];
  1130. // 鯖全体情報
  1131. void map_setusers(int);
  1132. int map_getusers(void);
  1133. // block削除関連
  1134. int map_freeblock(struct block_list *bl);
  1135. int map_freeblock_lock(void);
  1136. int map_freeblock_unlock(void);
  1137. // block関連
  1138. int map_addblock_sub(struct block_list *, int);
  1139. int map_delblock_sub(struct block_list *, int);
  1140. #define map_addblock(bl) map_addblock_sub(bl,1)
  1141. #define map_delblock(bl) map_delblock_sub(bl,1)
  1142. int map_moveblock(struct block_list *, int, int, unsigned int);
  1143. int map_foreachinrange(int (*)(struct block_list*,va_list),struct block_list *,int,int,...);
  1144. int map_foreachinshootrange(int (*)(struct block_list*,va_list),struct block_list *,int,int,...);
  1145. int map_foreachinarea(int (*)(struct block_list*,va_list),int,int,int,int,int,int,...);
  1146. // -- moonsoul (added map_foreachincell)
  1147. int map_foreachincell(int (*)(struct block_list*,va_list),int,int,int,int,...);
  1148. int map_foreachinmovearea(int (*)(struct block_list*,va_list),int,int,int,int,int,int,int,int,...);
  1149. int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y0,int x1,int y1,int range,int type,...); // Celest
  1150. int map_foreachinmap(int (*)(struct block_list*,va_list),int,int,...);
  1151. int map_countnearpc(int,int,int);
  1152. //block関連に追加
  1153. int map_count_oncell(int m,int x,int y,int type);
  1154. struct skill_unit *map_find_skill_unit_oncell(struct block_list *,int x,int y,int skill_id,struct skill_unit *);
  1155. // 一時的object関連
  1156. int map_addobject(struct block_list *);
  1157. int map_delobject(int);
  1158. int map_delobjectnofree(int id);
  1159. void map_foreachobject(int (*)(struct block_list*,va_list),int,...);
  1160. int map_search_freecell(struct block_list *src, int m, short *x, short *y, int rx, int ry, int flag);
  1161. //
  1162. int map_quit(struct map_session_data *);
  1163. // npc
  1164. int map_addnpc(int,struct npc_data *);
  1165. // 床アイテム関連
  1166. int map_clearflooritem_timer(int,unsigned int,int,int);
  1167. int map_removemobs_timer(int,unsigned int,int,int);
  1168. #define map_clearflooritem(id) map_clearflooritem_timer(0,0,id,1)
  1169. int map_addflooritem(struct item *,int,int,int,int,struct map_session_data *,struct map_session_data *,struct map_session_data *,int);
  1170. // キャラid=>キャラ名 変換関連
  1171. void map_addchariddb(int charid,char *name);
  1172. void map_delchariddb(int charid);
  1173. int map_reqchariddb(struct map_session_data * sd,int charid);
  1174. char * map_charid2nick(int);
  1175. struct map_session_data * map_charid2sd(int);
  1176. struct map_session_data * map_id2sd(int);
  1177. struct block_list * map_id2bl(int);
  1178. int map_mapindex2mapid(unsigned short mapindex);
  1179. int map_mapname2mapid(char*);
  1180. int map_mapname2ipport(unsigned short,int*,int*);
  1181. int map_setipport(unsigned short map,unsigned long ip,int port);
  1182. int map_eraseipport(unsigned short map,unsigned long ip,int port);
  1183. int map_eraseallipport(void);
  1184. void map_addiddb(struct block_list *);
  1185. void map_deliddb(struct block_list *bl);
  1186. struct map_session_data** map_getallusers(int *users);
  1187. int map_foreachiddb(int (*)(DBKey,void*,va_list),...);
  1188. void map_addnickdb(struct map_session_data *);
  1189. struct map_session_data * map_nick2sd(char*);
  1190. int compare_item(struct item *a, struct item *b);
  1191. // その他
  1192. int map_check_dir(int s_dir,int t_dir);
  1193. int map_calc_dir( struct block_list *src,int x,int y);
  1194. int map_random_dir(struct block_list *bl, short *x, short *y); // [Skotlex]
  1195. // Water functions...
  1196. //
  1197. int map_setwaterheight(int m, char *mapname, int height);
  1198. int map_waterheight(char *mapname);
  1199. // path.cより
  1200. int path_search_real(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1,int flag,int flag2);
  1201. #define path_search(wpd,m,x0,y0,x1,y1,flag) path_search_real(wpd,m,x0,y0,x1,y1,flag,CELL_CHKNOPASS)
  1202. #define path_search2(wpd,m,x0,y0,x1,y1,flag) path_search_real(wpd,m,x0,y0,x1,y1,flag,CELL_CHKWALL)
  1203. int path_search_long_real(struct shootpath_data *spd,int m,int x0,int y0,int x1,int y1,int flag);
  1204. #define path_search_long(spd,m,x0,y0,x1,y1) path_search_long_real(spd,m,x0,y0,x1,y1,CELL_CHKWALL)
  1205. int path_blownpos(int m,int x0,int y0,int dx,int dy,int count);
  1206. // distance related functions [Skotlex]
  1207. #define check_distance_bl(bl1, bl2, distance) check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance)
  1208. #define check_distance_blxy(bl, x1, y1, distance) check_distance((bl)->x-(x1), (bl)->y-(y1), distance)
  1209. #define check_distance_xy(x0, y0, x1, y1, distance) check_distance((x0)-(x1), (y0)-(y1), distance)
  1210. int check_distance(int dx, int dy, int distance);
  1211. #define distance_bl(bl1, bl2) distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y)
  1212. #define distance_blxy(bl, x1, y1) distance((bl)->x-(x1), (bl)->y-(y1))
  1213. #define distance_xy(x0, y0, x1, y1) distance((x0)-(x1), (y0)-(y1))
  1214. unsigned int distance(int dx, int dy);
  1215. int cleanup_sub(struct block_list *bl, va_list ap);
  1216. void map_helpscreen(int flag); // [Valaris]
  1217. int map_delmap(char *mapname);
  1218. int map_addmobtolist(unsigned short m, struct spawn_data *spawn); // [Wizputer]
  1219. void map_spawnmobs(int); // [Wizputer]
  1220. void map_removemobs(int); // [Wizputer]
  1221. //Added for own save method
  1222. int charsql_db_init(int method);
  1223. extern char *INTER_CONF_NAME;
  1224. extern char *LOG_CONF_NAME;
  1225. extern char *MAP_CONF_NAME;
  1226. extern char *BATTLE_CONF_FILENAME;
  1227. extern char *ATCOMMAND_CONF_FILENAME;
  1228. extern char *CHARCOMMAND_CONF_FILENAME;
  1229. extern char *SCRIPT_CONF_NAME;
  1230. extern char *MSG_CONF_NAME;
  1231. extern char *GRF_PATH_FILENAME;
  1232. extern int charsave_method; //needed ..
  1233. #ifndef TXT_ONLY
  1234. // MySQL
  1235. #ifdef __WIN32
  1236. #include <my_global.h>
  1237. #include <my_sys.h>
  1238. #endif
  1239. #include <mysql.h>
  1240. extern char tmp_sql[65535];
  1241. extern int db_use_sqldbs;
  1242. extern MYSQL mmysql_handle;
  1243. extern MYSQL_RES* sql_res ;
  1244. extern MYSQL_ROW sql_row ;
  1245. extern MYSQL charsql_handle;
  1246. extern MYSQL_RES* charsql_res;
  1247. extern MYSQL_ROW charsql_row;
  1248. extern MYSQL logmysql_handle;
  1249. extern MYSQL_RES* logsql_res ;
  1250. extern MYSQL_ROW logsql_row ;
  1251. extern int mail_server_enable;
  1252. extern MYSQL mail_handle;
  1253. extern MYSQL_RES* mail_res ;
  1254. extern MYSQL_ROW mail_row ;
  1255. extern char item_db_db[32];
  1256. extern char item_db2_db[32];
  1257. extern char mob_db_db[32];
  1258. extern char mob_db2_db[32];
  1259. extern char login_db[32];
  1260. extern char login_db_level[32];
  1261. extern char login_db_account_id[32];
  1262. extern char gm_db[32];
  1263. extern char gm_db_level[32];
  1264. extern char gm_db_account_id[32];
  1265. extern int read_gm_interval;
  1266. extern char char_db[32];
  1267. extern char mail_db[32];
  1268. #endif /* not TXT_ONLY */
  1269. //Useful typedefs from jA [Skotlex]
  1270. typedef struct map_session_data TBL_PC;
  1271. typedef struct npc_data TBL_NPC;
  1272. typedef struct mob_data TBL_MOB;
  1273. typedef struct flooritem_data TBL_ITEM;
  1274. typedef struct chat_data TBL_CHAT;
  1275. typedef struct skill_unit TBL_SKILL;
  1276. typedef struct pet_data TBL_PET;
  1277. #define BL_CAST(type_, bl , dest) \
  1278. (((bl) == NULL || (bl)->type != type_) ? ((dest) = NULL, 0) : ((dest) = (T ## type_ *)(bl), 1))
  1279. extern int lowest_gm_level;
  1280. extern char main_chat_nick[16];
  1281. #endif