map.hpp 41 KB

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