map.hpp 36 KB

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