Guest User

Untitled

a guest
Oct 24th, 2016
115
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2.  
  3. #include <math.h>
  4. #include "ProtoReader.h"
  5.  
  6. #include "CsvReader.h"
  7.  
  8. #include <sstream>
  9.  
  10. using namespace std;
  11.  
  12. inline string trim_left(const string& str)
  13. {
  14. string::size_type n = str.find_first_not_of(" \t\v\n\r");
  15. return n == string::npos ? str : str.substr(n, str.length());
  16. }
  17.  
  18. inline string trim_right(const string& str)
  19. {
  20. string::size_type n = str.find_last_not_of(" \t\v\n\r");
  21. return n == string::npos ? str : str.substr(0, n + 1);
  22. }
  23.  
  24. string trim(const string& str){return trim_left(trim_right(str));}
  25.  
  26. static string* StringSplit(string strOrigin, string strTok)
  27. {
  28. unsigned int cutAt;
  29. int index = 0;
  30. string* strResult = new string[30];
  31.  
  32. while ((cutAt = strOrigin.find_first_of(strTok)) != strOrigin.npos)
  33. {
  34. if (cutAt > 0)
  35. {
  36. strResult[index++] = strOrigin.substr(0, cutAt);
  37. }
  38. strOrigin = strOrigin.substr(cutAt+1);
  39. }
  40.  
  41. if(strOrigin.length() > 0)
  42. {
  43. strResult[index++] = strOrigin.substr(0, cutAt);
  44. }
  45.  
  46. for( int i=0;i<index;i++)
  47. {
  48. strResult[i] = trim(strResult[i]);
  49. }
  50.  
  51. return strResult;
  52. }
  53.  
  54. int get_Item_Type_Value(string inputString)
  55. {
  56. string arType[] = {"ITEM_NONE", "ITEM_WEAPON",
  57. "ITEM_ARMOR",
  58. "ITEM_USE",
  59. "ITEM_AUTOUSE",
  60. "ITEM_MATERIAL",
  61. "ITEM_SPECIAL",
  62. "ITEM_TOOL",
  63. "ITEM_LOTTERY",
  64. "ITEM_ELK",
  65. "ITEM_METIN",
  66. "ITEM_CONTAINER",
  67. "ITEM_FISH",
  68. "ITEM_ROD",
  69. "ITEM_RESOURCE",
  70. "ITEM_CAMPFIRE",
  71. "ITEM_UNIQUE",
  72. "ITEM_SKILLBOOK",
  73. "ITEM_QUEST",
  74. "ITEM_POLYMORPH",
  75. "ITEM_TREASURE_BOX",
  76. "ITEM_TREASURE_KEY",
  77. "ITEM_SKILLFORGET",
  78. "ITEM_GIFTBOX",
  79. "ITEM_PICK",
  80. "ITEM_HAIR",
  81. "ITEM_TOTEM",
  82. "ITEM_BLEND",
  83. "ITEM_COSTUME",
  84. "ITEM_DS",
  85. "ITEM_SPECIAL_DS",
  86. "ITEM_EXTRACT",
  87. "ITEM_SECONDARY_COIN",
  88. "ITEM_RING",
  89. "ITEM_BELT",
  90. };
  91.  
  92.  
  93. int retInt = -1;
  94. for (unsigned int j=0;j<sizeof(arType)/sizeof(arType[0]);j++) {
  95. string tempString = arType[j];
  96. if (inputString.find(tempString)!=string::npos && tempString.find(inputString)!=string::npos) {
  97. retInt = j;
  98. break;
  99. }
  100. }
  101.  
  102. return retInt;
  103.  
  104. }
  105.  
  106. int get_Item_SubType_Value(unsigned int type_value, string inputString)
  107. {
  108. static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED","WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR", "WEAPON_CLAW"};
  109. static string arSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS", "ARMOR_NECK", "ARMOR_EAR", "ARMOR_NUM_TYPES"};
  110. static string arSub3[] = { "USE_POTION", "USE_TALISMAN", "USE_TUNING", "USE_MOVE", "USE_TREASURE_BOX", "USE_MONEYBAG", "USE_BAIT", "USE_ABILITY_UP", "USE_AFFECT", "USE_CREATE_STONE", "USE_SPECIAL", "USE_POTION_NODELAY", "USE_CLEAR", "USE_INVISIBILITY", "USE_DETACHMENT", "USE_BUCKET", "USE_POTION_CONTINUE", "USE_CLEAN_SOCKET", "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET", "USE_ADD_ATTRIBUTE2", "USE_RECIPE", "USE_CHANGE_ATTRIBUTE2", "USE_BIND", "USE_UNBIND", "USE_TIME_CHARGE_PER", "USE_TIME_CHARGE_FIX", "USE_PUT_INTO_BELT_SOCKET", "USE_PUT_INTO_RING_SOCKET"};
  111. static string arSub4[] = { "AUTOUSE_POTION", "AUTOUSE_ABILITY_UP", "AUTOUSE_BOMB", "AUTOUSE_GOLD", "AUTOUSE_MONEYBAG", "AUTOUSE_TREASURE_BOX"};
  112. static string arSub5[] = { "MATERIAL_LEATHER", "MATERIAL_BLOOD", "MATERIAL_ROOT", "MATERIAL_NEEDLE", "MATERIAL_JEWEL", "MATERIAL_DS_REFINE_NORMAL", "MATERIAL_DS_REFINE_BLESSED", "MATERIAL_DS_REFINE_HOLLY"};
  113. static string arSub6[] = { "SPECIAL_MAP", "SPECIAL_KEY", "SPECIAL_DOC", "SPECIAL_SPIRIT"};
  114. static string arSub7[] = { "TOOL_FISHING_ROD" };
  115. static string arSub8[] = { "LOTTERY_TICKET", "LOTTERY_INSTANT" };
  116. static string arSub10[] = { "METIN_NORMAL", "METIN_GOLD" };
  117. static string arSub12[] = { "FISH_ALIVE", "FISH_DEAD"};
  118. static string arSub14[] = { "RESOURCE_FISHBONE", "RESOURCE_WATERSTONEPIECE", "RESOURCE_WATERSTONE", "RESOURCE_BLOOD_PEARL","RESOURCE_BLUE_PEARL", "RESOURCE_WHITE_PEARL", "RESOURCE_BUCKET", "RESOURCE_CRYSTAL", "RESOURCE_GEM", "RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE" };
  119. static string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5", "UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};
  120. static string arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR" };
  121. static string arSub29[] = { "DS_SLOT1", "DS_SLOT2", "DS_SLOT3", "DS_SLOT4", "DS_SLOT5", "DS_SLOT6" };
  122. static string arSub31[] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART" };
  123.  
  124. static string* arSubType[] = {0, //0
  125. arSub1, //1
  126. arSub2, //2
  127. arSub3, //3
  128. arSub4, //4
  129. arSub5, //5
  130. arSub6, //6
  131. arSub7, //7
  132. arSub8, //8
  133. 0, //9
  134. arSub10, //10
  135. 0, //11
  136. arSub12, //12
  137. 0, //13
  138. arSub14, //14
  139. 0, //15
  140. arSub16, //16
  141. 0, //17
  142. 0, //18
  143. 0, //19
  144. 0, //20
  145. 0, //21
  146. 0, //22
  147. 0, //23
  148. 0, //24
  149. 0, //25
  150. 0, //26
  151. 0, //27
  152. arSub28, //28
  153. arSub29, //29
  154. arSub29, //30
  155. arSub31, //31
  156. 0, //32
  157. 0, //33
  158. 0, //34
  159. };
  160. static int arNumberOfSubtype[_countof(arSubType)] = {
  161. 0,
  162. sizeof(arSub1)/sizeof(arSub1[0]),
  163. sizeof(arSub2)/sizeof(arSub2[0]),
  164. sizeof(arSub3)/sizeof(arSub3[0]),
  165. sizeof(arSub4)/sizeof(arSub4[0]),
  166. sizeof(arSub5)/sizeof(arSub5[0]),
  167. sizeof(arSub6)/sizeof(arSub6[0]),
  168. sizeof(arSub7)/sizeof(arSub7[0]),
  169. sizeof(arSub8)/sizeof(arSub8[0]),
  170. 0,
  171. sizeof(arSub10)/sizeof(arSub10[0]),
  172. 0,
  173. sizeof(arSub12)/sizeof(arSub12[0]),
  174. 0,
  175. sizeof(arSub14)/sizeof(arSub14[0]),
  176. 0,
  177. sizeof(arSub16)/sizeof(arSub16[0]),
  178. 0,
  179. 0,
  180. 0,
  181. 0,
  182. 0,
  183. 0,
  184. 0,
  185. 0,
  186. 0,
  187. 0,
  188. 0,
  189. sizeof(arSub28)/sizeof(arSub28[0]),
  190. sizeof(arSub29)/sizeof(arSub29[0]),
  191. sizeof(arSub29)/sizeof(arSub29[0]),
  192. sizeof(arSub31)/sizeof(arSub31[0]),
  193. 0, // 32
  194. 0, // 33
  195. 0, // 34
  196. };
  197.  
  198.  
  199. assert(_countof(arSubType) > type_value && "Subtype rule: Out of range!!");
  200.  
  201. if (_countof(arSubType) <= type_value)
  202. {
  203. sys_err("SubType : Out of range!! (type_value: %d, count of registered subtype: %d", type_value, _countof(arSubType));
  204. return -1;
  205. }
  206.  
  207. if (arSubType[type_value]==0) {
  208. return 0;
  209. }
  210.  
  211. int retInt = -1;
  212. for (int j=0;j<arNumberOfSubtype[type_value];j++) {
  213. string tempString = arSubType[type_value][j];
  214. string tempInputString = trim(inputString);
  215. if (tempInputString.compare(tempString)==0)
  216. {
  217. retInt = j;
  218. break;
  219. }
  220. }
  221. return retInt;
  222. }
  223.  
  224. int get_Item_AntiFlag_Value(string inputString)
  225. {
  226.  
  227. string arAntiFlag[] = {
  228. "ANTI_FEMALE",
  229. "ANTI_MALE",
  230. "ANTI_MUSA",
  231. "ANTI_ASSASSIN",
  232. "ANTI_SURA",
  233. "ANTI_MUDANG",
  234. "ANTI_GET",
  235. "ANTI_DROP",
  236. "ANTI_SELL",
  237. "ANTI_EMPIRE_A",
  238. "ANTI_EMPIRE_B",
  239. "ANTI_EMPIRE_C",
  240. "ANTI_SAVE",
  241. "ANTI_GIVE",
  242. "ANTI_PKDROP",
  243. "ANTI_STACK",
  244. "ANTI_MYSHOP",
  245. "ANTI_SAFEBOX",
  246. "ANTI_WOLFMAN"
  247. };
  248.  
  249. int retValue = 0;
  250. string* arInputString = StringSplit(inputString, "|");
  251. for(unsigned int i =0;i<sizeof(arAntiFlag)/sizeof(arAntiFlag[0]);i++) {
  252. string tempString = arAntiFlag[i];
  253. for (unsigned int j=0; j<30 ; j++)
  254. {
  255. string tempString2 = arInputString[j];
  256. if (tempString2.compare(tempString)==0) {
  257. retValue = retValue + pow((float)2,(float)i);
  258. }
  259.  
  260. if(tempString2.compare("") == 0)
  261. break;
  262. }
  263. }
  264. delete []arInputString;
  265. return retValue;
  266. }
  267.  
  268. int get_Item_Flag_Value(string inputString)
  269. {
  270.  
  271. string arFlag[] = {
  272. "ITEM_TUNABLE",
  273. "ITEM_SAVE",
  274. "ITEM_STACKABLE",
  275. "COUNT_PER_1GOLD",
  276. "ITEM_SLOW_QUERY",
  277. "ITEM_UNIQUE",
  278. "ITEM_MAKECOUNT",
  279. "ITEM_IRREMOVABLE",
  280. "CONFIRM_WHEN_USE",
  281. "QUEST_USE",
  282. "QUEST_USE_MULTIPLE",
  283. "QUEST_GIVE",
  284. "ITEM_QUEST",
  285. "LOG",
  286. "STACKABLE",
  287. "SLOW_QUERY",
  288. "REFINEABLE",
  289. "IRREMOVABLE",
  290. "ITEM_APPLICABLE"
  291. };
  292.  
  293. int retValue = 0;
  294. string* arInputString = StringSplit(inputString, "|");
  295. for(unsigned int i =0;i<sizeof(arFlag)/sizeof(arFlag[0]);i++) {
  296. string tempString = arFlag[i];
  297. for (unsigned int j=0; j<30 ; j++)
  298. {
  299. string tempString2 = arInputString[j];
  300. if (tempString2.compare(tempString)==0) {
  301. retValue = retValue + pow((float)2,(float)i);
  302. }
  303. if(tempString2.compare("") == 0)
  304. break;
  305. }
  306. }
  307. delete []arInputString;
  308. return retValue;
  309. }
  310.  
  311. int get_Item_WearFlag_Value(string inputString)
  312. {
  313.  
  314. string arWearrFlag[] = {
  315. "WEAR_BODY",
  316. "WEAR_HEAD",
  317. "WEAR_FOOTS",
  318. "WEAR_WRIST",
  319. "WEAR_WEAPON",
  320. "WEAR_NECK",
  321. "WEAR_EAR",
  322. "WEAR_SHIELD",
  323. "WEAR_UNIQUE",
  324. "WEAR_ARROW",
  325. "WEAR_HAIR",
  326. "WEAR_ABILITY"
  327. };
  328.  
  329. int retValue = 0;
  330. string* arInputString = StringSplit(inputString, "|");
  331. for(unsigned int i =0;i<sizeof(arWearrFlag)/sizeof(arWearrFlag[0]);i++) {
  332. string tempString = arWearrFlag[i];
  333. for (unsigned int j=0; j<30 ; j++)
  334. {
  335. string tempString2 = arInputString[j];
  336. if (tempString2.compare(tempString)==0) {
  337. retValue = retValue + pow((float)2,(float)i);
  338. }
  339.  
  340. if(tempString2.compare("") == 0)
  341. break;
  342. }
  343. }
  344. delete []arInputString;
  345. return retValue;
  346. }
  347.  
  348. int get_Item_Immune_Value(string inputString)
  349. {
  350.  
  351. string arImmune[] = {"PARA","CURSE","STUN","SLEEP","SLOW","POISON","TERROR"};
  352.  
  353. int retValue = 0;
  354. string* arInputString = StringSplit(inputString, "|");
  355. for(unsigned int i =0;i<sizeof(arImmune)/sizeof(arImmune[0]);i++) {
  356. string tempString = arImmune[i];
  357. for (unsigned int j=0; j<30 ; j++)
  358. {
  359. string tempString2 = arInputString[j];
  360. if (tempString2.compare(tempString)==0) {
  361. retValue = retValue + pow((float)2,(float)i);
  362. }
  363.  
  364. if(tempString2.compare("") == 0)
  365. break;
  366. }
  367. }
  368. delete []arInputString;
  369. return retValue;
  370. }
  371.  
  372. int get_Item_LimitType_Value(string inputString)
  373. {
  374. string arLimitType[] = {"LIMIT_NONE", "LEVEL", "STR", "DEX", "INT", "CON", "PC_BANG", "REAL_TIME", "REAL_TIME_FIRST_USE", "TIMER_BASED_ON_WEAR"};
  375.  
  376. int retInt = -1;
  377. for (unsigned int j=0;j<sizeof(arLimitType)/sizeof(arLimitType[0]);j++) {
  378. string tempString = arLimitType[j];
  379. string tempInputString = trim(inputString);
  380. if (tempInputString.compare(tempString)==0)
  381. {
  382. retInt = j;
  383. break;
  384. }
  385. }
  386. return retInt;
  387. }
  388.  
  389.  
  390. int get_Item_ApplyType_Value(string inputString)
  391. {
  392. string arApplyType[] = {"APPLY_NONE", "APPLY_MAX_HP", "APPLY_MAX_SP", "APPLY_CON", "APPLY_INT", "APPLY_STR", "APPLY_DEX", "APPLY_ATT_SPEED",
  393. "APPLY_MOV_SPEED", "APPLY_CAST_SPEED", "APPLY_HP_REGEN", "APPLY_SP_REGEN", "APPLY_POISON_PCT", "APPLY_STUN_PCT",
  394. "APPLY_SLOW_PCT", "APPLY_CRITICAL_PCT", "APPLY_PENETRATE_PCT", "APPLY_ATTBONUS_HUMAN", "APPLY_ATTBONUS_ANIMAL",
  395. "APPLY_ATTBONUS_ORC", "APPLY_ATTBONUS_MILGYO", "APPLY_ATTBONUS_UNDEAD", "APPLY_ATTBONUS_DEVIL", "APPLY_STEAL_HP",
  396. "APPLY_STEAL_SP", "APPLY_MANA_BURN_PCT", "APPLY_DAMAGE_SP_RECOVER", "APPLY_BLOCK", "APPLY_DODGE", "APPLY_RESIST_SWORD",
  397. "APPLY_RESIST_TWOHAND", "APPLY_RESIST_DAGGER", "APPLY_RESIST_BELL", "APPLY_RESIST_FAN", "APPLY_RESIST_BOW", "APPLY_RESIST_FIRE",
  398. "APPLY_RESIST_ELEC", "APPLY_RESIST_MAGIC", "APPLY_RESIST_WIND", "APPLY_REFLECT_MELEE", "APPLY_REFLECT_CURSE", "APPLY_POISON_REDUCE",
  399. "APPLY_KILL_SP_RECOVER", "APPLY_EXP_DOUBLE_BONUS", "APPLY_GOLD_DOUBLE_BONUS", "APPLY_ITEM_DROP_BONUS", "APPLY_POTION_BONUS",
  400. "APPLY_KILL_HP_RECOVER", "APPLY_IMMUNE_STUN", "APPLY_IMMUNE_SLOW", "APPLY_IMMUNE_FALL", "APPLY_SKILL", "APPLY_BOW_DISTANCE",
  401. "APPLY_ATT_GRADE_BONUS", "APPLY_DEF_GRADE_BONUS", "APPLY_MAGIC_ATT_GRADE", "APPLY_MAGIC_DEF_GRADE", "APPLY_CURSE_PCT",
  402. "APPLY_MAX_STAMINA", "APPLY_ATTBONUS_WARRIOR", "APPLY_ATTBONUS_ASSASSIN", "APPLY_ATTBONUS_SURA", "APPLY_ATTBONUS_SHAMAN",
  403. "APPLY_ATTBONUS_MONSTER", "APPLY_MALL_ATTBONUS", "APPLY_MALL_DEFBONUS", "APPLY_MALL_EXPBONUS", "APPLY_MALL_ITEMBONUS",
  404. "APPLY_MALL_GOLDBONUS", "APPLY_MAX_HP_PCT", "APPLY_MAX_SP_PCT", "APPLY_SKILL_DAMAGE_BONUS", "APPLY_NORMAL_HIT_DAMAGE_BONUS",
  405. "APPLY_SKILL_DEFEND_BONUS", "APPLY_NORMAL_HIT_DEFEND_BONUS", "APPLY_PC_BANG_EXP_BONUS", "APPLY_PC_BANG_DROP_BONUS",
  406. "APPLY_EXTRACT_HP_PCT", "APPLY_RESIST_WARRIOR", "APPLY_RESIST_ASSASSIN", "APPLY_RESIST_SURA", "APPLY_RESIST_SHAMAN",
  407. "APPLY_ENERGY", "APPLY_DEF_GRADE", "APPLY_COSTUME_ATTR_BONUS", "APPLY_MAGIC_ATTBONUS_PER", "APPLY_MELEE_MAGIC_ATTBONUS_PER",
  408. "APPLY_RESIST_ICE", "APPLY_RESIST_EARTH", "APPLY_RESIST_DARK", "APPLY_ANTI_CRITICAL_PCT", "APPLY_ANTI_PENETRATE_PCT",
  409. "APPLY_BLEEDING_REDUCE", "APPLY_BLEEDING_PCT", "APPLY_ATTBONUS_WOLFMAN", "APPLY_RESIST_WOLFMAN", "APPLY_RESIST_CLAW",
  410. };
  411.  
  412. int retInt = -1;
  413. for (unsigned int j=0;j<sizeof(arApplyType)/sizeof(arApplyType[0]);j++) {
  414. string tempString = arApplyType[j];
  415. string tempInputString = trim(inputString);
  416. if (tempInputString.compare(tempString)==0)
  417. {
  418. retInt = j;
  419. break;
  420. }
  421. }
  422. return retInt;
  423.  
  424. }
  425. int get_Mob_Rank_Value(string inputString)
  426. {
  427. string arRank[] = {"PAWN", "S_PAWN", "KNIGHT", "S_KNIGHT", "BOSS", "KING"};
  428.  
  429. int retInt = -1;
  430. for (unsigned int j=0;j<sizeof(arRank)/sizeof(arRank[0]);j++) {
  431. string tempString = arRank[j];
  432. string tempInputString = trim(inputString);
  433. if (tempInputString.compare(tempString)==0)
  434. {
  435. retInt = j;
  436. break;
  437. }
  438. }
  439. return retInt;
  440. }
  441. int get_Mob_Type_Value(string inputString)
  442. {
  443. string arType[] = { "MONSTER", "NPC", "STONE", "WARP", "DOOR", "BUILDING", "PC", "POLYMORPH_PC", "HORSE", "GOTO"};
  444.  
  445. int retInt = -1;
  446. for (unsigned int j=0;j<sizeof(arType)/sizeof(arType[0]);j++) {
  447. string tempString = arType[j];
  448. string tempInputString = trim(inputString);
  449. if (tempInputString.compare(tempString)==0)
  450. {
  451. retInt = j;
  452. break;
  453. }
  454. }
  455. return retInt;
  456. }
  457.  
  458. int get_Mob_BattleType_Value(string inputString)
  459. {
  460. string arBattleType[] = { "MELEE", "RANGE", "MAGIC", "SPECIAL", "POWER", "TANKER", "SUPER_POWER", "SUPER_TANKER"};
  461.  
  462. int retInt = -1;
  463. for (unsigned int j=0;j<sizeof(arBattleType)/sizeof(arBattleType[0]);j++) {
  464. string tempString = arBattleType[j];
  465. string tempInputString = trim(inputString);
  466. if (tempInputString.compare(tempString)==0)
  467. {
  468. retInt = j;
  469. break;
  470. }
  471. }
  472. return retInt;
  473. }
  474.  
  475. int get_Mob_Size_Value(string inputString)
  476. {
  477. string arSize[] = { "SAMLL", "MEDIUM", "BIG"};
  478.  
  479. int retInt = 0;
  480.  
  481. for (unsigned int j=0;j<sizeof(arSize)/sizeof(arSize[0]);j++) {
  482. string tempString = arSize[j];
  483. string tempInputString = trim(inputString);
  484. if (tempInputString.compare(tempString)==0)
  485. {
  486.  
  487. retInt = j + 1;
  488. break;
  489. }
  490. }
  491.  
  492. return retInt;
  493. }
  494.  
  495. int get_Mob_AIFlag_Value(string inputString)
  496. {
  497. string arAIFlag[] = {"AGGR","NOMOVE","COWARD","NOATTSHINSU","NOATTCHUNJO","NOATTJINNO","ATTMOB","BERSERK","STONESKIN","GODSPEED","DEATHBLOW","REVIVE"};
  498.  
  499.  
  500. int retValue = 0;
  501. string* arInputString = StringSplit(inputString, ",");
  502. for(unsigned int i =0;i<sizeof(arAIFlag)/sizeof(arAIFlag[0]);i++) {
  503. string tempString = arAIFlag[i];
  504. for (unsigned int j=0; j<30 ; j++)
  505. {
  506. string tempString2 = arInputString[j];
  507. if (tempString2.compare(tempString)==0) {
  508. retValue = retValue + pow((float)2,(float)i);
  509. }
  510.  
  511. if(tempString2.compare("") == 0)
  512. break;
  513. }
  514. }
  515. delete []arInputString;
  516. return retValue;
  517. }
  518. int get_Mob_RaceFlag_Value(string inputString)
  519. {
  520. string arRaceFlag[] = {"ANIMAL","UNDEAD","DEVIL","HUMAN","ORC","MILGYO","INSECT","FIRE","ICE","DESERT","TREE",
  521. "ATT_ELEC","ATT_FIRE","ATT_ICE","ATT_WIND","ATT_EARTH","ATT_DARK"};
  522.  
  523. int retValue = 0;
  524. string* arInputString = StringSplit(inputString, ",");
  525. for(unsigned int i =0;i<sizeof(arRaceFlag)/sizeof(arRaceFlag[0]);i++) {
  526. string tempString = arRaceFlag[i];
  527. for (unsigned int j=0; j<30 ; j++)
  528. {
  529. string tempString2 = arInputString[j];
  530. if (tempString2.compare(tempString)==0) {
  531. retValue = retValue + pow((float)2,(float)i);
  532. }
  533. if(tempString2.compare("") == 0)
  534. break;
  535. }
  536. }
  537. delete []arInputString;
  538. return retValue;
  539. }
  540. int get_Mob_ImmuneFlag_Value(string inputString)
  541. {
  542. string arImmuneFlag[] = {"STUN","SLOW","FALL","CURSE","POISON","TERROR", "REFLECT"};
  543.  
  544. int retValue = 0;
  545. string* arInputString = StringSplit(inputString, ",");
  546. for(unsigned int i =0;i<sizeof(arImmuneFlag)/sizeof(arImmuneFlag[0]);i++) {
  547. string tempString = arImmuneFlag[i];
  548. for (unsigned int j=0; j<30 ; j++)
  549. {
  550. string tempString2 = arInputString[j];
  551. if (tempString2.compare(tempString)==0) {
  552. retValue = retValue + pow((float)2,(float)i);
  553. }
  554.  
  555. if(tempString2.compare("") == 0)
  556. break;
  557. }
  558. }
  559. delete []arInputString;
  560. return retValue;
  561. }
  562.  
  563.  
  564. #ifndef __DUMP_PROTO__
  565. bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable,std::map<int,const char*> &nameMap)
  566. {
  567. int col = 0;
  568. str_to_number(mobTable->dwVnum, csvTable.AsStringByIndex(col++));
  569. strlcpy(mobTable->szName, csvTable.AsStringByIndex(col++), sizeof(mobTable->szName));
  570.  
  571. map<int,const char*>::iterator it;
  572. it = nameMap.find(mobTable->dwVnum);
  573. if (it != nameMap.end()) {
  574. const char * localeName = it->second;
  575. strlcpy(mobTable->szLocaleName, localeName, sizeof (mobTable->szLocaleName));
  576. } else {
  577. strlcpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName));
  578. }
  579.  
  580. int rankValue = get_Mob_Rank_Value(csvTable.AsStringByIndex(col++));
  581. mobTable->bRank = rankValue;
  582. //TYPE
  583. int typeValue = get_Mob_Type_Value(csvTable.AsStringByIndex(col++));
  584. mobTable->bType = typeValue;
  585. //BATTLE_TYPE
  586. int battleTypeValue = get_Mob_BattleType_Value(csvTable.AsStringByIndex(col++));
  587. mobTable->bBattleType = battleTypeValue;
  588.  
  589. str_to_number(mobTable->bLevel, csvTable.AsStringByIndex(col++));
  590. //SIZE
  591. int sizeValue = get_Mob_Size_Value(csvTable.AsStringByIndex(col++));
  592. mobTable->bSize = sizeValue;
  593. //AI_FLAG
  594. int aiFlagValue = get_Mob_AIFlag_Value(csvTable.AsStringByIndex(col++));
  595. mobTable->dwAIFlag = aiFlagValue;
  596. //mount_capacity;
  597. col++;
  598. //RACE_FLAG
  599. int raceFlagValue = get_Mob_RaceFlag_Value(csvTable.AsStringByIndex(col++));
  600. mobTable->dwRaceFlag = raceFlagValue;
  601. //IMMUNE_FLAG
  602. int immuneFlagValue = get_Mob_ImmuneFlag_Value(csvTable.AsStringByIndex(col++));
  603. mobTable->dwImmuneFlag = immuneFlagValue;
  604.  
  605. str_to_number(mobTable->bEmpire, csvTable.AsStringByIndex(col++)); //col = 11
  606.  
  607. strlcpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder));
  608.  
  609. str_to_number(mobTable->bOnClickType, csvTable.AsStringByIndex(col++));
  610.  
  611. str_to_number(mobTable->bStr, csvTable.AsStringByIndex(col++));
  612. str_to_number(mobTable->bDex, csvTable.AsStringByIndex(col++));
  613. str_to_number(mobTable->bCon, csvTable.AsStringByIndex(col++));
  614. str_to_number(mobTable->bInt, csvTable.AsStringByIndex(col++));
  615. str_to_number(mobTable->dwDamageRange[0], csvTable.AsStringByIndex(col++));
  616. str_to_number(mobTable->dwDamageRange[1], csvTable.AsStringByIndex(col++));
  617. str_to_number(mobTable->dwMaxHP, csvTable.AsStringByIndex(col++));
  618. str_to_number(mobTable->bRegenCycle, csvTable.AsStringByIndex(col++));
  619. str_to_number(mobTable->bRegenPercent, csvTable.AsStringByIndex(col++));
  620. str_to_number(mobTable->dwGoldMin, csvTable.AsStringByIndex(col++));
  621. str_to_number(mobTable->dwGoldMax, csvTable.AsStringByIndex(col++));
  622. str_to_number(mobTable->dwExp, csvTable.AsStringByIndex(col++));
  623. str_to_number(mobTable->wDef, csvTable.AsStringByIndex(col++));
  624. str_to_number(mobTable->sAttackSpeed, csvTable.AsStringByIndex(col++));
  625. str_to_number(mobTable->sMovingSpeed, csvTable.AsStringByIndex(col++));
  626. str_to_number(mobTable->bAggresiveHPPct, csvTable.AsStringByIndex(col++));
  627. str_to_number(mobTable->wAggressiveSight, csvTable.AsStringByIndex(col++));
  628. str_to_number(mobTable->wAttackRange, csvTable.AsStringByIndex(col++));
  629.  
  630. str_to_number(mobTable->dwDropItemVnum, csvTable.AsStringByIndex(col++)); //32
  631. str_to_number(mobTable->dwResurrectionVnum, csvTable.AsStringByIndex(col++));
  632. for (unsigned int i = 0; i < MOB_ENCHANTS_MAX_NUM; ++i)
  633. str_to_number(mobTable->cEnchants[i], csvTable.AsStringByIndex(col++));
  634.  
  635. for (unsigned int i = 0; i < MOB_RESISTS_MAX_NUM; ++i)
  636. str_to_number(mobTable->cResists[i], csvTable.AsStringByIndex(col++));
  637.  
  638. str_to_number(mobTable->fDamMultiply, csvTable.AsStringByIndex(col++));
  639. str_to_number(mobTable->dwSummonVnum, csvTable.AsStringByIndex(col++));
  640. str_to_number(mobTable->dwDrainSP, csvTable.AsStringByIndex(col++));
  641.  
  642. //Mob_Color
  643. ++col;
  644.  
  645. str_to_number(mobTable->dwPolymorphItemVnum, csvTable.AsStringByIndex(col++));
  646.  
  647. str_to_number(mobTable->Skills[0].bLevel, csvTable.AsStringByIndex(col++));
  648. str_to_number(mobTable->Skills[0].dwVnum, csvTable.AsStringByIndex(col++));
  649. str_to_number(mobTable->Skills[1].bLevel, csvTable.AsStringByIndex(col++));
  650. str_to_number(mobTable->Skills[1].dwVnum, csvTable.AsStringByIndex(col++));
  651. str_to_number(mobTable->Skills[2].bLevel, csvTable.AsStringByIndex(col++));
  652. str_to_number(mobTable->Skills[2].dwVnum, csvTable.AsStringByIndex(col++));
  653. str_to_number(mobTable->Skills[3].bLevel, csvTable.AsStringByIndex(col++));
  654. str_to_number(mobTable->Skills[3].dwVnum, csvTable.AsStringByIndex(col++));
  655. str_to_number(mobTable->Skills[4].bLevel, csvTable.AsStringByIndex(col++));
  656. str_to_number(mobTable->Skills[4].dwVnum, csvTable.AsStringByIndex(col++));
  657.  
  658. str_to_number(mobTable->bBerserkPoint, csvTable.AsStringByIndex(col++));
  659. str_to_number(mobTable->bStoneSkinPoint, csvTable.AsStringByIndex(col++));
  660. str_to_number(mobTable->bGodSpeedPoint, csvTable.AsStringByIndex(col++));
  661. str_to_number(mobTable->bDeathBlowPoint, csvTable.AsStringByIndex(col++));
  662. str_to_number(mobTable->bRevivePoint, csvTable.AsStringByIndex(col++));
  663.  
  664. sys_log(0, "MOB #%-5d %-24s level: %-3u rank: %u empire: %d", mobTable->dwVnum, mobTable->szLocaleName, mobTable->bLevel, mobTable->bRank, mobTable->bEmpire);
  665.  
  666. return true;
  667. }
  668.  
  669. bool Set_Proto_Item_Table(TItemTable *itemTable, cCsvTable &csvTable,std::map<int,const char*> &nameMap)
  670. {
  671. int col = 0;
  672.  
  673. int dataArray[33];
  674. for (unsigned int i=0; i<sizeof(dataArray)/sizeof(dataArray[0]);i++) {
  675. int validCheck = 0;
  676. if (i==2) {
  677. dataArray[i] = get_Item_Type_Value(csvTable.AsStringByIndex(col));
  678. validCheck = dataArray[i];
  679. } else if (i==3) {
  680. dataArray[i] = get_Item_SubType_Value(dataArray[i-1], csvTable.AsStringByIndex(col));
  681. validCheck = dataArray[i];
  682. } else if (i==5) {
  683. dataArray[i] = get_Item_AntiFlag_Value(csvTable.AsStringByIndex(col));
  684. validCheck = dataArray[i];
  685. } else if (i==6) {
  686. dataArray[i] = get_Item_Flag_Value(csvTable.AsStringByIndex(col));
  687. validCheck = dataArray[i];
  688. } else if (i==7) {
  689. dataArray[i] = get_Item_WearFlag_Value(csvTable.AsStringByIndex(col));
  690. validCheck = dataArray[i];
  691. } else if (i==8) {
  692. dataArray[i] = get_Item_Immune_Value(csvTable.AsStringByIndex(col));
  693. validCheck = dataArray[i];
  694. } else if (i==14) {
  695. dataArray[i] = get_Item_LimitType_Value(csvTable.AsStringByIndex(col));
  696. validCheck = dataArray[i];
  697. } else if (i==16) {
  698. dataArray[i] = get_Item_LimitType_Value(csvTable.AsStringByIndex(col));
  699. validCheck = dataArray[i];
  700. } else if (i==18) {
  701. dataArray[i] = get_Item_ApplyType_Value(csvTable.AsStringByIndex(col));
  702. validCheck = dataArray[i];
  703. } else if (i==20) {
  704. dataArray[i] = get_Item_ApplyType_Value(csvTable.AsStringByIndex(col));
  705. validCheck = dataArray[i];
  706. } else if (i==22) {
  707. dataArray[i] = get_Item_ApplyType_Value(csvTable.AsStringByIndex(col));
  708. validCheck = dataArray[i];
  709. } else {
  710. str_to_number(dataArray[i], csvTable.AsStringByIndex(col));
  711. }
  712.  
  713. if (validCheck == -1)
  714. {
  715. std::ostringstream dataStream;
  716.  
  717. for (unsigned int j = 0; j < i; ++j)
  718. dataStream << dataArray[j] << ",";
  719.  
  720. sys_err("ItemProto Reading Failed : Invalid value. (index: %d, col: %d, value: %s)", i, col, csvTable.AsStringByIndex(col));
  721. sys_err("\t%d ~ %d Values: %s", 0, i, dataStream.str().c_str());
  722.  
  723. exit(0);
  724. }
  725.  
  726. col = col + 1;
  727. }
  728.  
  729. {
  730. std::string s(csvTable.AsStringByIndex(0));
  731. unsigned int pos = s.find("~");
  732. if (std::string::npos == pos)
  733. {
  734. itemTable->dwVnum = dataArray[0];
  735. itemTable->dwVnumRange = 0;
  736. }
  737. else
  738. {
  739. std::string s_start_vnum (s.substr(0, pos));
  740. std::string s_end_vnum (s.substr(pos +1 ));
  741.  
  742. int start_vnum = atoi(s_start_vnum.c_str());
  743. int end_vnum = atoi(s_end_vnum.c_str());
  744. if (0 == start_vnum || (0 != end_vnum && end_vnum < start_vnum))
  745. {
  746. sys_err ("INVALID VNUM %s", s.c_str());
  747. return false;
  748. }
  749. itemTable->dwVnum = start_vnum;
  750. itemTable->dwVnumRange = end_vnum - start_vnum;
  751. }
  752. }
  753.  
  754. strlcpy(itemTable->szName, csvTable.AsStringByIndex(1), sizeof(itemTable->szName));
  755. map<int,const char*>::iterator it;
  756. it = nameMap.find(itemTable->dwVnum);
  757. if (it != nameMap.end()) {
  758. const char * localeName = it->second;
  759. strlcpy(itemTable->szLocaleName, localeName, sizeof (itemTable->szLocaleName));
  760. } else {
  761. strlcpy(itemTable->szLocaleName, itemTable->szName, sizeof (itemTable->szLocaleName));
  762. }
  763. itemTable->bType = dataArray[2];
  764. itemTable->bSubType = dataArray[3];
  765. itemTable->bSize = dataArray[4];
  766. itemTable->dwAntiFlags = dataArray[5];
  767. itemTable->dwFlags = dataArray[6];
  768. itemTable->dwWearFlags = dataArray[7];
  769. itemTable->dwImmuneFlag = dataArray[8];
  770. itemTable->dwGold = dataArray[9];
  771. itemTable->dwShopBuyPrice = dataArray[10];
  772. itemTable->dwRefinedVnum = dataArray[11];
  773. itemTable->wRefineSet = dataArray[12];
  774. itemTable->bAlterToMagicItemPct = dataArray[13];
  775. itemTable->cLimitRealTimeFirstUseIndex = -1;
  776. itemTable->cLimitTimerBasedOnWearIndex = -1;
  777.  
  778. int i;
  779.  
  780. for (i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  781. {
  782. itemTable->aLimits[i].bType = dataArray[14+i*2];
  783. itemTable->aLimits[i].lValue = dataArray[15+i*2];
  784.  
  785. if (LIMIT_REAL_TIME_START_FIRST_USE == itemTable->aLimits[i].bType)
  786. itemTable->cLimitRealTimeFirstUseIndex = (char)i;
  787.  
  788. if (LIMIT_TIMER_BASED_ON_WEAR == itemTable->aLimits[i].bType)
  789. itemTable->cLimitTimerBasedOnWearIndex = (char)i;
  790.  
  791. }
  792.  
  793. for (i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
  794. {
  795. itemTable->aApplies[i].bType = dataArray[18+i*2];
  796. itemTable->aApplies[i].lValue = dataArray[19+i*2];
  797. }
  798.  
  799. for (i = 0; i < ITEM_VALUES_MAX_NUM; ++i)
  800. itemTable->alValues[i] = dataArray[24+i];
  801.  
  802. itemTable->bGainSocketPct = dataArray[31];
  803. itemTable->sAddonType = dataArray[32];
  804.  
  805. str_to_number(itemTable->bWeight, "0");
  806.  
  807. return true;
  808. }
  809.  
  810. #endif
RAW Paste Data