map.hpp 36 KB

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