map.h 43 KB

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