Mercurial > mm7
view Items.cpp @ 391:86637e3f59a9
Some AI subs
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 08:46:50 +0200 |
parents | b509ef97807a |
children | 4a42c2f97aa2 |
line wrap: on
line source
#include <stdlib.h> #include <assert.h> #include "Items.h" #include "MapInfo.h" #include "FrameTableInc.h" #include "Allocator.h" #include "LOD.h" #include "Monsters.h" #include "Party.h" #include "FactionTable.h" #include "StorylineTextTable.h" #include "texts.h" #include "mm7_data.h" ItemGen *ptr_50C9A4; struct ItemsTable *pItemsTable; // 005D29E0 //----- (00439DF3) -------------------------------------------------------- int ItemGen::_439DF3_get_additional_damage(int *damage_type, bool *draintargetHP) { *damage_type = 0; if ( !uItemID ) return 0; UpdateTempBonus(pParty->uTimePlayed); if (uItemID == 501 ) //Iron Feather -sword { *damage_type = 1; return rand() % 10 + 6; } if (uItemID == 507 ) //Ghoulsbane -axe { *damage_type = 0; return rand() % 16 + 3; } if ( uItemID == 510 ) //Ullyses -bow { *damage_type = 2; return rand() % 4 + 9; } if ( uItemID == 517 ) //Old Nick -dagger { *damage_type = 8; return 8; } switch (uSpecEnchantmentType) { case 4: //Adds 3-4 points of Cold damage. *damage_type = 2; return rand() % 2 + 3; break; case 5: //Adds 6-8 points of Cold damage. *damage_type = 2; return rand() % 3 + 6; break; case 6: //Adds 9-12 points of Cold damage. *damage_type = 2; return rand() % 4 + 9; break; case 7: //Adds 2-5 points of Electrical damage. *damage_type = 1; return rand() % 4 + 2; break; case 8: //Adds 4-10 points of Electrical damage. *damage_type = 1; return rand() % 7 + 4; break; case 9: //Adds 6-15 points of Electrical damage. *damage_type = 1; return rand() % 10 + 6; break; case 10: //Adds 1-6 points of Fire damage. *damage_type = 0; return GetDiceResult(1, 6); break; case 11: //Adds 2-12 points of Fire damage. *damage_type = 0; return GetDiceResult(2, 6); break; case 12: //Adds 3-18 points of Fire damage. *damage_type = 0; return GetDiceResult(3, 6); break; case 13: //Adds 5 points of Body damage. *damage_type = 8; return 5; break; case 14: //Adds 8 points of Body damage. *damage_type = 8; return 8; break; case 15: //Adds 12 points of Body damage. *damage_type = 8; return 12; break; case 16: //Drain Hit Points from target. case 41: //Drain Hit Points from target and Increased Weapon speed. *damage_type = 10; *draintargetHP = true; return 0; break; case 46: //Adds 10-20 points of Fire damage and +25 Might. *damage_type = 0; return rand() % 11 + 10; break; default: *damage_type = 0; return 0; } } //----- (00402F07) -------------------------------------------------------- void ItemGen::Reset() { this->uHolderPlayer = 0; this->uAttributes = 0; this->uNumCharges = 0; this->uSpecEnchantmentType = 0; this->_bonus_strength = 0; this->uEncantmentType = 0; this->uItemID = 0; this->uBodyAnchor = 0; this->uExpireTime = 0i64; } //----- (00458260) -------------------------------------------------------- void ItemGen::UpdateTempBonus(__int64 uTimePlayed) { unsigned int v2; // eax@1 v2 = this->uAttributes; if ( v2 & ITEM_TEMP_BONUS ) { if ( uTimePlayed > (signed __int64)this->uExpireTime ) { this->uEncantmentType = 0; LOBYTE(v2) = v2 & 0xF7; this->uSpecEnchantmentType = 0; this->uAttributes = v2; } } } //----- (0045814E) -------------------------------------------------------- void ItemsTable::Release() { if ( pMonstersTXT_Raw ) pAllocator->FreeChunk(pMonstersTXT_Raw); if ( pMonsterPlacementTXT_Raw ) pAllocator->FreeChunk(pMonsterPlacementTXT_Raw); if ( pSkillDescTXT_Raw ) pAllocator->FreeChunk(pSkillDescTXT_Raw); if (pSpcItemsTXT_Raw ) pAllocator->FreeChunk(pSpcItemsTXT_Raw); if ( pStdItemsTXT_Raw ) pAllocator->FreeChunk(pStdItemsTXT_Raw); if ( pRndItemsTXT_Raw ) pAllocator->FreeChunk(pRndItemsTXT_Raw); if ( pItemsTXT_Raw ) pAllocator->FreeChunk(pItemsTXT_Raw); if ( pHostileTXT_Raw ) pAllocator->FreeChunk(pHostileTXT_Raw); if ( pHistoryTXT_Raw ) pAllocator->FreeChunk(pHistoryTXT_Raw); if ( pPotionsTXT_Raw ) pAllocator->FreeChunk(pPotionsTXT_Raw); if ( pPotionNotesTXT_Raw ) pAllocator->FreeChunk(pPotionNotesTXT_Raw); pSpcItemsTXT_Raw = NULL; pSkillDescTXT_Raw = NULL; pStdItemsTXT_Raw = NULL; pRndItemsTXT_Raw = NULL; pItemsTXT_Raw = NULL; } //----- (00456D84) -------------------------------------------------------- void ItemsTable::Initialize() { int i,j; char* test_string; unsigned char c; bool break_loop; unsigned int temp_str_len; char* tmp_pos; int decode_step; int item_counter; pMapStats = new MapStats; pMapStats->Initialize(); pMonsterStats = new MonsterStats; pMonsterStats->Initialize(); pMonsterStats->InitializePlacements(); pSpellStats = new SpellStats; pSpellStats->Initialize(); LoadPotions(); LoadPotionNotes(); pFactionTable = new FactionTable; pFactionTable->Initialize(); pStorylineText = new StorylineText; pStorylineText->Initialize(); pStdItemsTXT_Raw = NULL; pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0); strtok(pStdItemsTXT_Raw, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); //Standard Bonuses by Group for (i=0;i<24;++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (decode_step) { case 0: pEnchantments[i].pBonusStat=RemoveQuotes(test_string); break; case 1: pEnchantments[i].pOfName= RemoveQuotes(test_string); break; default: pEnchantments[i].to_item[decode_step-2]=atoi(test_string); } } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<11)&&!break_loop); } memset(&pEnchantmentsSumm, 0, 36); for(i=0;i<9;++i) { for (j=0;j<24;++j) pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i]; } //Bonus range for Standard by Level strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); for(i=0;i<6;++i) //counted from 1 { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (decode_step==2) bonus_ranges[i].minR = atoi(test_string); else if (decode_step==3) bonus_ranges[i].maxR =atoi(test_string); ++decode_step; test_string=tmp_pos+1; } while ((decode_step<4)&&!break_loop); } pSpcItemsTXT_Raw = 0; pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0); strtok(pSpcItemsTXT_Raw, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); for (i=0;i<72;++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (decode_step) { case 0: pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(test_string); break; case 1: pSpecialEnchantments[i].pNameAdd= RemoveQuotes(test_string); break; case 14: int res; res=atoi(test_string); if(!res) { ++test_string; while (*test_string==' ')//fix X 2 case ++test_string; res=atoi(test_string); } pSpecialEnchantments[i].iValue=res; break; case 15: pSpecialEnchantments[i].iTreasureLevel= tolower(*test_string) - 97;; break; default: pSpecialEnchantments[i].to_item_apply[decode_step-2]=atoi(test_string); } } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<16)&&!break_loop); } pSpecialEnchantments_count = 71; memset(&pSpecialEnchantmentsSumm, 0, 96); for(i=0;i<12;++i) { for (j=0;j<pSpecialEnchantments_count;++j) pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i]; } Initialize2DA(); pItemsTXT_Raw = NULL; pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0); strtok(pItemsTXT_Raw, "\r"); strtok(NULL, "\r"); uAllItemsCount = 0; item_counter = 0; while (true) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (decode_step) { case 0: //Item # item_counter=atoi(test_string); uAllItemsCount=item_counter; break; case 1: //Pic File pItems[item_counter].pIconName = RemoveQuotes(test_string); break; case 2: //Name pItems[item_counter].pName = RemoveQuotes(test_string); break; case 3: //Value pItems[item_counter].uValue=atoi(test_string); break; case 4: //Equip Stat { if ( !_strcmpi(test_string, "weapon") ) { pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; break; } if ( !_strcmpi(test_string, "weapon2") ) { pItems[item_counter].uEquipType = EQUIP_TWO_HANDED; break; } if ( !_strcmpi(test_string, "weapon1or2") ) { pItems[item_counter].uEquipType = EQUIP_ONE_OR_TWO_HANDS; break; } if ( !(_strcmpi(test_string, "missile")&&_strcmpi(test_string, "bow"))) { pItems[item_counter].uEquipType = EQUIP_BOW; break; } if ( !_strcmpi(test_string, "armor") ) { pItems[item_counter].uEquipType = EQUIP_ARMOUR; break; } if ( !_strcmpi(test_string, "shield") ) { pItems[item_counter].uEquipType = EQUIP_SHIELD; break; } if ( !_strcmpi(test_string, "helm") ) { pItems[item_counter].uEquipType = EQUIP_HELMET; break; } if ( !_strcmpi(test_string, "belt") ) { pItems[item_counter].uEquipType = EQUIP_BELT; break; } if ( !_strcmpi(test_string, "cloak") ) { pItems[item_counter].uEquipType = EQUIP_CLOAK; break; } if ( !_strcmpi(test_string, "gauntlets") ) { pItems[item_counter].uEquipType = EQUIP_GAUNTLETS; break; } if ( !_strcmpi(test_string, "boots") ) { pItems[item_counter].uEquipType = EQUIP_BOOTS; break; } if ( !_strcmpi(test_string, "ring") ) { pItems[item_counter].uEquipType = EQUIP_RING; break; } if ( !_strcmpi(test_string, "amulet") ) { pItems[item_counter].uEquipType = EQUIP_AMULET; break; } if ( !_strcmpi(test_string, "weaponw") ) { pItems[item_counter].uEquipType = EQUIP_WAND; break; } if ( !(_strcmpi(test_string, "herb")&&_strcmpi(test_string, "reagent"))) { pItems[item_counter].uEquipType = EQUIP_REAGENT; break; } if ( !_strcmpi(test_string, "bottle") ) { pItems[item_counter].uEquipType = EQUIP_POTION; break; } if ( !_strcmpi(test_string, "sscroll") ) { pItems[item_counter].uEquipType = EQUIP_SPELL_SCROLL; break; } if ( !_strcmpi(test_string, "book") ) { pItems[item_counter].uEquipType = EQUIP_BOOK; break; } if ( !_strcmpi(test_string, "mscroll") ) { pItems[item_counter].uEquipType = EQUIP_MESSAGE_SCROLL; break; } if ( !_strcmpi(test_string, "gold") ) { pItems[item_counter].uEquipType = EQUIP_GOLD; break; } if ( !_strcmpi(test_string, "gem") ) { pItems[item_counter].uEquipType = EQUIP_GEM; break; } pItems[item_counter].uEquipType = EQUIP_NONE; break; } case 5: //Skill Group { if ( !_strcmpi(test_string, "staff") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_STAFF; break; } if ( !_strcmpi(test_string, "sword") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_SWORD; break; } if ( !_strcmpi(test_string, "dagger") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_DAGGER; break; } if ( !_strcmpi(test_string, "axe") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_AXE; break; } if ( !_strcmpi(test_string, "spear") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_SPEAR; break; } if ( !_strcmpi(test_string, "bow") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_BOW; break; } if ( !_strcmpi(test_string, "mace") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_MACE; break; } if ( !_strcmpi(test_string, "blaster") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_BLASTER; break; } if ( !_strcmpi(test_string, "shield") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_SHIELD; break; } if ( !_strcmpi(test_string, "leather") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_LEATHER; break; } if ( !_strcmpi(test_string, "chain") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_CHAIN; break; } if ( !_strcmpi(test_string, "plate") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_PLATE; break; } if ( !_strcmpi(test_string, "club") ) { pItems[item_counter].uSkillType = PLAYER_SKILL_CLUB; break; } pItems[item_counter].uSkillType = PLAYER_SKILL_MISC; break; } case 6: //Mod1 { int ii; char* test_char; int tst_len; tst_len=strlen(test_string); pItems[item_counter].uDamageDice=0; pItems[item_counter].uDamageRoll=0; test_char=test_string; for (ii=0; ii<tst_len; ++ii) { if (tolower(*test_char)=='d') { *test_char=0; pItems[item_counter].uDamageDice=atoi(test_string); pItems[item_counter].uDamageRoll=atoi(test_char+1); *test_char='d'; break; } ++test_char; } test_char=test_string; if ((ii==tst_len)&&(tolower(*test_char)=='s')) { pItems[item_counter].uDamageDice=atoi(test_char+1); pItems[item_counter].uDamageRoll=1; } break; } case 7: //Mod2 pItems[item_counter].uDamageMod=atoi(test_string); break; case 8: //material { if ( !_strcmpi(test_string, "artifact") ) { pItems[item_counter].uMaterial = MATERIAL_ARTEFACT; break; } if ( !_strcmpi(test_string, "relic") ) { pItems[item_counter].uMaterial = MATERIAL_RELIC; break; } if ( !_strcmpi(test_string, "special") ) { pItems[item_counter].uMaterial = MATERIAL_SPECIAL; break; } pItems[item_counter].uMaterial = MATERIAL_COMMON; break;} case 9: //ID/Rep/St pItems[item_counter].uItemID_Rep_St=atoi(test_string); break; case 10: //Not identified name pItems[item_counter].pUnidentifiedName = RemoveQuotes(test_string); break; case 11: //Sprite Index pItems[item_counter].uSpriteID=atoi(test_string); break; case 12: //VarA { pItems[item_counter]._additional_value=0; pItems[item_counter]._bonus_type=0; if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL) { for(int ii=0; ii<24; ++ii) { if (stricmp(test_string,pEnchantments[ii].pBonusStat)) { pItems[item_counter]._bonus_type=ii+1; break; } } if (!pItems[item_counter]._bonus_type) { for(int ii=0; ii<72; ++ii) { if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement)) { pItems[item_counter]._additional_value=ii+1; } } } } break; } case 13: //VarB if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type)) { char b_s=atoi(test_string); if (b_s) pItems[item_counter]._bonus_strength=b_s; else pItems[item_counter]._bonus_strength=1; } else pItems[item_counter]._bonus_strength=0; break; case 14: //Equip X pItems[item_counter].uEquipX=atoi(test_string); break; case 15: //Equip Y pItems[item_counter].uEquipY=atoi(test_string); break; case 16: //Notes pItems[item_counter].pDescription = RemoveQuotes(test_string); break; } } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<17)&&!break_loop); ++item_counter; if (item_counter>799) break; } pRndItemsTXT_Raw = NULL; uAllItemsCount = item_counter; pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0); strtok(pRndItemsTXT_Raw, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); item_counter = 0; while (true) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (decode_step) { case 0: item_counter=atoi(test_string); break; case 2: pItems[item_counter].uChanceByTreasureLvl1=atoi(test_string); break; case 3: pItems[item_counter].uChanceByTreasureLvl2=atoi(test_string); break; case 4: pItems[item_counter].uChanceByTreasureLvl3=atoi(test_string); break; case 5: pItems[item_counter].uChanceByTreasureLvl4=atoi(test_string); break; case 6: pItems[item_counter].uChanceByTreasureLvl5=atoi(test_string); break; case 7: pItems[item_counter].uChanceByTreasureLvl6=atoi(test_string); break; } } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<8)&&!break_loop); ++item_counter; if (item_counter>618) break; } if ( pRndItemsTXT_Raw ) { pAllocator->FreeChunk(pRndItemsTXT_Raw); pRndItemsTXT_Raw = NULL; } //ChanceByTreasureLvl Summ - anti cheating? memset(&uChanceByTreasureLvlSumm, 0, 24); for(i=0;i<6;++i) { for (j=0;j<800;++j) uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i]; } strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); strtok(NULL, "\r"); for (i=0;i<3;++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (decode_step) { case 2: switch (i) { case 0: uBonusChanceStandart[0]=atoi(test_string); break; case 1: uBonusChanceSpecial[0]=atoi(test_string); break; case 2: uBonusChanceWpSpecial[0]=atoi(test_string); break; } break; case 3: switch (i) { case 0: uBonusChanceStandart[1]=atoi(test_string); break; case 1: uBonusChanceSpecial[1]=atoi(test_string); break; case 2: uBonusChanceWpSpecial[1]=atoi(test_string); break; } break; case 4: switch (i) { case 0: uBonusChanceStandart[2]=atoi(test_string); break; case 1: uBonusChanceSpecial[2]=atoi(test_string); break; case 2: uBonusChanceWpSpecial[2]=atoi(test_string); break; } break; case 5: switch (i) { case 0: uBonusChanceStandart[3]=atoi(test_string); break; case 1: uBonusChanceSpecial[3]=atoi(test_string); break; case 2: uBonusChanceWpSpecial[3]=atoi(test_string); break; } break; case 6: switch (i) { case 0: uBonusChanceStandart[4]=atoi(test_string); break; case 1: uBonusChanceSpecial[4]=atoi(test_string); break; case 2: uBonusChanceWpSpecial[4]=atoi(test_string); break; } break; case 7: switch (i) { case 0: uBonusChanceStandart[5]=atoi(test_string); break; case 1: uBonusChanceSpecial[5]=atoi(test_string); break; case 2: uBonusChanceWpSpecial[5]=atoi(test_string); break; } break; } } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<8)&&!break_loop); } pSkillDescTXT_Raw = NULL; pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); strtok(pSkillDescTXT_Raw, "\r"); for (i=0; i<37; ++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (decode_step) { case 1: pSkillDesc[i] = RemoveQuotes(test_string); break; case 2: pNormalSkillDesc[i] = RemoveQuotes(test_string); break; case 3: pExpertSkillDesc[i] = RemoveQuotes(test_string); break; case 4: pMasterSkillDesc[i] = RemoveQuotes(test_string); break; case 5: pGrandSkillDesc[i] = RemoveQuotes(test_string); break; } } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<6)&&!break_loop); } pStatsTXT_Raw = 0; pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); strtok(pStatsTXT_Raw, "\r"); for (i=0; i<26; ++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { switch (i) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: pAttributeDescriptions[i] = RemoveQuotes(test_string); break; case 7: pHealthPointsAttributeDescription = RemoveQuotes(test_string); break; case 8: pArmourClassAttributeDescription = RemoveQuotes(test_string); break; case 9: pSpellPointsAttributeDescription = RemoveQuotes(test_string); break; case 10: pPlayerConditionAttributeDescription = RemoveQuotes(test_string); break; case 11: pFastSpellAttributeDescription = RemoveQuotes(test_string); break; case 12: pPlayerAgeAttributeDescription = RemoveQuotes(test_string); break; case 13: pPlayerLevelAttributeDescription = RemoveQuotes(test_string); break; case 14: pPlayerExperienceAttributeDescription = RemoveQuotes(test_string); break; case 15: pAttackBonusAttributeDescription = RemoveQuotes(test_string); break; case 16: pAttackDamageAttributeDescription = RemoveQuotes(test_string); break; case 17: pMissleBonusAttributeDescription = RemoveQuotes(test_string); break; case 18: pMissleDamageAttributeDescription = RemoveQuotes(test_string); break; case 19: pFireResistanceAttributeDescription = RemoveQuotes(test_string); break; case 20: pAirResistanceAttributeDescription = RemoveQuotes(test_string); break; case 21: pWaterResistanceAttributeDescription = RemoveQuotes(test_string); break; case 22: pEarthResistanceAttributeDescription = RemoveQuotes(test_string); break; case 23: pMindResistanceAttributeDescription = RemoveQuotes(test_string); break; case 24: pBodyResistanceAttributeDescription = RemoveQuotes(test_string); break; case 25: pSkillPointsAttributeDescription = RemoveQuotes(test_string); break; } } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<2)&&!break_loop); } pClassTXT_Raw = 0; pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0); strtok(pClassTXT_Raw, "\r"); for (i=0; i<36; ++i) { test_string = strtok(NULL, "\r") + 1; break_loop = false; decode_step=0; do { c = *(unsigned char*)test_string; temp_str_len = 0; while((c!='\t')&&(c>0)) { ++temp_str_len; c=test_string[temp_str_len]; } tmp_pos=test_string+temp_str_len; if (*tmp_pos == 0) break_loop = true; *tmp_pos = 0; if (temp_str_len) { //if(i) pClassDescriptions[i]=RemoveQuotes(test_string); } else { if (!decode_step) break_loop = true; } ++decode_step; test_string=tmp_pos+1; } while ((decode_step<2)&&!break_loop); } } //----- (00456D17) -------------------------------------------------------- void ItemsTable::SetSpecialBonus(ItemGen *pItem) { if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL ) { pItem->uEncantmentType = pItems[pItem->uItemID]._bonus_type; pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value; pItem->_bonus_strength = pItems[pItem->uItemID]._bonus_strength; } } //----- (00456D43) -------------------------------------------------------- bool ItemsTable::IsMaterialSpecial(ItemGen *pItem) { return this->pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL; } //----- (00456D5E) -------------------------------------------------------- bool ItemsTable::IsMaterialNonCommon(ItemGen *pItem) { return pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL || pItems[pItem->uItemID].uMaterial == MATERIAL_RELIC || pItems[pItem->uItemID].uMaterial == MATERIAL_ARTEFACT; } //----- (00453B3C) -------------------------------------------------------- void ItemsTable::LoadPotions() { CHAR Text[90]; // [sp+Ch] [bp-6Ch]@26 char* test_string; unsigned int uRow; unsigned int uColumn; unsigned __int8 potion_value; if ( pPotionsTXT_Raw ) pAllocator->FreeChunk(pPotionsTXT_Raw); pPotionsTXT_Raw = NULL; pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); test_string = strtok(pPotionsTXT_Raw,"\t\r\n"); while ( 1 ) { if ( !test_string ) { MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); return; } if ( !strcmp(test_string, "222") ) break; test_string = strtok(NULL, "\t\r\n"); } while ( 1 ) { test_string = strtok(NULL, "\t\r\n"); if ( !test_string ) { MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); return; } if ( !strcmp(test_string, "222") ) break; } for (uRow = 0;uRow < 50; ++uRow) { int skip_count; for (skip_count = 0;skip_count < 6; ++skip_count) { if ( !strtok(NULL, "\r\t\n") ) break; } if ( skip_count != 6 ) break; for (uColumn = 0; uColumn < 50; ++uColumn) { test_string = strtok(NULL, "\r\t\n"); if ( !test_string ) break; potion_value = atoi(test_string); unsigned char c=*test_string; if ( !potion_value ) { if ( tolower(c) == 'e' ) potion_value = atoi(test_string + 1); else potion_value = 0; } this->potion_data[uRow][uColumn]=potion_value; } if ( uColumn != 50 ) break; strtok(NULL, "\r\t\n"); } if ( uRow != 50 ) { wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); } if ( pPotionsTXT_Raw ) { pAllocator->FreeChunk(pPotionsTXT_Raw); pPotionsTXT_Raw = 0; } } //----- (00453CE5) -------------------------------------------------------- void ItemsTable::LoadPotionNotes() { CHAR Text[90]; char* test_string; unsigned int uRow; unsigned int uColumn; unsigned __int8 potion_note; if ( pPotionNotesTXT_Raw ) pAllocator->FreeChunk(pPotionNotesTXT_Raw); pPotionNotesTXT_Raw = NULL; pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n"); while ( 1 ) { if ( !test_string ) { MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); return; } if ( !strcmp(test_string, "222") ) break; test_string = strtok(NULL, "\t\r\n"); } while ( 1 ) { test_string = strtok(NULL, "\t\r\n"); if ( !test_string ) { MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); return; } if ( !strcmp(test_string, "222") ) break; } for (uRow = 0;uRow < 50; ++uRow) { int skip_count; for (skip_count = 0;skip_count < 6; ++skip_count) { if ( !strtok(NULL, "\r\t\n") ) break; } if ( skip_count != 6 ) break; for (uColumn = 0; uColumn < 50; ++uColumn) { test_string = strtok(NULL, "\r\t\n"); if ( !test_string ) break; potion_note = atoi(test_string); unsigned char c=*test_string; if ( !potion_note ) { if ( tolower(c) == 'e' ) potion_note = atoi(test_string + 1); else potion_note = 0; } this->potion_note[uRow][uColumn]=potion_note; } if ( uColumn != 50 ) break; strtok(NULL, "\r\t\n"); } if ( uRow != 50 ) { wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, uColumn); MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); } } //----- (00456442) -------------------------------------------------------- unsigned int ItemGen::GetValue() { ItemGen *v1; // esi@1 unsigned int uBaseValue; // edi@1 int v3; // eax@4 int v4; // esi@5 unsigned int result; // eax@7 v1 = this; uBaseValue = pItemsTable->pItems[this->uItemID].uValue; if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) return uBaseValue; if ( v1->uEncantmentType ) { v3 = 100 * v1->_bonus_strength; return uBaseValue + v3; } v4 = v1->uSpecEnchantmentType; if ( !v4 ) { result = uBaseValue; } else { v3 = pItemsTable->pSpecialEnchantments[v4].iTreasureLevel; if ( (unsigned int)v3 > 0xA ) return uBaseValue + v3; result = uBaseValue * v3; } return result; } //----- (00456499) -------------------------------------------------------- const char *ItemGen::GetDisplayName() { if (Identified()) return GetIdentifiedName(); else return pItemsTable->pItems[uItemID].pUnidentifiedName; } //----- (004564B3) -------------------------------------------------------- const char *ItemGen::GetIdentifiedName() { unsigned __int8 equip_type; const char *player_name; const char *nameModificator; const char *format_str; equip_type = pItemsTable->pItems[uItemID].uEquipType; if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) ) { sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); return item__getname_buffer; } sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); if ( uItemID == ITEM_LICH_JAR ) //Lich Jar { if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) ) { player_name = pPlayers[uHolderPlayer]->pName; strlen(player_name); if ( player_name[strlen(player_name) - 1] == 's' ) format_str = pGlobalTXT_LocalizationStrings[655]; //"%s' Jar" else format_str = pGlobalTXT_LocalizationStrings[654]; //"%s's Jar" sprintf(item__getname_buffer, format_str, pPlayers[uHolderPlayer]->pName); return item__getname_buffer; } } if ( !pItemsTable->IsMaterialNonCommon(this) ) { if ( uEncantmentType ) { strcat(item__getname_buffer, " "); nameModificator = pItemsTable->pEnchantments[uEncantmentType-1].pOfName; } else { if ( !uSpecEnchantmentType ) return item__getname_buffer; if ( uSpecEnchantmentType == 16 //Drain Hit Points from target. || uSpecEnchantmentType == 39 //Double damage vs Demons. || uSpecEnchantmentType == 40 //Double damage vs Dragons || uSpecEnchantmentType == 45 //+5 Speed and Accuracy || uSpecEnchantmentType == 56 //+5 Might and Endurance. || uSpecEnchantmentType == 57 //+5 Intellect and Personality. || uSpecEnchantmentType == 58 //Increased Value. || uSpecEnchantmentType == 60 //+3 Unarmed and Dodging skills || uSpecEnchantmentType == 61 //+3 Stealing and Disarm skills. || uSpecEnchantmentType == 59 //Increased Weapon speed. || uSpecEnchantmentType == 63 //Double Damage vs. Elves. || uSpecEnchantmentType == 64 //Double Damage vs. Undead. || uSpecEnchantmentType == 67 //Adds 5 points of Body damage and +2 Disarm skill. || uSpecEnchantmentType == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class. { //enchantment and name positions inverted! sprintf( item__getname_buffer, "%s %s", pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd, pItemsTable->pItems[uItemID].pName); return item__getname_buffer; } strcat(item__getname_buffer, " "); nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd; } strcat(item__getname_buffer, nameModificator); } return item__getname_buffer; } //----- (00456620) -------------------------------------------------------- void ItemsTable::GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *out_item) { ItemGen *v4; // esi@1 ItemsTable *v5; // edi@1 int v6; // ebx@3 int *v7; // ecx@33 //int v8; // eax@34 //int v9; // eax@39 int v10; // ebx@43 int v11; // ecx@47 unsigned int *v12; // edx@48 unsigned int v13; // eax@49 signed int v14; // ebx@52 int v15; // eax@53 signed int v16; // eax@55 int v17; // ebx@57 int v18; // edx@62 signed int v19; // ebx@70 unsigned __int8 v20; // al@81 int v21; // eax@84 int v22; // ebx@85 int v23; // eax@86 int v24; // ebx@86 int v25; // edx@86 int v26; // edx@89 unsigned int v27; // eax@89 int i; // ebx@89 unsigned int v29; // ecx@90 int v30; // ebx@91 int v31; // eax@91 int v32; // ecx@91 int v33; // eax@91 int v34; // eax@97 unsigned __int8 v35; // sf@97 unsigned __int8 v36; // of@97 int v37; // ebx@98 int v38; // edx@99 signed int v39; // ebx@101 int v40; // ecx@102 char v41; // zf@107 char v42; // al@108 char v43; // al@111 int *v44; // edx@118 int v45; // eax@120 int v46; // edx@120 int *j; // eax@121 unsigned int v48; // ecx@123 int v49; // eax@123 int v50; // eax@123 int Dst[800]; // [sp+Ch] [bp-C88h]@33 int v52; // [sp+C8Ch] [bp-8h]@33 int v53; // [sp+C90h] [bp-4h]@1 int v54; // [sp+C9Ch] [bp+8h]@3 //int v55; // [sp+CA0h] [bp+Ch]@34 signed int v56; // [sp+CA0h] [bp+Ch]@55 int v57; // [sp+CA0h] [bp+Ch]@62 int *v58; // [sp+CA0h] [bp+Ch]@102 int v59; // [sp+CA0h] [bp+Ch]@123 //signed int a2a; // [sp+CA4h] [bp+10h]@33 int a2b; // [sp+CA4h] [bp+10h]@101 int a2c; // [sp+CA4h] [bp+10h]@120 v53 = -1; v5 = this; if (!out_item) out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen"); memset(out_item, 0, sizeof(*out_item)); v4 = out_item; v6 = treasure_level - 1; v54 = treasure_level - 1; if ( uTreasureType ) //generate known treasure type { ITEM_EQUIP_TYPE requested_equip; PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; switch (uTreasureType) { case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break; case 21: requested_equip = EQUIP_ARMOUR; break; case 22: requested_skill = PLAYER_SKILL_MISC; break; case 23: requested_skill = PLAYER_SKILL_SWORD; break; case 24: requested_skill = PLAYER_SKILL_DAGGER; break; case 25: requested_skill = PLAYER_SKILL_AXE; break; case 26: requested_skill = PLAYER_SKILL_SPEAR; break; case 27: requested_skill = PLAYER_SKILL_BOW; break; case 28: requested_skill = PLAYER_SKILL_MACE; break; case 29: requested_skill = PLAYER_SKILL_CLUB; break; case 30: requested_skill = PLAYER_SKILL_STAFF; break; case 31: requested_skill = PLAYER_SKILL_LEATHER; break; case 32: requested_skill = PLAYER_SKILL_CHAIN; break; case 33: requested_skill = PLAYER_SKILL_PLATE; break; case 34: requested_equip = EQUIP_SHIELD; break; case 35: requested_equip = EQUIP_HELMET; break; case 36: requested_equip = EQUIP_BELT; break; case 37: requested_equip = EQUIP_CLOAK; break; case 38: requested_equip = EQUIP_GAUNTLETS; break; case 39: requested_equip = EQUIP_BOOTS; break; case 40: requested_equip = EQUIP_RING; break; case 41: requested_equip = EQUIP_AMULET; break; case 42: requested_equip = EQUIP_WAND; break; case 43: requested_equip = EQUIP_SPELL_SCROLL; break; case 44: requested_equip = EQUIP_POTION; break; case 45: requested_equip = EQUIP_REAGENT; break; case 46: requested_equip = EQUIP_GEM; break; default: __debugbreak(); // check this condition requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1); break; } memset(Dst, 0, sizeof(Dst)); v52 = 0; v7 = Dst; //a2a = 1; if (requested_skill == PLAYER_SKILL_INVALID) // no skill for this item needed { for (uint i = 1; i < 500; ++i) { if (pItems[i].uEquipType == requested_equip) { *v7++ = i; v52 += pItems[i].uChanceByTreasureLvl[v6]; } } } else //have needed skill { for (uint i = 1; i < 500; ++i) { if (pItems[i].uSkillType == requested_skill) { *v7++ = i; v52 += pItems[i].uChanceByTreasureLvl[v6]; } } } v10 = 0; if ( v52 ) v10 = rand() % v52; out_item->uItemID = *Dst; if (!out_item->uItemID) out_item->uItemID = 1; v11 = pItems[out_item->uItemID].uChanceByTreasureLvl[v6]; if ( v11 < v10 ) { v12 = (uint *)Dst; do { ++v12; v13 = *v12; out_item->uItemID = *v12; v11 += pItems[v13].uChanceByTreasureLvl[v6]; } while ( v11 < v10 ); } if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) {// if it potion set potion spec out_item->uEncantmentType = 0; for (int i=0; i<2; ++i) out_item->uEncantmentType += rand() % 4 + 1; out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; } } else { v16 = 0; v56 = 0; do v56 += pParty->field_7BA[v16++]; while ( v16 < 29 ); v17 = rand() % 29; if ( v6 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) { pParty->field_7BA[v17] = 1; out_item->uAttributes = 0; out_item->uItemID = v17 + 500; SetSpecialBonus(out_item); return; } v57 = 0; v18 = rand() % v5->uChanceByTreasureLvlSumm[v54];// v5->field_11684[v54]; out_item->uItemID = 0; if ( v18 > 0 ) { do v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6]; while ( v57 < v18 ); } if ( !v18 ) out_item->uItemID = 1; if ( !out_item->uItemID ) out_item->uItemID = 1; if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) {// if it potion set potion spec out_item->uEncantmentType = 0; for (int i=0; i<2; ++i) out_item->uEncantmentType += rand() % 4 + 1; out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; } out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; } if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) ) v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; if ( pItemsTable->pItems[v4->uItemID + 1].uItemID_Rep_St ) v4->uAttributes = 0; else v4->uAttributes = 1; if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) { out_item->uSpecEnchantmentType = 0; out_item->uEncantmentType = 0; } v20 = pItems[out_item->uItemID].uEquipType; if ( v20 <= EQUIP_BOW ) { v37 = v5->uBonusChanceWpSpecial[v54]; if ( !*(unsigned int *)v37 ) return; v38 = rand() % 100; v36 = __OFSUB__(v38, *(unsigned int *)v37); v35 = v38 - *(unsigned int *)v37 < 0; } else { if ( v20 > EQUIP_AMULET ) { if ( v20 == EQUIP_WAND ) { v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; out_item->uNumCharges = v21; out_item->uMaxCharges = v21; } return; } v22 = (int)&uBonusChanceStandart[v6]; if ( !*(unsigned int *)v22 ) return; v24 = *(unsigned int *)v22; v25 = rand() % 100; if ( !uBonusChanceSpecial[v6] && !(v25 < v24)) return; if ( v25 < v24 || v25 < v24) { v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[v4->uItemID].uEquipType + 3]; v27 = v4->uItemID; v4->uEncantmentType = 0; for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1]; i < v26; i += pEnchantments[v4->uEncantmentType].to_item[pItems[v29].uEquipType + 1] ) { v29 = v4->uItemID; ++v4->uEncantmentType; } ++v4->uEncantmentType; v30 = 10;// v5->field_116D8[2 * v54 + 12]; v31 = rand(); v32 = v4->uEncantmentType - 1; v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30; v4->_bonus_strength = v33; if ( v32 == 21 || v32 == 22 || v32 == 23 ) v4->_bonus_strength = v33 >> 1; if ( v4->_bonus_strength <= 0 ) v4->_bonus_strength = 1; return; } v34 = v24 + 10;//*(unsigned int *)&v5->field_1169C[4 * v54 + 24]; v36 = __OFSUB__(v25, v34); v35 = v25 - v34 < 0; } if ( !(v35 ^ v36) ) return; memset(&Dst, 0, 0xC80u); v39 = 0; a2b = 0; if ( pSpecialEnchantments_count > 0 ) { v52 = -16 - (uint)this; v58 = (int *)&Dst; v40 = (int)&pSpecialEnchantments[1]; do { switch ( v6 ) { case 2: if ( !*(unsigned char *)v40 ) { v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) { v44 = v58; ++v58; *v44 = a2b; } ++a2b; v40 += 28; continue; } v41 = *(unsigned char *)v40 == 1; break; case 3: v43 = *(unsigned char *)v40; if ( !*(unsigned char *)v40 || v43 == 1 ) { v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) { v44 = v58; ++v58; *v44 = a2b; } ++a2b; v40 += 28; continue; } v41 = v43 == 2; break; case 4: v42 = *(unsigned char *)v40; if ( *(unsigned char *)v40 == 1 || v42 == 2 ) { v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) { v44 = v58; ++v58; *v44 = a2b; } ++a2b; v40 += 28; continue; } v41 = v42 == 3; break; default: if ( v6 != 5 ) { ++a2b; v40 += 28; continue; } v41 = *(unsigned char *)v40 == 3; break; } if ( v41 ) { v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType); if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) ) { v44 = v58; ++v58; *v44 = a2b; } } LABEL_119: ++a2b; v40 += 28; } while ( a2b < pSpecialEnchantments_count ); } v45 = rand(); v4->uSpecEnchantmentType = *(uint *)Dst; v46 = v45 % v39 + 1; a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType); if ( a2c < v46 ) { for ( j = (int *)&Dst; ; j = (int *)v59 ) { v48 = v4->uItemID; v49 = (int)(j + 1); v59 = v49; v50 = *(unsigned int *)v49; v4->uSpecEnchantmentType = v50; a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType); if ( a2c >= v46 ) break; } } ++v4->uSpecEnchantmentType; } //----- (004505CC) -------------------------------------------------------- bool ItemGen::GenerateArtifact() { ItemGen *v1; // edi@1 signed int uNumArtifactsNotFound; // esi@1 int v3; // eax@1 bool result; // eax@6 int artifacts_list[32]; // [sp+8h] [bp-A0h]@3 char Dst[32]; // [sp+88h] [bp-20h]@1 auto a2 = this; v1 = a2; memset(artifacts_list, 0,sizeof(artifacts_list)); uNumArtifactsNotFound = 0; for (int i=500;i<529;++i) if ( !pParty->field_3C.pIsArtifactFound[i] ) artifacts_list[uNumArtifactsNotFound++] = i; Reset(); if ( uNumArtifactsNotFound ) { uItemID = artifacts_list[rand() % uNumArtifactsNotFound]; pItemsTable->SetSpecialBonus(this); return true; } else return false; } // 4505CC: using guessed type int var_A0[32];