csv2yaml.cpp 118 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <fstream>
  4. #include <functional>
  5. #include <iostream>
  6. #include <locale>
  7. #include <map>
  8. #include <unordered_map>
  9. #include <vector>
  10. #ifdef WIN32
  11. #include <conio.h>
  12. #else
  13. #include <termios.h>
  14. #include <unistd.h>
  15. #include <stdio.h>
  16. #endif
  17. #include <yaml-cpp/yaml.h>
  18. #include "../common/cbasetypes.hpp"
  19. #include "../common/core.hpp"
  20. #include "../common/malloc.hpp"
  21. #include "../common/mmo.hpp"
  22. #include "../common/nullpo.hpp"
  23. #include "../common/showmsg.hpp"
  24. #include "../common/strlib.hpp"
  25. #include "../common/utilities.hpp"
  26. #include "../common/utils.hpp"
  27. #ifdef WIN32
  28. #include "../common/winapi.hpp"
  29. #endif
  30. // Only for constants - do not use functions of it or linking will fail
  31. #include "../map/achievement.hpp"
  32. #include "../map/battle.hpp"
  33. #include "../map/battleground.hpp"
  34. #include "../map/channel.hpp"
  35. #include "../map/chat.hpp"
  36. #include "../map/date.hpp"
  37. #include "../map/instance.hpp"
  38. #include "../map/mercenary.hpp"
  39. #include "../map/mob.hpp"
  40. #include "../map/npc.hpp"
  41. #include "../map/pc.hpp"
  42. #include "../map/pet.hpp"
  43. #include "../map/quest.hpp"
  44. #include "../map/script.hpp"
  45. #include "../map/skill.hpp"
  46. #include "../map/storage.hpp"
  47. using namespace rathena;
  48. #define MAX_MAP_PER_INSTANCE 255
  49. #ifndef WIN32
  50. int getch( void ){
  51. struct termios oldattr, newattr;
  52. int ch;
  53. tcgetattr( STDIN_FILENO, &oldattr );
  54. newattr = oldattr;
  55. newattr.c_lflag &= ~( ICANON | ECHO );
  56. tcsetattr( STDIN_FILENO, TCSANOW, &newattr );
  57. ch = getchar();
  58. tcsetattr( STDIN_FILENO, TCSANOW, &oldattr );
  59. return ch;
  60. }
  61. #endif
  62. // Required constant and structure definitions
  63. #define MAX_GUILD_SKILL_REQUIRE 5
  64. #define MAX_SKILL_ITEM_REQUIRE 10
  65. #define MAX_SKILL_STATUS_REQUIRE 3
  66. #define MAX_SKILL_EQUIP_REQUIRE 10
  67. #define MAX_QUEST_DROPS 3
  68. struct s_skill_unit_csv : s_skill_db {
  69. std::string target_str;
  70. int unit_flag_csv;
  71. };
  72. std::unordered_map<uint16, s_skill_require> skill_require;
  73. std::unordered_map<uint16, s_skill_db> skill_cast;
  74. std::unordered_map<uint16, s_skill_db> skill_castnodex;
  75. std::unordered_map<uint16, s_skill_unit_csv> skill_unit;
  76. std::unordered_map<uint16, s_skill_copyable> skill_copyable;
  77. std::unordered_map<uint16, s_skill_db> skill_nearnpc;
  78. struct s_item_flag_csv2yaml {
  79. bool buyingstore, dead_branch, group, guid, broadcast, bindOnEquip, delay_consume;
  80. e_item_drop_effect dropEffect;
  81. };
  82. struct s_item_delay_csv2yaml {
  83. uint32 delay;
  84. std::string sc;
  85. };
  86. struct s_item_stack_csv2yaml {
  87. uint16 amount;
  88. bool inventory, cart, storage, guild_storage;
  89. };
  90. struct s_item_nouse_csv2yaml {
  91. uint16 override;
  92. bool sitting;
  93. };
  94. struct s_item_trade_csv2yaml {
  95. uint16 override;
  96. bool drop, trade, trade_partner, sell, cart, storage, guild_storage, mail, auction;
  97. };
  98. std::unordered_map<t_itemid, t_itemid> item_avail;
  99. std::unordered_map<t_itemid, bool> item_buyingstore;
  100. std::unordered_map<t_itemid, s_item_flag_csv2yaml> item_flag;
  101. std::unordered_map<t_itemid, s_item_delay_csv2yaml> item_delay;
  102. std::unordered_map<t_itemid, s_item_stack_csv2yaml> item_stack;
  103. std::unordered_map<t_itemid, s_item_nouse_csv2yaml> item_nouse;
  104. std::unordered_map<t_itemid, s_item_trade_csv2yaml> item_trade;
  105. struct s_random_opt_group_csv : s_random_opt_group {
  106. std::vector<uint16> rate;
  107. };
  108. std::unordered_map<uint16, std::string> rand_opt_db;
  109. std::unordered_map<uint16, s_random_opt_group_csv> rand_opt_group;
  110. static std::map<std::string, int> um_mapid2jobname {
  111. { "Novice", JOB_NOVICE }, // Novice and Super Novice share the same value
  112. { "SuperNovice", JOB_NOVICE },
  113. { "Swordman", JOB_SWORDMAN },
  114. { "Mage", JOB_MAGE },
  115. { "Archer", JOB_ARCHER },
  116. { "Acolyte", JOB_ACOLYTE },
  117. { "Merchant", JOB_MERCHANT },
  118. { "Thief", JOB_THIEF },
  119. { "Knight", JOB_KNIGHT },
  120. { "Priest", JOB_PRIEST },
  121. { "Wizard", JOB_WIZARD },
  122. { "Blacksmith", JOB_BLACKSMITH },
  123. { "Hunter", JOB_HUNTER },
  124. { "Assassin", JOB_ASSASSIN },
  125. { "Crusader", JOB_CRUSADER },
  126. { "Monk", JOB_MONK },
  127. { "Sage", JOB_SAGE },
  128. { "Rogue", JOB_ROGUE },
  129. { "Alchemist", JOB_ALCHEMIST },
  130. { "BardDancer", JOB_BARD }, // Bard and Dancer share the same value
  131. { "BardDancer", JOB_DANCER },
  132. { "Gunslinger", JOB_GUNSLINGER },
  133. { "Ninja", JOB_NINJA },
  134. { "Taekwon", 21 },
  135. { "StarGladiator", 22 },
  136. { "SoulLinker", 23 },
  137. // { "Gangsi", 26 },
  138. // { "DeathKnight", 27 },
  139. // { "DarkCollector", 28 },
  140. #ifdef RENEWAL
  141. { "KagerouOboro", 29 }, // Kagerou and Oboro share the same value
  142. { "Rebellion", 30 },
  143. { "Summoner", 31 },
  144. #endif
  145. };
  146. static std::unordered_map<std::string, equip_pos> um_equipnames {
  147. { "Head_Low", EQP_HEAD_LOW },
  148. { "Head_Mid", EQP_HEAD_MID },
  149. { "Head_Top", EQP_HEAD_TOP },
  150. { "Right_Hand", EQP_HAND_R },
  151. { "Left_Hand", EQP_HAND_L },
  152. { "Armor", EQP_ARMOR },
  153. { "Shoes", EQP_SHOES },
  154. { "Garment", EQP_GARMENT },
  155. { "Right_Accessory", EQP_ACC_R },
  156. { "Left_Accessory", EQP_ACC_L },
  157. { "Costume_Head_Top", EQP_COSTUME_HEAD_TOP },
  158. { "Costume_Head_Mid", EQP_COSTUME_HEAD_MID },
  159. { "Costume_Head_Low", EQP_COSTUME_HEAD_LOW },
  160. { "Costume_Garment", EQP_COSTUME_GARMENT },
  161. { "Ammo", EQP_AMMO },
  162. { "Shadow_Armor", EQP_SHADOW_ARMOR },
  163. { "Shadow_Weapon", EQP_SHADOW_WEAPON },
  164. { "Shadow_Shield", EQP_SHADOW_SHIELD },
  165. { "Shadow_Shoes", EQP_SHADOW_SHOES },
  166. { "Shadow_Right_Accessory", EQP_SHADOW_ACC_R },
  167. { "Shadow_Left_Accessory", EQP_SHADOW_ACC_L },
  168. };
  169. // Forward declaration of conversion functions
  170. static bool guild_read_guildskill_tree_db( char* split[], int columns, int current );
  171. static bool pet_read_db( const char* file );
  172. static bool skill_parse_row_magicmushroomdb(char *split[], int column, int current);
  173. static bool skill_parse_row_abradb(char* split[], int columns, int current);
  174. static bool skill_parse_row_spellbookdb(char* split[], int columns, int current);
  175. static bool mob_readdb_mobavail(char *str[], int columns, int current);
  176. static bool skill_parse_row_requiredb(char* split[], int columns, int current);
  177. static bool skill_parse_row_castdb(char* split[], int columns, int current);
  178. static bool skill_parse_row_castnodexdb(char* split[], int columns, int current);
  179. static bool skill_parse_row_unitdb(char* split[], int columns, int current);
  180. static bool skill_parse_row_copyabledb(char* split[], int columns, int current);
  181. static bool skill_parse_row_nonearnpcrangedb(char* split[], int columns, int current);
  182. static bool skill_parse_row_skilldb(char* split[], int columns, int current);
  183. static bool quest_read_db(char *split[], int columns, int current);
  184. static bool instance_readdb_sub(char* str[], int columns, int current);
  185. static bool itemdb_read_itemavail(char *str[], int columns, int current);
  186. static bool itemdb_read_buyingstore(char* fields[], int columns, int current);
  187. static bool itemdb_read_flag(char* fields[], int columns, int current);
  188. static bool itemdb_read_itemdelay(char* str[], int columns, int current);
  189. static bool itemdb_read_stack(char* fields[], int columns, int current);
  190. static bool itemdb_read_nouse(char* fields[], int columns, int current);
  191. static bool itemdb_read_itemtrade(char* fields[], int columns, int current);
  192. static bool itemdb_read_db(const char *file);
  193. static bool itemdb_read_randomopt(const char* file);
  194. static bool itemdb_read_randomopt_group(char *str[], int columns, int current);
  195. static bool itemdb_randomopt_group_yaml(void);
  196. // Constants for conversion
  197. std::unordered_map<t_itemid, std::string> aegis_itemnames;
  198. std::unordered_map<t_itemid, t_itemid> aegis_itemviewid;
  199. std::unordered_map<uint16, std::string> aegis_mobnames;
  200. std::unordered_map<uint16, std::string> aegis_skillnames;
  201. std::unordered_map<const char*, int64> constants;
  202. // Forward declaration of constant loading functions
  203. static bool parse_item_constants_txt( const char* path );
  204. static bool parse_mob_constants( char* split[], int columns, int current );
  205. static bool parse_skill_constants_txt( char* split[], int columns, int current );
  206. static bool parse_skill_constants_yml(std::string path, std::string filename);
  207. static void init_random_option_constants();
  208. bool fileExists( const std::string& path );
  209. bool askConfirmation( const char* fmt, ... );
  210. // Skill database data to memory
  211. static void skill_txt_data(const std::string& modePath, const std::string& fixedPath) {
  212. skill_require.clear();
  213. skill_cast.clear();
  214. skill_castnodex.clear();
  215. skill_unit.clear();
  216. skill_copyable.clear();
  217. skill_nearnpc.clear();
  218. if (fileExists(modePath + "/skill_require_db.txt"))
  219. sv_readdb(modePath.c_str(), "skill_require_db.txt", ',', 34, 34, -1, skill_parse_row_requiredb, false);
  220. if (fileExists(modePath + "/skill_cast_db.txt"))
  221. sv_readdb(modePath.c_str(), "skill_cast_db.txt", ',', 7, 8, -1, skill_parse_row_castdb, false);
  222. if (fileExists(modePath + "/skill_castnodex_db.txt"))
  223. sv_readdb(modePath.c_str(), "skill_castnodex_db.txt", ',', 2, 3, -1, skill_parse_row_castnodexdb, false);
  224. if (fileExists(modePath + "/skill_unit_db.txt"))
  225. sv_readdb(modePath.c_str(), "skill_unit_db.txt", ',', 8, 8, -1, skill_parse_row_unitdb, false);
  226. if (fileExists(fixedPath + "/skill_copyable_db.txt"))
  227. sv_readdb(fixedPath.c_str(), "skill_copyable_db.txt", ',', 2, 4, -1, skill_parse_row_copyabledb, false);
  228. if (fileExists(fixedPath + "/skill_nonearnpc_db.txt"))
  229. sv_readdb(fixedPath.c_str(), "skill_nonearnpc_db.txt", ',', 2, 3, -1, skill_parse_row_nonearnpcrangedb, false);
  230. }
  231. // Item database data to memory
  232. static void item_txt_data(const std::string& modePath, const std::string& fixedPath) {
  233. item_avail.clear();
  234. item_buyingstore.clear();
  235. item_flag.clear();
  236. item_delay.clear();
  237. item_stack.clear();
  238. item_nouse.clear();
  239. item_trade.clear();
  240. if (fileExists(fixedPath + "/item_avail.txt"))
  241. sv_readdb(fixedPath.c_str(), "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail, false);
  242. if (fileExists(modePath + "/item_buyingstore.txt"))
  243. sv_readdb(modePath.c_str(), "item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore, false);
  244. if (fileExists(modePath + "/item_flag.txt"))
  245. sv_readdb(modePath.c_str(), "item_flag.txt", ',', 2, 2, -1, &itemdb_read_flag, false);
  246. if (fileExists(modePath + "/item_delay.txt"))
  247. sv_readdb(modePath.c_str(), "item_delay.txt", ',', 2, 3, -1, &itemdb_read_itemdelay, false);
  248. if (fileExists(modePath + "/item_stack.txt"))
  249. sv_readdb(modePath.c_str(), "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack, false);
  250. if (fileExists(fixedPath + "/item_nouse.txt"))
  251. sv_readdb(fixedPath.c_str(), "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse, false);
  252. if (fileExists(modePath + "/item_trade.txt"))
  253. sv_readdb(modePath.c_str(), "item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade, false);
  254. }
  255. YAML::Emitter body;
  256. // Implement the function instead of including the original version by linking
  257. void script_set_constant_( const char* name, int64 value, const char* constant_name, bool isparameter, bool deprecated ){
  258. constants[name] = value;
  259. }
  260. const char* constant_lookup( int32 value, const char* prefix ){
  261. if (prefix == nullptr)
  262. return nullptr;
  263. for( auto const& pair : constants ){
  264. // Same prefix group and same value
  265. if( strncasecmp( pair.first, prefix, strlen( prefix ) ) == 0 && pair.second == value ){
  266. return pair.first;
  267. }
  268. }
  269. return nullptr;
  270. }
  271. int64 constant_lookup_int(const char* constant) {
  272. if (constant == nullptr)
  273. return -100;
  274. for (auto const &pair : constants) {
  275. if (strlen(pair.first) == strlen(constant) && strncasecmp(pair.first, constant, strlen(constant)) == 0) {
  276. return pair.second;
  277. }
  278. }
  279. return -100;
  280. }
  281. void copyFileIfExists( std::ofstream& file,const std::string& name, bool newLine ){
  282. std::string path = "doc/yaml/db/" + name + ".yml";
  283. if( fileExists( path ) ){
  284. std::ifstream source( path, std::ios::binary );
  285. std::istreambuf_iterator<char> begin_source( source );
  286. std::istreambuf_iterator<char> end_source;
  287. std::ostreambuf_iterator<char> begin_dest( file );
  288. copy( begin_source, end_source, begin_dest );
  289. source.close();
  290. if( newLine ){
  291. file << "\n";
  292. }
  293. }
  294. }
  295. void prepareHeader(std::ofstream &file, const std::string& type, uint32 version, const std::string& name) {
  296. copyFileIfExists( file, "license", false );
  297. copyFileIfExists( file, name, true );
  298. YAML::Emitter header(file);
  299. header << YAML::BeginMap;
  300. header << YAML::Key << "Header";
  301. header << YAML::BeginMap;
  302. header << YAML::Key << "Type" << YAML::Value << type;
  303. header << YAML::Key << "Version" << YAML::Value << version;
  304. header << YAML::EndMap;
  305. header << YAML::EndMap;
  306. file << "\n";
  307. file << "\n";
  308. }
  309. void prepareBody(void) {
  310. body << YAML::BeginMap;
  311. body << YAML::Key << "Body";
  312. body << YAML::BeginSeq;
  313. }
  314. void finalizeBody(void) {
  315. body << YAML::EndSeq;
  316. body << YAML::EndMap;
  317. }
  318. template<typename Func>
  319. bool process( const std::string& type, uint32 version, const std::vector<std::string>& paths, const std::string& name, Func lambda, const std::string& rename = "" ){
  320. for( const std::string& path : paths ){
  321. const std::string name_ext = name + ".txt";
  322. const std::string from = path + "/" + name_ext;
  323. const std::string to = path + "/" + (rename.size() > 0 ? rename : name) + ".yml";
  324. if( fileExists( from ) ){
  325. if( !askConfirmation( "Found the file \"%s\", which requires migration to yml.\nDo you want to convert it now? (Y/N)\n", from.c_str() ) ){
  326. continue;
  327. }
  328. if (fileExists(to)) {
  329. if (!askConfirmation("The file \"%s\" already exists.\nDo you want to replace it? (Y/N)\n", to.c_str())) {
  330. continue;
  331. }
  332. }
  333. std::ofstream out;
  334. body.~Emitter();
  335. new (&body) YAML::Emitter();
  336. out.open(to);
  337. if (!out.is_open()) {
  338. ShowError("Can not open file \"%s\" for writing.\n", to.c_str());
  339. return false;
  340. }
  341. prepareHeader(out, type, version, (rename.size() > 0 ? rename : name));
  342. prepareBody();
  343. if( !lambda( path, name_ext ) ){
  344. out.close();
  345. return false;
  346. }
  347. finalizeBody();
  348. out << body.c_str();
  349. // Make sure there is an empty line at the end of the file for git
  350. out << "\n";
  351. out.close();
  352. // TODO: do you want to delete?
  353. }
  354. }
  355. return true;
  356. }
  357. int do_init( int argc, char** argv ){
  358. const std::string path_db = std::string( db_path );
  359. const std::string path_db_mode = path_db + "/" + DBPATH;
  360. const std::string path_db_import = path_db + "/" + DBIMPORT + "/";
  361. // Loads required conversion constants
  362. if (fileExists(item_db.getDefaultLocation())) {
  363. item_db.load();
  364. } else {
  365. parse_item_constants_txt( ( path_db_mode + "item_db.txt" ).c_str() );
  366. parse_item_constants_txt( ( path_db_import + "item_db.txt" ).c_str() );
  367. }
  368. sv_readdb( path_db_mode.c_str(), "mob_db.txt", ',', 31 + 2 * MAX_MVP_DROP + 2 * MAX_MOB_DROP, 31 + 2 * MAX_MVP_DROP + 2 * MAX_MOB_DROP, -1, &parse_mob_constants, false );
  369. sv_readdb( path_db_import.c_str(), "mob_db.txt", ',', 31 + 2 * MAX_MVP_DROP + 2 * MAX_MOB_DROP, 31 + 2 * MAX_MVP_DROP + 2 * MAX_MOB_DROP, -1, &parse_mob_constants, false );
  370. if (fileExists(path_db + "/" + "skill_db.yml")) {
  371. parse_skill_constants_yml(path_db_mode, "skill_db.yml");
  372. parse_skill_constants_yml(path_db_import + "/", "skill_db.yml");
  373. } else {
  374. sv_readdb(path_db_mode.c_str(), "skill_db.txt", ',', 18, 18, -1, parse_skill_constants_txt, false);
  375. sv_readdb(path_db_import.c_str(), "skill_db.txt", ',', 18, 18, -1, parse_skill_constants_txt, false);
  376. }
  377. // Load constants
  378. #define export_constant_npc(a) export_constant(a)
  379. init_random_option_constants();
  380. #include "../map/script_constants.hpp"
  381. std::vector<std::string> root_paths = {
  382. path_db,
  383. path_db_mode,
  384. path_db_import
  385. };
  386. if( !process( "GUILD_SKILL_TREE_DB", 1, root_paths, "guild_skill_tree", []( const std::string& path, const std::string& name_ext ) -> bool {
  387. return sv_readdb( path.c_str(), name_ext.c_str(), ',', 2 + MAX_GUILD_SKILL_REQUIRE * 2, 2 + MAX_GUILD_SKILL_REQUIRE * 2, -1, &guild_read_guildskill_tree_db, false );
  388. } ) ){
  389. return 0;
  390. }
  391. if( !process( "PET_DB", 1, root_paths, "pet_db", []( const std::string& path, const std::string& name_ext ) -> bool {
  392. return pet_read_db( ( path + name_ext ).c_str() );
  393. } ) ){
  394. return 0;
  395. }
  396. if (!process("MAGIC_MUSHROOM_DB", 1, root_paths, "magicmushroom_db", [](const std::string &path, const std::string &name_ext) -> bool {
  397. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 1, 1, -1, &skill_parse_row_magicmushroomdb, false);
  398. })) {
  399. return 0;
  400. }
  401. if (!process("ABRA_DB", 1, root_paths, "abra_db", [](const std::string& path, const std::string& name_ext) -> bool {
  402. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 3, 3, -1, &skill_parse_row_abradb, false);
  403. })) {
  404. return 0;
  405. }
  406. if (!process("READING_SPELLBOOK_DB", 1, root_paths, "spellbook_db", [](const std::string& path, const std::string& name_ext) -> bool {
  407. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 3, 3, -1, &skill_parse_row_spellbookdb, false);
  408. })) {
  409. return 0;
  410. }
  411. if (!process("MOB_AVAIL_DB", 1, root_paths, "mob_avail", [](const std::string& path, const std::string& name_ext) -> bool {
  412. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 2, 12, -1, &mob_readdb_mobavail, false);
  413. })) {
  414. return 0;
  415. }
  416. skill_txt_data( path_db_mode, path_db );
  417. if (!process("SKILL_DB", 1, { path_db_mode }, "skill_db", [](const std::string& path, const std::string& name_ext) -> bool {
  418. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 18, 18, -1, &skill_parse_row_skilldb, false);
  419. })){
  420. return 0;
  421. }
  422. skill_txt_data( path_db_import, path_db_import );
  423. if (!process("SKILL_DB", 1, { path_db_import }, "skill_db", [](const std::string& path, const std::string& name_ext) -> bool {
  424. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 18, 18, -1, &skill_parse_row_skilldb, false);
  425. })){
  426. return 0;
  427. }
  428. if (!process("QUEST_DB", 1, root_paths, "quest_db", [](const std::string &path, const std::string &name_ext) -> bool {
  429. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 3 + MAX_QUEST_OBJECTIVES * 2 + MAX_QUEST_DROPS * 3, 100, -1, &quest_read_db, false);
  430. })) {
  431. return 0;
  432. }
  433. if (!process("INSTANCE_DB", 1, root_paths, "instance_db", [](const std::string& path, const std::string& name_ext) -> bool {
  434. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 7, 7 + MAX_MAP_PER_INSTANCE, -1, &instance_readdb_sub, false);
  435. })) {
  436. return 0;
  437. }
  438. item_txt_data(path_db_mode, path_db);
  439. if (!process("ITEM_DB", 1, { path_db_mode }, "item_db", [](const std::string& path, const std::string& name_ext) -> bool {
  440. return itemdb_read_db((path + name_ext).c_str());
  441. })) {
  442. return 0;
  443. }
  444. item_txt_data(path_db_import, path_db_import);
  445. if (!process("ITEM_DB", 1, { path_db_import }, "item_db", [](const std::string& path, const std::string& name_ext) -> bool {
  446. return itemdb_read_db((path + name_ext).c_str());
  447. })) {
  448. return 0;
  449. }
  450. rand_opt_db.clear();
  451. if (!process("RANDOM_OPTION_DB", 1, root_paths, "item_randomopt_db", [](const std::string& path, const std::string& name_ext) -> bool {
  452. return itemdb_read_randomopt((path + name_ext).c_str());
  453. })) {
  454. return 0;
  455. }
  456. rand_opt_group.clear();
  457. if (!process("RANDOM_OPTION_GROUP", 1, root_paths, "item_randomopt_group", [](const std::string& path, const std::string& name_ext) -> bool {
  458. return sv_readdb(path.c_str(), name_ext.c_str(), ',', 5, 2 + 5 * MAX_ITEM_RDM_OPT, -1, &itemdb_read_randomopt_group, false) && itemdb_randomopt_group_yaml();
  459. })) {
  460. return 0;
  461. }
  462. // TODO: add implementations ;-)
  463. return 0;
  464. }
  465. void do_final(void){
  466. }
  467. bool fileExists( const std::string& path ){
  468. std::ifstream in;
  469. in.open( path );
  470. if( in.is_open() ){
  471. in.close();
  472. return true;
  473. }else{
  474. return false;
  475. }
  476. }
  477. bool askConfirmation( const char* fmt, ... ){
  478. va_list ap;
  479. va_start( ap, fmt );
  480. _vShowMessage( MSG_NONE, fmt, ap );
  481. va_end( ap );
  482. char c = getch();
  483. if( c == 'Y' || c == 'y' ){
  484. return true;
  485. }else{
  486. return false;
  487. }
  488. }
  489. // Constant loading functions
  490. static bool parse_item_constants_txt( const char* path ){
  491. uint32 lines = 0, count = 0;
  492. char line[1024];
  493. FILE* fp;
  494. fp = fopen(path, "r");
  495. if (fp == NULL) {
  496. ShowWarning("parse_item_constants_txt: File not found \"%s\", skipping.\n", path);
  497. return false;
  498. }
  499. // process rows one by one
  500. while (fgets(line, sizeof(line), fp))
  501. {
  502. char *str[32], *p;
  503. int i;
  504. lines++;
  505. if (line[0] == '/' && line[1] == '/')
  506. continue;
  507. memset(str, 0, sizeof(str));
  508. p = strstr(line, "//");
  509. if (p != nullptr) {
  510. *p = '\0';
  511. }
  512. p = line;
  513. while (ISSPACE(*p))
  514. ++p;
  515. if (*p == '\0')
  516. continue;// empty line
  517. for (i = 0; i < 19; ++i)
  518. {
  519. str[i] = p;
  520. p = strchr(p, ',');
  521. if (p == NULL)
  522. break;// comma not found
  523. *p = '\0';
  524. ++p;
  525. }
  526. if (p == NULL)
  527. {
  528. ShowError("parse_item_constants_txt: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
  529. continue;
  530. }
  531. // Script
  532. if (*p != '{')
  533. {
  534. ShowError("parse_item_constants_txt: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
  535. continue;
  536. }
  537. str[19] = p + 1;
  538. p = strstr(p + 1, "},");
  539. if (p == NULL)
  540. {
  541. ShowError("parse_item_constants_txt: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
  542. continue;
  543. }
  544. *p = '\0';
  545. p += 2;
  546. // OnEquip_Script
  547. if (*p != '{')
  548. {
  549. ShowError("parse_item_constants_txt: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
  550. continue;
  551. }
  552. str[20] = p + 1;
  553. p = strstr(p + 1, "},");
  554. if (p == NULL)
  555. {
  556. ShowError("parse_item_constants_txt: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
  557. continue;
  558. }
  559. *p = '\0';
  560. p += 2;
  561. // OnUnequip_Script (last column)
  562. if (*p != '{')
  563. {
  564. ShowError("parse_item_constants_txt: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
  565. continue;
  566. }
  567. str[21] = p;
  568. p = &str[21][strlen(str[21]) - 2];
  569. if (*p != '}') {
  570. /* lets count to ensure it's not something silly e.g. a extra space at line ending */
  571. int lcurly = 0, rcurly = 0;
  572. for (size_t v = 0; v < strlen(str[21]); v++) {
  573. if (str[21][v] == '{')
  574. lcurly++;
  575. else if (str[21][v] == '}') {
  576. rcurly++;
  577. p = &str[21][v];
  578. }
  579. }
  580. if (lcurly != rcurly) {
  581. ShowError("parse_item_constants_txt: Mismatching curly braces in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
  582. continue;
  583. }
  584. }
  585. str[21] = str[21] + 1; //skip the first left curly
  586. *p = '\0'; //null the last right curly
  587. uint16 item_id = atoi( str[0] );
  588. char* name = trim( str[1] );
  589. aegis_itemnames[item_id] = std::string(name);
  590. if (atoi(str[14]) & (EQP_HELM | EQP_COSTUME_HELM) && util::umap_find(aegis_itemviewid, (t_itemid)atoi(str[18])) == nullptr)
  591. aegis_itemviewid[atoi(str[18])] = item_id;
  592. count++;
  593. }
  594. fclose(fp);
  595. ShowStatus("Done reading '" CL_WHITE "%u" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", count, path);
  596. return true;
  597. }
  598. const std::string ItemDatabase::getDefaultLocation(){
  599. return std::string( db_path ) + "/item_db.yml";
  600. }
  601. uint64 ItemDatabase::parseBodyNode(const YAML::Node& node) {
  602. t_itemid nameid;
  603. if (!this->asUInt32(node, "Id", nameid))
  604. return 0;
  605. if (this->nodeExists(node, "AegisName")) {
  606. std::string name;
  607. if (!this->asString(node, "AegisName", name))
  608. return 0;
  609. aegis_itemnames[nameid] = name;
  610. }
  611. if (this->nodeExists(node, "View")) {
  612. uint32 look;
  613. if (!this->asUInt32(node, "View", look))
  614. return 0;
  615. if( look > 0 ){
  616. if (this->nodeExists(node, "Locations")) {
  617. const YAML::Node& locationNode = node["Locations"];
  618. static std::vector<std::string> locations = {
  619. "Head_Low",
  620. "Head_Mid",
  621. "Head_Top",
  622. "Costume_Head_Low",
  623. "Costume_Head_Mid",
  624. "Costume_Head_Top"
  625. };
  626. for( std::string& location : locations ){
  627. if (this->nodeExists(locationNode, location)) {
  628. bool active;
  629. if (!this->asBool(locationNode, location, active))
  630. return 0;
  631. aegis_itemviewid[look] = nameid;
  632. break;
  633. }
  634. }
  635. }
  636. }
  637. }
  638. return 1;
  639. }
  640. void ItemDatabase::loadingFinished(){
  641. }
  642. ItemDatabase item_db;
  643. static bool parse_mob_constants( char* split[], int columns, int current ){
  644. uint16 mob_id = atoi( split[0] );
  645. char* name = trim( split[1] );
  646. aegis_mobnames[mob_id] = std::string( name );
  647. return true;
  648. }
  649. static bool parse_skill_constants_txt( char* split[], int columns, int current ){
  650. uint16 skill_id = atoi( split[0] );
  651. char* name = trim( split[16] );
  652. aegis_skillnames[skill_id] = std::string( name );
  653. return true;
  654. }
  655. static bool parse_skill_constants_yml(std::string path, std::string filename) {
  656. YAML::Node rootNode;
  657. try {
  658. rootNode = YAML::LoadFile(path + filename);
  659. } catch (YAML::Exception &e) {
  660. ShowError("Failed to read file from '" CL_WHITE "%s%s" CL_RESET "'.\n", path.c_str(), filename.c_str());
  661. ShowError("%s (Line %d: Column %d)\n", e.msg.c_str(), e.mark.line, e.mark.column);
  662. return false;
  663. }
  664. uint64 count = 0;
  665. for (const YAML::Node &body : rootNode["Body"]) {
  666. aegis_skillnames[body["Id"].as<uint16>()] = body["Name"].as<std::string>();
  667. count++;
  668. }
  669. ShowStatus("Done reading '" CL_WHITE "%" PRIu64 CL_RESET "' entries in '" CL_WHITE "%s%s" CL_RESET "'" CL_CLL "\n", count, path.c_str(), filename.c_str());
  670. return true;
  671. }
  672. /**
  673. * Split the string with ':' as separator and put each value for a skilllv
  674. * @param str: String to split
  675. * @param val: Array of MAX_SKILL_LEVEL to put value into
  676. * @return 0:error, x:number of value assign (should be MAX_SKILL_LEVEL)
  677. */
  678. int skill_split_atoi(char *str, int *val) {
  679. int i;
  680. for (i = 0; i < MAX_SKILL_LEVEL; i++) {
  681. if (!str)
  682. break;
  683. val[i] = atoi(str);
  684. str = strchr(str, ':');
  685. if (str)
  686. *str++ = 0;
  687. }
  688. if (i == 0) // No data found.
  689. return 0;
  690. if (i == 1) // Single value, have the whole range have the same value.
  691. return 1;
  692. return i;
  693. }
  694. /**
  695. * Split string to int by constant value (const.txt) or atoi()
  696. * @param *str: String input
  697. * @param *val: Temporary storage
  698. * @param *delim: Delimiter (for multiple value support)
  699. * @param min_value: Minimum value. If the splitted value is less or equal than this, will be skipped
  700. * @param max: Maximum number that can be allocated
  701. * @return count: Number of success
  702. */
  703. uint8 skill_split_atoi2(char *str, int64 *val, const char *delim, int min_value, uint16 max) {
  704. uint8 i = 0;
  705. char *p = strtok(str, delim);
  706. while (p != NULL) {
  707. int64 n = min_value;
  708. trim(p);
  709. if (ISDIGIT(p[0])) // If using numeric
  710. n = atoi(p);
  711. else {
  712. n = constant_lookup_int(p);
  713. p = strtok(NULL, delim);
  714. }
  715. if (n > min_value) {
  716. val[i] = n;
  717. i++;
  718. if (i >= max)
  719. break;
  720. }
  721. p = strtok(NULL, delim);
  722. }
  723. return i;
  724. }
  725. /**
  726. * Split string to int
  727. * @param str: String input
  728. * @param val1: Temporary storage to first value
  729. * @param val2: Temporary storage to second value
  730. */
  731. static void itemdb_re_split_atoi(char* str, int* val1, int* val2) {
  732. int i, val[2];
  733. for (i = 0; i < 2; i++) {
  734. if (!str)
  735. break;
  736. val[i] = atoi(str);
  737. str = strchr(str, ':');
  738. if (str)
  739. *str++ = 0;
  740. }
  741. if (i == 0) {
  742. *val1 = *val2 = 0;
  743. return; // no data found
  744. }
  745. if (i == 1) { // Single Value
  746. *val1 = val[0];
  747. *val2 = 0;
  748. return;
  749. }
  750. // We assume we have 2 values.
  751. *val1 = val[0];
  752. *val2 = val[1];
  753. return;
  754. }
  755. // Implementation of the conversion functions
  756. // Copied and adjusted from guild.cpp
  757. // <skill id>,<max lv>,<req id1>,<req lv1>,<req id2>,<req lv2>,<req id3>,<req lv3>,<req id4>,<req lv4>,<req id5>,<req lv5>
  758. static bool guild_read_guildskill_tree_db( char* split[], int columns, int current ){
  759. uint16 skill_id = (uint16)atoi(split[0]);
  760. std::string* name = util::umap_find( aegis_skillnames, skill_id );
  761. if( name == nullptr ){
  762. ShowError( "Skill name for skill id %hu is not known.\n", skill_id );
  763. return false;
  764. }
  765. body << YAML::BeginMap;
  766. body << YAML::Key << "Id" << YAML::Value << *name;
  767. body << YAML::Key << "MaxLevel" << YAML::Value << atoi(split[1]);
  768. if (atoi(split[2]) > 0) {
  769. body << YAML::Key << "Required";
  770. body << YAML::BeginSeq;
  771. for (int i = 0, j = 0; i < MAX_GUILD_SKILL_REQUIRE; i++) {
  772. uint16 required_skill_id = atoi(split[i * 2 + 2]);
  773. uint16 required_skill_level = atoi(split[i * 2 + 3]);
  774. if (required_skill_id == 0 || required_skill_level == 0) {
  775. continue;
  776. }
  777. std::string* required_name = util::umap_find(aegis_skillnames, required_skill_id);
  778. if (required_name == nullptr) {
  779. ShowError("Skill name for required skill id %hu is not known.\n", required_skill_id);
  780. return false;
  781. }
  782. body << YAML::BeginMap;
  783. body << YAML::Key << "Id" << YAML::Value << *required_name;
  784. body << YAML::Key << "Level" << YAML::Value << required_skill_level;
  785. body << YAML::EndMap;
  786. }
  787. body << YAML::EndSeq;
  788. }
  789. body << YAML::EndMap;
  790. return true;
  791. }
  792. // Copied and adjusted from pet.cpp
  793. static bool pet_read_db( const char* file ){
  794. FILE* fp = fopen( file, "r" );
  795. if( fp == nullptr ){
  796. ShowError( "can't read %s\n", file );
  797. return false;
  798. }
  799. int lines = 0;
  800. size_t entries = 0;
  801. char line[1024];
  802. while( fgets( line, sizeof(line), fp ) ) {
  803. char *str[22], *p;
  804. unsigned k;
  805. lines++;
  806. if(line[0] == '/' && line[1] == '/')
  807. continue;
  808. memset(str, 0, sizeof(str));
  809. p = line;
  810. while( ISSPACE(*p) )
  811. ++p;
  812. if( *p == '\0' )
  813. continue; // empty line
  814. for( k = 0; k < 20; ++k ) {
  815. str[k] = p;
  816. p = strchr(p,',');
  817. if( p == NULL )
  818. break; // comma not found
  819. *p = '\0';
  820. ++p;
  821. }
  822. if( p == NULL ) {
  823. ShowError("read_petdb: Insufficient columns in line %d, skipping.\n", lines);
  824. continue;
  825. }
  826. // Pet Script
  827. if( *p != '{' ) {
  828. ShowError("read_petdb: Invalid format (Pet Script column) in line %d, skipping.\n", lines);
  829. continue;
  830. }
  831. str[20] = p;
  832. p = strstr(p+1,"},");
  833. if( p == NULL ) {
  834. ShowError("read_petdb: Invalid format (Pet Script column) in line %d, skipping.\n", lines);
  835. continue;
  836. }
  837. p[1] = '\0';
  838. p += 2;
  839. // Equip Script
  840. if( *p != '{' ) {
  841. ShowError("read_petdb: Invalid format (Equip Script column) in line %d, skipping.\n", lines);
  842. continue;
  843. }
  844. str[21] = p;
  845. uint16 mob_id = atoi( str[0] );
  846. std::string* mob_name = util::umap_find( aegis_mobnames, mob_id );
  847. if( mob_name == nullptr ){
  848. ShowWarning( "pet_db reading: Invalid mob-class %hu, pet not read.\n", mob_id );
  849. continue;
  850. }
  851. body << YAML::BeginMap;
  852. body << YAML::Key << "Mob" << YAML::Value << *mob_name;
  853. t_itemid tame_item_id = strtoul( str[3], nullptr, 10 );
  854. if( tame_item_id > 0 ){
  855. std::string* tame_item_name = util::umap_find( aegis_itemnames, tame_item_id );
  856. if( tame_item_name == nullptr ){
  857. ShowError( "Item name for item id %u is not known.\n", tame_item_id );
  858. return false;
  859. }
  860. body << YAML::Key << "TameItem" << YAML::Value << *tame_item_name;
  861. }
  862. t_itemid egg_item_id = strtoul( str[4], nullptr, 10 );
  863. std::string* egg_item_name = util::umap_find( aegis_itemnames, egg_item_id );
  864. if( egg_item_name == nullptr ){
  865. ShowError( "Item name for item id %u is not known.\n", egg_item_id );
  866. return false;
  867. }
  868. body << YAML::Key << "EggItem" << YAML::Value << *egg_item_name;
  869. t_itemid equip_item_id = strtoul( str[5], nullptr, 10 );
  870. if( equip_item_id > 0 ){
  871. std::string* equip_item_name = util::umap_find( aegis_itemnames, equip_item_id );
  872. if( equip_item_name == nullptr ){
  873. ShowError( "Item name for item id %u is not known.\n", equip_item_id );
  874. return false;
  875. }
  876. body << YAML::Key << "EquipItem" << YAML::Value << *equip_item_name;
  877. }
  878. t_itemid food_item_id = strtoul( str[6], nullptr, 10 );
  879. if( food_item_id > 0 ){
  880. std::string* food_item_name = util::umap_find( aegis_itemnames, food_item_id );
  881. if( food_item_name == nullptr ){
  882. ShowError( "Item name for item id %u is not known.\n", food_item_id );
  883. return false;
  884. }
  885. body << YAML::Key << "FoodItem" << YAML::Value << *food_item_name;
  886. }
  887. body << YAML::Key << "Fullness" << YAML::Value << atoi(str[7]);
  888. // Default: 60
  889. if( atoi( str[8] ) != 60 ){
  890. body << YAML::Key << "HungryDelay" << YAML::Value << atoi(str[8]);
  891. }
  892. // Default: 250
  893. if( atoi( str[11] ) != 250 ){
  894. body << YAML::Key << "IntimacyStart" << YAML::Value << atoi(str[11]);
  895. }
  896. body << YAML::Key << "IntimacyFed" << YAML::Value << atoi(str[9]);
  897. // Default: -100
  898. if( atoi( str[10] ) != 100 ){
  899. body << YAML::Key << "IntimacyOverfed" << YAML::Value << -atoi(str[10]);
  900. }
  901. // pet_hungry_friendly_decrease battle_conf
  902. //body << YAML::Key << "IntimacyHungry" << YAML::Value << -5;
  903. // Default: -20
  904. if( atoi( str[12] ) != 20 ){
  905. body << YAML::Key << "IntimacyOwnerDie" << YAML::Value << -atoi(str[12]);
  906. }
  907. body << YAML::Key << "CaptureRate" << YAML::Value << atoi(str[13]);
  908. // Default: true
  909. if( atoi( str[15] ) == 0 ){
  910. body << YAML::Key << "SpecialPerformance" << YAML::Value << "false";
  911. }
  912. body << YAML::Key << "AttackRate" << YAML::Value << atoi(str[17]);
  913. body << YAML::Key << "RetaliateRate" << YAML::Value << atoi(str[18]);
  914. body << YAML::Key << "ChangeTargetRate" << YAML::Value << atoi(str[19]);
  915. if( *str[21] ){
  916. body << YAML::Key << "Script" << YAML::Value << YAML::Literal << str[21];
  917. }
  918. if( *str[20] ){
  919. body << YAML::Key << "SupportScript" << YAML::Value << YAML::Literal << str[20];
  920. }
  921. body << YAML::EndMap;
  922. entries++;
  923. }
  924. fclose(fp);
  925. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' pets in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file );
  926. return true;
  927. }
  928. // Copied and adjusted from skill.cpp
  929. static bool skill_parse_row_magicmushroomdb(char *split[], int column, int current)
  930. {
  931. uint16 skill_id = atoi(split[0]);
  932. std::string *skill_name = util::umap_find(aegis_skillnames, skill_id);
  933. if (skill_name == nullptr) {
  934. ShowError("Skill name for Magic Mushroom skill ID %hu is not known.\n", skill_id);
  935. return false;
  936. }
  937. body << YAML::BeginMap;
  938. body << YAML::Key << "Skill" << YAML::Value << *skill_name;
  939. body << YAML::EndMap;
  940. return true;
  941. }
  942. // Copied and adjusted from skill.cpp
  943. static bool skill_parse_row_abradb(char* split[], int columns, int current)
  944. {
  945. uint16 skill_id = atoi(split[0]);
  946. std::string *skill_name = util::umap_find(aegis_skillnames, skill_id);
  947. if (skill_name == nullptr) {
  948. ShowError("Skill name for Abra skill ID %hu is not known.\n", skill_id);
  949. return false;
  950. }
  951. body << YAML::BeginMap;
  952. body << YAML::Key << "Skill" << YAML::Value << *skill_name;
  953. int arr[MAX_SKILL_LEVEL];
  954. int arr_size = skill_split_atoi(split[2], arr);
  955. if (arr_size == 1) {
  956. if (arr[0] != 500)
  957. body << YAML::Key << "Probability" << YAML::Value << arr[0];
  958. } else {
  959. body << YAML::Key << "Probability";
  960. body << YAML::BeginSeq;
  961. for (int i = 0; i < arr_size; i++) {
  962. if (arr[i] > 0) {
  963. body << YAML::BeginMap;
  964. body << YAML::Key << "Level" << YAML::Value << i + 1;
  965. body << YAML::Key << "Probability" << YAML::Value << arr[i];
  966. body << YAML::EndMap;
  967. }
  968. }
  969. body << YAML::EndSeq;
  970. }
  971. body << YAML::EndMap;
  972. return true;
  973. }
  974. // Copied and adjusted from skill.cpp
  975. static bool skill_parse_row_spellbookdb(char* split[], int columns, int current)
  976. {
  977. uint16 skill_id = atoi(split[0]);
  978. std::string *skill_name = util::umap_find(aegis_skillnames, skill_id);
  979. if (skill_name == nullptr) {
  980. ShowError("Skill name for Spell Book skill ID %hu is not known.\n", skill_id);
  981. return false;
  982. }
  983. t_itemid nameid = strtoul(split[2], nullptr, 10);
  984. std::string *book_name = util::umap_find(aegis_itemnames, nameid);
  985. if (book_name == nullptr) {
  986. ShowError("Book name for item ID %u is not known.\n", nameid);
  987. return false;
  988. }
  989. body << YAML::BeginMap;
  990. body << YAML::Key << "Skill" << YAML::Value << *skill_name;
  991. body << YAML::Key << "Book" << YAML::Value << *book_name;
  992. body << YAML::Key << "PreservePoints" << YAML::Value << atoi(split[1]);
  993. body << YAML::EndMap;
  994. return true;
  995. }
  996. // Copied and adjusted from mob.cpp
  997. static bool mob_readdb_mobavail(char* str[], int columns, int current) {
  998. uint16 mob_id = atoi(str[0]);
  999. std::string *mob_name = util::umap_find(aegis_mobnames, mob_id);
  1000. if (mob_name == nullptr) {
  1001. ShowWarning("mob_avail reading: Invalid mob-class %hu, Mob not read.\n", mob_id);
  1002. return false;
  1003. }
  1004. body << YAML::BeginMap;
  1005. body << YAML::Key << "Mob" << YAML::Value << *mob_name;
  1006. uint16 sprite_id = atoi(str[1]);
  1007. std::string *sprite_name = util::umap_find(aegis_mobnames, sprite_id);
  1008. if (sprite_name == nullptr) {
  1009. char *sprite = const_cast<char *>(constant_lookup(sprite_id, "JOB_"));
  1010. if (sprite == nullptr) {
  1011. sprite = const_cast<char *>(constant_lookup(sprite_id, "JT_"));
  1012. if (sprite == nullptr) {
  1013. ShowError("Sprite name for id %d is not known.\n", sprite_id);
  1014. return false;
  1015. }
  1016. sprite += 3; // Strip JT_ here because the script engine doesn't send this prefix for NPC.
  1017. body << YAML::Key << "Sprite" << YAML::Value << sprite;
  1018. } else
  1019. body << YAML::Key << "Sprite" << YAML::Value << sprite;
  1020. } else
  1021. body << YAML::Key << "Sprite" << YAML::Value << *sprite_name;
  1022. if (columns == 12) {
  1023. body << YAML::Key << "Sex" << YAML::Value << (atoi(str[2]) ? "Male" : "Female");
  1024. if (atoi(str[3]) != 0)
  1025. body << YAML::Key << "HairStyle" << YAML::Value << atoi(str[3]);
  1026. if (atoi(str[4]) != 0)
  1027. body << YAML::Key << "HairColor" << YAML::Value << atoi(str[4]);
  1028. if (atoi(str[11]) != 0)
  1029. body << YAML::Key << "ClothColor" << YAML::Value << atoi(str[11]);
  1030. if (atoi(str[5]) != 0) {
  1031. t_itemid weapon_item_id = strtoul( str[5], nullptr, 10 );
  1032. std::string *weapon_item_name = util::umap_find(aegis_itemnames, weapon_item_id);
  1033. if (weapon_item_name == nullptr) {
  1034. ShowError("Item name for item ID %u (weapon) is not known.\n", weapon_item_id);
  1035. return false;
  1036. }
  1037. body << YAML::Key << "Weapon" << YAML::Value << *weapon_item_name;
  1038. }
  1039. if (atoi(str[6]) != 0) {
  1040. t_itemid shield_item_id = strtoul( str[6], nullptr, 10 );
  1041. std::string *shield_item_name = util::umap_find(aegis_itemnames, shield_item_id);
  1042. if (shield_item_name == nullptr) {
  1043. ShowError("Item name for item ID %u (shield) is not known.\n", shield_item_id);
  1044. return false;
  1045. }
  1046. body << YAML::Key << "Shield" << YAML::Value << *shield_item_name;
  1047. }
  1048. if (atoi(str[7]) != 0) {
  1049. t_itemid *headtop_item_id = util::umap_find(aegis_itemviewid, (t_itemid)atoi(str[7]));
  1050. if (headtop_item_id == nullptr) {
  1051. ShowError("Item ID for view ID %hu (head top) is not known.\n", atoi(str[7]));
  1052. return false;
  1053. }
  1054. std::string *headtop_item_name = util::umap_find(aegis_itemnames, (t_itemid)*headtop_item_id);
  1055. if (headtop_item_name == nullptr) {
  1056. ShowError("Item name for item ID %hu (head top) is not known.\n", *headtop_item_id);
  1057. return false;
  1058. }
  1059. body << YAML::Key << "HeadTop" << YAML::Value << *headtop_item_name;
  1060. }
  1061. if (atoi(str[8]) != 0) {
  1062. t_itemid *headmid_item_id = util::umap_find(aegis_itemviewid, (t_itemid)atoi(str[8]));
  1063. if (headmid_item_id == nullptr) {
  1064. ShowError("Item ID for view ID %hu (head mid) is not known.\n", atoi(str[8]));
  1065. return false;
  1066. }
  1067. std::string *headmid_item_name = util::umap_find(aegis_itemnames, (t_itemid)*headmid_item_id);
  1068. if (headmid_item_name == nullptr) {
  1069. ShowError("Item name for item ID %hu (head mid) is not known.\n", *headmid_item_id);
  1070. return false;
  1071. }
  1072. body << YAML::Key << "HeadMid" << YAML::Value << *headmid_item_name;
  1073. }
  1074. if (atoi(str[9]) != 0) {
  1075. t_itemid *headlow_item_id = util::umap_find(aegis_itemviewid, (t_itemid)atoi(str[9]));
  1076. if (headlow_item_id == nullptr) {
  1077. ShowError("Item ID for view ID %hu (head low) is not known.\n", atoi(str[9]));
  1078. return false;
  1079. }
  1080. std::string *headlow_item_name = util::umap_find(aegis_itemnames, (t_itemid)*headlow_item_id);
  1081. if (headlow_item_name == nullptr) {
  1082. ShowError("Item name for item ID %hu (head low) is not known.\n", *headlow_item_id);
  1083. return false;
  1084. }
  1085. body << YAML::Key << "HeadLow" << YAML::Value << *headlow_item_name;
  1086. }
  1087. if (atoi(str[10]) != 0) {
  1088. uint32 options = atoi(str[10]);
  1089. body << YAML::Key << "Options";
  1090. body << YAML::BeginMap;
  1091. while (options > OPTION_NOTHING && options <= OPTION_SUMMER2) {
  1092. if (options & OPTION_SIGHT) {
  1093. body << YAML::Key << "Sight" << YAML::Value << "true";
  1094. options &= ~OPTION_SIGHT;
  1095. } else if (options & OPTION_CART1) {
  1096. body << YAML::Key << "Cart1" << YAML::Value << "true";
  1097. options &= ~OPTION_CART1;
  1098. } else if (options & OPTION_FALCON) {
  1099. body << YAML::Key << "Falcon" << YAML::Value << "true";
  1100. options &= ~OPTION_FALCON;
  1101. } else if (options & OPTION_RIDING) {
  1102. body << YAML::Key << "Riding" << YAML::Value << "true";
  1103. options &= ~OPTION_RIDING;
  1104. } else if (options & OPTION_CART2) {
  1105. body << YAML::Key << "Cart2" << YAML::Value << "true";
  1106. options &= ~OPTION_CART2;
  1107. } else if (options & OPTION_CART3) {
  1108. body << YAML::Key << "Cart2" << YAML::Value << "true";
  1109. options &= ~OPTION_CART3;
  1110. } else if (options & OPTION_CART4) {
  1111. body << YAML::Key << "Cart4" << YAML::Value << "true";
  1112. options &= ~OPTION_CART4;
  1113. } else if (options & OPTION_CART5) {
  1114. body << YAML::Key << "Cart5" << YAML::Value << "true";
  1115. options &= ~OPTION_CART5;
  1116. } else if (options & OPTION_ORCISH) {
  1117. body << YAML::Key << "Orcish" << YAML::Value << "true";
  1118. options &= ~OPTION_ORCISH;
  1119. } else if (options & OPTION_WEDDING) {
  1120. body << YAML::Key << "Wedding" << YAML::Value << "true";
  1121. options &= ~OPTION_WEDDING;
  1122. } else if (options & OPTION_RUWACH) {
  1123. body << YAML::Key << "Ruwach" << YAML::Value << "true";
  1124. options &= ~OPTION_RUWACH;
  1125. } else if (options & OPTION_FLYING) {
  1126. body << YAML::Key << "Flying" << YAML::Value << "true";
  1127. options &= ~OPTION_FLYING;
  1128. } else if (options & OPTION_XMAS) {
  1129. body << YAML::Key << "Xmas" << YAML::Value << "true";
  1130. options &= ~OPTION_XMAS;
  1131. } else if (options & OPTION_TRANSFORM) {
  1132. body << YAML::Key << "Transform" << YAML::Value << "true";
  1133. options &= ~OPTION_TRANSFORM;
  1134. } else if (options & OPTION_SUMMER) {
  1135. body << YAML::Key << "Summer" << YAML::Value << "true";
  1136. options &= ~OPTION_SUMMER;
  1137. } else if (options & OPTION_DRAGON1) {
  1138. body << YAML::Key << "Dragon1" << YAML::Value << "true";
  1139. options &= ~OPTION_DRAGON1;
  1140. } else if (options & OPTION_WUG) {
  1141. body << YAML::Key << "Wug" << YAML::Value << "true";
  1142. options &= ~OPTION_WUG;
  1143. } else if (options & OPTION_WUGRIDER) {
  1144. body << YAML::Key << "WugRider" << YAML::Value << "true";
  1145. options &= ~OPTION_WUGRIDER;
  1146. } else if (options & OPTION_MADOGEAR) {
  1147. body << YAML::Key << "MadoGear" << YAML::Value << "true";
  1148. options &= ~OPTION_MADOGEAR;
  1149. } else if (options & OPTION_DRAGON2) {
  1150. body << YAML::Key << "Dragon2" << YAML::Value << "true";
  1151. options &= ~OPTION_DRAGON2;
  1152. } else if (options & OPTION_DRAGON3) {
  1153. body << YAML::Key << "Dragon3" << YAML::Value << "true";
  1154. options &= ~OPTION_DRAGON3;
  1155. } else if (options & OPTION_DRAGON4) {
  1156. body << YAML::Key << "Dragon4" << YAML::Value << "true";
  1157. options &= ~OPTION_DRAGON4;
  1158. } else if (options & OPTION_DRAGON5) {
  1159. body << YAML::Key << "Dragon5" << YAML::Value << "true";
  1160. options &= ~OPTION_DRAGON5;
  1161. } else if (options & OPTION_HANBOK) {
  1162. body << YAML::Key << "Hanbok" << YAML::Value << "true";
  1163. options &= ~OPTION_HANBOK;
  1164. } else if (options & OPTION_OKTOBERFEST) {
  1165. body << YAML::Key << "Oktoberfest" << YAML::Value << "true";
  1166. options &= ~OPTION_OKTOBERFEST;
  1167. } else if (options & OPTION_SUMMER2) {
  1168. body << YAML::Key << "Summer2" << YAML::Value << "true";
  1169. options &= ~OPTION_SUMMER2;
  1170. }
  1171. }
  1172. body << YAML::EndMap;
  1173. }
  1174. } else if (columns == 3) {
  1175. if (atoi(str[5]) != 0) {
  1176. t_itemid peteq_item_id = strtoul( str[5], nullptr, 10 );
  1177. std::string *peteq_item_name = util::umap_find(aegis_itemnames, peteq_item_id);
  1178. if (peteq_item_name == nullptr) {
  1179. ShowError("Item name for item ID %u (pet equip) is not known.\n", peteq_item_id);
  1180. return false;
  1181. }
  1182. body << YAML::Key << "PetEquip" << YAML::Value << *peteq_item_name;
  1183. }
  1184. }
  1185. body << YAML::EndMap;
  1186. return true;
  1187. }
  1188. // skill_db.yml function
  1189. //----------------------
  1190. static bool skill_parse_row_requiredb(char* split[], int columns, int current)
  1191. {
  1192. s_skill_require entry = {};
  1193. skill_split_atoi(split[1], entry.hp);
  1194. skill_split_atoi(split[2], entry.mhp);
  1195. skill_split_atoi(split[3], entry.sp);
  1196. skill_split_atoi(split[4], entry.hp_rate);
  1197. skill_split_atoi(split[5], entry.sp_rate);
  1198. skill_split_atoi(split[6], entry.zeny);
  1199. char *p;
  1200. p = split[7];
  1201. while (p) {
  1202. int l = atoi(p);
  1203. if (l == 99) { // Any weapon
  1204. entry.weapon = 0;
  1205. break;
  1206. } else
  1207. entry.weapon |= 1 << l;
  1208. p = strchr(p, ':');
  1209. if (!p)
  1210. break;
  1211. p++;
  1212. }
  1213. p = split[8];
  1214. while (p) {
  1215. int l = atoi(p);
  1216. if (l == 99) { // Any ammo type
  1217. entry.ammo = AMMO_TYPE_ALL;
  1218. break;
  1219. } else if (l) // 0 stands for no requirement
  1220. entry.ammo |= 1 << l;
  1221. p = strchr(p, ':');
  1222. if (!p)
  1223. break;
  1224. p++;
  1225. }
  1226. skill_split_atoi(split[9], entry.ammo_qty);
  1227. if (strcmpi(split[10], "hidden") == 0) entry.state = ST_HIDDEN;
  1228. else if (strcmpi(split[10], "riding") == 0) entry.state = ST_RIDING;
  1229. else if (strcmpi(split[10], "falcon") == 0) entry.state = ST_FALCON;
  1230. else if (strcmpi(split[10], "cart") == 0) entry.state = ST_CART;
  1231. else if (strcmpi(split[10], "shield") == 0) entry.state = ST_SHIELD;
  1232. else if (strcmpi(split[10], "recover_weight_rate") == 0) entry.state = ST_RECOVER_WEIGHT_RATE;
  1233. else if (strcmpi(split[10], "move_enable") == 0) entry.state = ST_MOVE_ENABLE;
  1234. else if (strcmpi(split[10], "water") == 0) entry.state = ST_WATER;
  1235. else if (strcmpi(split[10], "dragon") == 0) entry.state = ST_RIDINGDRAGON;
  1236. else if (strcmpi(split[10], "warg") == 0) entry.state = ST_WUG;
  1237. else if (strcmpi(split[10], "ridingwarg") == 0) entry.state = ST_RIDINGWUG;
  1238. else if (strcmpi(split[10], "mado") == 0) entry.state = ST_MADO;
  1239. else if (strcmpi(split[10], "elementalspirit") == 0) entry.state = ST_ELEMENTALSPIRIT;
  1240. else if (strcmpi(split[10], "elementalspirit2") == 0) entry.state = ST_ELEMENTALSPIRIT2;
  1241. else if (strcmpi(split[10], "peco") == 0) entry.state = ST_PECO;
  1242. else if (strcmpi(split[10], "sunstance") == 0) entry.state = ST_SUNSTANCE;
  1243. else if (strcmpi(split[10], "moonstance") == 0) entry.state = ST_MOONSTANCE;
  1244. else if (strcmpi(split[10], "starstance") == 0) entry.state = ST_STARSTANCE;
  1245. else if (strcmpi(split[10], "universestance") == 0) entry.state = ST_UNIVERSESTANCE;
  1246. else entry.state = ST_NONE; // Unknown or no state
  1247. trim(split[11]);
  1248. if (split[11][0] != '\0' || atoi(split[11])) {
  1249. int64 require[MAX_SKILL_STATUS_REQUIRE];
  1250. int32 count;
  1251. if ((count = skill_split_atoi2(split[11], require, ":", SC_STONE, ARRAYLENGTH(require)))) {
  1252. for (int i = 0; i < count; i++) {
  1253. entry.status.push_back((sc_type)require[i]);
  1254. }
  1255. }
  1256. }
  1257. skill_split_atoi(split[12], entry.spiritball);
  1258. for (int i = 0; i < MAX_SKILL_ITEM_REQUIRE; i++) {
  1259. if (atoi(split[13 + 2 * i]) > 0) {
  1260. t_itemid item_id = strtoul( split[13 + 2 * i], nullptr, 10 );
  1261. std::string *item_name = util::umap_find(aegis_itemnames, item_id);
  1262. if (item_name == nullptr) {
  1263. ShowError("Item name for item id %u is not known.\n", item_id);
  1264. return false;
  1265. }
  1266. entry.itemid[i] = item_id;
  1267. entry.amount[i] = atoi(split[14 + 2 * i]);
  1268. }
  1269. }
  1270. trim(split[33]);
  1271. if (split[33][0] != '\0' || atoi(split[33])) {
  1272. int64 require[MAX_SKILL_EQUIP_REQUIRE];
  1273. int32 count;
  1274. if ((count = skill_split_atoi2(split[33], require, ":", 500, ARRAYLENGTH(require)))) {
  1275. for (int i = 0; i < count; i++) {
  1276. if (require[i] > 0)
  1277. entry.eqItem.push_back(static_cast<int32>(require[i]));
  1278. }
  1279. }
  1280. }
  1281. skill_require.insert({ atoi(split[0]), entry });
  1282. return true;
  1283. }
  1284. // skill_db.yml function
  1285. //----------------------
  1286. static bool skill_parse_row_castdb(char* split[], int columns, int current)
  1287. {
  1288. s_skill_db entry = {};
  1289. skill_split_atoi(split[1], entry.cast);
  1290. skill_split_atoi(split[2], entry.delay);
  1291. skill_split_atoi(split[3], entry.walkdelay);
  1292. skill_split_atoi(split[4], entry.upkeep_time);
  1293. skill_split_atoi(split[5], entry.upkeep_time2);
  1294. skill_split_atoi(split[6], entry.cooldown);
  1295. #ifdef RENEWAL_CAST
  1296. skill_split_atoi(split[7], (int *)entry.fixed_cast);
  1297. #endif
  1298. skill_cast.insert({ atoi(split[0]), entry });
  1299. return true;
  1300. }
  1301. // skill_db.yml function
  1302. //----------------------
  1303. static bool skill_parse_row_castnodexdb(char* split[], int columns, int current)
  1304. {
  1305. s_skill_db entry = {};
  1306. entry.castnodex = atoi(split[1]);
  1307. if (split[2]) // optional column
  1308. entry.delaynodex = atoi(split[2]);
  1309. skill_castnodex.insert({ atoi(split[0]), entry });
  1310. return true;
  1311. }
  1312. // skill_db.yml function
  1313. //----------------------
  1314. static bool skill_parse_row_unitdb(char* split[], int columns, int current)
  1315. {
  1316. s_skill_unit_csv entry = {};
  1317. entry.unit_id = (uint16)strtol(split[1], NULL, 16);
  1318. entry.unit_id2 = (uint16)strtol(split[2], NULL, 16);
  1319. skill_split_atoi(split[3], entry.unit_layout_type);
  1320. skill_split_atoi(split[4], entry.unit_range);
  1321. entry.unit_interval = atoi(split[5]);
  1322. entry.target_str = trim(split[6]);
  1323. entry.unit_flag_csv = strtol(split[7], NULL, 16);
  1324. skill_unit.insert({ atoi(split[0]), entry });
  1325. return true;
  1326. }
  1327. // skill_db.yml function
  1328. //----------------------
  1329. static bool skill_parse_row_copyabledb(char* split[], int column, int current)
  1330. {
  1331. s_skill_copyable entry = {};
  1332. int skill_id = -1;
  1333. trim(split[0]);
  1334. if (ISDIGIT(split[0][0]))
  1335. skill_id = atoi(split[0]);
  1336. else {
  1337. for (const auto &it : aegis_skillnames) {
  1338. if (it.second == split[0])
  1339. skill_id = it.first;
  1340. }
  1341. if (skill_id == -1) {
  1342. ShowError("Skill %s is unknown.\n", split[0]);
  1343. return false;
  1344. }
  1345. }
  1346. entry.option = atoi(split[1]);
  1347. entry.req_opt = cap_value(atoi(split[3]), 0, (0x2000) - 1);
  1348. skill_copyable.insert({ skill_id, entry });
  1349. return true;
  1350. }
  1351. // skill_db.yml function
  1352. //----------------------
  1353. static bool skill_parse_row_nonearnpcrangedb(char* split[], int column, int current)
  1354. {
  1355. s_skill_db entry = {};
  1356. int skill_id = -1;
  1357. trim(split[0]);
  1358. if (ISDIGIT(split[0][0]))
  1359. skill_id = atoi(split[0]);
  1360. else {
  1361. for (const auto &it : aegis_skillnames) {
  1362. if (it.second == split[0])
  1363. skill_id = it.first;
  1364. }
  1365. if (skill_id == -1) {
  1366. ShowError("Skill %s is unknown.\n", split[0]);
  1367. return false;
  1368. }
  1369. }
  1370. entry.unit_nonearnpc_range = max(atoi(split[1]), 0);
  1371. entry.unit_nonearnpc_type = (atoi(split[2])) ? cap_value(atoi(split[2]), 1, 15) : 15;
  1372. skill_nearnpc.insert({ skill_id, entry });
  1373. return true;
  1374. }
  1375. static bool isMultiLevel(int arr[]) {
  1376. int count = 0;
  1377. for (int i = 0; i < MAX_SKILL_LEVEL; i++) {
  1378. if (arr[i] != 0)
  1379. count++;
  1380. }
  1381. return (count == 0 || count == 1 ? false : true);
  1382. }
  1383. std::string name2Upper(std::string name) {
  1384. std::transform(name.begin(), name.end(), name.begin(), ::tolower);
  1385. name[0] = toupper(name[0]);
  1386. for (size_t i = 0; i < name.size(); i++) {
  1387. if (name[i - 1] == '_' || (name[i - 2] == '1' && name[i - 1] == 'h') || (name[i - 2] == '2' && name[i - 1] == 'h'))
  1388. name[i] = toupper(name[i]);
  1389. }
  1390. return name;
  1391. }
  1392. // Copied and adjusted from skill.cpp
  1393. static bool skill_parse_row_skilldb(char* split[], int columns, int current) {
  1394. int arr[MAX_SKILL_LEVEL], arr_size, skill_id = atoi(split[0]);
  1395. body << YAML::BeginMap;
  1396. body << YAML::Key << "Id" << YAML::Value << skill_id;
  1397. body << YAML::Key << "Name" << YAML::Value << trim(split[16]);
  1398. body << YAML::Key << "Description" << YAML::Value << trim(split[17]);
  1399. body << YAML::Key << "MaxLevel" << YAML::Value << atoi(split[7]);
  1400. if (strcmpi(split[13], "weapon") == 0)
  1401. body << YAML::Key << "Type" << YAML::Value << "Weapon";
  1402. else if (strcmpi(split[13], "magic") == 0)
  1403. body << YAML::Key << "Type" << YAML::Value << "Magic";
  1404. else if (strcmpi(split[13], "misc") == 0)
  1405. body << YAML::Key << "Type" << YAML::Value << "Misc";
  1406. std::string constant;
  1407. if (atoi(split[3]) != 0) {
  1408. constant = constant_lookup(atoi(split[3]), "INF_");
  1409. constant.erase(0, 4);
  1410. constant.erase(constant.size() - 6);
  1411. body << YAML::Key << "TargetType" << YAML::Value << name2Upper(constant);
  1412. }
  1413. uint64 nk_val = strtol(split[5], NULL, 0);
  1414. if (nk_val) {
  1415. body << YAML::Key << "DamageFlags";
  1416. body << YAML::BeginMap;
  1417. if (nk_val & 0x1)
  1418. body << YAML::Key << "NoDamage" << YAML::Value << "true";
  1419. if (nk_val & 0x2)
  1420. body << YAML::Key << "Splash" << YAML::Value << "true";
  1421. if (nk_val & 0x4)
  1422. body << YAML::Key << "SplashSplit" << YAML::Value << "true";
  1423. if (nk_val & 0x8)
  1424. body << YAML::Key << "IgnoreAtkCard" << YAML::Value << "true";
  1425. if (nk_val & 0x10)
  1426. body << YAML::Key << "IgnoreElement" << YAML::Value << "true";
  1427. if (nk_val & 0x20)
  1428. body << YAML::Key << "IgnoreDefense" << YAML::Value << "true";
  1429. if (nk_val & 0x40)
  1430. body << YAML::Key << "IgnoreFlee" << YAML::Value << "true";
  1431. if (nk_val & 0x80)
  1432. body << YAML::Key << "IgnoreDefCard" << YAML::Value << "true";
  1433. if (nk_val & 0x100)
  1434. body << YAML::Key << "Critical" << YAML::Value << "true";
  1435. body << YAML::EndMap;
  1436. }
  1437. uint64 inf2_val = strtol(split[11], nullptr, 0);
  1438. uint64 inf3_val = strtol(split[15], nullptr, 0);
  1439. if (inf2_val || inf3_val) {
  1440. body << YAML::Key << "Flags";
  1441. body << YAML::BeginMap;
  1442. if (inf2_val & 0x1)
  1443. body << YAML::Key << "IsQuest" << YAML::Value << "true";
  1444. if (inf2_val & 0x2)
  1445. body << YAML::Key << "IsNpc" << YAML::Value << "true";
  1446. if (inf2_val & 0x4)
  1447. body << YAML::Key << "IsWedding" << YAML::Value << "true";
  1448. if (inf2_val & 0x8)
  1449. body << YAML::Key << "IsSpirit" << YAML::Value << "true";
  1450. if (inf2_val & 0x10)
  1451. body << YAML::Key << "IsGuild" << YAML::Value << "true";
  1452. if (inf2_val & 0x20)
  1453. body << YAML::Key << "IsSong" << YAML::Value << "true";
  1454. if (inf2_val & 0x40)
  1455. body << YAML::Key << "IsEnsemble" << YAML::Value << "true";
  1456. if (inf2_val & 0x80)
  1457. body << YAML::Key << "IsTrap" << YAML::Value << "true";
  1458. if (inf2_val & 0x100)
  1459. body << YAML::Key << "TargetSelf" << YAML::Value << "true";
  1460. if (inf2_val & 0x200)
  1461. body << YAML::Key << "NoTargetSelf" << YAML::Value << "true";
  1462. if (inf2_val & 0x400)
  1463. body << YAML::Key << "PartyOnly" << YAML::Value << "true";
  1464. if (inf2_val & 0x800)
  1465. body << YAML::Key << "GuildOnly" << YAML::Value << "true";
  1466. if (inf2_val & 0x1000)
  1467. body << YAML::Key << "NoTargetEnemy" << YAML::Value << "true";
  1468. if (inf2_val & 0x2000)
  1469. body << YAML::Key << "IsAutoShadowSpell" << YAML::Value << "true";
  1470. if (inf2_val & 0x4000)
  1471. body << YAML::Key << "IsChorus" << YAML::Value << "true";
  1472. if (inf2_val & 0x8000)
  1473. body << YAML::Key << "IgnoreBgReduction" << YAML::Value << "true";
  1474. if (inf2_val & 0x10000)
  1475. body << YAML::Key << "IgnoreGvgReduction" << YAML::Value << "true";
  1476. if (inf2_val & 0x20000)
  1477. body << YAML::Key << "DisableNearNpc" << YAML::Value << "true";
  1478. if (inf2_val & 0x40000)
  1479. body << YAML::Key << "TargetTrap" << YAML::Value << "true"; // ?
  1480. if (inf3_val & 0x1)
  1481. body << YAML::Key << "IgnoreLandProtector" << YAML::Value << "true";
  1482. if (inf3_val & 0x4)
  1483. body << YAML::Key << "AllowWhenHidden" << YAML::Value << "true";
  1484. if (inf3_val & 0x8)
  1485. body << YAML::Key << "AllowWhenPerforming" << YAML::Value << "true";
  1486. if (inf3_val & 0x10)
  1487. body << YAML::Key << "TargetEmperium" << YAML::Value << "true";
  1488. if (inf3_val & 0x20)
  1489. body << YAML::Key << "IgnoreStasis" << YAML::Value << "true";
  1490. if (inf3_val & 0x40)
  1491. body << YAML::Key << "IgnoreKagehumi" << YAML::Value << "true";
  1492. if (inf3_val & 0x80)
  1493. body << YAML::Key << "AlterRangeVulture" << YAML::Value << "true";
  1494. if (inf3_val & 0x100)
  1495. body << YAML::Key << "AlterRangeSnakeEye" << YAML::Value << "true";
  1496. if (inf3_val & 0x200)
  1497. body << YAML::Key << "AlterRangeShadowJump" << YAML::Value << "true";
  1498. if (inf3_val & 0x400)
  1499. body << YAML::Key << "AlterRangeRadius" << YAML::Value << "true";
  1500. if (inf3_val & 0x800)
  1501. body << YAML::Key << "AlterRangeResearchTrap" << YAML::Value << "true";
  1502. if (inf3_val & 0x1000)
  1503. body << YAML::Key << "IgnoreHovering" << YAML::Value << "true";
  1504. if (inf3_val & 0x2000)
  1505. body << YAML::Key << "AllowOnWarg" << YAML::Value << "true";
  1506. if (inf3_val & 0x4000)
  1507. body << YAML::Key << "AllowOnMado" << YAML::Value << "true";
  1508. if (inf3_val & 0x8000)
  1509. body << YAML::Key << "TargetManHole" << YAML::Value << "true";
  1510. if (inf3_val & 0x10000)
  1511. body << YAML::Key << "TargetHidden" << YAML::Value << "true";
  1512. if (inf3_val & 0x40000)
  1513. body << YAML::Key << "IncreaseDanceWithWugDamage" << YAML::Value << "true";
  1514. if (inf3_val & 0x80000)
  1515. body << YAML::Key << "IgnoreWugBite" << YAML::Value << "true";
  1516. if (inf3_val & 0x100000)
  1517. body << YAML::Key << "IgnoreAutoGuard" << YAML::Value << "true";
  1518. if (inf3_val & 0x200000)
  1519. body << YAML::Key << "IgnoreCicada" << YAML::Value << "true";
  1520. body << YAML::EndMap;
  1521. }
  1522. memset(arr, 0, sizeof(arr));
  1523. arr_size = skill_split_atoi(split[1], arr);
  1524. if (arr_size != 0) {
  1525. if (arr_size == 1) {
  1526. if (arr[0] != 0) {
  1527. body << YAML::Key << "Range";
  1528. body << YAML::Value << arr[0];
  1529. }
  1530. } else {
  1531. body << YAML::Key << "Range";
  1532. body << YAML::BeginSeq;
  1533. for (int i = 0; i < arr_size; i++) {
  1534. body << YAML::BeginMap;
  1535. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1536. body << YAML::Key << "Size" << YAML::Value << arr[i];
  1537. body << YAML::EndMap;
  1538. }
  1539. body << YAML::EndSeq;
  1540. }
  1541. }
  1542. if (atoi(split[2]) != 0) {
  1543. constant = constant_lookup(atoi(split[2]), "DMG_");
  1544. constant.erase(0, 4);
  1545. body << YAML::Key << "Hit" << YAML::Value << name2Upper(constant);
  1546. }
  1547. memset(arr, 0, sizeof(arr));
  1548. arr_size = skill_split_atoi(split[8], arr);
  1549. if (arr_size != 0) {
  1550. if (arr_size == 1) {
  1551. if (arr[0] != 0) {
  1552. body << YAML::Key << "HitCount";
  1553. body << YAML::Value << arr[0];
  1554. }
  1555. } else {
  1556. body << YAML::Key << "HitCount";
  1557. body << YAML::BeginSeq;
  1558. for (int i = 0; i < arr_size; i++) {
  1559. body << YAML::BeginMap;
  1560. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1561. body << YAML::Key << "Count" << YAML::Value << arr[i];
  1562. body << YAML::EndMap;
  1563. }
  1564. body << YAML::EndSeq;
  1565. }
  1566. }
  1567. memset(arr, 0, sizeof(arr));
  1568. arr_size = skill_split_atoi(split[4], arr);
  1569. if (arr_size != 0) {
  1570. if (arr_size == 1) {
  1571. if (arr[0] != 0){
  1572. body << YAML::Key << "Element";
  1573. if (arr[0] == -1)
  1574. body << YAML::Value << "Weapon";
  1575. else if (arr[0] == -2)
  1576. body << YAML::Value << "Endowed";
  1577. else if (arr[0] == -3)
  1578. body << YAML::Value << "Random";
  1579. else {
  1580. constant = constant_lookup(arr[0], "ELE_");
  1581. constant.erase(0, 4);
  1582. body << YAML::Value << name2Upper(constant);
  1583. }
  1584. }
  1585. } else {
  1586. body << YAML::Key << "Element";
  1587. body << YAML::BeginSeq;
  1588. for (int i = 0; i < arr_size; i++) {
  1589. body << YAML::BeginMap;
  1590. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1591. if (arr[i] == -1)
  1592. body << YAML::Key << "Element" << YAML::Value << "Weapon";
  1593. else if (arr[i] == -2)
  1594. body << YAML::Key << "Element" << YAML::Value << "Endowed";
  1595. else if (arr[i] == -3)
  1596. body << YAML::Key << "Element" << YAML::Value << "Random";
  1597. else {
  1598. constant = constant_lookup(arr[i], "ELE_");
  1599. constant.erase(0, 4);
  1600. body << YAML::Key << "Element" << YAML::Value << name2Upper(constant);
  1601. }
  1602. body << YAML::EndMap;
  1603. }
  1604. body << YAML::EndSeq;
  1605. }
  1606. }
  1607. memset(arr, 0, sizeof(arr));
  1608. arr_size = skill_split_atoi(split[6], arr);
  1609. if (arr_size != 0) {
  1610. if (arr_size == 1) {
  1611. if (arr[0] != 0) {
  1612. body << YAML::Key << "SplashArea";
  1613. body << YAML::Value << arr[0];
  1614. }
  1615. } else {
  1616. body << YAML::Key << "SplashArea";
  1617. body << YAML::BeginSeq;
  1618. for (int i = 0; i < arr_size; i++) {
  1619. body << YAML::BeginMap;
  1620. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1621. body << YAML::Key << "Area" << YAML::Value << arr[i];
  1622. body << YAML::EndMap;
  1623. }
  1624. body << YAML::EndSeq;
  1625. }
  1626. }
  1627. memset(arr, 0, sizeof(arr));
  1628. arr_size = skill_split_atoi(split[12], arr);
  1629. if (arr_size != 0) {
  1630. if (arr_size == 1) {
  1631. if (arr[0] != 0) {
  1632. body << YAML::Key << "ActiveInstance";
  1633. body << YAML::Value << arr[0];
  1634. }
  1635. } else {
  1636. body << YAML::Key << "ActiveInstance";
  1637. body << YAML::BeginSeq;
  1638. for (int i = 0; i < arr_size; i++) {
  1639. body << YAML::BeginMap;
  1640. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1641. body << YAML::Key << "Max" << YAML::Value << arr[i];
  1642. body << YAML::EndMap;
  1643. }
  1644. body << YAML::EndSeq;
  1645. }
  1646. }
  1647. memset(arr, 0, sizeof(arr));
  1648. arr_size = skill_split_atoi(split[14], arr);
  1649. if (arr_size != 0) {
  1650. if (arr_size == 1) {
  1651. if (arr[0] != 0) {
  1652. body << YAML::Key << "Knockback";
  1653. body << YAML::Value << arr[0];
  1654. }
  1655. } else {
  1656. body << YAML::Key << "Knockback";
  1657. body << YAML::BeginSeq;
  1658. for (int i = 0; i < arr_size; i++) {
  1659. body << YAML::BeginMap;
  1660. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1661. body << YAML::Key << "Amount" << YAML::Value << arr[i];
  1662. body << YAML::EndMap;
  1663. }
  1664. body << YAML::EndSeq;
  1665. }
  1666. }
  1667. auto it_copyable = skill_copyable.find(skill_id);
  1668. if (it_copyable != skill_copyable.end()) {
  1669. body << YAML::Key << "CopyFlags";
  1670. body << YAML::BeginMap;
  1671. body << YAML::Key << "Skill";
  1672. body << YAML::BeginMap;
  1673. if (it_copyable->second.option & 1)
  1674. body << YAML::Key << "Plagiarism" << YAML::Value << "true";
  1675. if (it_copyable->second.option & 2)
  1676. body << YAML::Key << "Reproduce" << YAML::Value << "true";
  1677. body << YAML::EndMap;
  1678. if (it_copyable->second.req_opt > 0) {
  1679. body << YAML::Key << "RemoveRequirement";
  1680. body << YAML::BeginMap;
  1681. if (it_copyable->second.req_opt & 0x1)
  1682. body << YAML::Key << "HpCost" << YAML::Value << "true";
  1683. if (it_copyable->second.req_opt & 0x4)
  1684. body << YAML::Key << "SpCost" << YAML::Value << "true";
  1685. if (it_copyable->second.req_opt & 0x8)
  1686. body << YAML::Key << "HpRateCost" << YAML::Value << "true";
  1687. if (it_copyable->second.req_opt & 0x10)
  1688. body << YAML::Key << "SpRateCost" << YAML::Value << "true";
  1689. if (it_copyable->second.req_opt & 0x2)
  1690. body << YAML::Key << "MaxHpTrigger" << YAML::Value << "true";
  1691. if (it_copyable->second.req_opt & 0x20)
  1692. body << YAML::Key << "ZenyCost" << YAML::Value << "true";
  1693. if (it_copyable->second.req_opt & 0x40)
  1694. body << YAML::Key << "Weapon" << YAML::Value << "true";
  1695. if (it_copyable->second.req_opt & 0x80)
  1696. body << YAML::Key << "Ammo" << YAML::Value << "true";
  1697. if (it_copyable->second.req_opt & 0x100)
  1698. body << YAML::Key << "State" << YAML::Value << "true";
  1699. if (it_copyable->second.req_opt & 0x200)
  1700. body << YAML::Key << "Status" << YAML::Value << "true";
  1701. if (it_copyable->second.req_opt & 0x400)
  1702. body << YAML::Key << "SpiritSphereCost" << YAML::Value << "true";
  1703. if (it_copyable->second.req_opt & 0x800)
  1704. body << YAML::Key << "ItemCost" << YAML::Value << "true";
  1705. if (it_copyable->second.req_opt & 0x1000)
  1706. body << YAML::Key << "Equipment" << YAML::Value << "true";
  1707. body << YAML::EndMap;
  1708. }
  1709. body << YAML::EndMap;
  1710. }
  1711. auto it_nearnpc = skill_nearnpc.find(skill_id);
  1712. if (it_nearnpc != skill_nearnpc.end()) {
  1713. body << YAML::Key << "NoNearNPC";
  1714. body << YAML::BeginMap;
  1715. if (it_nearnpc->second.unit_nonearnpc_range > 0)
  1716. body << YAML::Key << "AdditionalRange" << YAML::Value << it_nearnpc->second.unit_nonearnpc_range;
  1717. if (it_nearnpc->second.unit_nonearnpc_type > 0) {
  1718. body << YAML::Key << "Type";
  1719. body << YAML::BeginMap;
  1720. if (it_nearnpc->second.unit_nonearnpc_type & 1)
  1721. body << YAML::Key << "WarpPortal" << YAML::Value << "true";
  1722. if (it_nearnpc->second.unit_nonearnpc_type & 2)
  1723. body << YAML::Key << "Shop" << YAML::Value << "true";
  1724. if (it_nearnpc->second.unit_nonearnpc_type & 4)
  1725. body << YAML::Key << "Npc" << YAML::Value << "true";
  1726. if (it_nearnpc->second.unit_nonearnpc_type & 8)
  1727. body << YAML::Key << "Tomb" << YAML::Value << "true";
  1728. body << YAML::EndMap;
  1729. }
  1730. body << YAML::EndMap;
  1731. }
  1732. if (strcmpi(split[9], "yes") == 0)
  1733. body << YAML::Key << "CastCancel" << YAML::Value << "true";
  1734. if (atoi(split[10]) != 0)
  1735. body << YAML::Key << "CastDefenseReduction" << YAML::Value << atoi(split[10]);
  1736. auto it_cast = skill_cast.find(skill_id);
  1737. if (it_cast != skill_cast.end()) {
  1738. if (!isMultiLevel(it_cast->second.cast)) {
  1739. if (it_cast->second.cast[0] > 0)
  1740. body << YAML::Key << "CastTime" << YAML::Value << it_cast->second.cast[0];
  1741. } else {
  1742. body << YAML::Key << "CastTime";
  1743. body << YAML::BeginSeq;
  1744. for (size_t i = 0; i < ARRAYLENGTH(it_cast->second.cast); i++) {
  1745. if (it_cast->second.cast[i] > 0) {
  1746. body << YAML::BeginMap;
  1747. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1748. body << YAML::Key << "Time" << YAML::Value << it_cast->second.cast[i];
  1749. body << YAML::EndMap;
  1750. }
  1751. }
  1752. body << YAML::EndSeq;
  1753. }
  1754. if (!isMultiLevel(it_cast->second.delay)) {
  1755. if (it_cast->second.delay[0] > 0)
  1756. body << YAML::Key << "AfterCastActDelay" << YAML::Value << it_cast->second.delay[0];
  1757. } else {
  1758. body << YAML::Key << "AfterCastActDelay";
  1759. body << YAML::BeginSeq;
  1760. for (size_t i = 0; i < ARRAYLENGTH(it_cast->second.delay); i++) {
  1761. if (it_cast->second.delay[i] > 0) {
  1762. body << YAML::BeginMap;
  1763. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1764. body << YAML::Key << "Time" << YAML::Value << it_cast->second.delay[i];
  1765. body << YAML::EndMap;
  1766. }
  1767. }
  1768. body << YAML::EndSeq;
  1769. }
  1770. if (!isMultiLevel(it_cast->second.walkdelay)) {
  1771. if (it_cast->second.walkdelay[0] > 0)
  1772. body << YAML::Key << "AfterCastWalkDelay" << YAML::Value << it_cast->second.walkdelay[0];
  1773. } else {
  1774. body << YAML::Key << "AfterCastWalkDelay";
  1775. body << YAML::BeginSeq;
  1776. for (size_t i = 0; i < ARRAYLENGTH(it_cast->second.walkdelay); i++) {
  1777. if (it_cast->second.walkdelay[i] > 0) {
  1778. body << YAML::BeginMap;
  1779. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1780. body << YAML::Key << "Time" << YAML::Value << it_cast->second.walkdelay[i];
  1781. body << YAML::EndMap;
  1782. }
  1783. }
  1784. body << YAML::EndSeq;
  1785. }
  1786. if (!isMultiLevel(it_cast->second.upkeep_time)) {
  1787. if (it_cast->second.upkeep_time[0] != 0)
  1788. body << YAML::Key << "Duration1" << YAML::Value << it_cast->second.upkeep_time[0];
  1789. } else {
  1790. body << YAML::Key << "Duration1";
  1791. body << YAML::BeginSeq;
  1792. for (size_t i = 0; i < ARRAYLENGTH(it_cast->second.upkeep_time); i++) {
  1793. if (it_cast->second.upkeep_time[i] != 0) {
  1794. body << YAML::BeginMap;
  1795. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1796. body << YAML::Key << "Time" << YAML::Value << it_cast->second.upkeep_time[i];
  1797. body << YAML::EndMap;
  1798. }
  1799. }
  1800. body << YAML::EndSeq;
  1801. }
  1802. if (!isMultiLevel(it_cast->second.upkeep_time2)) {
  1803. if (it_cast->second.upkeep_time2[0] != 0)
  1804. body << YAML::Key << "Duration2" << YAML::Value << it_cast->second.upkeep_time2[0];
  1805. } else {
  1806. body << YAML::Key << "Duration2";
  1807. body << YAML::BeginSeq;
  1808. for (size_t i = 0; i < ARRAYLENGTH(it_cast->second.upkeep_time2); i++) {
  1809. if (it_cast->second.upkeep_time2[i] != 0) {
  1810. body << YAML::BeginMap;
  1811. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1812. body << YAML::Key << "Time" << YAML::Value << it_cast->second.upkeep_time2[i];
  1813. body << YAML::EndMap;
  1814. }
  1815. }
  1816. body << YAML::EndSeq;
  1817. }
  1818. if (!isMultiLevel(it_cast->second.cooldown)) {
  1819. if (it_cast->second.cooldown[0] > 0)
  1820. body << YAML::Key << "Cooldown" << YAML::Value << it_cast->second.cooldown[0];
  1821. } else {
  1822. body << YAML::Key << "Cooldown";
  1823. body << YAML::BeginSeq;
  1824. for (size_t i = 0; i < ARRAYLENGTH(it_cast->second.cooldown); i++) {
  1825. if (it_cast->second.cooldown[i] > 0) {
  1826. body << YAML::BeginMap;
  1827. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1828. body << YAML::Key << "Time" << YAML::Value << it_cast->second.cooldown[i];
  1829. body << YAML::EndMap;
  1830. }
  1831. }
  1832. body << YAML::EndSeq;
  1833. }
  1834. #ifdef RENEWAL_CAST
  1835. if (!isMultiLevel(it_cast->second.fixed_cast)) {
  1836. if (it_cast->second.fixed_cast[0] != 0)
  1837. body << YAML::Key << "FixedCastTime" << YAML::Value << it_cast->second.fixed_cast[0];
  1838. } else {
  1839. body << YAML::Key << "FixedCastTime";
  1840. body << YAML::BeginSeq;
  1841. for (size_t i = 0; i < ARRAYLENGTH(it_cast->second.fixed_cast); i++) {
  1842. if (it_cast->second.fixed_cast[i] != 0) {
  1843. body << YAML::BeginMap;
  1844. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1845. body << YAML::Key << "Time" << YAML::Value << it_cast->second.fixed_cast[i];
  1846. body << YAML::EndMap;
  1847. }
  1848. }
  1849. body << YAML::EndSeq;
  1850. }
  1851. #endif
  1852. }
  1853. auto it_castdex = skill_castnodex.find(skill_id);
  1854. if (it_castdex != skill_castnodex.end()) {
  1855. if (it_castdex->second.castnodex > 0) {
  1856. body << YAML::Key << "CastTimeFlags";
  1857. body << YAML::BeginMap;
  1858. if (it_castdex->second.castnodex & 1)
  1859. body << YAML::Key << "IgnoreDex" << YAML::Value << "true";
  1860. if (it_castdex->second.castnodex & 2)
  1861. body << YAML::Key << "IgnoreStatus" << YAML::Value << "true";
  1862. if (it_castdex->second.castnodex & 4)
  1863. body << YAML::Key << "IgnoreItemBonus" << YAML::Value << "true";
  1864. body << YAML::EndMap;
  1865. }
  1866. if (it_castdex->second.delaynodex > 0) {
  1867. body << YAML::Key << "CastDelayFlags";
  1868. body << YAML::BeginMap;
  1869. if (it_castdex->second.delaynodex & 1)
  1870. body << YAML::Key << "IgnoreDex" << YAML::Value << "true";
  1871. if (it_castdex->second.delaynodex & 2)
  1872. body << YAML::Key << "IgnoreStatus" << YAML::Value << "true";
  1873. if (it_castdex->second.delaynodex & 4)
  1874. body << YAML::Key << "IgnoreItemBonus" << YAML::Value << "true";
  1875. body << YAML::EndMap;
  1876. }
  1877. }
  1878. auto it_req = skill_require.find(skill_id);
  1879. if (it_req != skill_require.end()) {
  1880. body << YAML::Key << "Requires";
  1881. body << YAML::BeginMap;
  1882. if (!isMultiLevel(it_req->second.hp)) {
  1883. if (it_req->second.hp[0] > 0)
  1884. body << YAML::Key << "HpCost" << YAML::Value << it_req->second.hp[0];
  1885. } else {
  1886. body << YAML::Key << "HpCost";
  1887. body << YAML::BeginSeq;
  1888. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.hp); i++) {
  1889. if (it_req->second.hp[i] > 0) {
  1890. body << YAML::BeginMap;
  1891. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1892. body << YAML::Key << "Amount" << YAML::Value << it_req->second.hp[i];
  1893. body << YAML::EndMap;
  1894. }
  1895. }
  1896. body << YAML::EndSeq;
  1897. }
  1898. if (!isMultiLevel(it_req->second.sp)) {
  1899. if (it_req->second.sp[0] > 0)
  1900. body << YAML::Key << "SpCost" << YAML::Value << it_req->second.sp[0];
  1901. } else {
  1902. body << YAML::Key << "SpCost";
  1903. body << YAML::BeginSeq;
  1904. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.sp); i++) {
  1905. if (it_req->second.sp[i] > 0) {
  1906. body << YAML::BeginMap;
  1907. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1908. body << YAML::Key << "Amount" << YAML::Value << it_req->second.sp[i];
  1909. body << YAML::EndMap;
  1910. }
  1911. }
  1912. body << YAML::EndSeq;
  1913. }
  1914. if (!isMultiLevel(it_req->second.hp_rate)) {
  1915. if (it_req->second.hp_rate[0] != 0)
  1916. body << YAML::Key << "HpRateCost" << YAML::Value << it_req->second.hp_rate[0];
  1917. } else {
  1918. body << YAML::Key << "HpRateCost";
  1919. body << YAML::BeginSeq;
  1920. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.hp_rate); i++) {
  1921. if (it_req->second.hp_rate[i] != 0) {
  1922. body << YAML::BeginMap;
  1923. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1924. body << YAML::Key << "Amount" << YAML::Value << it_req->second.hp_rate[i];
  1925. body << YAML::EndMap;
  1926. }
  1927. }
  1928. body << YAML::EndSeq;
  1929. }
  1930. if (!isMultiLevel(it_req->second.sp_rate)) {
  1931. if (it_req->second.sp_rate[0] != 0)
  1932. body << YAML::Key << "SpRateCost" << YAML::Value << it_req->second.sp_rate[0];
  1933. } else {
  1934. body << YAML::Key << "SpRateCost";
  1935. body << YAML::BeginSeq;
  1936. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.sp_rate); i++) {
  1937. if (it_req->second.sp_rate[i] != 0) {
  1938. body << YAML::BeginMap;
  1939. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1940. body << YAML::Key << "Amount" << YAML::Value << it_req->second.sp_rate[i];
  1941. body << YAML::EndMap;
  1942. }
  1943. }
  1944. body << YAML::EndSeq;
  1945. }
  1946. if (!isMultiLevel(it_req->second.mhp)) {
  1947. if (it_req->second.mhp[0] > 0)
  1948. body << YAML::Key << "MaxHpTrigger" << YAML::Value << it_req->second.mhp[0];
  1949. } else {
  1950. body << YAML::Key << "MaxHpTrigger";
  1951. body << YAML::BeginSeq;
  1952. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.mhp); i++) {
  1953. if (it_req->second.mhp[i] > 0) {
  1954. body << YAML::BeginMap;
  1955. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1956. body << YAML::Key << "Amount" << YAML::Value << it_req->second.mhp[i];
  1957. body << YAML::EndMap;
  1958. }
  1959. }
  1960. body << YAML::EndSeq;
  1961. }
  1962. if (!isMultiLevel(it_req->second.zeny)) {
  1963. if (it_req->second.zeny[0] > 0)
  1964. body << YAML::Key << "ZenyCost" << YAML::Value << it_req->second.zeny[0];
  1965. } else {
  1966. body << YAML::Key << "ZenyCost";
  1967. body << YAML::BeginSeq;
  1968. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.zeny); i++) {
  1969. if (it_req->second.zeny[i] > 0) {
  1970. body << YAML::BeginMap;
  1971. body << YAML::Key << "Level" << YAML::Value << i + 1;
  1972. body << YAML::Key << "Amount" << YAML::Value << it_req->second.zeny[i];
  1973. body << YAML::EndMap;
  1974. }
  1975. }
  1976. body << YAML::EndSeq;
  1977. }
  1978. if (it_req->second.weapon != 0) {
  1979. body << YAML::Key << "Weapon";
  1980. body << YAML::BeginMap;
  1981. int temp = it_req->second.weapon;
  1982. if (temp != 99) { // Not "All"
  1983. for (int i = 0; i < MAX_WEAPON_TYPE_ALL; i++) {
  1984. if (i == MAX_WEAPON_TYPE)
  1985. continue;
  1986. if (temp & 1 << i) {
  1987. constant = constant_lookup(i, "W_");
  1988. constant.erase(0, 2);
  1989. body << YAML::Key << name2Upper(constant) << YAML::Value << "true";
  1990. temp ^= 1 << i;
  1991. }
  1992. }
  1993. }
  1994. body << YAML::EndMap;
  1995. }
  1996. if (it_req->second.ammo != 0) {
  1997. body << YAML::Key << "Ammo";
  1998. body << YAML::BeginMap;
  1999. int temp = it_req->second.ammo;
  2000. for (int i = 1; i < MAX_AMMO_TYPE; i++) {
  2001. if (temp & 1 << i) {
  2002. constant = constant_lookup(i, "A_");
  2003. constant.erase(0, 2);
  2004. body << YAML::Key << name2Upper(constant) << YAML::Value << "true";
  2005. temp ^= 1 << i;
  2006. }
  2007. }
  2008. body << YAML::EndMap;
  2009. }
  2010. if (!isMultiLevel(it_req->second.ammo_qty)) {
  2011. if (it_req->second.ammo_qty[0] > 0)
  2012. body << YAML::Key << "AmmoAmount" << YAML::Value << it_req->second.ammo_qty[0];
  2013. } else {
  2014. body << YAML::Key << "AmmoAmount";
  2015. body << YAML::BeginSeq;
  2016. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.ammo_qty); i++) {
  2017. if (it_req->second.ammo_qty[i] > 0) {
  2018. body << YAML::BeginMap;
  2019. body << YAML::Key << "Level" << YAML::Value << i + 1;
  2020. body << YAML::Key << "Amount" << YAML::Value << it_req->second.ammo_qty[i];
  2021. body << YAML::EndMap;
  2022. }
  2023. }
  2024. body << YAML::EndSeq;
  2025. }
  2026. if (it_req->second.state) {
  2027. constant = constant_lookup(it_req->second.state, "ST_");
  2028. constant.erase(0, 3);
  2029. body << YAML::Key << "State" << YAML::Value << name2Upper(constant);
  2030. }
  2031. if (it_req->second.status.size() > 0) {
  2032. body << YAML::Key << "Status";
  2033. body << YAML::BeginMap;
  2034. for (const auto &it : it_req->second.status) {
  2035. constant = constant_lookup(it, "SC_");
  2036. constant.erase(0, 3);
  2037. body << YAML::Key << name2Upper(constant) << YAML::Value << "true";
  2038. }
  2039. body << YAML::EndMap;
  2040. }
  2041. if (!isMultiLevel(it_req->second.spiritball)) {
  2042. if (it_req->second.spiritball[0] != 0)
  2043. body << YAML::Key << "SpiritSphereCost" << YAML::Value << it_req->second.spiritball[0];
  2044. } else {
  2045. body << YAML::Key << "SpiritSphereCost";
  2046. body << YAML::BeginSeq;
  2047. for (size_t i = 0; i < ARRAYLENGTH(it_req->second.spiritball); i++) {
  2048. if (it_req->second.spiritball[i] != 0) {
  2049. body << YAML::BeginMap;
  2050. body << YAML::Key << "Level" << YAML::Value << i + 1;
  2051. body << YAML::Key << "Amount" << YAML::Value << it_req->second.spiritball[i];
  2052. body << YAML::EndMap;
  2053. }
  2054. }
  2055. body << YAML::EndSeq;
  2056. }
  2057. if (it_req->second.itemid[0] > 0) {
  2058. body << YAML::Key << "ItemCost";
  2059. body << YAML::BeginSeq;
  2060. for (uint8 i = 0; i < ARRAYLENGTH(it_req->second.itemid); i++) {
  2061. if (it_req->second.itemid[i] > 0) {
  2062. body << YAML::BeginMap;
  2063. std::string *item_name = util::umap_find(aegis_itemnames, it_req->second.itemid[i]);
  2064. if (item_name == nullptr) {
  2065. ShowError("Item name for item id %hu is not known (itemcost).\n", it_req->second.itemid[i]);
  2066. return false;
  2067. }
  2068. body << YAML::Key << "Item" << YAML::Value << *item_name;
  2069. body << YAML::Key << "Amount" << YAML::Value << it_req->second.amount[i];
  2070. body << YAML::EndMap;
  2071. }
  2072. }
  2073. body << YAML::EndSeq;
  2074. }
  2075. if (it_req->second.eqItem.size() > 0) {
  2076. body << YAML::Key << "Equipment";
  2077. body << YAML::BeginMap;
  2078. for (const auto &it : it_req->second.eqItem) {
  2079. std::string *item_name = util::umap_find(aegis_itemnames, it);
  2080. if (item_name == nullptr) {
  2081. ShowError("Item name for item id %u is not known (equipment).\n", it);
  2082. return false;
  2083. }
  2084. body << YAML::Key << *item_name << YAML::Value << "true";
  2085. }
  2086. body << YAML::EndMap;
  2087. }
  2088. body << YAML::EndMap;
  2089. }
  2090. auto it_unit = skill_unit.find(skill_id);
  2091. if (it_unit != skill_unit.end()) {
  2092. body << YAML::Key << "Unit";
  2093. body << YAML::BeginMap;
  2094. constant = constant_lookup(it_unit->second.unit_id, "UNT_");
  2095. constant.erase(0, 4);
  2096. body << YAML::Key << "Id" << YAML::Value << name2Upper(constant);
  2097. if (it_unit->second.unit_id2 > 0) {
  2098. constant = constant_lookup(it_unit->second.unit_id2, "UNT_");
  2099. constant.erase(0, 4);
  2100. body << YAML::Key << "AlternateId" << YAML::Value << name2Upper(constant);
  2101. }
  2102. if (!isMultiLevel(it_unit->second.unit_layout_type)) {
  2103. if (it_unit->second.unit_layout_type[0] != 0)
  2104. body << YAML::Key << "Layout" << YAML::Value << it_unit->second.unit_layout_type[0];
  2105. } else {
  2106. body << YAML::Key << "Layout";
  2107. body << YAML::BeginSeq;
  2108. for (size_t i = 0; i < ARRAYLENGTH(it_unit->second.unit_layout_type); i++) {
  2109. if (it_unit->second.unit_layout_type[i] == 0 && i + 1 > 5)
  2110. continue;
  2111. body << YAML::BeginMap;
  2112. body << YAML::Key << "Level" << YAML::Value << i + 1;
  2113. body << YAML::Key << "Size" << YAML::Value << it_unit->second.unit_layout_type[i];
  2114. body << YAML::EndMap;
  2115. }
  2116. body << YAML::EndSeq;
  2117. }
  2118. if (!isMultiLevel(it_unit->second.unit_range)) {
  2119. if (it_unit->second.unit_range[0] != 0)
  2120. body << YAML::Key << "Range" << YAML::Value << it_unit->second.unit_range[0];
  2121. } else {
  2122. body << YAML::Key << "Range";
  2123. body << YAML::BeginSeq;
  2124. for (size_t i = 0; i < ARRAYLENGTH(it_unit->second.unit_range); i++) {
  2125. if (it_unit->second.unit_range[i] == 0 && i + 1 > 5)
  2126. continue;
  2127. body << YAML::BeginMap;
  2128. body << YAML::Key << "Level" << YAML::Value << i + 1;
  2129. body << YAML::Key << "Size" << YAML::Value << it_unit->second.unit_range[i];
  2130. body << YAML::EndMap;
  2131. }
  2132. body << YAML::EndSeq;
  2133. }
  2134. if (it_unit->second.unit_interval != 0)
  2135. body << YAML::Key << "Interval" << YAML::Value << it_unit->second.unit_interval;
  2136. if (it_unit->second.target_str.size() > 0) {
  2137. if (it_unit->second.target_str.compare("noenemy") == 0 || it_unit->second.target_str.compare("friend") == 0)
  2138. body << YAML::Key << "Target" << YAML::Value << "Friend";
  2139. //else if (it_unit->second.target_str.compare("noenemy") == 0) // Same as Friend
  2140. // body << YAML::Key << "Target" << YAML::Value << "NoEnemy";
  2141. else if (it_unit->second.target_str.compare("party") == 0)
  2142. body << YAML::Key << "Target" << YAML::Value << "Party";
  2143. else if (it_unit->second.target_str.compare("ally") == 0)
  2144. body << YAML::Key << "Target" << YAML::Value << "Ally";
  2145. else if (it_unit->second.target_str.compare("guild") == 0)
  2146. body << YAML::Key << "Target" << YAML::Value << "Guild";
  2147. //else if (it_unit->second.target_str.compare("all") == 0)
  2148. // body << YAML::Key << "Target" << YAML::Value << "All";
  2149. else if (it_unit->second.target_str.compare("enemy") == 0)
  2150. body << YAML::Key << "Target" << YAML::Value << "Enemy";
  2151. else if (it_unit->second.target_str.compare("self") == 0)
  2152. body << YAML::Key << "Target" << YAML::Value << "Self";
  2153. else if (it_unit->second.target_str.compare("sameguild") == 0)
  2154. body << YAML::Key << "Target" << YAML::Value << "SameGuild";
  2155. }
  2156. if (it_unit->second.unit_flag_csv > 0) {
  2157. body << YAML::Key << "Flag";
  2158. body << YAML::BeginMap;
  2159. if (it_unit->second.unit_flag_csv & 0x1)
  2160. body << YAML::Value << "NoEnemy" << YAML::Value << "true";
  2161. if (it_unit->second.unit_flag_csv & 0x2)
  2162. body << YAML::Value << "NoReiteration" << YAML::Value << "true";
  2163. if (it_unit->second.unit_flag_csv & 0x4)
  2164. body << YAML::Value << "NoFootSet" << YAML::Value << "true";
  2165. if (it_unit->second.unit_flag_csv & 0x8)
  2166. body << YAML::Value << "NoOverlap" << YAML::Value << "true";
  2167. if (it_unit->second.unit_flag_csv & 0x10)
  2168. body << YAML::Value << "PathCheck" << YAML::Value << "true";
  2169. if (it_unit->second.unit_flag_csv & 0x20)
  2170. body << YAML::Value << "NoPc" << YAML::Value << "true";
  2171. if (it_unit->second.unit_flag_csv & 0x40)
  2172. body << YAML::Value << "NoMob" << YAML::Value << "true";
  2173. if (it_unit->second.unit_flag_csv & 0x80)
  2174. body << YAML::Value << "Skill" << YAML::Value << "true";
  2175. if (it_unit->second.unit_flag_csv & 0x100)
  2176. body << YAML::Value << "Dance" << YAML::Value << "true";
  2177. if (it_unit->second.unit_flag_csv & 0x200)
  2178. body << YAML::Value << "Ensemble" << YAML::Value << "true";
  2179. if (it_unit->second.unit_flag_csv & 0x400)
  2180. body << YAML::Value << "Song" << YAML::Value << "true";
  2181. if (it_unit->second.unit_flag_csv & 0x800)
  2182. body << YAML::Value << "DualMode" << YAML::Value << "true";
  2183. if (it_unit->second.unit_flag_csv & 0x1000)
  2184. body << YAML::Value << "NoKnockback" << YAML::Value << "true";
  2185. if (it_unit->second.unit_flag_csv & 0x2000)
  2186. body << YAML::Value << "RangedSingleUnit" << YAML::Value << "true";
  2187. if (it_unit->second.unit_flag_csv & 0x4000)
  2188. body << YAML::Value << "CrazyWeedImmune" << YAML::Value << "true";
  2189. if (it_unit->second.unit_flag_csv & 0x8000)
  2190. body << YAML::Value << "RemovedByFireRain" << YAML::Value << "true";
  2191. if (it_unit->second.unit_flag_csv & 0x10000)
  2192. body << YAML::Value << "KnockbackGroup" << YAML::Value << "true";
  2193. if (it_unit->second.unit_flag_csv & 0x20000)
  2194. body << YAML::Value << "HiddenTrap" << YAML::Value << "true";
  2195. body << YAML::EndMap;
  2196. }
  2197. body << YAML::EndMap;
  2198. }
  2199. body << YAML::EndMap;
  2200. return true;
  2201. }
  2202. // Copied and adjusted from quest.cpp
  2203. static bool quest_read_db(char *split[], int columns, int current) {
  2204. int quest_id = atoi(split[0]);
  2205. if (quest_id < 0 || quest_id >= INT_MAX) {
  2206. ShowError("quest_read_db: Invalid quest ID '%d'.\n", quest_id);
  2207. return false;
  2208. }
  2209. body << YAML::BeginMap;
  2210. body << YAML::Key << "Id" << YAML::Value << quest_id;
  2211. std::string title = split[17];
  2212. if (columns > 18) { // If the title has a comma in it, concatenate
  2213. int col = 18;
  2214. while (col < columns) {
  2215. title += ',' + std::string(split[col]);
  2216. col++;
  2217. }
  2218. }
  2219. title.erase(std::remove(title.begin(), title.end(), '"'), title.end()); // Strip double quotes out
  2220. body << YAML::Key << "Title" << YAML::Value << title;
  2221. if (strchr(split[1], ':') == NULL) {
  2222. uint32 time = atoi(split[1]);
  2223. if (time > 0) {
  2224. int day = time / 86400;
  2225. time %= (24 * 3600);
  2226. int hour = time / 3600;
  2227. time %= 3600;
  2228. int minute = time / 60;
  2229. time %= 60;
  2230. int second = time;
  2231. std::string output = "+";
  2232. if (day > 0)
  2233. output += std::to_string(day) + "d";
  2234. if (hour > 0)
  2235. output += std::to_string(hour) + "h";
  2236. if (minute > 0)
  2237. output += std::to_string(minute) + "mn";
  2238. if (second > 0)
  2239. output += std::to_string(second) + "s";
  2240. body << YAML::Key << "TimeLimit" << YAML::Value << output;
  2241. }
  2242. } else {
  2243. if (*split[1]) {
  2244. std::string time_str(split[1]), hour = time_str.substr(0, time_str.find(':')), output = {};
  2245. time_str.erase(0, 3); // Remove "HH:"
  2246. if (std::stoi(hour) > 0)
  2247. output = std::to_string(std::stoi(hour)) + "h";
  2248. if (std::stoi(time_str) > 0)
  2249. output += std::to_string(std::stoi(time_str)) + "mn";
  2250. body << YAML::Key << "TimeLimit" << YAML::Value << output; // No quests in TXT format had days, default to 0
  2251. }
  2252. }
  2253. if (atoi(split[2]) > 0) {
  2254. body << YAML::Key << "Targets";
  2255. body << YAML::BeginSeq;
  2256. for (size_t i = 0; i < MAX_QUEST_OBJECTIVES; i++) {
  2257. int32 mob_id = (int32)atoi(split[i * 2 + 2]), count = atoi(split[i * 2 + 3]);
  2258. if (!mob_id || !count)
  2259. continue;
  2260. std::string *mob_name = util::umap_find(aegis_mobnames, static_cast<uint16>(mob_id));
  2261. if (!mob_name) {
  2262. ShowError("quest_read_db: Invalid mob-class %hu, target not read.\n", mob_id);
  2263. continue;
  2264. }
  2265. body << YAML::BeginMap;
  2266. body << YAML::Key << "Mob" << YAML::Value << *mob_name;
  2267. body << YAML::Key << "Count" << YAML::Value << count;
  2268. body << YAML::EndMap;
  2269. }
  2270. body << YAML::EndSeq;
  2271. }
  2272. if (atoi(split[2 * MAX_QUEST_OBJECTIVES + 2]) > 0) {
  2273. body << YAML::Key << "Drops";
  2274. body << YAML::BeginSeq;
  2275. for (size_t i = 0; i < MAX_QUEST_DROPS; i++) {
  2276. int32 mob_id = (int32)atoi(split[3 * i + (2 * MAX_QUEST_OBJECTIVES + 2)]);
  2277. t_itemid nameid = strtoul(split[3 * i + (2 * MAX_QUEST_OBJECTIVES + 3)], nullptr, 10);
  2278. if (!mob_id || !nameid)
  2279. continue;
  2280. std::string *mob_name = util::umap_find(aegis_mobnames, static_cast<uint16>(mob_id));
  2281. if (!mob_name) {
  2282. ShowError("quest_read_db: Invalid mob-class %hu, drop not read.\n", mob_id);
  2283. continue;
  2284. }
  2285. std::string *item_name = util::umap_find(aegis_itemnames, nameid);
  2286. if (!item_name) {
  2287. ShowError("quest_read_db: Invalid item name %u, drop not read.\n", nameid);
  2288. return false;
  2289. }
  2290. body << YAML::BeginMap;
  2291. body << YAML::Key << "Mob" << YAML::Value << *mob_name;
  2292. body << YAML::Key << "Item" << YAML::Value << *item_name;
  2293. //body << YAML::Key << "Count" << YAML::Value << 1; // Default is 1
  2294. body << YAML::Key << "Rate" << YAML::Value << atoi(split[3 * i + (2 * MAX_QUEST_OBJECTIVES + 4)]);
  2295. body << YAML::EndMap;
  2296. }
  2297. body << YAML::EndSeq;
  2298. }
  2299. body << YAML::EndMap;
  2300. return true;
  2301. }
  2302. // Copied and adjusted from instance.cpp
  2303. static bool instance_readdb_sub(char* str[], int columns, int current) {
  2304. body << YAML::BeginMap;
  2305. body << YAML::Key << "Id" << YAML::Value << atoi(str[0]);
  2306. body << YAML::Key << "Name" << YAML::Value << str[1];
  2307. if (atoi(str[2]) != 3600)
  2308. body << YAML::Key << "TimeLimit" << YAML::Value << atoi(str[2]);
  2309. if (atoi(str[3]) != 300)
  2310. body << YAML::Key << "IdleTimeOut" << YAML::Value << atoi(str[3]);
  2311. body << YAML::Key << "Enter";
  2312. body << YAML::BeginMap;
  2313. body << YAML::Key << "Map" << YAML::Value << str[4];
  2314. body << YAML::Key << "X" << YAML::Value << atoi(str[5]);
  2315. body << YAML::Key << "Y" << YAML::Value << atoi(str[6]);
  2316. body << YAML::EndMap;
  2317. if (columns > 7) {
  2318. body << YAML::Key << "AdditionalMaps";
  2319. body << YAML::BeginMap;
  2320. for (int i = 7; i < columns; i++) {
  2321. if (!strlen(str[i]))
  2322. continue;
  2323. if (strcmpi(str[4], str[i]) == 0)
  2324. continue;
  2325. body << YAML::Key << str[i] << YAML::Value << "true";
  2326. }
  2327. body << YAML::EndMap;
  2328. }
  2329. body << YAML::EndMap;
  2330. return true;
  2331. }
  2332. // item_db.yml function
  2333. //---------------------
  2334. static bool itemdb_read_itemavail(char *str[], int columns, int current) {
  2335. item_avail.insert({ strtoul(str[0], nullptr, 10), strtoul(str[1], nullptr, 10) });
  2336. return true;
  2337. }
  2338. // item_db.yml function
  2339. //---------------------
  2340. static bool itemdb_read_buyingstore(char* fields[], int columns, int current) {
  2341. item_buyingstore.insert({ strtoul(fields[0], nullptr, 10), true });
  2342. return true;
  2343. }
  2344. // item_db.yml function
  2345. //---------------------
  2346. static bool itemdb_read_flag(char* fields[], int columns, int current) {
  2347. s_item_flag_csv2yaml item = { 0 };
  2348. uint16 flag = abs(atoi(fields[1]));
  2349. if (flag & 1)
  2350. item.dead_branch = true;
  2351. if (flag & 2)
  2352. item.group = true;
  2353. if (flag & 4)
  2354. item.guid = true;
  2355. if (flag & 8)
  2356. item.bindOnEquip = true;
  2357. if (flag & 16)
  2358. item.broadcast = true;
  2359. if (flag & 32)
  2360. item.delay_consume = true;
  2361. if (flag & 64)
  2362. item.dropEffect = DROPEFFECT_CLIENT;
  2363. else if (flag & 128)
  2364. item.dropEffect = DROPEFFECT_WHITE_PILLAR;
  2365. else if (flag & 256)
  2366. item.dropEffect = DROPEFFECT_BLUE_PILLAR;
  2367. else if (flag & 512)
  2368. item.dropEffect = DROPEFFECT_YELLOW_PILLAR;
  2369. else if (flag & 1024)
  2370. item.dropEffect = DROPEFFECT_PURPLE_PILLAR;
  2371. else if (flag & 2048)
  2372. item.dropEffect = DROPEFFECT_ORANGE_PILLAR;
  2373. item_flag.insert({ strtoul(fields[0], nullptr, 10), item });
  2374. return true;
  2375. }
  2376. // item_db.yml function
  2377. //---------------------
  2378. static bool itemdb_read_itemdelay(char* str[], int columns, int current) {
  2379. s_item_delay_csv2yaml item = { 0 };
  2380. item.delay = atoi(str[1]);
  2381. if (columns == 3)
  2382. item.sc = trim(str[2]);
  2383. item_delay.insert({ strtoul(str[0], nullptr, 10), item });
  2384. return true;
  2385. }
  2386. // item_db.yml function
  2387. //---------------------
  2388. static bool itemdb_read_stack(char* fields[], int columns, int current) {
  2389. s_item_stack_csv2yaml item = { 0 };
  2390. item.amount = atoi(fields[1]);
  2391. int type = strtoul(fields[2], NULL, 10);
  2392. if (type & 1)
  2393. item.inventory = true;
  2394. if (type & 2)
  2395. item.cart = true;
  2396. if (type & 4)
  2397. item.storage = true;
  2398. if (type & 8)
  2399. item.guild_storage = true;
  2400. item_stack.insert({ strtoul(fields[0], nullptr, 10), item });
  2401. return true;
  2402. }
  2403. // item_db.yml function
  2404. //---------------------
  2405. static bool itemdb_read_nouse(char* fields[], int columns, int current) {
  2406. s_item_nouse_csv2yaml item = { 0 };
  2407. item.sitting = "true";
  2408. item.override = atoi(fields[2]);
  2409. item_nouse.insert({ strtoul(fields[0], nullptr, 10), item });
  2410. return true;
  2411. }
  2412. // item_db.yml function
  2413. //---------------------
  2414. static bool itemdb_read_itemtrade(char* str[], int columns, int current) {
  2415. s_item_trade_csv2yaml item = { 0 };
  2416. int flag = atoi(str[1]);
  2417. if (flag & 1)
  2418. item.drop = true;
  2419. if (flag & 2)
  2420. item.trade = true;
  2421. if (flag & 4)
  2422. item.trade_partner = true;
  2423. if (flag & 8)
  2424. item.sell = true;
  2425. if (flag & 16)
  2426. item.cart = true;
  2427. if (flag & 32)
  2428. item.storage = true;
  2429. if (flag & 64)
  2430. item.guild_storage = true;
  2431. if (flag & 128)
  2432. item.mail = true;
  2433. if (flag & 256)
  2434. item.auction = true;
  2435. item.override = atoi(str[2]);
  2436. item_trade.insert({ strtoul(str[0], nullptr, 10), item });
  2437. return true;
  2438. }
  2439. // Copied and adjusted from itemdb.cpp
  2440. static bool itemdb_read_db(const char* file) {
  2441. FILE* fp = fopen(file, "r");
  2442. if (fp == nullptr) {
  2443. ShowError("can't read %s\n", file);
  2444. return false;
  2445. }
  2446. int lines = 0;
  2447. size_t entries = 0;
  2448. char line[1024];
  2449. while (fgets(line, sizeof(line), fp)) {
  2450. char* str[32], * p;
  2451. int i;
  2452. lines++;
  2453. if (line[0] == '/' && line[1] == '/')
  2454. continue;
  2455. memset(str, 0, sizeof(str));
  2456. p = strstr(line, "//");
  2457. if (p != nullptr) {
  2458. *p = '\0';
  2459. }
  2460. p = line;
  2461. while (ISSPACE(*p))
  2462. ++p;
  2463. if (*p == '\0')
  2464. continue;// empty line
  2465. for (i = 0; i < 19; ++i) {
  2466. str[i] = p;
  2467. p = strchr(p, ',');
  2468. if (p == NULL)
  2469. break;// comma not found
  2470. *p = '\0';
  2471. ++p;
  2472. }
  2473. if (p == NULL) {
  2474. ShowError("itemdb_read_db: Insufficient columns in line %d (item with id %u), skipping.\n", lines, strtoul(str[0], nullptr, 10));
  2475. continue;
  2476. }
  2477. // Script
  2478. if (*p != '{') {
  2479. ShowError("itemdb_read_db: Invalid format (Script column) in line %d (item with id %u), skipping.\n", lines, strtoul(str[0], nullptr, 10));
  2480. continue;
  2481. }
  2482. str[19] = p + 1;
  2483. p = strstr(p + 1, "},");
  2484. if (p == NULL) {
  2485. ShowError("itemdb_read_db: Invalid format (Script column) in line %d (item with id %u), skipping.\n", lines, strtoul(str[0], nullptr, 10));
  2486. continue;
  2487. }
  2488. *p = '\0';
  2489. p += 2;
  2490. // OnEquip_Script
  2491. if (*p != '{') {
  2492. ShowError("itemdb_read_db: Invalid format (OnEquip_Script column) in line %d (item with id %u), skipping.\n", lines, strtoul(str[0], nullptr, 10));
  2493. continue;
  2494. }
  2495. str[20] = p + 1;
  2496. p = strstr(p + 1, "},");
  2497. if (p == NULL) {
  2498. ShowError("itemdb_read_db: Invalid format (OnEquip_Script column) in line %d (item with id %u), skipping.\n", lines, strtoul(str[0], nullptr, 10));
  2499. continue;
  2500. }
  2501. *p = '\0';
  2502. p += 2;
  2503. // OnUnequip_Script (last column)
  2504. if (*p != '{') {
  2505. ShowError("itemdb_read_db: Invalid format (OnUnequip_Script column) in line %d (item with id %u), skipping.\n", lines, strtoul(str[0], nullptr, 10));
  2506. continue;
  2507. }
  2508. str[21] = p;
  2509. p = &str[21][strlen(str[21]) - 2];
  2510. if (*p != '}') {
  2511. /* lets count to ensure it's not something silly e.g. a extra space at line ending */
  2512. int lcurly = 0, rcurly = 0;
  2513. for (size_t v = 0; v < strlen(str[21]); v++) {
  2514. if (str[21][v] == '{')
  2515. lcurly++;
  2516. else if (str[21][v] == '}') {
  2517. rcurly++;
  2518. p = &str[21][v];
  2519. }
  2520. }
  2521. if (lcurly != rcurly) {
  2522. ShowError("itemdb_read_db: Mismatching curly braces in line %d (item with id %u), skipping.\n", lines, strtoul(str[0], nullptr, 10));
  2523. continue;
  2524. }
  2525. }
  2526. str[21] = str[21] + 1; //skip the first left curly
  2527. *p = '\0'; //null the last right curly
  2528. t_itemid nameid = strtoul(str[0], nullptr, 10);
  2529. body << YAML::BeginMap;
  2530. body << YAML::Key << "Id" << YAML::Value << nameid;
  2531. body << YAML::Key << "AegisName" << YAML::Value << str[1];
  2532. body << YAML::Key << "Name" << YAML::Value << str[2];
  2533. int type = atoi(str[3]), subtype = atoi(str[18]);
  2534. const char* constant = constant_lookup( type, "IT_" );
  2535. if( constant == nullptr ){
  2536. ShowError( "itemdb_read_db: Unknown item type %d for item %u, skipping.\n", type, nameid );
  2537. continue;
  2538. }
  2539. body << YAML::Key << "Type" << YAML::Value << name2Upper( constant + 3 );
  2540. if( type == IT_WEAPON && subtype ){
  2541. constant = constant_lookup( subtype, "W_" );
  2542. if( constant == nullptr ){
  2543. ShowError( "itemdb_read_db: Unknown weapon type %d for item %u, skipping.\n", subtype, nameid );
  2544. continue;
  2545. }
  2546. body << YAML::Key << "SubType" << YAML::Value << name2Upper( constant + 2 );
  2547. }else if( type == IT_AMMO && subtype ){
  2548. constant = constant_lookup( subtype, "AMMO_" );
  2549. if( constant == nullptr ){
  2550. ShowError( "itemdb_read_db: Unknown ammo type %d for item %u, skipping.\n", subtype, nameid );
  2551. continue;
  2552. }
  2553. body << YAML::Key << "SubType" << YAML::Value << name2Upper(constant + 5);
  2554. }
  2555. if (atoi(str[4]) > 0)
  2556. body << YAML::Key << "Buy" << YAML::Value << atoi(str[4]);
  2557. if (atoi(str[5]) > 0) {
  2558. if (atoi(str[4]) / 2 != atoi(str[5]))
  2559. body << YAML::Key << "Sell" << YAML::Value << atoi(str[5]);
  2560. }
  2561. if (atoi(str[6]) > 0)
  2562. body << YAML::Key << "Weight" << YAML::Value << atoi(str[6]);
  2563. #ifdef RENEWAL
  2564. int atk = 0, matk = 0;
  2565. itemdb_re_split_atoi(str[7], &atk, &matk);
  2566. if (atk > 0)
  2567. body << YAML::Key << "Attack" << YAML::Value << atk;
  2568. if (matk > 0)
  2569. body << YAML::Key << "MagicAttack" << YAML::Value << matk;
  2570. #else
  2571. if (atoi(str[7]) > 0)
  2572. body << YAML::Key << "Attack" << YAML::Value << atoi(str[7]);
  2573. #endif
  2574. if (atoi(str[8]) > 0)
  2575. body << YAML::Key << "Defense" << YAML::Value << atoi(str[8]);
  2576. if (atoi(str[9]) > 0)
  2577. body << YAML::Key << "Range" << YAML::Value << atoi(str[9]);
  2578. if (atoi(str[10]) > 0)
  2579. body << YAML::Key << "Slots" << YAML::Value << atoi(str[10]);
  2580. bool equippable = type == IT_UNKNOWN ? false : type == IT_ETC ? false : type == IT_CARD ? false : type == IT_PETEGG ? false : type == IT_PETARMOR ? false : type == IT_UNKNOWN2 ? false : true;
  2581. if (equippable) {
  2582. uint64 temp_mask = strtoull(str[11], NULL, 0);
  2583. if (temp_mask == 0) {
  2584. //body << YAML::Key << "Jobs";
  2585. //body << YAML::BeginMap << YAML::Key << "All" << YAML::Value << "false" << YAML::EndMap;
  2586. } else if (temp_mask == 0xFFFFFFFF) { // Commented out because it's the default value
  2587. //body << YAML::Key << "Jobs";
  2588. //body << YAML::BeginMap << YAML::Key << "All" << YAML::Value << "true" << YAML::EndMap;
  2589. } else if (temp_mask == 0xFFFFFFFE) {
  2590. body << YAML::Key << "Jobs";
  2591. body << YAML::BeginMap;
  2592. body << YAML::Key << "All" << YAML::Value << "true";
  2593. body << YAML::Key << "Novice" << YAML::Value << "false";
  2594. body << YAML::Key << "SuperNovice" << YAML::Value << "false";
  2595. body << YAML::EndMap;
  2596. } else {
  2597. body << YAML::Key << "Jobs";
  2598. body << YAML::BeginMap;
  2599. for (const auto &it : um_mapid2jobname) {
  2600. uint64 job_mask = 1ULL << it.second;
  2601. if ((temp_mask & job_mask) == job_mask)
  2602. body << YAML::Key << it.first << YAML::Value << "true";
  2603. }
  2604. body << YAML::EndMap;
  2605. }
  2606. int temp_class = atoi(str[12]);
  2607. if (temp_class == ITEMJ_NONE) {
  2608. body << YAML::Key << "Classes";
  2609. body << YAML::BeginMap << YAML::Key << "All" << YAML::Value << "false" << YAML::EndMap;
  2610. } else if (temp_class == ITEMJ_ALL) { // Commented out because it's the default value
  2611. //body << YAML::Key << "Classes";
  2612. //body << YAML::BeginMap << YAML::Key << "All" << YAML::Value << "true" << YAML::EndMap;
  2613. } else {
  2614. body << YAML::Key << "Classes";
  2615. body << YAML::BeginMap;
  2616. if ((ITEMJ_THIRD & temp_class) && (ITEMJ_THIRD_UPPER & temp_class) && (ITEMJ_THIRD_BABY & temp_class)) {
  2617. temp_class &= ~ITEMJ_ALL_THIRD;
  2618. body << YAML::Key << "All_Third" << YAML::Value << "true";
  2619. }
  2620. if ((ITEMJ_UPPER & temp_class) && (ITEMJ_THIRD_UPPER & temp_class)) {
  2621. temp_class &= ~ITEMJ_ALL_UPPER;
  2622. body << YAML::Key << "All_Upper" << YAML::Value << "true";
  2623. }
  2624. if ((ITEMJ_BABY & temp_class) && (ITEMJ_THIRD_BABY & temp_class)) {
  2625. temp_class &= ~ITEMJ_ALL_BABY;
  2626. body << YAML::Key << "All_Baby" << YAML::Value << "true";
  2627. }
  2628. for (int32 i = ITEMJ_NONE; i <= ITEMJ_THIRD_BABY; i++) {
  2629. if (i & temp_class) {
  2630. const char* class_ = constant_lookup(i, "ITEMJ_");
  2631. if (class_ != nullptr)
  2632. body << YAML::Key << name2Upper(class_ + 6) << YAML::Value << "true";
  2633. }
  2634. }
  2635. body << YAML::EndMap;
  2636. }
  2637. switch (atoi(str[13])) {
  2638. case SEX_FEMALE:
  2639. body << YAML::Key << "Gender" << YAML::Value << "Female";
  2640. break;
  2641. case SEX_MALE:
  2642. body << YAML::Key << "Gender" << YAML::Value << "Male";
  2643. break;
  2644. //case SEX_BOTH: // Commented out because it's the default value
  2645. // body << YAML::Key << "Gender" << YAML::Value << "Both";
  2646. // break;
  2647. }
  2648. }
  2649. if (atoi(str[14]) > 0) {
  2650. int temp_loc = atoi(str[14]);
  2651. body << YAML::Key << "Locations";
  2652. body << YAML::BeginMap;
  2653. if ((EQP_HAND_R & temp_loc) && (EQP_HAND_L & temp_loc)) {
  2654. temp_loc &= ~EQP_ARMS;
  2655. body << YAML::Key << "Both_Hand" << YAML::Value << "true";
  2656. }
  2657. if ((EQP_ACC_R & temp_loc) && (EQP_ACC_L & temp_loc)) {
  2658. temp_loc &= ~EQP_ACC_RL;
  2659. body << YAML::Key << "Both_Accessory" << YAML::Value << "true";
  2660. }
  2661. for (const auto &it : um_equipnames) {
  2662. if (it.second & temp_loc)
  2663. body << YAML::Key << it.first << YAML::Value << "true";
  2664. }
  2665. body << YAML::EndMap;
  2666. }
  2667. if (atoi(str[15]) > 0)
  2668. body << YAML::Key << "WeaponLevel" << YAML::Value << atoi(str[15]);
  2669. int elv = 0, elvmax = 0;
  2670. itemdb_re_split_atoi(str[16], &elv, &elvmax);
  2671. if (elv > 0)
  2672. body << YAML::Key << "EquipLevelMin" << YAML::Value << elv;
  2673. if (elvmax > 0)
  2674. body << YAML::Key << "EquipLevelMax" << YAML::Value << elvmax;
  2675. if (atoi(str[17]) > 0)
  2676. body << YAML::Key << "Refineable" << YAML::Value << "true";
  2677. if (strtoul(str[18], nullptr, 10) > 0 && type != IT_WEAPON && type != IT_AMMO)
  2678. body << YAML::Key << "View" << YAML::Value << strtoul(str[18], nullptr, 10);
  2679. auto it_avail = item_avail.find(nameid);
  2680. if (it_avail != item_avail.end()) {
  2681. std::string *item_name = util::umap_find(aegis_itemnames, static_cast<t_itemid>(it_avail->second));
  2682. if (item_name == nullptr)
  2683. ShowError("Item name for item id %u is not known (item_avail).\n", it_avail->second);
  2684. else
  2685. body << YAML::Key << "AliasName" << YAML::Value << *item_name;
  2686. }
  2687. auto it_flag = item_flag.find(nameid);
  2688. auto it_buying = item_buyingstore.find(nameid);
  2689. if (it_flag != item_flag.end() || it_buying != item_buyingstore.end()) {
  2690. body << YAML::Key << "Flags";
  2691. body << YAML::BeginMap;
  2692. if (it_buying != item_buyingstore.end())
  2693. body << YAML::Key << "BuyingStore" << YAML::Value << "true";
  2694. if (it_flag != item_flag.end() && it_flag->second.dead_branch)
  2695. body << YAML::Key << "DeadBranch" << YAML::Value << it_flag->second.dead_branch;
  2696. if (it_flag != item_flag.end() && it_flag->second.group)
  2697. body << YAML::Key << "Container" << YAML::Value << it_flag->second.group;
  2698. if (it_flag != item_flag.end() && it_flag->second.guid)
  2699. body << YAML::Key << "UniqueId" << YAML::Value << it_flag->second.guid;
  2700. if (it_flag != item_flag.end() && it_flag->second.bindOnEquip)
  2701. body << YAML::Key << "BindOnEquip" << YAML::Value << it_flag->second.bindOnEquip;
  2702. if (it_flag != item_flag.end() && it_flag->second.broadcast)
  2703. body << YAML::Key << "DropAnnounce" << YAML::Value << it_flag->second.broadcast;
  2704. if (it_flag != item_flag.end() && it_flag->second.delay_consume)
  2705. body << YAML::Key << "NoConsume" << YAML::Value << it_flag->second.delay_consume;
  2706. if (it_flag != item_flag.end() && it_flag->second.dropEffect)
  2707. body << YAML::Key << "DropEffect" << YAML::Value << name2Upper(constant_lookup(it_flag->second.dropEffect, "DROPEFFECT_") + 11);
  2708. body << YAML::EndMap;
  2709. }
  2710. auto it_delay = item_delay.find(nameid);
  2711. if (it_delay != item_delay.end()) {
  2712. body << YAML::Key << "Delay";
  2713. body << YAML::BeginMap;
  2714. body << YAML::Key << "Duration" << YAML::Value << it_delay->second.delay;
  2715. if (it_delay->second.sc.size() > 0)
  2716. body << YAML::Key << "Status" << YAML::Value << name2Upper(it_delay->second.sc.erase(0, 3));
  2717. body << YAML::EndMap;
  2718. }
  2719. auto it_stack = item_stack.find(nameid);
  2720. if (it_stack != item_stack.end()) {
  2721. body << YAML::Key << "Stack";
  2722. body << YAML::BeginMap;
  2723. body << YAML::Key << "Amount" << YAML::Value << it_stack->second.amount;
  2724. if (it_stack->second.inventory)
  2725. body << YAML::Key << "Inventory" << YAML::Value << it_stack->second.inventory;
  2726. if (it_stack->second.cart)
  2727. body << YAML::Key << "Cart" << YAML::Value << it_stack->second.cart;
  2728. if (it_stack->second.storage)
  2729. body << YAML::Key << "Storage" << YAML::Value << it_stack->second.storage;
  2730. if (it_stack->second.guild_storage)
  2731. body << YAML::Key << "GuildStorage" << YAML::Value << it_stack->second.guild_storage;
  2732. body << YAML::EndMap;
  2733. }
  2734. auto it_nouse = item_nouse.find(nameid);
  2735. if (it_nouse != item_nouse.end()) {
  2736. body << YAML::Key << "NoUse";
  2737. body << YAML::BeginMap;
  2738. body << YAML::Key << "Override" << YAML::Value << it_nouse->second.override;
  2739. body << YAML::Key << "Sitting" << YAML::Value << "true";
  2740. body << YAML::EndMap;
  2741. }
  2742. auto it_trade = item_trade.find(nameid);
  2743. if (it_trade != item_trade.end()) {
  2744. body << YAML::Key << "Trade";
  2745. body << YAML::BeginMap;
  2746. body << YAML::Key << "Override" << YAML::Value << it_trade->second.override;
  2747. if (it_trade->second.drop)
  2748. body << YAML::Key << "NoDrop" << YAML::Value << it_trade->second.drop;
  2749. if (it_trade->second.trade)
  2750. body << YAML::Key << "NoTrade" << YAML::Value << it_trade->second.trade;
  2751. if (it_trade->second.trade_partner)
  2752. body << YAML::Key << "TradePartner" << YAML::Value << it_trade->second.trade_partner;
  2753. if (it_trade->second.sell)
  2754. body << YAML::Key << "NoSell" << YAML::Value << it_trade->second.sell;
  2755. if (it_trade->second.cart)
  2756. body << YAML::Key << "NoCart" << YAML::Value << it_trade->second.cart;
  2757. if (it_trade->second.storage)
  2758. body << YAML::Key << "NoStorage" << YAML::Value << it_trade->second.storage;
  2759. if (it_trade->second.guild_storage)
  2760. body << YAML::Key << "NoGuildStorage" << YAML::Value << it_trade->second.guild_storage;
  2761. if (it_trade->second.mail)
  2762. body << YAML::Key << "NoMail" << YAML::Value << it_trade->second.mail;
  2763. if (it_trade->second.auction)
  2764. body << YAML::Key << "NoAuction" << YAML::Value << it_trade->second.auction;
  2765. body << YAML::EndMap;
  2766. }
  2767. if (*str[19])
  2768. body << YAML::Key << "Script" << YAML::Value << YAML::Literal << trim(str[19]);
  2769. if (*str[20])
  2770. body << YAML::Key << "EquipScript" << YAML::Value << YAML::Literal << trim(str[20]);
  2771. if (*str[21])
  2772. body << YAML::Key << "UnEquipScript" << YAML::Value << YAML::Literal << trim(str[21]);
  2773. body << YAML::EndMap;
  2774. entries++;
  2775. }
  2776. fclose(fp);
  2777. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' items in '" CL_WHITE "%s" CL_RESET "'.\n", entries, file);
  2778. return true;
  2779. }
  2780. // Copied and adjusted from itemdb.cpp
  2781. static bool itemdb_read_randomopt(const char* file) {
  2782. FILE* fp = fopen( file, "r" );
  2783. if( fp == nullptr ){
  2784. ShowError( "Can't read %s\n", file );
  2785. return 0;
  2786. }
  2787. uint32 lines = 0, count = 0;
  2788. char line[1024];
  2789. char path[256];
  2790. while (fgets(line, sizeof(line), fp)) {
  2791. char *str[2], *p;
  2792. lines++;
  2793. if (line[0] == '/' && line[1] == '/') // Ignore comments
  2794. continue;
  2795. memset(str, 0, sizeof(str));
  2796. p = trim(line);
  2797. if (*p == '\0')
  2798. continue;// empty line
  2799. if (!strchr(p, ','))
  2800. {
  2801. ShowError("itemdb_read_randomopt: Insufficient columns in line %d of \"%s\", skipping.\n", lines, path);
  2802. continue;
  2803. }
  2804. str[0] = p;
  2805. p = strchr(p, ',');
  2806. *p = '\0';
  2807. p++;
  2808. str[1] = p;
  2809. if (str[1][0] != '{') {
  2810. ShowError("itemdb_read_randomopt(#1): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path);
  2811. continue;
  2812. }
  2813. /* no ending key anywhere (missing \}\) */
  2814. if (str[1][strlen(str[1]) - 1] != '}') {
  2815. ShowError("itemdb_read_randomopt(#2): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path);
  2816. continue;
  2817. } else {
  2818. str[0] = trim(str[0]);
  2819. int64 id = constant_lookup_int(str[0]);
  2820. if (id == -100) {
  2821. ShowError("itemdb_read_randomopt: Unknown random option '%s' constant, skipping.\n", str[0]);
  2822. continue;
  2823. }
  2824. body << YAML::BeginMap;
  2825. body << YAML::Key << "Id" << YAML::Value << id;
  2826. body << YAML::Key << "Option" << YAML::Value << str[0] + 7;
  2827. body << YAML::Key << "Script" << YAML::Literal << str[1];
  2828. body << YAML::EndMap;
  2829. rand_opt_db.insert({ count, str[0] + 7 });
  2830. }
  2831. count++;
  2832. }
  2833. fclose(fp);
  2834. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", count, file);
  2835. return true;
  2836. }
  2837. // Copied and adjusted from itemdb.cpp
  2838. static bool itemdb_read_randomopt_group(char* str[], int columns, int current) {
  2839. if ((columns - 2) % 3 != 0) {
  2840. ShowError("itemdb_read_randomopt_group: Invalid column entries '%d'.\n", columns);
  2841. return false;
  2842. }
  2843. uint16 id = static_cast<uint16>(rand_opt_group.size() + 1);
  2844. s_random_opt_group_csv *group = util::umap_find(rand_opt_group, id);
  2845. s_random_opt_group_csv group_entry;
  2846. if (group == nullptr)
  2847. group_entry.rate.push_back((uint16)strtoul(str[1], nullptr, 10));
  2848. for (int j = 0, k = 2; k < columns && j < MAX_ITEM_RDM_OPT; k += 3) {
  2849. int32 randid_tmp = -1;
  2850. for (const auto &opt : rand_opt_db) {
  2851. if (opt.second.compare(str[k]) == 0) {
  2852. randid_tmp = opt.first;
  2853. break;
  2854. }
  2855. }
  2856. if (randid_tmp < 0) {
  2857. ShowError("itemdb_read_randomopt_group: Invalid random group id '%s' in column %d!\n", str[k], k + 1);
  2858. continue;
  2859. }
  2860. std::vector<std::shared_ptr<s_random_opt_group_entry>> entries = {};
  2861. if (group != nullptr)
  2862. entries = group->slots[j];
  2863. std::shared_ptr<s_random_opt_group_entry> entry;
  2864. entry->id = static_cast<uint16>(randid_tmp);
  2865. entry->min_value = (int16)strtoul(str[k + 1], nullptr, 10);
  2866. entry->max_value = 0;
  2867. entry->param = (int8)strtoul(str[k + 2], nullptr, 10);
  2868. entry->chance = 0;
  2869. entries.push_back(entry);
  2870. if (group == nullptr)
  2871. group_entry.slots[j] = entries;
  2872. else
  2873. group->slots[j] = entries;
  2874. j++;
  2875. }
  2876. if (group == nullptr)
  2877. rand_opt_group.insert({ id, group_entry });
  2878. return true;
  2879. }
  2880. static bool itemdb_randomopt_group_yaml(void) {
  2881. for (const auto &it : rand_opt_group) {
  2882. body << YAML::BeginMap;
  2883. body << YAML::Key << "Id" << YAML::Value << it.first;
  2884. body << YAML::Key << "Group" << YAML::Value << it.second.name;
  2885. body << YAML::Key << "Slots";
  2886. body << YAML::BeginSeq;
  2887. for (size_t i = 0; i < it.second.rate.size(); i++) {
  2888. body << YAML::BeginMap;
  2889. body << YAML::Key << "Slot" << YAML::Value << i + 1;
  2890. body << YAML::Key << "Options";
  2891. body << YAML::BeginSeq;
  2892. for (size_t j = 0; j < it.second.slots.size(); j++) {
  2893. std::vector<std::shared_ptr<s_random_opt_group_entry>> options = it.second.slots.at(static_cast<uint16>(j));
  2894. for (const auto &opt_it : options) {
  2895. body << YAML::BeginMap;
  2896. for (const auto &opt : rand_opt_db) {
  2897. if (opt.first == opt_it->id) {
  2898. body << YAML::Key << "Option" << YAML::Value << opt.second;
  2899. break;
  2900. }
  2901. }
  2902. if (opt_it->min_value != 0)
  2903. body << YAML::Key << "MinValue" << YAML::Value << opt_it->min_value;
  2904. if (opt_it->param != 0)
  2905. body << YAML::Key << "Param" << YAML::Value << opt_it->param;
  2906. body << YAML::Key << "Chance" << YAML::Value << it.second.rate[i];
  2907. body << YAML::EndMap;
  2908. }
  2909. }
  2910. body << YAML::EndSeq;
  2911. body << YAML::EndMap;
  2912. }
  2913. body << YAML::EndSeq;
  2914. body << YAML::EndMap;
  2915. }
  2916. return true;
  2917. }
  2918. // Initialize Random Option constants
  2919. void init_random_option_constants() {
  2920. #define export_constant2(a, b) script_set_constant_(a, b, a, false, false)
  2921. export_constant2("RDMOPT_VAR_MAXHPAMOUNT", 1);
  2922. export_constant2("RDMOPT_VAR_MAXSPAMOUNT", 2);
  2923. export_constant2("RDMOPT_VAR_STRAMOUNT", 3);
  2924. export_constant2("RDMOPT_VAR_AGIAMOUNT", 4);
  2925. export_constant2("RDMOPT_VAR_VITAMOUNT", 5);
  2926. export_constant2("RDMOPT_VAR_INTAMOUNT", 6);
  2927. export_constant2("RDMOPT_VAR_DEXAMOUNT", 7);
  2928. export_constant2("RDMOPT_VAR_LUKAMOUNT", 8);
  2929. export_constant2("RDMOPT_VAR_MAXHPPERCENT", 9);
  2930. export_constant2("RDMOPT_VAR_MAXSPPERCENT", 10);
  2931. export_constant2("RDMOPT_VAR_HPACCELERATION", 11);
  2932. export_constant2("RDMOPT_VAR_SPACCELERATION", 12);
  2933. export_constant2("RDMOPT_VAR_ATKPERCENT", 13);
  2934. export_constant2("RDMOPT_VAR_MAGICATKPERCENT", 14);
  2935. export_constant2("RDMOPT_VAR_PLUSASPD", 15);
  2936. export_constant2("RDMOPT_VAR_PLUSASPDPERCENT", 16);
  2937. export_constant2("RDMOPT_VAR_ATTPOWER", 17);
  2938. export_constant2("RDMOPT_VAR_HITSUCCESSVALUE", 18);
  2939. export_constant2("RDMOPT_VAR_ATTMPOWER", 19);
  2940. export_constant2("RDMOPT_VAR_ITEMDEFPOWER", 20);
  2941. export_constant2("RDMOPT_VAR_MDEFPOWER", 21);
  2942. export_constant2("RDMOPT_VAR_AVOIDSUCCESSVALUE", 22);
  2943. export_constant2("RDMOPT_VAR_PLUSAVOIDSUCCESSVALUE", 23);
  2944. export_constant2("RDMOPT_VAR_CRITICALSUCCESSVALUE", 24);
  2945. export_constant2("RDMOPT_ATTR_TOLERACE_NOTHING", 25);
  2946. export_constant2("RDMOPT_ATTR_TOLERACE_WATER", 26);
  2947. export_constant2("RDMOPT_ATTR_TOLERACE_GROUND", 27);
  2948. export_constant2("RDMOPT_ATTR_TOLERACE_FIRE", 28);
  2949. export_constant2("RDMOPT_ATTR_TOLERACE_WIND", 29);
  2950. export_constant2("RDMOPT_ATTR_TOLERACE_POISON", 30);
  2951. export_constant2("RDMOPT_ATTR_TOLERACE_SAINT", 31);
  2952. export_constant2("RDMOPT_ATTR_TOLERACE_DARKNESS", 32);
  2953. export_constant2("RDMOPT_ATTR_TOLERACE_TELEKINESIS", 33);
  2954. export_constant2("RDMOPT_ATTR_TOLERACE_UNDEAD", 34);
  2955. export_constant2("RDMOPT_ATTR_TOLERACE_ALLBUTNOTHING", 35);
  2956. export_constant2("RDMOPT_DAMAGE_PROPERTY_NOTHING_USER", 36);
  2957. export_constant2("RDMOPT_DAMAGE_PROPERTY_NOTHING_TARGET", 37);
  2958. export_constant2("RDMOPT_DAMAGE_PROPERTY_WATER_USER", 38);
  2959. export_constant2("RDMOPT_DAMAGE_PROPERTY_WATER_TARGET", 39);
  2960. export_constant2("RDMOPT_DAMAGE_PROPERTY_GROUND_USER", 40);
  2961. export_constant2("RDMOPT_DAMAGE_PROPERTY_GROUND_TARGET", 41);
  2962. export_constant2("RDMOPT_DAMAGE_PROPERTY_FIRE_USER", 42);
  2963. export_constant2("RDMOPT_DAMAGE_PROPERTY_FIRE_TARGET", 43);
  2964. export_constant2("RDMOPT_DAMAGE_PROPERTY_WIND_USER", 44);
  2965. export_constant2("RDMOPT_DAMAGE_PROPERTY_WIND_TARGET", 45);
  2966. export_constant2("RDMOPT_DAMAGE_PROPERTY_POISON_USER", 46);
  2967. export_constant2("RDMOPT_DAMAGE_PROPERTY_POISON_TARGET", 47);
  2968. export_constant2("RDMOPT_DAMAGE_PROPERTY_SAINT_USER", 48);
  2969. export_constant2("RDMOPT_DAMAGE_PROPERTY_SAINT_TARGET", 49);
  2970. export_constant2("RDMOPT_DAMAGE_PROPERTY_DARKNESS_USER", 50);
  2971. export_constant2("RDMOPT_DAMAGE_PROPERTY_DARKNESS_TARGET", 51);
  2972. export_constant2("RDMOPT_DAMAGE_PROPERTY_TELEKINESIS_USER", 52);
  2973. export_constant2("RDMOPT_DAMAGE_PROPERTY_TELEKINESIS_TARGET", 53);
  2974. export_constant2("RDMOPT_DAMAGE_PROPERTY_UNDEAD_USER", 54);
  2975. export_constant2("RDMOPT_DAMAGE_PROPERTY_UNDEAD_TARGET", 55);
  2976. export_constant2("RDMOPT_MDAMAGE_PROPERTY_NOTHING_USER", 56);
  2977. export_constant2("RDMOPT_MDAMAGE_PROPERTY_NOTHING_TARGET", 57);
  2978. export_constant2("RDMOPT_MDAMAGE_PROPERTY_WATER_USER", 58);
  2979. export_constant2("RDMOPT_MDAMAGE_PROPERTY_WATER_TARGET", 59);
  2980. export_constant2("RDMOPT_MDAMAGE_PROPERTY_GROUND_USER", 60);
  2981. export_constant2("RDMOPT_MDAMAGE_PROPERTY_GROUND_TARGET", 61);
  2982. export_constant2("RDMOPT_MDAMAGE_PROPERTY_FIRE_USER", 62);
  2983. export_constant2("RDMOPT_MDAMAGE_PROPERTY_FIRE_TARGET", 63);
  2984. export_constant2("RDMOPT_MDAMAGE_PROPERTY_WIND_USER", 64);
  2985. export_constant2("RDMOPT_MDAMAGE_PROPERTY_WIND_TARGET", 65);
  2986. export_constant2("RDMOPT_MDAMAGE_PROPERTY_POISON_USER", 66);
  2987. export_constant2("RDMOPT_MDAMAGE_PROPERTY_POISON_TARGET", 67);
  2988. export_constant2("RDMOPT_MDAMAGE_PROPERTY_SAINT_USER", 68);
  2989. export_constant2("RDMOPT_MDAMAGE_PROPERTY_SAINT_TARGET", 69);
  2990. export_constant2("RDMOPT_MDAMAGE_PROPERTY_DARKNESS_USER", 70);
  2991. export_constant2("RDMOPT_MDAMAGE_PROPERTY_DARKNESS_TARGET", 71);
  2992. export_constant2("RDMOPT_MDAMAGE_PROPERTY_TELEKINESIS_USER", 72);
  2993. export_constant2("RDMOPT_MDAMAGE_PROPERTY_TELEKINESIS_TARGET", 73);
  2994. export_constant2("RDMOPT_MDAMAGE_PROPERTY_UNDEAD_USER", 74);
  2995. export_constant2("RDMOPT_MDAMAGE_PROPERTY_UNDEAD_TARGET", 75);
  2996. export_constant2("RDMOPT_BODY_ATTR_NOTHING", 76);
  2997. export_constant2("RDMOPT_BODY_ATTR_WATER", 77);
  2998. export_constant2("RDMOPT_BODY_ATTR_GROUND", 78);
  2999. export_constant2("RDMOPT_BODY_ATTR_FIRE", 79);
  3000. export_constant2("RDMOPT_BODY_ATTR_WIND", 80);
  3001. export_constant2("RDMOPT_BODY_ATTR_POISON", 81);
  3002. export_constant2("RDMOPT_BODY_ATTR_SAINT", 82);
  3003. export_constant2("RDMOPT_BODY_ATTR_DARKNESS", 83);
  3004. export_constant2("RDMOPT_BODY_ATTR_TELEKINESIS", 84);
  3005. export_constant2("RDMOPT_BODY_ATTR_UNDEAD", 85);
  3006. export_constant2("RDMOPT_RACE_TOLERACE_NOTHING", 87);
  3007. export_constant2("RDMOPT_RACE_TOLERACE_UNDEAD", 88);
  3008. export_constant2("RDMOPT_RACE_TOLERACE_ANIMAL", 89);
  3009. export_constant2("RDMOPT_RACE_TOLERACE_PLANT", 90);
  3010. export_constant2("RDMOPT_RACE_TOLERACE_INSECT", 91);
  3011. export_constant2("RDMOPT_RACE_TOLERACE_FISHS", 92);
  3012. export_constant2("RDMOPT_RACE_TOLERACE_DEVIL", 93);
  3013. export_constant2("RDMOPT_RACE_TOLERACE_HUMAN", 94);
  3014. export_constant2("RDMOPT_RACE_TOLERACE_ANGEL", 95);
  3015. export_constant2("RDMOPT_RACE_TOLERACE_DRAGON", 96);
  3016. export_constant2("RDMOPT_RACE_DAMAGE_NOTHING", 97);
  3017. export_constant2("RDMOPT_RACE_DAMAGE_UNDEAD", 98);
  3018. export_constant2("RDMOPT_RACE_DAMAGE_ANIMAL", 99);
  3019. export_constant2("RDMOPT_RACE_DAMAGE_PLANT", 100);
  3020. export_constant2("RDMOPT_RACE_DAMAGE_INSECT", 101);
  3021. export_constant2("RDMOPT_RACE_DAMAGE_FISHS", 102);
  3022. export_constant2("RDMOPT_RACE_DAMAGE_DEVIL", 103);
  3023. export_constant2("RDMOPT_RACE_DAMAGE_HUMAN", 104);
  3024. export_constant2("RDMOPT_RACE_DAMAGE_ANGEL", 105);
  3025. export_constant2("RDMOPT_RACE_DAMAGE_DRAGON", 106);
  3026. export_constant2("RDMOPT_RACE_MDAMAGE_NOTHING", 107);
  3027. export_constant2("RDMOPT_RACE_MDAMAGE_UNDEAD", 108);
  3028. export_constant2("RDMOPT_RACE_MDAMAGE_ANIMAL", 109);
  3029. export_constant2("RDMOPT_RACE_MDAMAGE_PLANT", 110);
  3030. export_constant2("RDMOPT_RACE_MDAMAGE_INSECT", 111);
  3031. export_constant2("RDMOPT_RACE_MDAMAGE_FISHS", 112);
  3032. export_constant2("RDMOPT_RACE_MDAMAGE_DEVIL", 113);
  3033. export_constant2("RDMOPT_RACE_MDAMAGE_HUMAN", 114);
  3034. export_constant2("RDMOPT_RACE_MDAMAGE_ANGEL", 115);
  3035. export_constant2("RDMOPT_RACE_MDAMAGE_DRAGON", 116);
  3036. export_constant2("RDMOPT_RACE_CRI_PERCENT_NOTHING", 117);
  3037. export_constant2("RDMOPT_RACE_CRI_PERCENT_UNDEAD", 118);
  3038. export_constant2("RDMOPT_RACE_CRI_PERCENT_ANIMAL", 119);
  3039. export_constant2("RDMOPT_RACE_CRI_PERCENT_PLANT", 120);
  3040. export_constant2("RDMOPT_RACE_CRI_PERCENT_INSECT", 121);
  3041. export_constant2("RDMOPT_RACE_CRI_PERCENT_FISHS", 122);
  3042. export_constant2("RDMOPT_RACE_CRI_PERCENT_DEVIL", 123);
  3043. export_constant2("RDMOPT_RACE_CRI_PERCENT_HUMAN", 124);
  3044. export_constant2("RDMOPT_RACE_CRI_PERCENT_ANGEL", 125);
  3045. export_constant2("RDMOPT_RACE_CRI_PERCENT_DRAGON", 126);
  3046. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_NOTHING", 127);
  3047. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_UNDEAD", 128);
  3048. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_ANIMAL", 129);
  3049. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_PLANT", 130);
  3050. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_INSECT", 131);
  3051. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_FISHS", 132);
  3052. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_DEVIL", 133);
  3053. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_HUMAN", 134);
  3054. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_ANGEL", 135);
  3055. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_DRAGON", 136);
  3056. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_NOTHING", 137);
  3057. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_UNDEAD", 138);
  3058. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_ANIMAL", 139);
  3059. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_PLANT", 140);
  3060. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_INSECT", 141);
  3061. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_FISHS", 142);
  3062. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_DEVIL", 143);
  3063. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_HUMAN", 144);
  3064. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_ANGEL", 145);
  3065. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_DRAGON", 146);
  3066. export_constant2("RDMOPT_CLASS_DAMAGE_NORMAL_TARGET", 147);
  3067. export_constant2("RDMOPT_CLASS_DAMAGE_BOSS_TARGET", 148);
  3068. export_constant2("RDMOPT_CLASS_DAMAGE_NORMAL_USER", 149);
  3069. export_constant2("RDMOPT_CLASS_DAMAGE_BOSS_USER", 150);
  3070. export_constant2("RDMOPT_CLASS_MDAMAGE_NORMAL", 151);
  3071. export_constant2("RDMOPT_CLASS_MDAMAGE_BOSS", 152);
  3072. export_constant2("RDMOPT_CLASS_IGNORE_DEF_PERCENT_NORMAL", 153);
  3073. export_constant2("RDMOPT_CLASS_IGNORE_DEF_PERCENT_BOSS", 154);
  3074. export_constant2("RDMOPT_CLASS_IGNORE_MDEF_PERCENT_NORMAL", 155);
  3075. export_constant2("RDMOPT_CLASS_IGNORE_MDEF_PERCENT_BOSS", 156);
  3076. export_constant2("RDMOPT_DAMAGE_SIZE_SMALL_TARGET", 157);
  3077. export_constant2("RDMOPT_DAMAGE_SIZE_MIDIUM_TARGET", 158);
  3078. export_constant2("RDMOPT_DAMAGE_SIZE_LARGE_TARGET", 159);
  3079. export_constant2("RDMOPT_DAMAGE_SIZE_SMALL_USER", 160);
  3080. export_constant2("RDMOPT_DAMAGE_SIZE_MIDIUM_USER", 161);
  3081. export_constant2("RDMOPT_DAMAGE_SIZE_LARGE_USER", 162);
  3082. export_constant2("RDMOPT_DAMAGE_SIZE_PERFECT", 163);
  3083. export_constant2("RDMOPT_DAMAGE_CRI_TARGET", 164);
  3084. export_constant2("RDMOPT_DAMAGE_CRI_USER", 165);
  3085. export_constant2("RDMOPT_RANGE_ATTACK_DAMAGE_TARGET", 166);
  3086. export_constant2("RDMOPT_RANGE_ATTACK_DAMAGE_USER", 167);
  3087. export_constant2("RDMOPT_HEAL_VALUE", 168);
  3088. export_constant2("RDMOPT_HEAL_MODIFY_PERCENT", 169);
  3089. export_constant2("RDMOPT_DEC_SPELL_CAST_TIME", 170);
  3090. export_constant2("RDMOPT_DEC_SPELL_DELAY_TIME", 171);
  3091. export_constant2("RDMOPT_DEC_SP_CONSUMPTION", 172);
  3092. export_constant2("RDMOPT_WEAPON_ATTR_NOTHING", 175);
  3093. export_constant2("RDMOPT_WEAPON_ATTR_WATER", 176);
  3094. export_constant2("RDMOPT_WEAPON_ATTR_GROUND", 177);
  3095. export_constant2("RDMOPT_WEAPON_ATTR_FIRE", 178);
  3096. export_constant2("RDMOPT_WEAPON_ATTR_WIND", 179);
  3097. export_constant2("RDMOPT_WEAPON_ATTR_POISON", 180);
  3098. export_constant2("RDMOPT_WEAPON_ATTR_SAINT", 181);
  3099. export_constant2("RDMOPT_WEAPON_ATTR_DARKNESS", 182);
  3100. export_constant2("RDMOPT_WEAPON_ATTR_TELEKINESIS", 183);
  3101. export_constant2("RDMOPT_WEAPON_ATTR_UNDEAD", 184);
  3102. export_constant2("RDMOPT_WEAPON_INDESTRUCTIBLE", 185);
  3103. export_constant2("RDMOPT_BODY_INDESTRUCTIBLE", 186);
  3104. export_constant2("RDMOPT_MDAMAGE_SIZE_SMALL_TARGET", 187);
  3105. export_constant2("RDMOPT_MDAMAGE_SIZE_MIDIUM_TARGET", 188);
  3106. export_constant2("RDMOPT_MDAMAGE_SIZE_LARGE_TARGET", 189);
  3107. export_constant2("RDMOPT_MDAMAGE_SIZE_SMALL_USER", 190);
  3108. export_constant2("RDMOPT_MDAMAGE_SIZE_MIDIUM_USER", 191);
  3109. export_constant2("RDMOPT_MDAMAGE_SIZE_LARGE_USER", 192);
  3110. export_constant2("RDMOPT_ATTR_TOLERACE_ALL", 193);
  3111. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_NOTHING", 194);
  3112. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_UNDEAD", 195);
  3113. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_ANIMAL", 196);
  3114. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_PLANT", 197);
  3115. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_INSECT", 198);
  3116. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_FISHS", 199);
  3117. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_DEVIL", 200);
  3118. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_HUMAN", 201);
  3119. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_ANGEL", 202);
  3120. export_constant2("RDMOPT_RACE_WEAPON_TOLERACE_DRAGON", 203);
  3121. export_constant2("RDMOPT_RACE_TOLERACE_PLAYER_HUMAN", 206);
  3122. export_constant2("RDMOPT_RACE_TOLERACE_PLAYER_DORAM", 207);
  3123. export_constant2("RDMOPT_RACE_DAMAGE_PLAYER_HUMAN", 208);
  3124. export_constant2("RDMOPT_RACE_DAMAGE_PLAYER_DORAM", 209);
  3125. export_constant2("RDMOPT_RACE_MDAMAGE_PLAYER_HUMAN", 210);
  3126. export_constant2("RDMOPT_RACE_MDAMAGE_PLAYER_DORAM", 211);
  3127. export_constant2("RDMOPT_RACE_CRI_PERCENT_PLAYER_HUMAN", 212);
  3128. export_constant2("RDMOPT_RACE_CRI_PERCENT_PLAYER_DORAM", 213);
  3129. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_PLAYER_HUMAN", 214);
  3130. export_constant2("RDMOPT_RACE_IGNORE_DEF_PERCENT_PLAYER_DORAM", 215);
  3131. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_PLAYER_HUMAN", 216);
  3132. export_constant2("RDMOPT_RACE_IGNORE_MDEF_PERCENT_PLAYER_DORAM", 217);
  3133. export_constant2("RDMOPT_MELEE_ATTACK_DAMAGE_TARGET", 219);
  3134. export_constant2("RDMOPT_MELEE_ATTACK_DAMAGE_USER", 220);
  3135. #undef export_constant2
  3136. }