map.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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 "../common/cbasetypes.h"
  6. #include "../common/core.h" // CORE_ST_LAST
  7. #include "../common/mmo.h"
  8. #include "../common/mapindex.h"
  9. #include "../common/db.h"
  10. #include <stdarg.h>
  11. struct npc_data;
  12. struct item_data;
  13. enum E_MAPSERVER_ST
  14. {
  15. MAPSERVER_ST_RUNNING = CORE_ST_LAST,
  16. MAPSERVER_ST_SHUTDOWN,
  17. MAPSERVER_ST_LAST
  18. };
  19. //Uncomment to enable the Cell Stack Limit mod.
  20. //It's only config is the battle_config cell_stack_limit.
  21. //Only chars affected are those defined in BL_CHAR (mobs and players currently)
  22. //#define CELL_NOSTACK
  23. //Uncomment to enable circular area checks.
  24. //By default, all range checks in Aegis are of Square shapes, so a weapon range
  25. // of 10 allows you to attack from anywhere within a 21x21 area.
  26. //Enabling this changes such checks to circular checks, which is more realistic,
  27. // but is not the official behaviour.
  28. //#define CIRCULAR_AREA
  29. #define MAX_NPC_PER_MAP 512
  30. #define BLOCK_SIZE 8
  31. #define AREA_SIZE battle_config.area_size
  32. #define DAMAGELOG_SIZE 30
  33. #define LOOTITEM_SIZE 10
  34. #define MAX_MOBSKILL 50
  35. #define MAX_MOB_LIST_PER_MAP 128
  36. #define MAX_EVENTQUEUE 2
  37. #define MAX_EVENTTIMER 32
  38. #define NATURAL_HEAL_INTERVAL 500
  39. #define MIN_FLOORITEM 2
  40. #define MAX_FLOORITEM START_ACCOUNT_NUM
  41. #define MAX_LEVEL 99
  42. #define MAX_DROP_PER_MAP 48
  43. #define MAX_IGNORE_LIST 20 // official is 14
  44. #define MAX_VENDING 12
  45. #define MAX_MAP_SIZE 512*512 // Wasn't there something like this already? Can't find it.. [Shinryo]
  46. #define MOBID_EMPERIUM 1288
  47. // Added definitions for WoESE objects. [L0ne_W0lf]
  48. #define MOBID_BARRICADE1 1905
  49. #define MOBID_BARRICADE2 1906
  50. #define MOBID_GUARIDAN_STONE1 1907
  51. #define MOBID_GUARIDAN_STONE2 1908
  52. //The following system marks a different job ID system used by the map server,
  53. //which makes a lot more sense than the normal one. [Skotlex]
  54. //
  55. //These marks the "level" of the job.
  56. #define JOBL_2_1 0x100 //256
  57. #define JOBL_2_2 0x200 //512
  58. #define JOBL_2 0x300
  59. #define JOBL_UPPER 0x1000 //4096
  60. #define JOBL_BABY 0x2000 //8192
  61. //for filtering and quick checking.
  62. #define MAPID_UPPERMASK 0x0fff
  63. #define MAPID_BASEMASK 0x00ff
  64. //First Jobs
  65. //Note the oddity of the novice:
  66. //Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type, too...
  67. enum {
  68. MAPID_NOVICE = 0x0,
  69. MAPID_SWORDMAN,
  70. MAPID_MAGE,
  71. MAPID_ARCHER,
  72. MAPID_ACOLYTE,
  73. MAPID_MERCHANT,
  74. MAPID_THIEF,
  75. MAPID_TAEKWON,
  76. MAPID_WEDDING,
  77. MAPID_GUNSLINGER,
  78. MAPID_NINJA,
  79. MAPID_XMAS,
  80. MAPID_SUMMER,
  81. //2_1 classes
  82. MAPID_SUPER_NOVICE = JOBL_2_1|0x0,
  83. MAPID_KNIGHT,
  84. MAPID_WIZARD,
  85. MAPID_HUNTER,
  86. MAPID_PRIEST,
  87. MAPID_BLACKSMITH,
  88. MAPID_ASSASSIN,
  89. MAPID_STAR_GLADIATOR,
  90. //2_2 classes
  91. MAPID_CRUSADER = JOBL_2_2|0x1,
  92. MAPID_SAGE,
  93. MAPID_BARDDANCER,
  94. MAPID_MONK,
  95. MAPID_ALCHEMIST,
  96. MAPID_ROGUE,
  97. MAPID_SOUL_LINKER,
  98. //1-1, advanced
  99. MAPID_NOVICE_HIGH = JOBL_UPPER|0x0,
  100. MAPID_SWORDMAN_HIGH,
  101. MAPID_MAGE_HIGH,
  102. MAPID_ARCHER_HIGH,
  103. MAPID_ACOLYTE_HIGH,
  104. MAPID_MERCHANT_HIGH,
  105. MAPID_THIEF_HIGH,
  106. //2_1 advanced
  107. MAPID_LORD_KNIGHT = JOBL_UPPER|JOBL_2_1|0x1,
  108. MAPID_HIGH_WIZARD,
  109. MAPID_SNIPER,
  110. MAPID_HIGH_PRIEST,
  111. MAPID_WHITESMITH,
  112. MAPID_ASSASSIN_CROSS,
  113. //2_2 advanced
  114. MAPID_PALADIN = JOBL_UPPER|JOBL_2_2|0x1,
  115. MAPID_PROFESSOR,
  116. MAPID_CLOWNGYPSY,
  117. MAPID_CHAMPION,
  118. MAPID_CREATOR,
  119. MAPID_STALKER,
  120. //1-1 baby
  121. MAPID_BABY = JOBL_BABY|0x0,
  122. MAPID_BABY_SWORDMAN,
  123. MAPID_BABY_MAGE,
  124. MAPID_BABY_ARCHER,
  125. MAPID_BABY_ACOLYTE,
  126. MAPID_BABY_MERCHANT,
  127. MAPID_BABY_THIEF,
  128. MAPID_BABY_TAEKWON,
  129. //2_1 baby
  130. MAPID_SUPER_BABY = JOBL_BABY|JOBL_2_1|0x0,
  131. MAPID_BABY_KNIGHT,
  132. MAPID_BABY_WIZARD,
  133. MAPID_BABY_HUNTER,
  134. MAPID_BABY_PRIEST,
  135. MAPID_BABY_BLACKSMITH,
  136. MAPID_BABY_ASSASSIN,
  137. MAPID_BABY_STAR_GLADIATOR,
  138. //2_2 baby
  139. MAPID_BABY_CRUSADER = JOBL_BABY|JOBL_2_2|0x1,
  140. MAPID_BABY_SAGE,
  141. MAPID_BABY_BARDDANCER,
  142. MAPID_BABY_MONK,
  143. MAPID_BABY_ALCHEMIST,
  144. MAPID_BABY_ROGUE,
  145. MAPID_BABY_SOUL_LINKER,
  146. };
  147. //Max size for inputs to Graffiti, Talkie Box and Vending text prompts
  148. #define MESSAGE_SIZE (79 + 1)
  149. //String length you can write in the 'talking box'
  150. #define CHATBOX_SIZE (70 + 1)
  151. //Chatroom-related string sizes
  152. #define CHATROOM_TITLE_SIZE (36 + 1)
  153. #define CHATROOM_PASS_SIZE (8 + 1)
  154. //Max allowed chat text length
  155. #define CHAT_SIZE_MAX (255 + 1)
  156. //24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
  157. #define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 )
  158. #define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000
  159. //Specifies maps where players may hit each other
  160. #define map_flag_vs(m) (map[m].flag.pvp || map[m].flag.gvg_dungeon || map[m].flag.gvg || ((agit_flag || agit2_flag) && map[m].flag.gvg_castle) || map[m].flag.battleground)
  161. //Specifies maps that have special GvG/WoE restrictions
  162. #define map_flag_gvg(m) (map[m].flag.gvg || ((agit_flag || agit2_flag) && map[m].flag.gvg_castle))
  163. //Specifies if the map is tagged as GvG/WoE (regardless of agit_flag status)
  164. #define map_flag_gvg2(m) (map[m].flag.gvg || map[m].flag.gvg_castle)
  165. // No Kill Steal Protection
  166. #define map_flag_ks(m) (map[m].flag.town || map[m].flag.pvp || map[m].flag.gvg || map[m].flag.battleground)
  167. //This stackable implementation does not means a BL can be more than one type at a time, but it's
  168. //meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex]
  169. enum bl_type {
  170. BL_NUL = 0x000,
  171. BL_PC = 0x001,
  172. BL_MOB = 0x002,
  173. BL_PET = 0x004,
  174. BL_HOM = 0x008,
  175. BL_MER = 0x010,
  176. BL_ITEM = 0x020,
  177. BL_SKILL = 0x040,
  178. BL_NPC = 0x080,
  179. BL_CHAT = 0x100,
  180. BL_ALL = 0xFFF,
  181. };
  182. //For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
  183. #define BL_CHAR (BL_PC|BL_MOB|BL_HOM|BL_MER)
  184. enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP };
  185. enum {
  186. RC_FORMLESS=0,
  187. RC_UNDEAD,
  188. RC_BRUTE,
  189. RC_PLANT,
  190. RC_INSECT,
  191. RC_FISH,
  192. RC_DEMON,
  193. RC_DEMIHUMAN,
  194. RC_ANGEL,
  195. RC_DRAGON,
  196. RC_BOSS,
  197. RC_NONBOSS,
  198. RC_NONDEMIHUMAN,
  199. RC_MAX
  200. };
  201. enum {
  202. RC2_NONE = 0,
  203. RC2_GOBLIN,
  204. RC2_KOBOLD,
  205. RC2_ORC,
  206. RC2_GOLEM,
  207. RC2_GUARDIAN,
  208. RC2_NINJA,
  209. RC2_MAX
  210. };
  211. enum {
  212. ELE_NEUTRAL=0,
  213. ELE_WATER,
  214. ELE_EARTH,
  215. ELE_FIRE,
  216. ELE_WIND,
  217. ELE_POISON,
  218. ELE_HOLY,
  219. ELE_DARK,
  220. ELE_GHOST,
  221. ELE_UNDEAD,
  222. ELE_MAX
  223. };
  224. enum auto_trigger_flag {
  225. ATF_SELF=0x01,
  226. ATF_TARGET=0x02,
  227. ATF_SHORT=0x04,
  228. ATF_LONG=0x08,
  229. ATF_WEAPON=0x10,
  230. ATF_MAGIC=0x20,
  231. ATF_MISC=0x40,
  232. };
  233. struct block_list {
  234. struct block_list *next,*prev;
  235. int id;
  236. short m,x,y;
  237. enum bl_type type;
  238. };
  239. // Mob List Held in memory for Dynamic Mobs [Wizputer]
  240. // Expanded to specify all mob-related spawn data by [Skotlex]
  241. struct spawn_data {
  242. short class_; //Class, used because a mob can change it's class
  243. unsigned short m,x,y; //Spawn information (map, point, spawn-area around point)
  244. signed short xs,ys;
  245. unsigned short num; //Number of mobs using this structure
  246. unsigned short active; //Number of mobs that are already spawned (for mob_remove_damaged: no)
  247. unsigned int delay1,delay2; //Min delay before respawning after spawn/death
  248. struct {
  249. unsigned int size :2; //Holds if mob has to be tiny/large
  250. unsigned int ai :2; //Holds if mob is special ai.
  251. unsigned int dynamic :1; //Whether this data is indexed by a map's dynamic mob list
  252. unsigned int boss : 1;
  253. } state;
  254. char name[NAME_LENGTH],eventname[EVENT_NAME_LENGTH]; //Name/event
  255. };
  256. struct flooritem_data {
  257. struct block_list bl;
  258. unsigned char subx,suby;
  259. int cleartimer;
  260. int first_get_charid,second_get_charid,third_get_charid;
  261. unsigned int first_get_tick,second_get_tick,third_get_tick;
  262. struct item item_data;
  263. };
  264. enum _sp {
  265. SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7
  266. SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15
  267. SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23
  268. SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31
  269. SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39
  270. SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47
  271. SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55
  272. SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60
  273. SP_CARTINFO=99, // 99
  274. SP_BASEJOB=119, // 100+19 - celest
  275. SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex]
  276. SP_KILLERRID=121,
  277. SP_KILLEDRID=122,
  278. // Mercenaries
  279. SP_MERCFLEE=165, SP_MERCKILLS=189, SP_MERCFAITH=190,
  280. // original 1000-
  281. SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002
  282. SP_CASTRATE, SP_MAXHPRATE, SP_MAXSPRATE, SP_SPRATE, // 1003-1006
  283. SP_ADDELE, SP_ADDRACE, SP_ADDSIZE, SP_SUBELE, SP_SUBRACE, // 1007-1011
  284. SP_ADDEFF, SP_RESEFF, // 1012-1013
  285. SP_BASE_ATK,SP_ASPD_RATE,SP_HP_RECOV_RATE,SP_SP_RECOV_RATE,SP_SPEED_RATE, // 1014-1018
  286. SP_CRITICAL_DEF,SP_NEAR_ATK_DEF,SP_LONG_ATK_DEF, // 1019-1021
  287. SP_DOUBLE_RATE, SP_DOUBLE_ADD_RATE, SP_SKILL_HEAL, SP_MATK_RATE, // 1022-1025
  288. SP_IGNORE_DEF_ELE,SP_IGNORE_DEF_RACE, // 1026-1027
  289. SP_ATK_RATE,SP_SPEED_ADDRATE,SP_SP_REGEN_RATE, // 1028-1030
  290. SP_MAGIC_ATK_DEF,SP_MISC_ATK_DEF, // 1031-1032
  291. SP_IGNORE_MDEF_ELE,SP_IGNORE_MDEF_RACE, // 1033-1034
  292. SP_MAGIC_ADDELE,SP_MAGIC_ADDRACE,SP_MAGIC_ADDSIZE, // 1035-1037
  293. SP_PERFECT_HIT_RATE,SP_PERFECT_HIT_ADD_RATE,SP_CRITICAL_RATE,SP_GET_ZENY_NUM,SP_ADD_GET_ZENY_NUM, // 1038-1042
  294. SP_ADD_DAMAGE_CLASS,SP_ADD_MAGIC_DAMAGE_CLASS,SP_ADD_DEF_CLASS,SP_ADD_MDEF_CLASS, // 1043-1046
  295. SP_ADD_MONSTER_DROP_ITEM,SP_DEF_RATIO_ATK_ELE,SP_DEF_RATIO_ATK_RACE,SP_UNBREAKABLE_GARMENT, // 1047-1050
  296. SP_HIT_RATE,SP_FLEE_RATE,SP_FLEE2_RATE,SP_DEF_RATE,SP_DEF2_RATE,SP_MDEF_RATE,SP_MDEF2_RATE, // 1051-1057
  297. SP_SPLASH_RANGE,SP_SPLASH_ADD_RANGE,SP_AUTOSPELL,SP_HP_DRAIN_RATE,SP_SP_DRAIN_RATE, // 1058-1062
  298. SP_SHORT_WEAPON_DAMAGE_RETURN,SP_LONG_WEAPON_DAMAGE_RETURN,SP_WEAPON_COMA_ELE,SP_WEAPON_COMA_RACE, // 1063-1066
  299. SP_ADDEFF2,SP_BREAK_WEAPON_RATE,SP_BREAK_ARMOR_RATE,SP_ADD_STEAL_RATE, // 1067-1070
  300. SP_MAGIC_DAMAGE_RETURN,SP_RANDOM_ATTACK_INCREASE,SP_ALL_STATS,SP_AGI_VIT,SP_AGI_DEX_STR,SP_PERFECT_HIDE, // 1071-1076
  301. SP_NO_KNOCKBACK,SP_CLASSCHANGE, // 1077-1078
  302. SP_HP_DRAIN_VALUE,SP_SP_DRAIN_VALUE, // 1079-1080
  303. SP_WEAPON_ATK,SP_WEAPON_ATK_RATE, // 1081-1082
  304. SP_DELAYRATE,SP_HP_DRAIN_RATE_RACE,SP_SP_DRAIN_RATE_RACE, // 1083-1085
  305. SP_IGNORE_MDEF_RATE,SP_IGNORE_DEF_RATE,SP_SKILL_HEAL2,SP_ADDEFF_ONSKILL, //1086-1089
  306. SP_ADD_HEAL_RATE,SP_ADD_HEAL2_RATE, //1090-1091
  307. SP_RESTART_FULL_RECOVER=2000,SP_NO_CASTCANCEL,SP_NO_SIZEFIX,SP_NO_MAGIC_DAMAGE,SP_NO_WEAPON_DAMAGE,SP_NO_GEMSTONE, // 2000-2005
  308. SP_NO_CASTCANCEL2,SP_NO_MISC_DAMAGE,SP_UNBREAKABLE_WEAPON,SP_UNBREAKABLE_ARMOR, SP_UNBREAKABLE_HELM, // 2006-2010
  309. SP_UNBREAKABLE_SHIELD, SP_LONG_ATK_RATE, // 2011-2012
  310. SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017
  311. SP_SKILL_ATK, SP_UNSTRIPABLE, SP_AUTOSPELL_ONSKILL, // 2018-2020
  312. SP_SP_GAIN_VALUE, SP_HP_REGEN_RATE, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025
  313. SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030
  314. SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033
  315. SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037
  316. SP_INTRAVISION, SP_ADD_MONSTER_DROP_ITEMGROUP, SP_SP_LOSS_RATE, // 2038-2040
  317. SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE, SP_MAGIC_SP_GAIN_VALUE, SP_MAGIC_HP_GAIN_VALUE, SP_ADD_CLASS_DROP_ITEM //2041-2045
  318. };
  319. enum _look {
  320. LOOK_BASE,
  321. LOOK_HAIR,
  322. LOOK_WEAPON,
  323. LOOK_HEAD_BOTTOM,
  324. LOOK_HEAD_TOP,
  325. LOOK_HEAD_MID,
  326. LOOK_HAIR_COLOR,
  327. LOOK_CLOTHES_COLOR,
  328. LOOK_SHIELD,
  329. LOOK_SHOES,
  330. LOOK_BODY,
  331. LOOK_FLOOR,
  332. LOOK_ROBE,
  333. };
  334. // used by map_setcell()
  335. typedef enum {
  336. CELL_WALKABLE,
  337. CELL_SHOOTABLE,
  338. CELL_WATER,
  339. CELL_NPC,
  340. CELL_BASILICA,
  341. CELL_LANDPROTECTOR,
  342. CELL_NOVENDING,
  343. CELL_NOCHAT,
  344. } cell_t;
  345. // used by map_getcell()
  346. typedef enum {
  347. CELL_GETTYPE, // retrieves a cell's 'gat' type
  348. CELL_CHKWALL, // wall (gat type 1)
  349. CELL_CHKWATER, // water (gat type 3)
  350. CELL_CHKCLIFF, // cliff/gap (gat type 5)
  351. CELL_CHKPASS, // passable cell (gat type non-1/5)
  352. CELL_CHKREACH, // Same as PASS, but ignores the cell-stacking mod.
  353. CELL_CHKNOPASS, // non-passable cell (gat types 1 and 5)
  354. CELL_CHKNOREACH, // Same as NOPASS, but ignores the cell-stacking mod.
  355. CELL_CHKSTACK, // whether cell is full (reached cell stacking limit)
  356. CELL_CHKNPC,
  357. CELL_CHKBASILICA,
  358. CELL_CHKLANDPROTECTOR,
  359. CELL_CHKNOVENDING,
  360. CELL_CHKNOCHAT,
  361. } cell_chk;
  362. struct mapcell
  363. {
  364. // terrain flags
  365. unsigned char
  366. walkable : 1,
  367. shootable : 1,
  368. water : 1;
  369. // dynamic flags
  370. unsigned char
  371. npc : 1,
  372. basilica : 1,
  373. landprotector : 1,
  374. novending : 1,
  375. nochat : 1;
  376. #ifdef CELL_NOSTACK
  377. unsigned char cell_bl; //Holds amount of bls in this cell.
  378. #endif
  379. };
  380. struct iwall_data {
  381. char wall_name[50];
  382. short m, x, y, size, dir;
  383. bool shootable;
  384. };
  385. struct map_data {
  386. char name[MAP_NAME_LENGTH];
  387. unsigned short index; // The map index used by the mapindex* functions.
  388. struct mapcell* cell; // Holds the information of each map cell (NULL if the map is not on this map-server).
  389. struct block_list **block;
  390. struct block_list **block_mob;
  391. int m;
  392. short xs,ys; // map dimensions (in cells)
  393. short bxs,bys; // map dimensions (in blocks)
  394. short bgscore_lion, bgscore_eagle; // Battleground ScoreBoard
  395. int npc_num;
  396. int users;
  397. int iwall_num; // Total of invisible walls in this map
  398. struct map_flag {
  399. unsigned town : 1; // [Suggestion to protect Mail System]
  400. unsigned autotrade : 1;
  401. unsigned allowks : 1; // [Kill Steal Protection]
  402. unsigned nomemo : 1;
  403. unsigned noteleport : 1;
  404. unsigned noreturn : 1;
  405. unsigned monster_noteleport : 1;
  406. unsigned nosave : 1;
  407. unsigned nobranch : 1;
  408. unsigned noexppenalty : 1;
  409. unsigned pvp : 1;
  410. unsigned pvp_noparty : 1;
  411. unsigned pvp_noguild : 1;
  412. unsigned pvp_nightmaredrop :1;
  413. unsigned pvp_nocalcrank : 1;
  414. unsigned gvg_castle : 1;
  415. unsigned gvg : 1; // Now it identifies gvg versus maps that are active 24/7
  416. unsigned gvg_dungeon : 1; // Celest
  417. unsigned gvg_noparty : 1;
  418. unsigned battleground : 2; // [BattleGround System]
  419. unsigned nozenypenalty : 1;
  420. unsigned notrade : 1;
  421. unsigned noskill : 1;
  422. unsigned nowarp : 1;
  423. unsigned nowarpto : 1;
  424. unsigned noicewall : 1; // [Valaris]
  425. unsigned snow : 1; // [Valaris]
  426. unsigned clouds : 1;
  427. unsigned clouds2 : 1; // [Valaris]
  428. unsigned fog : 1; // [Valaris]
  429. unsigned fireworks : 1;
  430. unsigned sakura : 1; // [Valaris]
  431. unsigned leaves : 1; // [Valaris]
  432. unsigned rain : 1; // [Valaris]
  433. unsigned nogo : 1; // [Valaris]
  434. unsigned nobaseexp : 1; // [Lorky] added by Lupus
  435. unsigned nojobexp : 1; // [Lorky]
  436. unsigned nomobloot : 1; // [Lorky]
  437. unsigned nomvploot : 1; // [Lorky]
  438. unsigned nightenabled :1; //For night display. [Skotlex]
  439. unsigned restricted : 1; // [Komurka]
  440. unsigned nodrop : 1;
  441. unsigned novending : 1;
  442. unsigned loadevent : 1;
  443. unsigned nochat :1;
  444. unsigned partylock :1;
  445. unsigned guildlock :1;
  446. unsigned src4instance : 1; // To flag this map when it's used as a src map for instances
  447. unsigned reset :1; // [Daegaladh]
  448. } flag;
  449. struct point save;
  450. struct npc_data *npc[MAX_NPC_PER_MAP];
  451. struct {
  452. int drop_id;
  453. int drop_type;
  454. int drop_per;
  455. } drop_list[MAX_DROP_PER_MAP];
  456. struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
  457. int mob_delete_timer; // [Skotlex]
  458. int zone; // zone number (for item/skill restrictions)
  459. int jexp; // map experience multiplicator
  460. int bexp; // map experience multiplicator
  461. int nocommand; //Blocks @/# commands for non-gms. [Skotlex]
  462. // Instance Variables
  463. int instance_id;
  464. int instance_src_map;
  465. };
  466. /// Stores information about a remote map (for multi-mapserver setups).
  467. /// Beginning of data structure matches 'map_data', to allow typecasting.
  468. struct map_data_other_server {
  469. char name[MAP_NAME_LENGTH];
  470. unsigned short index; //Index is the map index used by the mapindex* functions.
  471. struct mapcell* cell; // If this is NULL, the map is not on this map-server
  472. uint32 ip;
  473. uint16 port;
  474. };
  475. int map_getcell(int,int,int,cell_chk);
  476. int map_getcellp(struct map_data*,int,int,cell_chk);
  477. void map_setcell(int m, int x, int y, cell_t cell, bool flag);
  478. void map_setgatcell(int m, int x, int y, int gat);
  479. extern struct map_data map[];
  480. extern int map_num;
  481. extern int autosave_interval;
  482. extern int minsave_interval;
  483. extern int save_settings;
  484. extern int agit_flag;
  485. extern int agit2_flag;
  486. extern int night_flag; // 0=day, 1=night [Yor]
  487. extern int enable_spy; //Determines if @spy commands are active.
  488. extern char db_path[256];
  489. extern char motd_txt[];
  490. extern char help_txt[];
  491. extern char help2_txt[];
  492. extern char charhelp_txt[];
  493. extern char wisp_server_name[];
  494. // 鯖全体情報
  495. void map_setusers(int);
  496. int map_getusers(void);
  497. int map_usercount(void);
  498. // block削除関連
  499. int map_freeblock(struct block_list *bl);
  500. int map_freeblock_lock(void);
  501. int map_freeblock_unlock(void);
  502. // block関連
  503. int map_addblock(struct block_list* bl);
  504. int map_delblock(struct block_list* bl);
  505. int map_moveblock(struct block_list *, int, int, unsigned int);
  506. int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int type, ...);
  507. int map_foreachinshootrange(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int type, ...);
  508. int map_foreachinarea(int (*func)(struct block_list*,va_list), int m, int x0, int y0, int x1, int y1, int type, ...);
  509. int map_forcountinarea(int (*func)(struct block_list*,va_list), int m, int x0, int y0, int x1, int y1, int count, int type, ...);
  510. int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int dx, int dy, int type, ...);
  511. int map_foreachincell(int (*func)(struct block_list*,va_list), int m, int x, int y, int type, ...);
  512. int map_foreachinpath(int (*func)(struct block_list*,va_list), int m, int x0, int y0, int x1, int y1, int range, int length, int type, ...);
  513. int map_foreachinmap(int (*func)(struct block_list*,va_list), int m, int type, ...);
  514. //block関連に追加
  515. int map_count_oncell(int m,int x,int y,int type);
  516. struct skill_unit *map_find_skill_unit_oncell(struct block_list *,int x,int y,int skill_id,struct skill_unit *);
  517. // 一時的object関連
  518. int map_get_new_object_id(void);
  519. int map_search_freecell(struct block_list *src, int m, short *x, short *y, int rx, int ry, int flag);
  520. //
  521. int map_quit(struct map_session_data *);
  522. // npc
  523. bool map_addnpc(int,struct npc_data *);
  524. // 床アイテム関連
  525. int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data);
  526. int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data);
  527. #define map_clearflooritem(id) map_clearflooritem_timer(0,0,id,1)
  528. int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int first_charid,int second_charid,int third_charid,int flags);
  529. // キャラid=>キャラ名 変換関連
  530. void map_addnickdb(int charid, const char* nick);
  531. void map_delnickdb(int charid, const char* nick);
  532. void map_reqnickdb(struct map_session_data* sd,int charid);
  533. const char* map_charid2nick(int charid);
  534. struct map_session_data* map_charid2sd(int charid);
  535. struct map_session_data * map_id2sd(int id);
  536. struct mob_data * map_id2md(int id);
  537. struct npc_data * map_id2nd(int id);
  538. struct homun_data* map_id2hd(int id);
  539. struct mercenary_data* map_id2mc(int id);
  540. struct chat_data* map_id2cd(int id);
  541. struct block_list * map_id2bl(int id);
  542. #define map_id2index(id) map[(id)].index
  543. int map_mapindex2mapid(unsigned short mapindex);
  544. int map_mapname2mapid(const char* name);
  545. int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port);
  546. int map_setipport(unsigned short map, uint32 ip, uint16 port);
  547. int map_eraseipport(unsigned short map, uint32 ip, uint16 port);
  548. int map_eraseallipport(void);
  549. void map_addiddb(struct block_list *);
  550. void map_deliddb(struct block_list *bl);
  551. void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...);
  552. void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...);
  553. void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...);
  554. void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...);
  555. void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...);
  556. struct map_session_data * map_nick2sd(const char*);
  557. struct mob_data * map_getmob_boss(int m);
  558. struct mob_data * map_id2boss(int id);
  559. /// Bitfield of flags for the iterator.
  560. enum e_mapitflags
  561. {
  562. MAPIT_NORMAL = 0,
  563. // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold auth'ed, active players.
  564. };
  565. struct s_mapiterator;
  566. struct s_mapiterator* mapit_alloc(enum e_mapitflags flags, enum bl_type types);
  567. void mapit_free(struct s_mapiterator* mapit);
  568. struct block_list* mapit_first(struct s_mapiterator* mapit);
  569. struct block_list* mapit_last(struct s_mapiterator* mapit);
  570. struct block_list* mapit_next(struct s_mapiterator* mapit);
  571. struct block_list* mapit_prev(struct s_mapiterator* mapit);
  572. bool mapit_exists(struct s_mapiterator* mapit);
  573. #define mapit_getallusers() mapit_alloc(MAPIT_NORMAL,BL_PC)
  574. #define mapit_geteachpc() mapit_alloc(MAPIT_NORMAL,BL_PC)
  575. #define mapit_geteachmob() mapit_alloc(MAPIT_NORMAL,BL_MOB)
  576. #define mapit_geteachnpc() mapit_alloc(MAPIT_NORMAL,BL_NPC)
  577. #define mapit_geteachiddb() mapit_alloc(MAPIT_NORMAL,BL_ALL)
  578. // その他
  579. int map_check_dir(int s_dir,int t_dir);
  580. unsigned char map_calc_dir( struct block_list *src,int x,int y);
  581. int map_random_dir(struct block_list *bl, short *x, short *y); // [Skotlex]
  582. int cleanup_sub(struct block_list *bl, va_list ap);
  583. void map_helpscreen(int flag); // [Valaris]
  584. int map_delmap(char* mapname);
  585. void map_flags_init(void);
  586. bool map_iwall_set(int m, int x, int y, int size, int dir, bool shootable, const char* wall_name);
  587. void map_iwall_get(struct map_session_data *sd);
  588. void map_iwall_remove(const char *wall_name);
  589. int map_addmobtolist(unsigned short m, struct spawn_data *spawn); // [Wizputer]
  590. void map_spawnmobs(int); // [Wizputer]
  591. void map_removemobs(int); // [Wizputer]
  592. void do_reconnect_map(void); //Invoked on map-char reconnection [Skotlex]
  593. void map_addmap2db(struct map_data *m);
  594. void map_removemapdb(struct map_data *m);
  595. extern char *INTER_CONF_NAME;
  596. extern char *LOG_CONF_NAME;
  597. extern char *MAP_CONF_NAME;
  598. extern char *BATTLE_CONF_FILENAME;
  599. extern char *ATCOMMAND_CONF_FILENAME;
  600. extern char *SCRIPT_CONF_NAME;
  601. extern char *MSG_CONF_NAME;
  602. extern char *GRF_PATH_FILENAME;
  603. extern char *map_server_dns;
  604. //Useful typedefs from jA [Skotlex]
  605. typedef struct map_session_data TBL_PC;
  606. typedef struct npc_data TBL_NPC;
  607. typedef struct mob_data TBL_MOB;
  608. typedef struct flooritem_data TBL_ITEM;
  609. typedef struct chat_data TBL_CHAT;
  610. typedef struct skill_unit TBL_SKILL;
  611. typedef struct pet_data TBL_PET;
  612. typedef struct homun_data TBL_HOM;
  613. typedef struct mercenary_data TBL_MER;
  614. #define BL_CAST(type_, bl) \
  615. ( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) )
  616. extern char main_chat_nick[16];
  617. #ifndef TXT_ONLY
  618. #include "../common/sql.h"
  619. extern int db_use_sqldbs;
  620. extern Sql* mmysql_handle;
  621. extern Sql* logmysql_handle;
  622. extern char item_db_db[32];
  623. extern char item_db2_db[32];
  624. extern char mob_db_db[32];
  625. extern char mob_db2_db[32];
  626. #endif /* not TXT_ONLY */
  627. void do_shutdown(void);
  628. #endif /* _MAP_H_ */