map.h 43 KB

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