26 {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}},
27 {{1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}},
28 {{1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}},
29 {{2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}},
30 {{2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5}},
31 {{2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}},
32 {{2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}
39 extern std::vector<char*>
Tokenize(
char*
input,
const char separator);
43 bool* draintargetHP) {
44 *draintargetHP =
false;
51 return rand() % 10 + 6;
55 return rand() % 16 + 3;
59 return rand() % 4 + 9;
69 return rand() % 2 + 3;
73 return rand() % 3 + 6;
77 return rand() % 4 + 9;
81 return rand() % 4 + 2;
85 return rand() % 7 + 4;
89 return rand() % 10 + 6;
118 *draintargetHP =
true;
124 return rand() % 11 + 10;
182 std::map<std::string, ITEM_EQUIP_TYPE, ci_less> equipStatMap;
207 std::map<std::string, PLAYER_SKILL_TYPE, ci_less> equipSkillMap;
222 std::map<std::string, ITEM_MATERIAL, ci_less> materialMap;
255 for (
int i = 0; i < 24; ++i) {
256 test_string = strtok(NULL,
"\r") + 1;
257 auto tokens =
Tokenize(test_string,
'\t');
260 for (
int j = 0; j < 9; j++) {
266 for (
int i = 0; i < 9; ++i) {
267 for (
int j = 0; j < 24; ++j)
277 for (
int i = 0; i < 6; ++i) {
278 test_string = strtok(NULL,
"\r") + 1;
279 auto tokens =
Tokenize(test_string,
'\t');
280 Assert(tokens.size() == 4,
"Invalid number of tokens");
290 for (
int i = 0; i < 72; ++i) {
291 test_string = strtok(NULL,
"\r") + 1;
292 auto tokens =
Tokenize(test_string,
'\t');
293 Assert(tokens.size() >= 17,
"Invalid number of tokens");
296 for (
int j = 0; j < 12; j++) {
300 res = atoi(tokens[14]);
304 while (*tokens[14] ==
' ')
306 res = atoi(tokens[14]);
315 for (
int i = 0; i < 12; ++i) {
328 while (item_counter < 800) {
329 test_string = strtok(NULL,
"\r") + 1;
331 extern std::vector<char*>
Tokenize(
char*
input,
const char separator);
332 auto tokens =
Tokenize(test_string,
'\t');
334 item_counter = atoi(tokens[0]);
338 pItems[item_counter].uValue = atoi(tokens[3]);
339 auto findResult = equipStatMap.find(tokens[4]);
340 pItems[item_counter].uEquipType =
341 findResult == equipStatMap.end() ?
EQUIP_NONE : findResult->second;
342 auto findResult2 = equipSkillMap.find(tokens[5]);
343 pItems[item_counter].uSkillType = findResult2 == equipSkillMap.end()
345 : findResult2->second;
346 auto tokens2 =
Tokenize(tokens[6],
'd');
347 if (tokens2.size() == 2) {
348 pItems[item_counter].uDamageDice = atoi(tokens2[0]);
349 pItems[item_counter].uDamageRoll = atoi(tokens2[1]);
350 }
else if (tolower(tokens2[0][0]) !=
's') {
351 pItems[item_counter].uDamageDice = atoi(tokens2[0]);
352 pItems[item_counter].uDamageRoll = 1;
354 pItems[item_counter].uDamageDice = 0;
355 pItems[item_counter].uDamageRoll = 0;
357 pItems[item_counter].uDamageMod = atoi(tokens[7]);
358 auto findResult3 = materialMap.find(tokens[8]);
359 pItems[item_counter].uMaterial = findResult3 == materialMap.end()
361 : findResult3->second;
362 pItems[item_counter].uItemID_Rep_St = atoi(tokens[9]);
364 pItems[item_counter].uSpriteID = atoi(tokens[11]);
366 pItems[item_counter]._additional_value = 0;
367 pItems[item_counter]._bonus_type = 0;
369 for (
int ii = 0; ii < 24; ++ii) {
371 pItems[item_counter]._bonus_type = ii + 1;
375 if (!
pItems[item_counter]._bonus_type) {
376 for (
int ii = 0; ii < 72; ++ii) {
377 if (!_stricmp(tokens[12],
379 pItems[item_counter]._additional_value = ii + 1;
386 (
pItems[item_counter]._bonus_type)) {
387 char b_s = atoi(tokens[13]);
389 pItems[item_counter]._bonus_strength = b_s;
391 pItems[item_counter]._bonus_strength = 1;
393 pItems[item_counter]._bonus_strength = 0;
395 pItems[item_counter].uEquipX = atoi(tokens[14]);
396 pItems[item_counter].uEquipY = atoi(tokens[15]);
407 for (item_counter = 0; item_counter < 619; item_counter++) {
408 test_string = strtok(NULL,
"\r") + 1;
409 auto tokens =
Tokenize(test_string,
'\t');
410 Assert(tokens.size() > 7,
"Invalid number of tokens");
411 item_counter = atoi(tokens[0]);
412 pItems[item_counter].uChanceByTreasureLvl1 = atoi(tokens[2]);
413 pItems[item_counter].uChanceByTreasureLvl2 = atoi(tokens[3]);
414 pItems[item_counter].uChanceByTreasureLvl3 = atoi(tokens[4]);
415 pItems[item_counter].uChanceByTreasureLvl4 = atoi(tokens[5]);
416 pItems[item_counter].uChanceByTreasureLvl5 = atoi(tokens[6]);
417 pItems[item_counter].uChanceByTreasureLvl6 = atoi(tokens[7]);
422 for (
int i = 0; i < 6; ++i) {
423 for (
int j = 1; j < item_counter; ++j)
432 for (
int i = 0; i < 3; ++i) {
433 test_string = strtok(NULL,
"\r") + 1;
434 auto tokens =
Tokenize(test_string,
'\t');
435 Assert(tokens.size() > 7,
"Invalid number of tokens");
498 unsigned int uColumn;
499 unsigned __int8 potion_value;
505 while (test_string) {
506 tokens =
Tokenize(test_string,
'\t');
507 if (!strcmp(tokens[0],
"222"))
break;
508 test_string = strtok(NULL,
"\r") + 1;
515 for (uRow = 0; uRow < 50; ++uRow) {
516 if (tokens.size() < 50) {
517 logger->
Warning(L
"Error Parsing Potion Table at Row: %d Column: %d",
518 uRow, tokens.size());
521 for (uColumn = 0; uColumn < 50; ++uColumn) {
522 char* currValue = tokens[uColumn + 7];
523 potion_value = atoi(currValue);
524 if (!potion_value && tolower(currValue[0]) ==
'e') {
525 potion_value = atoi(currValue + 1);
530 test_string = strtok(NULL,
"\r") + 1;
532 logger->
Warning(L
"Error Parsing Potion Table at Row: %d Column: %d",
536 tokens =
Tokenize(test_string,
'\t');
545 unsigned int uColumn;
552 while (test_string) {
553 tokens =
Tokenize(test_string,
'\t');
554 if (!strcmp(tokens[0],
"222"))
break;
555 test_string = strtok(NULL,
"\r") + 1;
562 for (uRow = 0; uRow < 50; ++uRow) {
563 if (tokens.size() < 50) {
564 logger->
Warning(L
"Error Parsing Potion Table at Row: %d Column: %d",
565 uRow, tokens.size());
568 for (uColumn = 0; uColumn < 50; ++uColumn) {
569 char* currValue = tokens[uColumn + 7];
571 if (!
potion_note && tolower(currValue[0]) ==
'e') {
577 test_string = strtok(NULL,
"\r") + 1;
579 logger->
Warning(L
"Error Parsing Potion Table at Row: %d Column: %d",
583 tokens =
Tokenize(test_string,
'\t');
589 unsigned int uBaseValue;
590 unsigned int mod, bonus;
602 return uBaseValue + bonus;
604 return uBaseValue * bonus;
620 unsigned __int8 equip_type;
631 if (player_name[strlen(player_name) - 1] ==
's')
682 int treasureLevelMinus1;
687 unsigned int special_chance;
702 memset(out_item, 0,
sizeof(*out_item));
704 treasureLevelMinus1 = treasure_level - 1;
708 switch (uTreasureType) {
795 memset(val_list, 0,
sizeof(val_list));
799 if (requested_skill ==
801 for (
uint i = 1; i < 500; ++i) {
802 if (
pItems[i].uEquipType == requested_equip) {
806 pItems[i].uChanceByTreasureLvl[treasure_level - 1];
810 for (
uint i = 1; i < 500; ++i) {
811 if (
pItems[i].uSkillType == requested_skill) {
815 pItems[i].uChanceByTreasureLvl[treasure_level - 1];
822 current_chance = rand() % total_chance + 1;
825 while (tmp_chance < current_chance) {
826 out_item->
uItemID = val_list[j];
827 tmp_chance +=
pItems[val_list[j]]
828 .uChanceByTreasureLvl[treasure_level - 1];
836 if (treasureLevelMinus1 == 5) {
855 .uChanceByTreasureLvl[treasureLevelMinus1];
862 for (
int i = 0; i < 2; ++i)
886 if ((
uint)(rand() % 100) >=
900 special_chance = rand() % 100;
917 if (v32 == 21 || v32 == 22 ||
925 }
else if (special_chance >=
942 memset(&val_list, 0, 3200);
951 if ((treasure_level - 1 == 2) && (tr_lv == 1 || tr_lv == 0) ||
952 (treasure_level - 1 == 3) &&
953 (tr_lv == 2 || tr_lv == 1 || tr_lv == 0) ||
954 (treasure_level - 1 == 4) &&
955 (tr_lv == 3 || tr_lv == 2 || tr_lv == 1) ||
956 (treasure_level - 1 == 5) && (tr_lv == 3)) {
966 v46 = rand() % spc_sum + 1;
979 signed int uNumArtifactsNotFound;
980 int artifacts_list[32];
982 memset(artifacts_list, 0,
sizeof(artifacts_list));
983 uNumArtifactsNotFound = 0;
985 for (
int i = 500; i < 529; ++i)
987 artifacts_list[uNumArtifactsNotFound++] = i;
990 if (uNumArtifactsNotFound) {
991 uItemID = artifacts_list[rand() % uNumArtifactsNotFound];
999 std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>*>
1001 std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>*>
1003 std::map<int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>*>
1006 #define NEWBONUSINTOSPECIALLIST(x, y) \
1007 AddToMap(ItemGen::specialBonusMap, enchId, x, y);
1008 #define NEWBONUSINTOSPECIALLIST2(x, y, z) \
1009 AddToMap(ItemGen::specialBonusMap, enchId, x, y, z);
1011 #define NEWBONUSINTOREGULARLIST(x) \
1012 AddToMap(ItemGen::regularBonusMap, enchId, x);
1014 #define NEWBONUSINTOARTIFACTLIST(x, y) \
1015 AddToMap(ItemGen::artifactBonusMap, itemId, x, y);
1016 #define NEWBONUSINTOARTIFACTLIST2(x, y, z) \
1017 AddToMap(ItemGen::artifactBonusMap, itemId, x, y, z);
1020 std::map<
int, std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>*>& maptoadd,
1022 unsigned __int16
Player::*skillPtr ) {
1023 auto key = maptoadd.find(enchId);
1024 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currMap;
1025 if (key == maptoadd.end()) {
1026 currMap =
new std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>;
1027 maptoadd[enchId] = currMap;
1029 currMap = key->second;
1031 Assert(currMap->find(attrId) == currMap->end(),
1032 "Attribute %d already present for enchantment %d", attrId, enchId);
1033 (*currMap)[attrId] =
new CEnchantment(bonusValue, skillPtr);
1451 int* halfSkillBonus) {
1456 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList =
1458 if (currList->find(attrToGet) != currList->end()) {
1460 if (currBonus->
statPtr != NULL) {
1462 *halfSkillBonus = owner->*currBonus->
statPtr / 2;
1464 if (*additiveBonus < currBonus->statBonus) {
1481 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList =
1483 if (currList->find(attrToGet) != currList->end()) {
1485 if (currBonus->
statPtr != NULL) {
1486 *bonusSum = owner->*currBonus->
statPtr / 2;
1499 std::map<CHARACTER_ATTRIBUTE_TYPE, CEnchantment*>* currList =
1501 return (currList->find(attrToGet) != currList->end());
1545 if (item_id > 500) {
1603 switch (pEquipType) {
1606 return sprintf(pOut,
"item%3.3dv%d", item_id,
index);
1607 else if (shoulder == 1)
1608 return sprintf(pOut,
"item%3.3dv%da1", item_id,
index);
1609 else if (shoulder == 2)
1610 return sprintf(pOut,
"item%3.3dv%da2", item_id,
index);
1614 return sprintf(pOut,
"item%3.3dv%d", item_id,
index);
1616 return sprintf(pOut,
"item%3.3dv%da1", item_id,
index);
1618 return sprintf(pOut,
"item%3.3dv%d", item_id,
index);
1629 if ((
p2DEvents[_2da_idx - 1].uType != 4 ||
1630 (
signed int)this->
uItemID < 740 || (
signed int)this->
uItemID > 771) &&
1631 ((
signed int)this->
uItemID >= 600 ||
1632 (
signed int)this->
uItemID >= 529 &&
1633 (
signed int)this->
uItemID <= 599) ||
1636 switch (
p2DEvents[_2da_idx - 1].uType) {
1656 (
signed int)this->
uItemID < 740) &&