map.h 44 KB

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