map.hpp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef MAP_HPP
  4. #define MAP_HPP
  5. #include <algorithm>
  6. #include <stdarg.h>
  7. #include <string>
  8. #include <unordered_map>
  9. #include <vector>
  10. #include "../common/cbasetypes.hpp"
  11. #include "../common/core.hpp" // CORE_ST_LAST
  12. #include "../common/db.hpp"
  13. #include "../common/mapindex.hpp"
  14. #include "../common/mmo.hpp"
  15. #include "../common/msg_conf.hpp"
  16. #include "../common/timer.hpp"
  17. #include "../config/core.hpp"
  18. #include "script.hpp"
  19. struct npc_data;
  20. struct item_data;
  21. struct Channel;
  22. enum E_MAPSERVER_ST {
  23. MAPSERVER_ST_RUNNING = CORE_ST_LAST,
  24. MAPSERVER_ST_STARTING,
  25. MAPSERVER_ST_SHUTDOWN,
  26. MAPSERVER_ST_LAST
  27. };
  28. struct map_data *map_getmapdata(int16 m);
  29. #define msg_config_read(cfgName,isnew) map_msg_config_read(cfgName,isnew)
  30. #define msg_txt(sd,msg_number) map_msg_txt(sd,msg_number)
  31. #define do_final_msg() map_do_final_msg()
  32. int map_msg_config_read(const char *cfgName,int lang);
  33. const char* map_msg_txt(struct map_session_data *sd,int msg_number);
  34. void map_do_final_msg(void);
  35. void map_msg_reload(void);
  36. #define MAX_NPC_PER_MAP 512
  37. #define AREA_SIZE battle_config.area_size
  38. #define DAMAGELOG_SIZE 30
  39. #define LOOTITEM_SIZE 10
  40. #define MAX_MOBSKILL 50 //Max 128, see mob skill_idx type if need this higher
  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 MIN_FLOORITEM 2
  46. #define MAX_FLOORITEM START_ACCOUNT_NUM
  47. #define MAX_LEVEL 200
  48. #define MAX_DROP_PER_MAP 48
  49. #define MAX_IGNORE_LIST 20 // official is 14
  50. #define MAX_VENDING 12
  51. #define MAX_MAP_SIZE 512*512 // Wasn't there something like this already? Can't find it.. [Shinryo]
  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 //768
  59. #define JOBL_UPPER 0x1000 //4096
  60. #define JOBL_BABY 0x2000 //8192
  61. #define JOBL_THIRD 0x4000 //16384
  62. //for filtering and quick checking.
  63. #define MAPID_BASEMASK 0x00ff
  64. #define MAPID_UPPERMASK 0x0fff
  65. #define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK)
  66. //First Jobs
  67. //Note the oddity of the novice:
  68. //Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type, too...
  69. enum e_mapid : uint64{
  70. //Novice And 1-1 Jobs
  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,
  83. MAPID_SUMMER,
  84. MAPID_HANBOK,
  85. MAPID_GANGSI,
  86. MAPID_OKTOBERFEST,
  87. MAPID_SUMMONER,
  88. MAPID_SUMMER2,
  89. //2-1 Jobs
  90. MAPID_SUPER_NOVICE = JOBL_2_1|MAPID_NOVICE,
  91. MAPID_KNIGHT,
  92. MAPID_WIZARD,
  93. MAPID_HUNTER,
  94. MAPID_PRIEST,
  95. MAPID_BLACKSMITH,
  96. MAPID_ASSASSIN,
  97. MAPID_STAR_GLADIATOR,
  98. MAPID_REBELLION = JOBL_2_1|MAPID_GUNSLINGER,
  99. MAPID_KAGEROUOBORO,
  100. MAPID_DEATH_KNIGHT = JOBL_2_1|MAPID_GANGSI,
  101. //2-2 Jobs
  102. MAPID_CRUSADER = JOBL_2_2|MAPID_SWORDMAN,
  103. MAPID_SAGE,
  104. MAPID_BARDDANCER,
  105. MAPID_MONK,
  106. MAPID_ALCHEMIST,
  107. MAPID_ROGUE,
  108. MAPID_SOUL_LINKER,
  109. MAPID_DARK_COLLECTOR = JOBL_2_2|MAPID_GANGSI,
  110. //Trans Novice And Trans 1-1 Jobs
  111. MAPID_NOVICE_HIGH = JOBL_UPPER|MAPID_NOVICE,
  112. MAPID_SWORDMAN_HIGH,
  113. MAPID_MAGE_HIGH,
  114. MAPID_ARCHER_HIGH,
  115. MAPID_ACOLYTE_HIGH,
  116. MAPID_MERCHANT_HIGH,
  117. MAPID_THIEF_HIGH,
  118. //Trans 2-1 Jobs
  119. MAPID_LORD_KNIGHT = JOBL_UPPER|MAPID_KNIGHT,
  120. MAPID_HIGH_WIZARD,
  121. MAPID_SNIPER,
  122. MAPID_HIGH_PRIEST,
  123. MAPID_WHITESMITH,
  124. MAPID_ASSASSIN_CROSS,
  125. //Trans 2-2 Jobs
  126. MAPID_PALADIN = JOBL_UPPER|MAPID_CRUSADER,
  127. MAPID_PROFESSOR,
  128. MAPID_CLOWNGYPSY,
  129. MAPID_CHAMPION,
  130. MAPID_CREATOR,
  131. MAPID_STALKER,
  132. //Baby Novice And Baby 1-1 Jobs
  133. MAPID_BABY = JOBL_BABY|MAPID_NOVICE,
  134. MAPID_BABY_SWORDMAN,
  135. MAPID_BABY_MAGE,
  136. MAPID_BABY_ARCHER,
  137. MAPID_BABY_ACOLYTE,
  138. MAPID_BABY_MERCHANT,
  139. MAPID_BABY_THIEF,
  140. MAPID_BABY_TAEKWON,
  141. MAPID_BABY_GUNSLINGER = JOBL_BABY|MAPID_GUNSLINGER,
  142. MAPID_BABY_NINJA,
  143. MAPID_BABY_SUMMONER = JOBL_BABY|MAPID_SUMMONER,
  144. //Baby 2-1 Jobs
  145. MAPID_SUPER_BABY = JOBL_BABY|MAPID_SUPER_NOVICE,
  146. MAPID_BABY_KNIGHT,
  147. MAPID_BABY_WIZARD,
  148. MAPID_BABY_HUNTER,
  149. MAPID_BABY_PRIEST,
  150. MAPID_BABY_BLACKSMITH,
  151. MAPID_BABY_ASSASSIN,
  152. MAPID_BABY_STAR_GLADIATOR,
  153. MAPID_BABY_REBELLION = JOBL_BABY|MAPID_REBELLION,
  154. MAPID_BABY_KAGEROUOBORO,
  155. //Baby 2-2 Jobs
  156. MAPID_BABY_CRUSADER = JOBL_BABY|MAPID_CRUSADER,
  157. MAPID_BABY_SAGE,
  158. MAPID_BABY_BARDDANCER,
  159. MAPID_BABY_MONK,
  160. MAPID_BABY_ALCHEMIST,
  161. MAPID_BABY_ROGUE,
  162. MAPID_BABY_SOUL_LINKER,
  163. //3-1 Jobs
  164. MAPID_SUPER_NOVICE_E = JOBL_THIRD|MAPID_SUPER_NOVICE,
  165. MAPID_RUNE_KNIGHT,
  166. MAPID_WARLOCK,
  167. MAPID_RANGER,
  168. MAPID_ARCH_BISHOP,
  169. MAPID_MECHANIC,
  170. MAPID_GUILLOTINE_CROSS,
  171. MAPID_STAR_EMPEROR,
  172. //3-2 Jobs
  173. MAPID_ROYAL_GUARD = JOBL_THIRD|MAPID_CRUSADER,
  174. MAPID_SORCERER,
  175. MAPID_MINSTRELWANDERER,
  176. MAPID_SURA,
  177. MAPID_GENETIC,
  178. MAPID_SHADOW_CHASER,
  179. MAPID_SOUL_REAPER,
  180. //Trans 3-1 Jobs
  181. MAPID_RUNE_KNIGHT_T = JOBL_THIRD|MAPID_LORD_KNIGHT,
  182. MAPID_WARLOCK_T,
  183. MAPID_RANGER_T,
  184. MAPID_ARCH_BISHOP_T,
  185. MAPID_MECHANIC_T,
  186. MAPID_GUILLOTINE_CROSS_T,
  187. //Trans 3-2 Jobs
  188. MAPID_ROYAL_GUARD_T = JOBL_THIRD|MAPID_PALADIN,
  189. MAPID_SORCERER_T,
  190. MAPID_MINSTRELWANDERER_T,
  191. MAPID_SURA_T,
  192. MAPID_GENETIC_T,
  193. MAPID_SHADOW_CHASER_T,
  194. //Baby 3-1 Jobs
  195. MAPID_SUPER_BABY_E = JOBL_THIRD|MAPID_SUPER_BABY,
  196. MAPID_BABY_RUNE_KNIGHT,
  197. MAPID_BABY_WARLOCK,
  198. MAPID_BABY_RANGER,
  199. MAPID_BABY_ARCH_BISHOP,
  200. MAPID_BABY_MECHANIC,
  201. MAPID_BABY_GUILLOTINE_CROSS,
  202. MAPID_BABY_STAR_EMPEROR,
  203. //Baby 3-2 Jobs
  204. MAPID_BABY_ROYAL_GUARD = JOBL_THIRD|MAPID_BABY_CRUSADER,
  205. MAPID_BABY_SORCERER,
  206. MAPID_BABY_MINSTRELWANDERER,
  207. MAPID_BABY_SURA,
  208. MAPID_BABY_GENETIC,
  209. MAPID_BABY_SHADOW_CHASER,
  210. MAPID_BABY_SOUL_REAPER,
  211. // Additional constants
  212. MAPID_ALL = UINT64_MAX
  213. };
  214. //Max size for inputs to Graffiti, Talkie Box and Vending text prompts
  215. #define MESSAGE_SIZE (79 + 1)
  216. // Max size for inputs to Graffiti, Talkie Box text prompts
  217. #if PACKETVER_MAIN_NUM >= 20190904 || PACKETVER_RE_NUM >= 20190904 || PACKETVER_ZERO_NUM >= 20190828
  218. #define TALKBOX_MESSAGE_SIZE 21
  219. #else
  220. #define TALKBOX_MESSAGE_SIZE (79 + 1)
  221. #endif
  222. //String length you can write in the 'talking box'
  223. #define CHATBOX_SIZE (70 + 1)
  224. //Chatroom-related string sizes
  225. #define CHATROOM_TITLE_SIZE (36 + 1)
  226. #define CHATROOM_PASS_SIZE (8 + 1)
  227. //Max allowed chat text length
  228. #define CHAT_SIZE_MAX (255 + 1)
  229. #define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000
  230. //This stackable implementation does not means a BL can be more than one type at a time, but it's
  231. //meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex]
  232. enum bl_type : uint16{
  233. BL_NUL = 0x000,
  234. BL_PC = 0x001,
  235. BL_MOB = 0x002,
  236. BL_PET = 0x004,
  237. BL_HOM = 0x008,
  238. BL_MER = 0x010,
  239. BL_ITEM = 0x020,
  240. BL_SKILL = 0x040,
  241. BL_NPC = 0x080,
  242. BL_CHAT = 0x100,
  243. BL_ELEM = 0x200,
  244. BL_ALL = 0xFFF,
  245. };
  246. /// For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
  247. #define BL_CHAR (BL_PC|BL_MOB|BL_HOM|BL_MER|BL_ELEM)
  248. /// NPC Subtype
  249. enum npc_subtype : uint8{
  250. NPCTYPE_WARP, /// Warp
  251. NPCTYPE_SHOP, /// Shop
  252. NPCTYPE_SCRIPT, /// Script
  253. NPCTYPE_CASHSHOP, /// Cashshop
  254. NPCTYPE_ITEMSHOP, /// Itemshop
  255. NPCTYPE_POINTSHOP, /// Pointshop
  256. NPCTYPE_TOMB, /// Monster tomb
  257. NPCTYPE_MARKETSHOP, /// Marketshop
  258. };
  259. enum e_race : int8{
  260. RC_NONE_ = -1, //don't give us bonus
  261. RC_FORMLESS = 0,
  262. RC_UNDEAD,
  263. RC_BRUTE,
  264. RC_PLANT,
  265. RC_INSECT,
  266. RC_FISH,
  267. RC_DEMON,
  268. RC_DEMIHUMAN,
  269. RC_ANGEL,
  270. RC_DRAGON,
  271. RC_PLAYER_HUMAN,
  272. RC_PLAYER_DORAM,
  273. RC_ALL,
  274. RC_MAX //auto upd enum for array size
  275. };
  276. enum e_race2 : uint8{
  277. RC2_NONE = 0,
  278. RC2_GOBLIN,
  279. RC2_KOBOLD,
  280. RC2_ORC,
  281. RC2_GOLEM,
  282. RC2_GUARDIAN, // Deprecated to CLASS_GUARDIAN
  283. RC2_NINJA,
  284. RC2_GVG,
  285. RC2_BATTLEFIELD, // Deprecated to CLASS_BATTLEFIELD
  286. RC2_TREASURE,
  287. RC2_BIOLAB,
  288. RC2_MANUK,
  289. RC2_SPLENDIDE,
  290. RC2_SCARABA,
  291. RC2_OGH_ATK_DEF,
  292. RC2_OGH_HIDDEN,
  293. RC2_BIO5_SWORDMAN_THIEF,
  294. RC2_BIO5_ACOLYTE_MERCHANT,
  295. RC2_BIO5_MAGE_ARCHER,
  296. RC2_BIO5_MVP,
  297. RC2_CLOCKTOWER,
  298. RC2_THANATOS,
  299. RC2_FACEWORM,
  300. RC2_HEARTHUNTER,
  301. RC2_ROCKRIDGE,
  302. RC2_WERNER_LAB,
  303. RC2_TEMPLE_DEMON,
  304. RC2_ILLUSION_VAMPIRE,
  305. RC2_MAX
  306. };
  307. /// Element list
  308. enum e_element : int8{
  309. ELE_NONE=-1,
  310. ELE_NEUTRAL=0,
  311. ELE_WATER,
  312. ELE_EARTH,
  313. ELE_FIRE,
  314. ELE_WIND,
  315. ELE_POISON,
  316. ELE_HOLY,
  317. ELE_DARK,
  318. ELE_GHOST,
  319. ELE_UNDEAD,
  320. ELE_ALL,
  321. ELE_MAX,
  322. ELE_WEAPON,
  323. ELE_ENDOWED,
  324. ELE_RANDOM,
  325. };
  326. static std::unordered_map<std::string, e_element> um_eleid2elename {
  327. { "Neutral", ELE_NEUTRAL },
  328. { "Water", ELE_WATER },
  329. { "Earth", ELE_EARTH },
  330. { "Fire", ELE_FIRE },
  331. { "Wind", ELE_WIND },
  332. { "Poison", ELE_POISON },
  333. { "Holy", ELE_HOLY },
  334. { "Dark", ELE_DARK },
  335. { "Ghost", ELE_GHOST },
  336. { "Undead", ELE_UNDEAD },
  337. };
  338. #define MAX_ELE_LEVEL 4 /// Maximum Element level
  339. /**
  340. * Types of spirit charms
  341. * NOTE: Code assumes that this matches the first entries in enum elements
  342. */
  343. enum spirit_charm_types {
  344. CHARM_TYPE_NONE = 0,
  345. CHARM_TYPE_WATER,
  346. CHARM_TYPE_LAND,
  347. CHARM_TYPE_FIRE,
  348. CHARM_TYPE_WIND
  349. };
  350. enum mob_ai {
  351. AI_NONE = 0,
  352. AI_ATTACK,
  353. AI_SPHERE,
  354. AI_FLORA,
  355. AI_ZANZOU,
  356. AI_LEGION,
  357. AI_FAW,
  358. AI_GUILD,
  359. AI_MAX
  360. };
  361. enum auto_trigger_flag {
  362. ATF_SELF = 0x01,
  363. ATF_TARGET = 0x02,
  364. ATF_SHORT = 0x04,
  365. ATF_LONG = 0x08,
  366. ATF_WEAPON = 0x10,
  367. ATF_MAGIC = 0x20,
  368. ATF_MISC = 0x40,
  369. };
  370. struct block_list {
  371. struct block_list *next,*prev;
  372. int id;
  373. int16 m,x,y;
  374. enum bl_type type;
  375. };
  376. // Mob List Held in memory for Dynamic Mobs [Wizputer]
  377. // Expanded to specify all mob-related spawn data by [Skotlex]
  378. struct spawn_data {
  379. short id; //ID, used because a mob can change it's class
  380. unsigned short m, x, y; //Spawn information (map, point, spawn-area around point)
  381. signed short xs, ys;
  382. unsigned short num; //Number of mobs using this structure
  383. unsigned short active;//Number of mobs that are already spawned (for mob_remove_damaged: no)
  384. unsigned int delay1, delay2; //Spawn delay (fixed base + random variance)
  385. unsigned int level;
  386. struct {
  387. unsigned int size : 2; //Holds if mob has to be tiny/large
  388. enum mob_ai ai; //Special ai for summoned monsters.
  389. unsigned int dynamic : 1; //Whether this data is indexed by a map's dynamic mob list
  390. unsigned int boss : 1; //0: Non-boss monster | 1: Boss monster
  391. } state;
  392. char name[NAME_LENGTH], eventname[EVENT_NAME_LENGTH]; //Name/event
  393. };
  394. struct flooritem_data {
  395. struct block_list bl;
  396. unsigned char subx,suby;
  397. int cleartimer;
  398. int first_get_charid,second_get_charid,third_get_charid;
  399. t_tick first_get_tick,second_get_tick,third_get_tick;
  400. struct item item;
  401. unsigned short mob_id; ///< ID of monster who dropped it. 0 for non-monster who dropped it.
  402. };
  403. enum _sp {
  404. SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7
  405. SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15
  406. SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23
  407. SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31
  408. SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39
  409. SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47
  410. SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55
  411. SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60
  412. SP_CARTINFO=99, // 99
  413. SP_KILLEDGID=118,
  414. SP_BASEJOB=119, // 100+19 - celest
  415. SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex]
  416. SP_KILLERRID=121,
  417. SP_KILLEDRID=122,
  418. SP_SITTING=123,
  419. SP_CHARMOVE=124,
  420. SP_CHARRENAME=125,
  421. SP_CHARFONT=126,
  422. SP_BANK_VAULT = 127,
  423. SP_ROULETTE_BRONZE = 128,
  424. SP_ROULETTE_SILVER = 129,
  425. SP_ROULETTE_GOLD = 130,
  426. SP_CASHPOINTS, SP_KAFRAPOINTS,
  427. SP_PCDIECOUNTER, SP_COOKMASTERY,
  428. SP_ACHIEVEMENT_LEVEL,
  429. // Mercenaries
  430. SP_MERCFLEE=165, SP_MERCKILLS=189, SP_MERCFAITH=190,
  431. // original 1000-
  432. SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002
  433. SP_CASTRATE, SP_MAXHPRATE, SP_MAXSPRATE, SP_SPRATE, // 1003-1006
  434. SP_ADDELE, SP_ADDRACE, SP_ADDSIZE, SP_SUBELE, SP_SUBRACE, // 1007-1011
  435. SP_ADDEFF, SP_RESEFF, // 1012-1013
  436. SP_BASE_ATK,SP_ASPD_RATE,SP_HP_RECOV_RATE,SP_SP_RECOV_RATE,SP_SPEED_RATE, // 1014-1018
  437. SP_CRITICAL_DEF,SP_NEAR_ATK_DEF,SP_LONG_ATK_DEF, // 1019-1021
  438. SP_DOUBLE_RATE, SP_DOUBLE_ADD_RATE, SP_SKILL_HEAL, SP_MATK_RATE, // 1022-1025
  439. SP_IGNORE_DEF_ELE,SP_IGNORE_DEF_RACE, // 1026-1027
  440. SP_ATK_RATE,SP_SPEED_ADDRATE,SP_SP_REGEN_RATE, // 1028-1030
  441. SP_MAGIC_ATK_DEF,SP_MISC_ATK_DEF, // 1031-1032
  442. SP_IGNORE_MDEF_ELE,SP_IGNORE_MDEF_RACE, // 1033-1034
  443. SP_MAGIC_ADDELE,SP_MAGIC_ADDRACE,SP_MAGIC_ADDSIZE, // 1035-1037
  444. SP_PERFECT_HIT_RATE,SP_PERFECT_HIT_ADD_RATE,SP_CRITICAL_RATE,SP_GET_ZENY_NUM,SP_ADD_GET_ZENY_NUM, // 1038-1042
  445. SP_ADD_DAMAGE_CLASS,SP_ADD_MAGIC_DAMAGE_CLASS,SP_ADD_DEF_MONSTER,SP_ADD_MDEF_MONSTER, // 1043-1046
  446. SP_ADD_MONSTER_DROP_ITEM,SP_DEF_RATIO_ATK_ELE,SP_DEF_RATIO_ATK_RACE,SP_UNBREAKABLE_GARMENT, // 1047-1050
  447. SP_HIT_RATE,SP_FLEE_RATE,SP_FLEE2_RATE,SP_DEF_RATE,SP_DEF2_RATE,SP_MDEF_RATE,SP_MDEF2_RATE, // 1051-1057
  448. SP_SPLASH_RANGE,SP_SPLASH_ADD_RANGE,SP_AUTOSPELL,SP_HP_DRAIN_RATE,SP_SP_DRAIN_RATE, // 1058-1062
  449. SP_SHORT_WEAPON_DAMAGE_RETURN,SP_LONG_WEAPON_DAMAGE_RETURN,SP_WEAPON_COMA_ELE,SP_WEAPON_COMA_RACE, // 1063-1066
  450. SP_ADDEFF2,SP_BREAK_WEAPON_RATE,SP_BREAK_ARMOR_RATE,SP_ADD_STEAL_RATE, // 1067-1070
  451. SP_MAGIC_DAMAGE_RETURN,SP_ALL_STATS=1073,SP_AGI_VIT,SP_AGI_DEX_STR,SP_PERFECT_HIDE, // 1071-1076
  452. SP_NO_KNOCKBACK,SP_CLASSCHANGE, // 1077-1078
  453. SP_HP_DRAIN_VALUE,SP_SP_DRAIN_VALUE, // 1079-1080
  454. SP_WEAPON_ATK,SP_WEAPON_DAMAGE_RATE, // 1081-1082
  455. SP_DELAYRATE,SP_HP_DRAIN_VALUE_RACE, SP_SP_DRAIN_VALUE_RACE, // 1083-1085
  456. SP_IGNORE_MDEF_RACE_RATE,SP_IGNORE_DEF_RACE_RATE,SP_SKILL_HEAL2,SP_ADDEFF_ONSKILL, //1086-1089
  457. SP_ADD_HEAL_RATE,SP_ADD_HEAL2_RATE, SP_EQUIP_ATK, //1090-1092
  458. SP_RESTART_FULL_RECOVER=2000,SP_NO_CASTCANCEL,SP_NO_SIZEFIX,SP_NO_MAGIC_DAMAGE,SP_NO_WEAPON_DAMAGE,SP_NO_GEMSTONE, // 2000-2005
  459. SP_NO_CASTCANCEL2,SP_NO_MISC_DAMAGE,SP_UNBREAKABLE_WEAPON,SP_UNBREAKABLE_ARMOR, SP_UNBREAKABLE_HELM, // 2006-2010
  460. SP_UNBREAKABLE_SHIELD, SP_LONG_ATK_RATE, // 2011-2012
  461. SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017
  462. SP_SKILL_ATK, SP_UNSTRIPABLE, SP_AUTOSPELL_ONSKILL, // 2018-2020
  463. SP_SP_GAIN_VALUE, SP_HP_REGEN_RATE, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025
  464. SP_SUBSIZE, SP_HP_DRAIN_VALUE_CLASS, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_CLASS, SP_EXP_ADDRACE, // 2026-2030
  465. SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033
  466. SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037
  467. SP_INTRAVISION, SP_ADD_MONSTER_DROP_ITEMGROUP, SP_SP_LOSS_RATE, // 2038-2040
  468. SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE, SP_MAGIC_SP_GAIN_VALUE, SP_MAGIC_HP_GAIN_VALUE, SP_ADD_MONSTER_ID_DROP_ITEM, //2041-2045
  469. SP_EMATK, SP_COMA_CLASS, SP_COMA_RACE, SP_SKILL_USE_SP_RATE, //2046-2049
  470. SP_SKILL_COOLDOWN,SP_SKILL_FIXEDCAST, SP_SKILL_VARIABLECAST, SP_FIXCASTRATE, SP_VARCASTRATE, //2050-2054
  471. SP_SKILL_USE_SP,SP_MAGIC_ATK_ELE, SP_ADD_FIXEDCAST, SP_ADD_VARIABLECAST, //2055-2058
  472. SP_SET_DEF_RACE,SP_SET_MDEF_RACE,SP_HP_VANISH_RATE, //2059-2061
  473. SP_IGNORE_DEF_CLASS, SP_DEF_RATIO_ATK_CLASS, SP_ADDCLASS, SP_SUBCLASS, SP_MAGIC_ADDCLASS, //2062-2066
  474. SP_WEAPON_COMA_CLASS, SP_IGNORE_MDEF_CLASS_RATE, SP_EXP_ADDCLASS, SP_ADD_CLASS_DROP_ITEM, //2067-2070
  475. SP_ADD_CLASS_DROP_ITEMGROUP, SP_ADDMAXWEIGHT, SP_ADD_ITEMGROUP_HEAL_RATE, // 2071-2073
  476. SP_HP_VANISH_RACE_RATE, SP_SP_VANISH_RACE_RATE, SP_ABSORB_DMG_MAXHP, SP_SUB_SKILL, SP_SUBDEF_ELE, // 2074-2078
  477. SP_STATE_NORECOVER_RACE, SP_CRITICAL_RANGEATK, SP_MAGIC_ADDRACE2, SP_IGNORE_MDEF_RACE2_RATE, // 2079-2082
  478. SP_WEAPON_ATK_RATE, SP_WEAPON_MATK_RATE, SP_DROP_ADDRACE, SP_DROP_ADDCLASS, SP_NO_MADO_FUEL, // 2083-2087
  479. SP_IGNORE_DEF_CLASS_RATE, SP_REGEN_PERCENT_HP, SP_REGEN_PERCENT_SP, SP_SKILL_DELAY, SP_NO_WALK_DELAY, //2088-2092
  480. SP_LONG_SP_GAIN_VALUE, SP_LONG_HP_GAIN_VALUE, SP_SHORT_ATK_RATE, SP_MAGIC_SUBSIZE, SP_CRIT_DEF_RATE, // 2093-2097
  481. SP_MAGIC_SUBDEF_ELE, SP_REDUCE_DAMAGE_RETURN, SP_ADD_ITEM_SPHEAL_RATE, SP_ADD_ITEMGROUP_SPHEAL_RATE, // 2098-2101
  482. };
  483. enum _look {
  484. LOOK_BASE,
  485. LOOK_HAIR,
  486. LOOK_WEAPON,
  487. LOOK_HEAD_BOTTOM,
  488. LOOK_HEAD_TOP,
  489. LOOK_HEAD_MID,
  490. LOOK_HAIR_COLOR,
  491. LOOK_CLOTHES_COLOR,
  492. LOOK_SHIELD,
  493. LOOK_SHOES,
  494. LOOK_BODY, //Purpose Unknown. Doesen't appear to do anything.
  495. LOOK_RESET_COSTUMES,//Makes all headgear sprites on player vanish when activated.
  496. LOOK_ROBE,
  497. // LOOK_FLOOR, // TODO : fix me!! offcial use this ?
  498. LOOK_BODY2
  499. };
  500. enum e_mapflag : int16 {
  501. MF_INVALID = -1,
  502. MF_MIN = 0,
  503. MF_NOMEMO = 0,
  504. MF_NOTELEPORT,
  505. MF_NOSAVE,
  506. MF_NOBRANCH,
  507. MF_NOPENALTY,
  508. MF_NOZENYPENALTY,
  509. MF_PVP,
  510. MF_PVP_NOPARTY,
  511. MF_PVP_NOGUILD,
  512. MF_GVG,
  513. MF_GVG_NOPARTY, //10
  514. MF_NOTRADE,
  515. MF_NOSKILL,
  516. MF_NOWARP,
  517. MF_PARTYLOCK,
  518. MF_NOICEWALL,
  519. MF_SNOW,
  520. MF_FOG,
  521. MF_SAKURA,
  522. MF_LEAVES,
  523. //MF_RAIN, //20 - No longer available, keeping here just in case it's back someday. [Ind]
  524. // 21 free
  525. MF_NOGO = 22,
  526. MF_CLOUDS,
  527. MF_CLOUDS2,
  528. MF_FIREWORKS,
  529. MF_GVG_CASTLE,
  530. MF_GVG_DUNGEON,
  531. MF_NIGHTENABLED,
  532. MF_NOBASEEXP,
  533. MF_NOJOBEXP, //30
  534. MF_NOMOBLOOT,
  535. MF_NOMVPLOOT,
  536. MF_NORETURN,
  537. MF_NOWARPTO,
  538. MF_PVP_NIGHTMAREDROP,
  539. MF_RESTRICTED,
  540. MF_NOCOMMAND,
  541. MF_NODROP,
  542. MF_JEXP,
  543. MF_BEXP, //40
  544. MF_NOVENDING,
  545. MF_LOADEVENT,
  546. MF_NOCHAT,
  547. MF_NOEXPPENALTY,
  548. MF_GUILDLOCK,
  549. MF_TOWN,
  550. MF_AUTOTRADE,
  551. MF_ALLOWKS,
  552. MF_MONSTER_NOTELEPORT,
  553. MF_PVP_NOCALCRANK, //50
  554. MF_BATTLEGROUND,
  555. MF_RESET,
  556. MF_NOMAPCHANNELAUTOJOIN,
  557. MF_NOUSECART,
  558. MF_NOITEMCONSUMPTION,
  559. MF_NOSUNMOONSTARMIRACLE,
  560. MF_NOMINEEFFECT,
  561. MF_NOLOCKON,
  562. MF_NOTOMB,
  563. MF_SKILL_DAMAGE, //60
  564. MF_NOCOSTUME,
  565. MF_GVG_TE_CASTLE,
  566. MF_GVG_TE,
  567. MF_HIDEMOBHPBAR,
  568. MF_NOLOOT,
  569. MF_NOEXP,
  570. MF_PRIVATEAIRSHIP_SOURCE,
  571. MF_PRIVATEAIRSHIP_DESTINATION,
  572. MF_SKILL_DURATION,
  573. MF_NOCASHSHOP,
  574. MF_NORODEX,
  575. MF_MAX
  576. };
  577. /// Enum of damage types
  578. enum e_skill_damage_type : uint8 {
  579. SKILLDMG_PC,
  580. SKILLDMG_MOB,
  581. SKILLDMG_BOSS,
  582. SKILLDMG_OTHER,
  583. SKILLDMG_MAX,
  584. SKILLDMG_CASTER, ///< Only used on getter for caster value
  585. };
  586. /// Struct for MF_SKILL_DAMAGE
  587. struct s_skill_damage {
  588. unsigned int map; ///< Maps (used for skill_damage_db.txt)
  589. uint16 caster; ///< Caster type
  590. int rate[SKILLDMG_MAX]; ///< Used for when all skills are adjusted
  591. };
  592. /// Struct of MF_SKILL_DURATION
  593. struct s_skill_duration {
  594. uint16 skill_id; ///< Skill ID
  595. uint16 per; ///< Rate
  596. };
  597. /// Enum for item drop type for MF_PVP_NIGHTMAREDROP
  598. enum e_nightmare_drop_type : uint8 {
  599. NMDT_INVENTORY = 0x1,
  600. NMDT_EQUIP = 0x2,
  601. NMDT_ALL = (NMDT_INVENTORY|NMDT_EQUIP)
  602. };
  603. /// Struct for MF_PVP_NIGHTMAREDROP
  604. struct s_drop_list {
  605. int drop_id;
  606. int drop_per;
  607. enum e_nightmare_drop_type drop_type;
  608. };
  609. /// Union for mapflag values
  610. union u_mapflag_args {
  611. struct point nosave;
  612. struct s_drop_list nightmaredrop;
  613. struct s_skill_damage skill_damage;
  614. struct s_skill_duration skill_duration;
  615. int flag_val;
  616. };
  617. // used by map_setcell()
  618. enum cell_t{
  619. CELL_WALKABLE,
  620. CELL_SHOOTABLE,
  621. CELL_WATER,
  622. CELL_NPC,
  623. CELL_BASILICA,
  624. CELL_LANDPROTECTOR,
  625. CELL_NOVENDING,
  626. CELL_NOCHAT,
  627. CELL_MAELSTROM,
  628. CELL_ICEWALL,
  629. };
  630. // used by map_getcell()
  631. enum cell_chk : uint8 {
  632. CELL_GETTYPE, // Retrieves a cell's 'gat' type
  633. CELL_CHKWALL, // Whether the cell is a wall (gat type 1)
  634. CELL_CHKWATER, // Whether the cell is water (gat type 3)
  635. CELL_CHKCLIFF, // Whether the cell is a cliff/gap (gat type 5)
  636. CELL_CHKPASS, // Whether the cell is passable (gat type not 1 and 5)
  637. CELL_CHKREACH, // Whether the cell is passable, but ignores the cell stacking limit
  638. CELL_CHKNOPASS, // Whether the cell is non-passable (gat types 1 and 5)
  639. CELL_CHKNOREACH, // Whether the cell is non-passable, but ignores the cell stacking limit
  640. CELL_CHKSTACK, // Whether the cell is full (reached cell stacking limit)
  641. CELL_CHKNPC, // Whether the cell has an OnTouch NPC
  642. CELL_CHKBASILICA, // Whether the cell has Basilica
  643. CELL_CHKLANDPROTECTOR, // Whether the cell has Land Protector
  644. CELL_CHKNOVENDING, // Whether the cell denies MC_VENDING skill
  645. CELL_CHKNOCHAT, // Whether the cell denies Player Chat Window
  646. CELL_CHKMAELSTROM, // Whether the cell has Maelstrom
  647. CELL_CHKICEWALL, // Whether the cell has Ice Wall
  648. };
  649. struct mapcell
  650. {
  651. // terrain flags
  652. unsigned char
  653. walkable : 1,
  654. shootable : 1,
  655. water : 1;
  656. // dynamic flags
  657. unsigned char
  658. npc : 1,
  659. basilica : 1,
  660. landprotector : 1,
  661. novending : 1,
  662. nochat : 1,
  663. maelstrom : 1,
  664. icewall : 1;
  665. #ifdef CELL_NOSTACK
  666. unsigned char cell_bl; //Holds amount of bls in this cell.
  667. #endif
  668. };
  669. struct iwall_data {
  670. char wall_name[50];
  671. short m, x, y, size;
  672. int8 dir;
  673. bool shootable;
  674. };
  675. struct map_data {
  676. char name[MAP_NAME_LENGTH];
  677. uint16 index; // The map index used by the mapindex* functions.
  678. struct mapcell* cell; // Holds the information of each map cell (NULL if the map is not on this map-server).
  679. struct block_list **block;
  680. struct block_list **block_mob;
  681. int16 m;
  682. int16 xs,ys; // map dimensions (in cells)
  683. int16 bxs,bys; // map dimensions (in blocks)
  684. int16 bgscore_lion, bgscore_eagle; // Battleground ScoreBoard
  685. int npc_num; // number total of npc on the map
  686. int npc_num_area; // number of npc with a trigger area on the map
  687. int npc_num_warp; // number of warp npc on the map
  688. int users;
  689. int users_pvp;
  690. int iwall_num; // Total of invisible walls in this map
  691. std::unordered_map<int16, int> flag;
  692. struct point save;
  693. std::vector<s_drop_list> drop_list;
  694. uint32 zone; // zone number (for item/skill restrictions)
  695. struct s_skill_damage damage_adjust; // Used for overall skill damage adjustment
  696. std::unordered_map<uint16, s_skill_damage> skill_damage; // Used for single skill damage adjustment
  697. std::unordered_map<uint16, int> skill_duration;
  698. struct npc_data *npc[MAX_NPC_PER_MAP];
  699. struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
  700. int mob_delete_timer; // Timer ID for map_removemobs_timer [Skotlex]
  701. // Instance Variables
  702. int instance_id;
  703. int instance_src_map;
  704. /* rAthena Local Chat */
  705. struct Channel *channel;
  706. /* ShowEvent Data Cache */
  707. std::vector<int> qi_npc;
  708. /* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */
  709. unsigned short hpmeter_visible;
  710. };
  711. /// Stores information about a remote map (for multi-mapserver setups).
  712. /// Beginning of data structure matches 'map_data', to allow typecasting.
  713. struct map_data_other_server {
  714. char name[MAP_NAME_LENGTH];
  715. unsigned short index; //Index is the map index used by the mapindex* functions.
  716. struct mapcell* cell; // If this is NULL, the map is not on this map-server
  717. uint32 ip;
  718. uint16 port;
  719. };
  720. int map_getcell(int16 m,int16 x,int16 y,cell_chk cellchk);
  721. int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk);
  722. void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag);
  723. void map_setgatcell(int16 m, int16 x, int16 y, int gat);
  724. extern struct map_data map[];
  725. extern int map_num;
  726. extern int autosave_interval;
  727. extern int minsave_interval;
  728. extern int16 save_settings;
  729. extern int night_flag; // 0=day, 1=night [Yor]
  730. extern int enable_spy; //Determines if @spy commands are active.
  731. extern uint32 start_status_points;
  732. // Agit Flags
  733. extern bool agit_flag;
  734. extern bool agit2_flag;
  735. extern bool agit3_flag;
  736. #define is_agit_start() (agit_flag || agit2_flag || agit3_flag)
  737. /**
  738. * Specifies maps where players may hit each other
  739. * @param mapdata: Map Data
  740. * @return True on success or false otherwise
  741. */
  742. inline bool mapdata_flag_vs(struct map_data *mapdata) {
  743. if (mapdata == nullptr)
  744. return false;
  745. if (mapdata->flag[MF_PVP] || mapdata->flag[MF_GVG_DUNGEON] || mapdata->flag[MF_GVG] || ((agit_flag || agit2_flag) && mapdata->flag[MF_GVG_CASTLE]) || mapdata->flag[MF_GVG_TE] || (agit3_flag && mapdata->flag[MF_GVG_TE_CASTLE]) || mapdata->flag[MF_BATTLEGROUND])
  746. return true;
  747. return false;
  748. }
  749. /**
  750. * Versus map: PVP, BG, GVG, GVG Dungeons, and GVG Castles (regardless of agit_flag status)
  751. * @param mapdata: Map Data
  752. * @return True on success or false otherwise
  753. */
  754. inline bool mapdata_flag_vs2(struct map_data *mapdata) {
  755. if (mapdata == nullptr)
  756. return false;
  757. if (mapdata->flag[MF_PVP] || mapdata->flag[MF_GVG_DUNGEON] || mapdata->flag[MF_GVG] || mapdata->flag[MF_GVG_CASTLE] || mapdata->flag[MF_GVG_TE] || mapdata->flag[MF_GVG_TE_CASTLE] || mapdata->flag[MF_BATTLEGROUND])
  758. return true;
  759. return false;
  760. }
  761. /**
  762. * Specifies maps that have special GvG/WoE restrictions
  763. * @param mapdata: Map Data
  764. * @return True on success or false otherwise
  765. */
  766. inline bool mapdata_flag_gvg(struct map_data *mapdata) {
  767. if (mapdata == nullptr)
  768. return false;
  769. if (mapdata->flag[MF_GVG] || ((agit_flag || agit2_flag) && mapdata->flag[MF_GVG_CASTLE]) || mapdata->flag[MF_GVG_TE] || (agit3_flag && mapdata->flag[MF_GVG_TE_CASTLE]))
  770. return true;
  771. return false;
  772. }
  773. /**
  774. * Specifies if the map is tagged as GvG/WoE (regardless of agit_flag status)
  775. * @param mapdata: Map Data
  776. * @return True on success or false otherwise
  777. */
  778. inline bool mapdata_flag_gvg2(struct map_data *mapdata) {
  779. if (mapdata == nullptr)
  780. return false;
  781. if (mapdata->flag[MF_GVG] || mapdata->flag[MF_GVG_TE] || mapdata->flag[MF_GVG_CASTLE] || mapdata->flag[MF_GVG_TE_CASTLE])
  782. return true;
  783. return false;
  784. }
  785. /**
  786. * No Kill Steal Protection
  787. * @param mapdata: Map Data
  788. * @return True on success or false otherwise
  789. */
  790. inline bool mapdata_flag_ks(struct map_data *mapdata) {
  791. if (mapdata == nullptr)
  792. return false;
  793. if (mapdata->flag[MF_TOWN] || mapdata->flag[MF_PVP] || mapdata->flag[MF_GVG] || mapdata->flag[MF_GVG_TE] || mapdata->flag[MF_BATTLEGROUND])
  794. return true;
  795. return false;
  796. }
  797. /**
  798. * WOE:TE Maps (regardless of agit_flag status)
  799. * @param mapdata: Map Data
  800. * @return True on success or false otherwise
  801. * @author Cydh
  802. */
  803. inline bool mapdata_flag_gvg2_te(struct map_data *mapdata) {
  804. if (mapdata == nullptr)
  805. return false;
  806. if (mapdata->flag[MF_GVG_TE] || mapdata->flag[MF_GVG_TE_CASTLE])
  807. return true;
  808. return false;
  809. }
  810. /**
  811. * Check if map is GVG maps exclusion for item, skill, and status restriction check (regardless of agit_flag status)
  812. * @param mapdata: Map Data
  813. * @return True on success or false otherwise
  814. * @author Cydh
  815. */
  816. inline bool mapdata_flag_gvg2_no_te(struct map_data *mapdata) {
  817. if (mapdata == nullptr)
  818. return false;
  819. if (mapdata->flag[MF_GVG] || mapdata->flag[MF_GVG_CASTLE])
  820. return true;
  821. return false;
  822. }
  823. /// Backwards compatibility
  824. inline bool map_flag_vs(int16 m) {
  825. if (m < 0)
  826. return false;
  827. struct map_data *mapdata = &map[m];
  828. return mapdata_flag_vs(mapdata);
  829. }
  830. inline bool map_flag_vs2(int16 m) {
  831. if (m < 0)
  832. return false;
  833. struct map_data *mapdata = &map[m];
  834. return mapdata_flag_vs2(mapdata);
  835. }
  836. inline bool map_flag_gvg(int16 m) {
  837. if (m < 0)
  838. return false;
  839. struct map_data *mapdata = &map[m];
  840. return mapdata_flag_gvg(mapdata);
  841. }
  842. inline bool map_flag_gvg2(int16 m) {
  843. if (m < 0)
  844. return false;
  845. struct map_data *mapdata = &map[m];
  846. return mapdata_flag_gvg2(mapdata);
  847. }
  848. inline bool map_flag_ks(int16 m) {
  849. if (m < 0)
  850. return false;
  851. struct map_data *mapdata = &map[m];
  852. return mapdata_flag_ks(mapdata);
  853. }
  854. inline bool map_flag_gvg2_te(int16 m) {
  855. if (m < 0)
  856. return false;
  857. struct map_data *mapdata = &map[m];
  858. return mapdata_flag_gvg2_te(mapdata);
  859. }
  860. inline bool map_flag_gvg2_no_te(int16 m) {
  861. if (m < 0)
  862. return false;
  863. struct map_data *mapdata = &map[m];
  864. return mapdata_flag_gvg2_no_te(mapdata);
  865. }
  866. extern char motd_txt[];
  867. extern char charhelp_txt[];
  868. extern char channel_conf[];
  869. extern char wisp_server_name[];
  870. struct s_map_default {
  871. char mapname[MAP_NAME_LENGTH];
  872. unsigned short x;
  873. unsigned short y;
  874. };
  875. extern struct s_map_default map_default;
  876. /// Type of 'save_settings'
  877. enum save_settings_type {
  878. CHARSAVE_NONE = 0x000, /// Never
  879. CHARSAVE_TRADE = 0x001, /// After trading
  880. CHARSAVE_VENDING = 0x002, /// After vending (open/transaction)
  881. CHARSAVE_STORAGE = 0x004, /// After closing storage/guild storage.
  882. CHARSAVE_PET = 0x008, /// After hatching/returning to egg a pet.
  883. CHARSAVE_MAIL = 0x010, /// After successfully sending a mail with attachment
  884. CHARSAVE_AUCTION = 0x020, /// After successfully submitting an item for auction
  885. CHARSAVE_QUEST = 0x040, /// After successfully get/delete/complete a quest
  886. CHARSAVE_BANK = 0x080, /// After every bank transaction (deposit/withdraw)
  887. CHARSAVE_ATTENDANCE = 0x100, /// After every attendence reward
  888. CHARSAVE_ALL = 0xFFF, /// Always
  889. };
  890. // users
  891. void map_setusers(int);
  892. int map_getusers(void);
  893. int map_usercount(void);
  894. // blocklist lock
  895. int map_freeblock(struct block_list *bl);
  896. int map_freeblock_lock(void);
  897. int map_freeblock_unlock(void);
  898. // blocklist manipulation
  899. int map_addblock(struct block_list* bl);
  900. int map_delblock(struct block_list* bl);
  901. int map_moveblock(struct block_list *, int, int, t_tick);
  902. int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
  903. int map_foreachinallrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
  904. int map_foreachinshootrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
  905. int map_foreachinarea(int(*func)(struct block_list*, va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...);
  906. int map_foreachinallarea(int(*func)(struct block_list*, va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...);
  907. int map_foreachinshootarea(int(*func)(struct block_list*, va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...);
  908. int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int count, int type, ...);
  909. int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, ...);
  910. int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, ...);
  911. int map_foreachincell(int (*func)(struct block_list*,va_list), int16 m, int16 x, int16 y, int type, ...);
  912. int map_foreachinpath(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, ...);
  913. int map_foreachindir(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int offset, int type, ...);
  914. int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type, ...);
  915. //blocklist nb in one cell
  916. int map_count_oncell(int16 m,int16 x,int16 y,int type,int flag);
  917. struct skill_unit *map_find_skill_unit_oncell(struct block_list *,int16 x,int16 y,uint16 skill_id,struct skill_unit *, int flag);
  918. // search and creation
  919. int map_get_new_object_id(void);
  920. int map_search_freecell(struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag);
  921. bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag);
  922. //
  923. int map_quit(struct map_session_data *);
  924. // npc
  925. bool map_addnpc(int16 m,struct npc_data *);
  926. // map item
  927. TIMER_FUNC(map_clearflooritem_timer);
  928. TIMER_FUNC(map_removemobs_timer);
  929. void map_clearflooritem(struct block_list* bl);
  930. int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id, bool canShowEffect = false);
  931. // instances
  932. int map_addinstancemap(int src_m, int instance_id);
  933. int map_delinstancemap(int m);
  934. void map_data_copyall(void);
  935. void map_data_copy(struct map_data *dst_map, struct map_data *src_map);
  936. // player to map session
  937. void map_addnickdb(int charid, const char* nick);
  938. void map_delnickdb(int charid, const char* nick);
  939. void map_reqnickdb(struct map_session_data* sd,int charid);
  940. const char* map_charid2nick(int charid);
  941. struct map_session_data* map_charid2sd(int charid);
  942. struct map_session_data * map_id2sd(int id);
  943. struct mob_data * map_id2md(int id);
  944. struct npc_data * map_id2nd(int id);
  945. struct homun_data* map_id2hd(int id);
  946. struct mercenary_data* map_id2mc(int id);
  947. struct pet_data* map_id2pd(int id);
  948. struct elemental_data* map_id2ed(int id);
  949. struct chat_data* map_id2cd(int id);
  950. struct block_list * map_id2bl(int id);
  951. bool map_blid_exists( int id );
  952. #define map_id2index(id) map[(id)].index
  953. const char* map_mapid2mapname(int m);
  954. int16 map_mapindex2mapid(unsigned short mapindex);
  955. int16 map_mapname2mapid(const char* name);
  956. int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port);
  957. int map_setipport(unsigned short map, uint32 ip, uint16 port);
  958. int map_eraseipport(unsigned short map, uint32 ip, uint16 port);
  959. int map_eraseallipport(void);
  960. void map_addiddb(struct block_list *);
  961. void map_deliddb(struct block_list *bl);
  962. void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...);
  963. void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...);
  964. void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...);
  965. void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...);
  966. void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...);
  967. struct map_session_data * map_nick2sd(const char* nick, bool allow_partial);
  968. struct mob_data * map_getmob_boss(int16 m);
  969. struct mob_data * map_id2boss(int id);
  970. // reload config file looking only for npcs
  971. void map_reloadnpc(bool clear);
  972. void map_remove_questinfo(int m, struct npc_data *nd);
  973. /// Bitfield of flags for the iterator.
  974. enum e_mapitflags
  975. {
  976. MAPIT_NORMAL = 0,
  977. // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold auth'ed, active players.
  978. };
  979. struct s_mapiterator;
  980. struct s_mapiterator* mapit_alloc(enum e_mapitflags flags, enum bl_type types);
  981. void mapit_free(struct s_mapiterator* mapit);
  982. struct block_list* mapit_first(struct s_mapiterator* mapit);
  983. struct block_list* mapit_last(struct s_mapiterator* mapit);
  984. struct block_list* mapit_next(struct s_mapiterator* mapit);
  985. struct block_list* mapit_prev(struct s_mapiterator* mapit);
  986. bool mapit_exists(struct s_mapiterator* mapit);
  987. #define mapit_getallusers() mapit_alloc(MAPIT_NORMAL,BL_PC)
  988. #define mapit_geteachpc() mapit_alloc(MAPIT_NORMAL,BL_PC)
  989. #define mapit_geteachmob() mapit_alloc(MAPIT_NORMAL,BL_MOB)
  990. #define mapit_geteachnpc() mapit_alloc(MAPIT_NORMAL,BL_NPC)
  991. #define mapit_geteachiddb() mapit_alloc(MAPIT_NORMAL,BL_ALL)
  992. int map_check_dir(int s_dir,int t_dir);
  993. uint8 map_calc_dir(struct block_list *src,int16 x,int16 y);
  994. uint8 map_calc_dir_xy(int16 srcx, int16 srcy, int16 x, int16 y, uint8 srcdir);
  995. int map_random_dir(struct block_list *bl, int16 *x, int16 *y); // [Skotlex]
  996. int cleanup_sub(struct block_list *bl, va_list ap);
  997. int map_delmap(char* mapname);
  998. void map_flags_init(void);
  999. bool map_iwall_exist(const char* wall_name);
  1000. bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable, const char* wall_name);
  1001. void map_iwall_get(struct map_session_data *sd);
  1002. bool map_iwall_remove(const char *wall_name);
  1003. int map_addmobtolist(unsigned short m, struct spawn_data *spawn); // [Wizputer]
  1004. void map_spawnmobs(int16 m); // [Wizputer]
  1005. void map_removemobs(int16 m); // [Wizputer]
  1006. void map_addmap2db(struct map_data *m);
  1007. void map_removemapdb(struct map_data *m);
  1008. void map_skill_damage_add(struct map_data *m, uint16 skill_id, union u_mapflag_args *args);
  1009. void map_skill_duration_add(struct map_data *mapd, uint16 skill_id, uint16 per);
  1010. enum e_mapflag map_getmapflag_by_name(char* name);
  1011. bool map_getmapflag_name(enum e_mapflag mapflag, char* output);
  1012. int map_getmapflag_sub(int16 m, enum e_mapflag mapflag, union u_mapflag_args *args);
  1013. bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_mapflag_args *args);
  1014. #define map_getmapflag(m, mapflag) map_getmapflag_sub(m, mapflag, NULL)
  1015. #define map_setmapflag(m, mapflag, status) map_setmapflag_sub(m, mapflag, status, NULL)
  1016. #define CHK_ELEMENT(ele) ((ele) > ELE_NONE && (ele) < ELE_MAX) /// Check valid Element
  1017. #define CHK_ELEMENT_LEVEL(lv) ((lv) >= 1 && (lv) <= MAX_ELE_LEVEL) /// Check valid element level
  1018. #define CHK_RACE(race) ((race) > RC_NONE_ && (race) < RC_MAX) /// Check valid Race
  1019. #define CHK_RACE2(race2) ((race2) >= RC2_NONE && (race2) < RC2_MAX) /// Check valid Race2
  1020. #define CHK_CLASS(class_) ((class_) > CLASS_NONE && (class_) < CLASS_MAX) /// Check valid Class
  1021. //Other languages supported
  1022. extern const char*MSG_CONF_NAME_RUS;
  1023. extern const char*MSG_CONF_NAME_SPN;
  1024. extern const char*MSG_CONF_NAME_GRM;
  1025. extern const char*MSG_CONF_NAME_CHN;
  1026. extern const char*MSG_CONF_NAME_MAL;
  1027. extern const char*MSG_CONF_NAME_IDN;
  1028. extern const char*MSG_CONF_NAME_FRN;
  1029. extern const char*MSG_CONF_NAME_POR;
  1030. extern const char*MSG_CONF_NAME_THA;
  1031. //Useful typedefs from jA [Skotlex]
  1032. typedef struct map_session_data TBL_PC;
  1033. typedef struct npc_data TBL_NPC;
  1034. typedef struct mob_data TBL_MOB;
  1035. typedef struct flooritem_data TBL_ITEM;
  1036. typedef struct chat_data TBL_CHAT;
  1037. typedef struct skill_unit TBL_SKILL;
  1038. typedef struct pet_data TBL_PET;
  1039. typedef struct homun_data TBL_HOM;
  1040. typedef struct mercenary_data TBL_MER;
  1041. typedef struct elemental_data TBL_ELEM;
  1042. #define BL_CAST(type_, bl) \
  1043. ( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) )
  1044. #include "../common/sql.hpp"
  1045. extern int db_use_sqldbs;
  1046. extern Sql* mmysql_handle;
  1047. extern Sql* qsmysql_handle;
  1048. extern Sql* logmysql_handle;
  1049. extern char buyingstores_table[32];
  1050. extern char buyingstore_items_table[32];
  1051. extern char item_table[32];
  1052. extern char item2_table[32];
  1053. extern char mob_table[32];
  1054. extern char mob2_table[32];
  1055. extern char mob_skill_table[32];
  1056. extern char mob_skill2_table[32];
  1057. extern char vendings_table[32];
  1058. extern char vending_items_table[32];
  1059. extern char market_table[32];
  1060. extern char roulette_table[32];
  1061. extern char guild_storage_log_table[32];
  1062. void do_shutdown(void);
  1063. #endif /* MAP_HPP */