map.h 23 KB

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