Mercurial > mm7
diff Items.cpp @ 0:9c0607679772
init
author | Ritor1 |
---|---|
date | Sat, 12 Jan 2013 09:45:18 +0600 |
parents | |
children | 038a4d09406f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Items.cpp Sat Jan 12 09:45:18 2013 +0600 @@ -0,0 +1,2284 @@ +#include <stdlib.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 "mm7_data.h" + + + + + +ItemGen *ptr_50C9A4; + +struct ItemsTable *pItemsTable; + + + + + +//----- (00439DF3) -------------------------------------------------------- +int ItemGen::_439DF3_get_additional_damage(int *a2, int *a3) +{ + int *v3; // edi@1 + ItemGen *v4; // ebx@1 + signed int v5; // esi@1 + unsigned int v7; // ecx@5 + signed int v8; // ebx@7 + int v9; // edx@22 + int v10; // eax@24 + int v11; // edx@25 + int v12; // ebx@28 + int v13; // ebx@29 + int v14; // ebx@30 + int v15; // ebx@31 + int v16; // ebx@32 + signed int v17; // [sp-4h] [bp-10h]@24 + + auto a1 = this; + v3 = a2; + v4 = a1; + v5 = 0; + *a2 = 0; + if ( !a1->uItemID ) + return 0; + UpdateTempBonus(pParty->uTimePlayed); + if ( v4->uItemID == 501 ) + { +LABEL_45: + *v3 = 1; + v10 = rand(); + v17 = 10; + return v10 % v17 + 6; + } + if ( v4->uItemID == 507 ) + { + *v3 = 0; + v11 = rand() % 16; + return v11 + 3; + } + v7 = 3; + if ( v4->uItemID == 510 ) + { + *v3 = 2; + v9 = rand() % 4; + return v9 + 9; + } + if ( v4->uItemID == 517 ) + goto LABEL_36; + v8 = v4->uAdditionalValue; + if ( v8 > 46 ) + { +LABEL_42: + v5 = 0; + goto LABEL_37; + } + if ( v8 == 46 ) + { + *v3 = 0; + return rand() % 11 + 10; + } + if ( v8 > 11 ) + { + v12 = v8 - 12; + if ( !v12 ) + { + *v3 = 0; + return GetDiceResult(v7, 6u); + } + v13 = v12 - 1; + if ( !v13 ) + { + *v3 = 8; + return 5; + } + v14 = v13 - 1; + if ( v14 ) + { + v15 = v14 - 1; + if ( v15 ) + { + v16 = v15 - 1; + if ( !v16 || v16 == 25 ) + { + *v3 = 10; + *a3 = 1; + return v5; + } + goto LABEL_42; + } + *v3 = 2; + return 12; + } +LABEL_36: + v5 = 8; +LABEL_37: + *v3 = v5; + return v5; + } + if ( v8 == 11 ) + { + *v3 = 0; + v7 = 2; + return GetDiceResult(v7, 6u); + } + if ( v8 == 4 ) + { + *v3 = 2; + v11 = rand() % 2; + return v11 + 3; + } + if ( v8 == 5 ) + { + *v3 = 2; + v10 = rand(); + v17 = 3; + return v10 % v17 + 6; + } + if ( v8 == 6 ) + { + *v3 = 2; + v9 = rand() % 4; + return v9 + 9; + } + if ( v8 == 7 ) + { + *v3 = 1; + return rand() % 4 + 2; + } + if ( v8 == 8 ) + { + *v3 = 1; + return rand() % 7 + 4; + } + if ( v8 == 9 ) + goto LABEL_45; + if ( v8 != 10 ) + goto LABEL_42; + *v3 = 0; + v7 = 1; + return GetDiceResult(v7, 6u); +} + + +//----- (00402F07) -------------------------------------------------------- +void ItemGen::Reset() +{ + this->field_1A = 0; + this->uAttributes = 0; + this->uNumCharges = 0; + this->uAdditionalValue = 0; + this->_bonus_strength = 0; + this->_bonus_type = 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->_bonus_type = 0; + LOBYTE(v2) = v2 & 0xF7; + this->uAdditionalValue = 0; + this->uAttributes = v2; + } + } +} + +//----- (0045814E) -------------------------------------------------------- +char *ItemsTable::Release() +{ + ItemsTable *v1; // edi@1 + char *result; // eax@23 + + v1 = this; + if ( pMonstersTXT_Raw ) + pAllocator->FreeChunk(pMonstersTXT_Raw); + if ( pMonsterPlacementTXT_Raw ) + pAllocator->FreeChunk(pMonsterPlacementTXT_Raw); + if ( pSkillDescTXT_Raw ) + pAllocator->FreeChunk(pSkillDescTXT_Raw); + if ( v1->pSpcItemsTXT_Raw ) + pAllocator->FreeChunk(v1->pSpcItemsTXT_Raw); + if ( v1->pStdItemsTXT_Raw ) + pAllocator->FreeChunk(v1->pStdItemsTXT_Raw); + if ( v1->pRndItemsTXT_Raw ) + pAllocator->FreeChunk(v1->pRndItemsTXT_Raw); + if ( v1->pItemsTXT_Raw ) + pAllocator->FreeChunk(v1->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); + v1->pSpcItemsTXT_Raw = 0; + pSkillDescTXT_Raw = 0; + v1->pStdItemsTXT_Raw = 0; + v1->pRndItemsTXT_Raw = pSkillDescTXT_Raw; + result = pSkillDescTXT_Raw; + v1->pItemsTXT_Raw = pSkillDescTXT_Raw; + return result; +} + + +//----- (00456D84) -------------------------------------------------------- +void ItemsTable::Initialize() +{ + //ItemsTable *v1; // edi@1 + char *v2; // eax@1 + char *v3; // eax@2 + char v4; // cl@3 + int v5; // esi@3 + char *v6; // esi@21 + char *v7; // eax@21 + char *v8; // ecx@22 + char *v9; // eax@26 + char v10; // dl@27 + int v11; // ecx@27 + int v12; // esi@31 + char *v13; // eax@39 + int v14; // esi@40 + char v15; // cl@41 + int v16; // eax@41 + char v17; // zf@53 + int v18; // eax@57 + int *v19; // esi@66 + char *v20; // edx@66 + int v21; // eax@66 + char *v22; // ecx@68 + char *v23; // eax@71 + int v24; // esi@71 + char *v25; // ebx@72 + char v26; // cl@73 + int v27; // eax@73 + char *v28; // ST3C_4@160 + char *v29; // ST3C_4@163 + char *v30; // eax@175 + char *v31; // eax@188 + char v32; // al@190 + char *v33; // eax@199 + const char *v34; // ebx@199 + int v35; // esi@199 + char *v36; // eax@200 + char v37; // dl@201 + int v38; // ecx@201 + char *v39; // esi@229 + char *v40; // eax@229 + char *v41; // ecx@230 + char *v42; // esi@233 + char *v43; // eax@234 + char v44; // dl@235 + int v45; // ecx@235 + signed int v46; // edi@287 + char *v47; // ecx@288 + char v48; // dl@289 + int v49; // eax@289 + int v50; // esi@293 + signed int v51; // edi@312 + char *v52; // ecx@312 + char v53; // dl@313 + int v54; // eax@313 + int v55; // esi@317 + signed int v56; // edi@348 + char *v57; // eax@348 + char v58; // dl@349 + int v59; // ecx@349 + int v60; // esi@353 + char *Str; // [sp+Ch] [bp-18h]@1 + signed int Stra; // [sp+Ch] [bp-18h]@22 + signed int Strb; // [sp+Ch] [bp-18h]@25 + signed int Strc; // [sp+Ch] [bp-18h]@39 + signed int Strd; // [sp+Ch] [bp-18h]@66 + signed int Stre; // [sp+Ch] [bp-18h]@156 + const char **Strf; // [sp+Ch] [bp-18h]@176 + const char **Strg; // [sp+Ch] [bp-18h]@182 + signed int Strh; // [sp+Ch] [bp-18h]@230 + signed int Stri; // [sp+Ch] [bp-18h]@311 + char **Strj; // [sp+Ch] [bp-18h]@347 + int v72; // [sp+10h] [bp-14h]@7 + signed int v73; // [sp+10h] [bp-14h]@21 + int v74; // [sp+10h] [bp-14h]@45 + int v75; // [sp+10h] [bp-14h]@77 + int v76; // [sp+10h] [bp-14h]@205 + signed int v77; // [sp+10h] [bp-14h]@229 + int v78; // [sp+10h] [bp-14h]@239 + signed int v79; // [sp+14h] [bp-10h]@1 + char *v80; // [sp+14h] [bp-10h]@39 + char *v81; // [sp+14h] [bp-10h]@175 + char *v82; // [sp+14h] [bp-10h]@188 + int v83; // [sp+18h] [bp-Ch]@67 + size_t v84; // [sp+18h] [bp-Ch]@156 + signed int v85; // [sp+18h] [bp-Ch]@176 + signed int v86; // [sp+18h] [bp-Ch]@182 + signed int v87; // [sp+18h] [bp-Ch]@233 + signed int v88; // [sp+1Ch] [bp-8h]@2 + signed int v89; // [sp+1Ch] [bp-8h]@26 + signed int v90; // [sp+1Ch] [bp-8h]@40 + signed int v91; // [sp+1Ch] [bp-8h]@72 + signed int v92; // [sp+1Ch] [bp-8h]@200 + signed int v93; // [sp+1Ch] [bp-8h]@234 + signed int v94; // [sp+1Ch] [bp-8h]@288 + signed int v95; // [sp+1Ch] [bp-8h]@312 + signed int v96; // [sp+1Ch] [bp-8h]@348 + signed int v97; // [sp+20h] [bp-4h]@2 + signed int v98; // [sp+20h] [bp-4h]@26 + signed int v99; // [sp+20h] [bp-4h]@40 + signed int v100; // [sp+20h] [bp-4h]@72 + signed int v101; // [sp+20h] [bp-4h]@200 + signed int v102; // [sp+20h] [bp-4h]@234 + signed int v103; // [sp+20h] [bp-4h]@288 + + //v1 = this; + + 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 = 0; + v2 = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0); + pStdItemsTXT_Raw = v2; + strtok(v2, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + Str = (char *)&pEnchantments[0].pParam; + v79 = 24; + do + { + v3 = strtok(0, "\r") + 1; + v97 = 0; + v88 = 0; + do + { + v4 = *v3; + v5 = 0; + while ( v4 != 9 && v4 ) + { + ++v5; + v4 = v3[v5]; + } + v72 = (int)&v3[v5]; + if ( !v3[v5] ) + v88 = 1; + v3[v5] = 0; + if ( v5 ) + { + if ( v97 ) + { + if ( v97 == 1 ) + { + *(unsigned int *)Str = (int)RemoveQuotes(v3); + } + else + { + if ( v97 > 1 ) + Str[v97 + 6] = atoi(v3); + } + } + else + { + *((char **)Str + 1) = RemoveQuotes(v3); + } + } + else + { + if ( !v97 ) + v88 = 1; + } + ++v97; + v3 = (char *)(v72 + 1); + } + while ( v97 <= 10 && !v88 ); + Str += 20; + --v79; + } + while ( v79 ); + v6 = (char *)&field_116D8[3]; + memset(&field_116D8[3], 0, 0x24u); + v7 = &pEnchantments[0].field_8[4]; + v73 = 9; + do + { + v8 = v7; + Stra = 24; + do + { + *(unsigned int *)v6 += (unsigned __int8)*v8; + v8 += 20; + --Stra; + } + while ( Stra ); + v6 += 4; + ++v7; + --v73; + } + while ( v73 ); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + Strb = 17856; + do + { + v9 = strtok(0, "\r") + 1; + v98 = 0; + v89 = 0; + do + { + v10 = *v9; + v11 = 0; + while ( v10 != 9 && v10 ) + { + ++v11; + v10 = v9[v11]; + } + v12 = (int)&v9[v11]; + if ( !v9[v11] ) + v89 = 1; + *(unsigned char *)v12 = 0; + if ( v11 && v98 > 1 ) + *(&pItems[0].uItemID + v98 + Strb) = atoi(v9); + ++v98; + v9 = (char *)(v12 + 1); + } + while ( v98 < 4 && !v89 ); + Strb += 2; + } + while ( Strb < 17868 ); + pSpcItemsTXT_Raw = 0; + v13 = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0); + pSpcItemsTXT_Raw = v13; + strtok(v13, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + v80 = (char *)&pSpecialEnchantments[0].pParam; + Strc = 72; + do + { + v99 = 0; + v14 = (int)(strtok(0, "\r") + 1); + v90 = 0; + do + { + v15 = *(unsigned char *)v14; + v16 = 0; + while ( v15 != 9 && v15 ) + { + ++v16; + v15 = *(unsigned char *)(v16 + v14); + } + v74 = v16 + v14; + if ( !*(unsigned char *)(v16 + v14) ) + v90 = 1; + *(unsigned char *)(v16 + v14) = 0; + if ( v16 ) + { + if ( v99 ) + { + if ( v99 == 1 ) + { + *(char **)v80 = RemoveQuotes((char *)v14); + } + else + { + if ( v99 <= 1 ) + { + v17 = v99 == 14; + } + else + { + v17 = v99 == 14; + if ( v99 < 14 ) + { + v80[v99 + 6] = atoi((const char *)v14); + goto LABEL_63; + } + } + if ( v17 ) + { + v18 = atoi((const char *)v14); + *((unsigned int *)v80 + 5) = v18; + if ( !v18 ) + *((unsigned int *)v80 + 5) = atoi((const char *)(v14 + 1)); + } + else + { + if ( v99 == 15 ) + v80[24] = tolower(*(unsigned char *)v14) - 97; + } + } + } + else + { + *((char **)v80 + 1) = RemoveQuotes((char *)v14); + } + } + else + { + if ( !v99 ) + v90 = 1; + } +LABEL_63: + ++v99; + v14 = v74 + 1; + } + while ( v99 <= 15 && !v90 ); + v80 += 28; + --Strc; + } + while ( Strc ); + v19 = field_11738; + memset(field_11738, 0, 0x60u); + v20 = &pSpecialEnchantments[0].field_8[4]; + Strd = 12; + v21 = 71; + field_11798 = 71; + do + { + v83 = 0; + if ( v21 > 0 ) + { + v22 = v20; + do + { + *v19 += (unsigned __int8)*v22; + ++v83; + v21 = field_11798; + v22 += 28; + } + while ( v83 < v21 ); + } + ++v19; + ++v20; + --Strd; + } + while ( Strd ); + Initialize2DA(); + pItemsTXT_Raw = 0; + v23 = (char *)pEvents_LOD->LoadRaw("items.txt", 0); + pItemsTXT_Raw = v23; + strtok(v23, "\r"); + v24 = 0; + strtok(0, "\r"); + pItems[0].uItemID = 0; + while ( 2 ) + { + v100 = 0; + v25 = strtok(0, "\r") + 1; + v91 = 0; + while ( 2 ) + { + v26 = *v25; + v27 = 0; + while ( v26 != 9 && v26 ) + { + ++v27; + v26 = v25[v27]; + } + v75 = (int)&v25[v27]; + if ( !v25[v27] ) + v91 = 1; + v25[v27] = 0; + if ( v27 ) + { + switch ( v100 ) + { + case 0: + v24 = atoi(v25); + break; + case 1: + pItems[v24].pIconName = (char *)RemoveQuotes(v25); + break; + case 2: + pItems[v24].pName = (char *)RemoveQuotes(v25); + break; + case 3: + pItems[v24].uValue = atoi(v25); + break; + case 4: + if ( !_strcmpi(v25, "weapon") ) + goto LABEL_89; + if ( _strcmpi(v25, "weapon2") ) + { + if ( _strcmpi(v25, "weapon1or2") ) + { + if ( _strcmpi(v25, "missile") && _strcmpi(v25, "bow") ) + { + if ( _strcmpi(v25, "armor") ) + { + if ( _strcmpi(v25, "shield") ) + { + if ( _strcmpi(v25, "helm") ) + { + if ( _strcmpi(v25, "belt") ) + { + if ( _strcmpi(v25, "cloak") ) + { + if ( _strcmpi(v25, "gauntlets") ) + { + if ( _strcmpi(v25, "boots") ) + { + if ( _strcmpi(v25, "ring") ) + { + if ( _strcmpi(v25, "amulet") ) + { + if ( _strcmpi(v25, "weaponw") ) + { + if ( _strcmpi(v25, "herb") && _strcmpi(v25, "reagent") ) + { + if ( _strcmpi(v25, "bottle") ) + { + if ( _strcmpi(v25, "sscroll") ) + { + if ( _strcmpi(v25, "book") ) + { + if ( _strcmpi(v25, "mscroll") ) + { + if ( _strcmpi(v25, "gold") ) + { + if ( _strcmpi(v25, "gem") ) + pItems[v24].uEquipType = 20; + else + pItems[v24].uEquipType = 19; + } + else + { + pItems[v24].uEquipType = 18; + } + } + else + { + pItems[v24].uEquipType = 17; + } + } + else + { + pItems[v24].uEquipType = 16; + } + } + else + { + pItems[v24].uEquipType = 15; + } + } + else + { + pItems[v24].uEquipType = 14; + } + } + else + { + pItems[v24].uEquipType = 13; + } + } + else + { + pItems[v24].uEquipType = 12; + } + } + else + { + pItems[v24].uEquipType = 11; + } + } + else + { + pItems[v24].uEquipType = 10; + } + } + else + { + pItems[v24].uEquipType = 9; + } + } + else + { + pItems[v24].uEquipType = 8; + } + } + else + { + pItems[v24].uEquipType = 7; + } + } + else + { + pItems[v24].uEquipType = 6; + } + } + else + { + pItems[v24].uEquipType = 5; + } + } + else + { + pItems[v24].uEquipType = 4; + } + } + else + { + pItems[v24].uEquipType = 3; + } + } + else + { + pItems[v24].uEquipType = 2; + } + } + else + { +LABEL_89: + pItems[v24].uEquipType = 0; + } + } + else + { + pItems[v24].uEquipType = 1; + } + break; + case 5: + if ( _strcmpi(v25, "staff") ) + { + if ( _strcmpi(v25, "sword") ) + { + if ( _strcmpi(v25, "dagger") ) + { + if ( _strcmpi(v25, "axe") ) + { + if ( _strcmpi(v25, "spear") ) + { + if ( _strcmpi(v25, "bow") ) + { + if ( _strcmpi(v25, "mace") ) + { + if ( _strcmpi(v25, "blaster") ) + { + if ( _strcmpi(v25, "shield") ) + { + if ( _strcmpi(v25, "leather") ) + { + if ( _strcmpi(v25, "chain") ) + { + if ( _strcmpi(v25, "plate") ) + { + if ( _strcmpi(v25, "club") ) + pItems[v24].uSkillType = 38; + else + pItems[v24].uSkillType = 37; + } + else + { + pItems[v24].uSkillType = 11; + } + } + else + { + pItems[v24].uSkillType = 10; + } + } + else + { + pItems[v24].uSkillType = 9; + } + } + else + { + pItems[v24].uSkillType = 8; + } + } + else + { + pItems[v24].uSkillType = 7; + } + } + else + { + pItems[v24].uSkillType = 6; + } + } + else + { + pItems[v24].uSkillType = 5; + } + } + else + { + pItems[v24].uSkillType = 4; + } + } + else + { + pItems[v24].uSkillType = 3; + } + } + else + { + pItems[v24].uSkillType = 2; + } + } + else + { + pItems[v24].uSkillType = 1; + } + } + else + { + pItems[v24].uSkillType = 0; + } + break; + case 6: + Stre = 0; + v84 = strlen(v25); + if ( (signed int)v84 > 0 ) + { + while ( tolower((unsigned __int8)v25[Stre]) != 'd' ) + { + ++Stre; + if ( Stre >= (signed int)v84 ) + goto LABEL_161; + } + v25[Stre] = 0; + v28 = (char *)&pItems[v24]; + v28[34] = atoi(v25); + v28[35] = atoi(&v25[Stre + 1]); + v25[Stre] = 'd'; + } +LABEL_161: + if ( Stre == v84 && tolower((unsigned __int8)*v25) != 115 ) + { + v29 = (char *)&pItems[v24]; + v29[34] = atoi(v25); + v29[35] = 1; + } + break; + case 7: + pItems[v24].uDamageMod = atoi(v25); + break; + case 8: + if ( _strcmpi(v25, "artifact") ) + { + if ( _strcmpi(v25, "relic") ) + { + if ( _strcmpi(v25, "special") ) + pItems[v24].uMaterial = 0; + else + pItems[v24].uMaterial = 3; + } + else + { + pItems[v24].uMaterial = 2; + } + } + else + { + pItems[v24].uMaterial = 1; + } + break; + case 9: + BYTE2(pItems[v24 + 1].uItemID) = atoi(v25); + break; + case 10: + pItems[v24].pUnidentifiedName = (char *)RemoveQuotes(v25); + break; + case 11: + pItems[v24].uSpriteID = atoi(v25); + break; + case 12: + v30 = (char *)&pItems[v24]; + v81 = v30; + if ( v30[37] == 3 ) + { + v85 = 0; + Strf = (const char **)&pEnchantments[0].pParam; + while ( _strcmpi(*Strf, v25) ) + { + ++v85; + Strf += 5; + if ( v85 >= 24 ) + goto LABEL_181; + } + v81[39] = v85 + 1; +LABEL_181: + if ( !v81[39] ) + { + v86 = 0; + Strg = (const char **)&pSpecialEnchantments[0].pParam; + while ( _strcmpi(*Strg, v25) ) + { + ++v86; + Strg += 7; + if ( v86 >= 72 ) + goto LABEL_196; + } + v81[38] = v86 + 1; + } + } + else + { + v30[38] = 0; + v30[39] = 0; + } + break; + case 13: + v31 = (char *)&pItems[v24]; + v82 = v31; + if ( v31[37] == 3 && v31[39] ) + { + v32 = atoi(v25); + v82[40] = v32; + if ( !v32 ) + v82[40] = 1; + } + else + { + v31[40] = 0; + } + break; + case 14: + pItems[v24].uEquipX = atoi(v25); + break; + case 15: + pItems[v24].uEquipY = atoi(v25); + break; + case 16: + pItems[v24].pDescription = (char *)RemoveQuotes(v25); + break; + default: + break; + } + } +LABEL_196: + ++v100; + v25 = (char *)(v75 + 1); + if ( v100 <= 16 && !v91 ) + continue; + break; + } + ++v24; + if ( v24 < 800 ) + continue; + break; + } + pRndItemsTXT_Raw = 0; + pItems[0].uItemID = v24; + v33 = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0); + v34 = "\r"; + pRndItemsTXT_Raw = v33; + strtok(v33, "\r"); + v35 = 0; + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + do + { + v101 = 0; + v36 = strtok(0, "\r") + 1; + v92 = 0; + do + { + v37 = *v36; + v38 = 0; + while ( v37 != 9 && v37 ) + { + ++v38; + v37 = v36[v38]; + } + v76 = (int)&v36[v38]; + if ( !v36[v38] ) + v92 = 1; + *(unsigned char *)v76 = 0; + if ( v38 ) + { + if ( v101 ) + { + switch ( v101 ) + { + case 2: + pItems[v35].field_2C = atoi(v36); + break; + case 3: + pItems[v35].field_2D = atoi(v36); + break; + case 4: + pItems[v35].field_2E = atoi(v36); + break; + case 5: + pItems[v35].field_2F = atoi(v36); + break; + case 6: + *((unsigned char *)&pItems[0].uItemID + 16 * (3 * v35 + 3)) = atoi(v36); + break; + case 7: + BYTE1(pItems[v35 + 1].uItemID) = atoi(v36); + break; + } + } + else + { + v35 = atoi(v36); + } + } + else + { + if ( !v101 ) + v92 = 1; + } + ++v101; + v36 = (char *)(v76 + 1); + } + while ( v101 <= 7 && !v92 ); + ++v35; + } + while ( v35 < 619 ); + if ( pRndItemsTXT_Raw ) + { + pAllocator->FreeChunk(pRndItemsTXT_Raw); + pRndItemsTXT_Raw = 0; + } + v39 = (char *)field_11684; + memset(field_11684, 0, 0x18u); + v40 = &pItems[0].field_2C; + v77 = 6; + do + { + v41 = v40; + Strh = 800; + do + { + *(unsigned int *)v39 += (unsigned __int8)*v41; + v41 += 48; + --Strh; + } + while ( Strh ); + v39 += 4; + ++v40; + --v77; + } + while ( v77 ); + v42 = 0; + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + strtok(0, "\r"); + v87 = 0; + do + { + v43 = strtok(v42, "\r") + 1; + v102 = (signed int)v42; + v93 = (signed int)v42; + do + { + v44 = *v43; + v45 = 0; + while ( v44 != 9 && v44 ) + { + ++v45; + v44 = v43[v45]; + } + v78 = (int)&v43[v45]; + if ( !v43[v45] ) + v93 = 1; + v42 = 0; + *(unsigned char *)v78 = 0; + if ( v45 ) + { + switch ( v102 ) + { + case 2: + if ( v87 ) + { + if ( v87 == 1 ) + { + *(unsigned int *)&field_1169C[24] = atoi(v43); + } + else + { + if ( v87 == 2 ) + *(unsigned int *)&field_1169C[48] = atoi(v43); + } + } + else + { + *(unsigned int *)&field_1169C[0] = atoi(v43); + } + break; + case 3: + if ( v87 ) + { + if ( v87 == 1 ) + { + *(unsigned int *)&field_1169C[28] = atoi(v43); + } + else + { + if ( v87 == 2 ) + *(unsigned int *)&field_1169C[52] = atoi(v43); + } + } + else + { + *(unsigned int *)&field_1169C[4] = atoi(v43); + } + break; + case 4: + if ( v87 ) + { + if ( v87 == 1 ) + { + *(unsigned int *)&field_1169C[32] = atoi(v43); + } + else + { + if ( v87 == 2 ) + *(unsigned int *)&field_1169C[56] = atoi(v43); + } + } + else + { + *(unsigned int *)&field_1169C[8] = atoi(v43); + } + break; + case 5: + if ( v87 ) + { + if ( v87 == 1 ) + { + *(unsigned int *)&field_1169C[36] = atoi(v43); + } + else + { + if ( v87 == 2 ) + field_116D8[0] = atoi(v43); + } + } + else + { + *(unsigned int *)&field_1169C[12] = atoi(v43); + } + break; + case 6: + if ( v87 ) + { + if ( v87 == 1 ) + { + *(unsigned int *)&field_1169C[40] = atoi(v43); + } + else + { + if ( v87 == 2 ) + field_116D8[1] = atoi(v43); + } + } + else + { + *(unsigned int *)&field_1169C[16] = atoi(v43); + } + break; + case 7: + if ( v87 ) + { + if ( v87 == 1 ) + { + *(unsigned int *)&field_1169C[44] = atoi(v43); + } + else + { + if ( v87 == 2 ) + field_116D8[2] = atoi(v43); + } + } + else + { + *(unsigned int *)&field_1169C[20] = atoi(v43); + } + break; + } + } + ++v102; + v43 = (char *)(v78 + 1); + } + while ( v102 <= 7 && !v93 ); + ++v87; + } + while ( v87 < 3 ); + pSkillDescTXT_Raw = 0; + pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); + strtok(pSkillDescTXT_Raw, "\r"); + v46 = 0; + do + { + v103 = 0; + v94 = 0; + v47 = strtok(0, "\r") + 1; + do + { + v48 = *v47; + v49 = 0; + while ( v48 != 9 && v48 ) + { + ++v49; + v48 = v47[v49]; + } + v50 = (int)&v47[v49]; + if ( !v47[v49] ) + v94 = 1; + *(unsigned char *)v50 = 0; + if ( v49 ) + { + switch ( v103 ) + { + case 1: + pSkillDesc[v46] = (char *)RemoveQuotes(v47); + break; + case 2: + pNormalSkillDesc[v46] = (char *)RemoveQuotes(v47); + break; + case 3: + pExpertSkillDesc[v46] = (char *)RemoveQuotes(v47); + break; + case 4: + pMasterSkillDesc[v46] = (char *)RemoveQuotes(v47); + break; + case 5: + pGrandSkillDesc[v46] = (char *)RemoveQuotes(v47); + break; + } + } + else + { + if ( !v103 ) + v94 = 1; + } + ++v103; + v47 = (char *)(v50 + 1); + } + while ( v103 <= 5 && !v94 ); + ++v46; + } + while ( v46 < 37 ); + pStatsTXT_Raw = 0; + pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); + strtok(pStatsTXT_Raw, "\r"); + Stri = 0; + do + { + v51 = 0; + v95 = 0; + v52 = strtok(0, v34) + 1; + do + { + v53 = *v52; + v54 = 0; + if ( *v52 != 9 ) + { + do + { + if ( !v53 ) + break; + ++v54; + v53 = v52[v54]; + } + while ( v53 != 9 ); + v34 = "\r"; + } + v55 = (int)&v52[v54]; + if ( !v52[v54] ) + v95 = 1; + *(unsigned char *)v55 = 0; + if ( v54 ) + { + if ( v51 ) + { + switch ( Stri ) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + pAttributeDescriptions[Stri] = (char *)RemoveQuotes(v52); + break; + case 7: + pHealthPointsAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 8: + pArmourClassAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 9: + pSpellPointsAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 10: + pPlayerConditionAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 11: + pFastSpellAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 12: + pPlayerAgeAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 13: + pPlayerLevelAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 14: + pPlayerExperienceAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 15: + pAttackBonusAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 16: + pAttackDamageAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 17: + pMissleBonusAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 18: + pMissleDamageAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 19: + pFireResistanceAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 20: + pAirResistanceAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 21: + pWaterResistanceAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 22: + pEarthResistanceAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 23: + pMindResistanceAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 24: + pBodyResistanceAttributeDescription = (char *)RemoveQuotes(v52); + break; + case 25: + pSkillPointsAttributeDescription = (char *)RemoveQuotes(v52); + break; + default: + break; + } + } + } + else + { + if ( !v51 ) + v95 = 1; + } + ++v51; + v52 = (char *)(v55 + 1); + } + while ( v51 < 2 && !v95 ); + ++Stri; + } + while ( Stri < 26 ); + pClassTXT_Raw = 0; + pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0); + strtok(pClassTXT_Raw, v34); + Strj = pClassDescriptions; + do + { + v56 = 0; + v57 = strtok(0, v34) + 1; + v96 = 0; + do + { + v58 = *v57; + v59 = 0; + if ( *v57 != 9 ) + { + do + { + if ( !v58 ) + break; + ++v59; + v58 = v57[v59]; + } + while ( v58 != 9 ); + v34 = "\r"; + } + v60 = (int)&v57[v59]; + if ( !v57[v59] ) + v96 = 1; + *(unsigned char *)v60 = 0; + if ( v59 ) + { + if ( v56 ) + *Strj = (char *)RemoveQuotes(v57); + } + else + { + if ( !v56 ) + v96 = 1; + } + ++v56; + v57 = (char *)(v60 + 1); + } + while ( v56 < 2 && !v96 ); + ++Strj; + } + while ( (signed int)Strj <= (signed int)&pClassDescriptions[35] ); +} + +//----- (00456D17) -------------------------------------------------------- +void ItemsTable::SetSpecialBonus(ItemGen *pItem) +{ + ItemDesc *v2; // eax@1 + + v2 = &this->pItems[pItem->uItemID]; + if ( v2->uMaterial == 3 ) + { + pItem->_bonus_type = v2->_bonus_type; + pItem->uAdditionalValue = v2->_additional_value; + pItem->_bonus_strength = v2->_bonus_strength; + } +} + +//----- (00456D43) -------------------------------------------------------- +bool ItemsTable::_456D43_is_material_equals_3(ItemGen *pItem) +{ + return this->pItems[pItem->uItemID].uMaterial == 3; +} + +//----- (00456D5E) -------------------------------------------------------- +bool ItemsTable::_456D5E_is_some_material(ItemGen *pItem) +{ + unsigned __int8 v2; // al@1 + + v2 = this->pItems[pItem->uItemID].uMaterial; + return v2 == 3 || v2 == 1 || v2 == 2; +} + + +//----- (00453B3C) -------------------------------------------------------- +void ItemsTable::LoadPotions() +{ + char *i; // eax@3 + signed int v2; // esi@11 + char *v3; // eax@16 + char *v4; // edi@16 + __int16 v5; // ax@17 + char *v6; // esi@17 + CHAR Text; // [sp+Ch] [bp-6Ch]@26 + ItemsTable *v8; // [sp+68h] [bp-10h]@1 + int v9; // [sp+6Ch] [bp-Ch]@10 + int v10; // [sp+70h] [bp-8h]@10 + char *v11; // [sp+74h] [bp-4h]@4 + + v8 = this; + if ( pPotionsTXT_Raw ) + pAllocator->FreeChunk(pPotionsTXT_Raw); + pPotionsTXT_Raw = 0; + pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); + for ( i = strtok(pPotionsTXT_Raw, "\t\r\n"); ; i = strtok(0, "\t\r\n") ) + { + v11 = i; + if ( !strcmp(i, "222") ) + break; + if ( !v11 ) + { +LABEL_20: + MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", 0x10u); + return; + } + } + while ( 1 ) + { + v11 = strtok(0, "\t\r\n"); + if ( !strcmp(v11, "222") ) + break; + if ( !v11 ) + goto LABEL_20; + } + v9 = 0; + v10 = 30642; + do + { + v11 = 0; + v2 = 0; + do + { + if ( !strtok(0, "\r\t\n") ) + break; + ++v2; + } + while ( v2 < 6 ); + if ( v2 != 6 ) + break; + v11 = 0; + do + { + v3 = strtok(0, "\r\t\n"); + v4 = v3; + if ( !v3 ) + break; + v5 = atoi(v3); + v6 = (char *)v8 + 2 * (uint)&v11[v10]; + *(_WORD *)v6 = v5; + if ( !v5 ) + { + if ( tolower((unsigned __int8)*v4) == 101 ) + *(_WORD *)v6 = atoi(v4 + 1); + else + *(_WORD *)v6 = 0; + } + ++v11; + } + while ( (signed int)v11 < 50 ); + if ( v11 != (char *)50 ) + break; + strtok(0, "\r\t\n"); + v10 += 50; + ++v9; + } + while ( v10 < 33142 ); + if ( v9 != 50 ) + { + wsprintfA(&Text, "Error Parsing Potion Table at Row: %d Column: %d", v9, v11); + MessageBoxA(0, &Text, "Parsing Error", 0x10u); + } + if ( pPotionsTXT_Raw ) + { + pAllocator->FreeChunk(pPotionsTXT_Raw); + pPotionsTXT_Raw = 0; + } +} + +//----- (00453CE5) -------------------------------------------------------- +void ItemsTable::LoadPotionNotes() +{ + char *i; // eax@3 + signed int v2; // esi@11 + char *v3; // eax@16 + char *v4; // edi@16 + __int16 v5; // ax@17 + char *v6; // esi@17 + CHAR *v7; // [sp-Ch] [bp-84h]@20 + const CHAR *v8; // [sp-8h] [bp-80h]@20 + UINT v9; // [sp-4h] [bp-7Ch]@20 + CHAR Text; // [sp+Ch] [bp-6Ch]@26 + ItemsTable *v11; // [sp+68h] [bp-10h]@1 + int v12; // [sp+6Ch] [bp-Ch]@10 + int v13; // [sp+70h] [bp-8h]@10 + char *v14; // [sp+74h] [bp-4h]@4 + + v11 = this; + if ( pPotionNotesTXT_Raw ) + pAllocator->FreeChunk(pPotionNotesTXT_Raw); + pPotionNotesTXT_Raw = 0; + pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); + for ( i = strtok(pPotionNotesTXT_Raw, "\t\r\n"); ; i = strtok(0, "\t\r\n") ) + { + v14 = i; + if ( !strcmp(i, "222") ) + break; + if ( !v14 ) + { +LABEL_20: + v9 = 16; + v8 = "Load Error"; + v7 = "Error Pre-Parsing Potion Table"; +LABEL_27: + MessageBoxA(0, v7, v8, v9); + return; + } + } + while ( 1 ) + { + v14 = strtok(0, "\t\r\n"); + if ( !strcmp(v14, "222") ) + break; + if ( !v14 ) + goto LABEL_20; + } + v12 = 0; + v13 = 33142; + do + { + v14 = 0; + v2 = 0; + do + { + if ( !strtok(0, "\r\t\n") ) + break; + ++v2; + } + while ( v2 < 6 ); + if ( v2 != 6 ) + break; + v14 = 0; + do + { + v3 = strtok(0, "\r\t\n"); + v4 = v3; + if ( !v3 ) + break; + v5 = atoi(v3); + v6 = (char *)v11 + 2 * (unsigned int)&v14[v13]; + *(unsigned short *)v6 = v5; + if ( !v5 ) + { + if ( tolower((unsigned __int8)*v4) == 101 ) + *(unsigned short *)v6 = atoi(v4 + 1); + else + *(unsigned short *)v6 = 0; + } + ++v14; + } + while ( (signed int)v14 < 50 ); + if ( v14 != (char *)50 ) + break; + strtok(0, "\r\t\n"); + v13 += 50; + ++v12; + } + while ( v13 < 35642 ); + if ( v12 != 50 ) + { + wsprintfA(&Text, "Error Parsing Potion Autonote Table at Row: %d Column: %d", v12, v14); + v9 = 16; + v8 = "Parsing Error"; + v7 = &Text; + goto LABEL_27; + } +} + + +//----- (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->_456D5E_is_some_material(this) ) + goto LABEL_12; + if ( v1->_bonus_type ) + { + v3 = 100 * v1->_bonus_strength; + return uBaseValue + v3; + } + v4 = v1->uAdditionalValue; + if ( !v4 ) + { +LABEL_12: + result = uBaseValue; + } + else + { + v3 = *(unsigned int *)&pItemsTable->pEnchantments[23].field_8[28 * v4 + 8]; + if ( (unsigned int)v3 > 0xA ) + return uBaseValue + v3; + result = uBaseValue * v3; + } + return result; +} + +//----- (00456499) -------------------------------------------------------- +const char *ItemGen::GetDisplayName() +{ + const char *result; // eax@2 + + if ( this->uAttributes & ITEM_IDENTIFIED ) + result = GetIdentifiedName(); + else + result = pItemsTable->pItems[uItemID].pUnidentifiedName; + return result; +} + +//----- (004564B3) -------------------------------------------------------- +const char *ItemGen::GetIdentifiedName() +{ + ItemGen *v1; // esi@1 + unsigned int v2; // eax@1 + unsigned __int8 v3; // cl@1 + char *v4; // edi@4 + char v5; // al@6 + const char *v6; // esi@8 + int v7; // eax@15 + const char *v9; // [sp-Ch] [bp-14h]@14 + const char *v10; // [sp-8h] [bp-10h]@4 + char *v11; // [sp-4h] [bp-Ch]@4 + + v1 = this; + v2 = this->uItemID; + v3 = pItemsTable->pItems[v2].uEquipType; + if ( v3 >= EQUIP_REAGENT && (v3 <= EQUIP_POTION || v3 == EQUIP_GOLD) ) + { + v11 = pItemsTable->pItems[v2].pName; + v4 = item__getname_buffer; + v10 = "%s"; +LABEL_10: + sprintf(v4, v10, v11); + return v4; + } + v4 = item__getname_buffer; + sprintf(item__getname_buffer, "%s", pItemsTable->pItems[v2].pName); + if ( v1->uItemID == 601 ) + { + v5 = v1->field_1A; + if ( (unsigned __int8)v5 >= 1u ) + { + if ( (unsigned __int8)v5 <= 4u ) + { + v6 = pPlayers[(unsigned __int8)v5]->pName; + strlen(pPlayers[(unsigned __int8)v5]->pName); + v11 = (char *)v6; + if ( v6[strlen(v6) - 1] == 115 ) + v10 = pGlobalTXT_LocalizationStrings[655]; + else + v10 = pGlobalTXT_LocalizationStrings[654]; + goto LABEL_10; + } + } + } + if ( !pItemsTable->_456D5E_is_some_material(v1) ) + { + if ( v1->_bonus_type ) + { + strcat(item__getname_buffer, " "); + v9 = (const char *)*((unsigned int *)&pItemsTable->pItems[799].uEquipType + 5 * v1->_bonus_type); + } + else + { + v7 = v1->uAdditionalValue; + if ( !v7 ) + return v4; + if ( v7 == 16 + || v7 == 39 + || v7 == 40 + || v7 == 45 + || v7 == 56 + || v7 == 57 + || v7 == 58 + || v7 == 60 + || v7 == 61 + || v7 == 59 + || v7 == 63 + || v7 == 64 + || v7 == 67 + || v7 == 68 ) + { + sprintf( + item__getname_buffer, + "%s %s", + *(unsigned int *)&pItemsTable->pEnchantments[22].field_8[28 * v7 + 8], + pItemsTable->pItems[v1->uItemID].pName); + return v4; + } + strcat(item__getname_buffer, " "); + v9 = *(const char **)&pItemsTable->pEnchantments[22].field_8[28 * v1->uAdditionalValue + 8]; + } + strcat(item__getname_buffer, v9); + } + return v4; +} + + +//----- (00456620) -------------------------------------------------------- +void ItemsTable::GenerateItem(int a2, int a3, ItemGen *pItem) +{ + 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 + unsigned char Dst[0xC80]; // [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; + v4 = pItem; + v5 = this; + if ( !pItem ) + v4 = (ItemGen *)pAllocator->AllocNamedChunk(pItem, 0x24u, "newItemGen"); + memset(v4, 0, 0x24u); + v6 = a2 - 1; + v54 = a2 - 1; + if ( a3 ) + { + switch ( a3 ) + { + case 20: + a3 = EQUIP_ONE_OR_TWO_HANDS; + break; + case 21: + a3 = 3; + break; + case 22: + v53 = 38; + break; + case 23: + v53 = 1; + break; + case 24: + v53 = 2; + break; + case 25: + v53 = 3; + break; + case 26: + v53 = 4; + break; + case 27: + v53 = 5; + break; + case 28: + v53 = 6; + break; + case 30: + v53 = 0; + break; + case 31: + v53 = 9; + break; + case 32: + v53 = 10; + break; + case 33: + v53 = 0xBu; + break; + case 34: + a3 = 4; + break; + case 35: + a3 = 5; + break; + case 36: + a3 = 6; + break; + case 37: + a3 = 7; + break; + case 38: + a3 = 8; + break; + case 39: + a3 = EQUIP_BOOTS; + break; + case 40: + a3 = EQUIP_RING; + break; + case 41: + a3 = 0xBu; + break; + case 42: + a3 = EQUIP_C; + break; + case 43: + a3 = EQUIP_F; + break; + case 44: + a3 = EQUIP_POTION; + break; + case 45: + a3 = EQUIP_REAGENT; + break; + case 46: + a3 = EQUIP_GEM; + break; + case 29: + v53 = 37; + break; + default: + --a3; + break; + } + memset(&Dst, 0, 0xC80u); + v52 = 0; + v7 = (int *)&Dst; + a2a = 1; + if ( v53 == -1 ) + { + v53 = (int)&v5->pItems[1].uEquipType; + v9 = (int)(&v5->pItems[1].field_2C + v6); + do + { + if ( *(unsigned char *)v53 == a3 ) + { + *v7 = a2a; + ++v7; + v52 += *(unsigned char *)v9; + } + ++a2a; + v53 += 48; + v9 += 48; + } + while ( a2a < 500 ); + } + else + { + v55 = (int)&v5->pItems[1].uSkillType; + v8 = (int)(&v5->pItems[1].field_2C + v6); + do + { + if ( *(unsigned char *)v55 == v53 ) + { + *v7 = a2a; + ++v7; + v52 += *(unsigned char *)v8; + } + ++a2a; + v55 += 48; + v8 += 48; + } + while ( a2a < 500 ); + } + v10 = 0; + if ( v52 ) + v10 = rand() % v52; + v4->uItemID = *(uint *)Dst; + if ( !Dst ) + v4->uItemID = 1; + v11 = *(&v5->pItems[v4->uItemID].field_2C + v54); + if ( v11 < v10 ) + { + v12 = (uint *)Dst; + do + { + ++v12; + v13 = *v12; + v4->uItemID = *v12; + v11 += *(&v5->pItems[v13].field_2C + v54); + } + while ( v11 < v10 ); + } + if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) + { + v4->_bonus_type = 0; + v14 = 2; + do + { + v4->_bonus_type += rand() % 4 + 1; + v15 = v4->_bonus_type; + --v14; + } + while ( v14 ); +LABEL_72: + v4->_bonus_type = v15 * (v54 + 1); + goto LABEL_73; + } + } + else + { + v16 = 0; + v56 = 0; + do + v56 += pParty->field_7BA[v16++]; + while ( v16 < 29 ); + v17 = rand() % 29; + if ( v54 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) + { + pParty->field_7BA[v17] = 1; + v4->uAttributes = 0; + v4->uItemID = v17 + 500; + v5->SetSpecialBonus(v4); + return; + } + v57 = 0; + v18 = rand() % v5->field_11684[v54]; + v4->uItemID = 0; + if ( v18 > 0 ) + { + do + v57 += *(&v5->pItems[v4->uItemID++ + 1].field_2C + v54); + while ( v57 < v18 ); + } + if ( !v18 ) + v4->uItemID = 1; + if ( !v4->uItemID ) + v4->uItemID = 1; + if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) + { + v4->_bonus_type = 0; + v19 = 2; + do + { + v4->_bonus_type += rand() % 4 + 1; + v15 = v4->_bonus_type; + --v19; + } + while ( v19 ); + goto LABEL_72; + } + } +LABEL_73: + 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 ( BYTE2(pItemsTable->pItems[v4->uItemID + 1].uItemID) ) + v4->uAttributes = 0; + else + v4->uAttributes = 1; + if ( v5->pItems[v4->uItemID].uEquipType != EQUIP_POTION ) + { + v4->uAdditionalValue = 0; + v4->_bonus_type = 0; + } + v20 = v5->pItems[v4->uItemID].uEquipType; + if ( v20 <= EQUIP_BOW ) + { + v37 = (int)&v5->field_1169C[4 * v54 + 48]; + 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_C ) + { + v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; + v4->uNumCharges = v21; + v4->uMaxCharges = v21; + } + return; + } + v22 = (int)&v5->field_1169C[4 * v54]; + if ( !*(unsigned int *)v22 ) + return; + v23 = rand(); + v24 = *(unsigned int *)v22; + v25 = v23 % 100; + if ( v23 % 100 < v24 ) + goto LABEL_127; + if ( !*(unsigned int *)&v5->field_1169C[4 * v54 + 24] ) + return; + if ( v25 < v24 ) + { +LABEL_127: + v26 = rand() % v5->field_116D8[v5->pItems[v4->uItemID].uEquipType]; + v27 = v4->uItemID; + v4->_bonus_type = 0; + for ( i = v5->pEnchantments[0].field_8[v5->pItems[v27].uEquipType + 1]; + i < v26; + i += v5->pEnchantments[v4->_bonus_type].field_8[v5->pItems[v29].uEquipType + 1] ) + { + v29 = v4->uItemID; + ++v4->_bonus_type; + } + ++v4->_bonus_type; + v30 = v5->field_116D8[2 * v54 + 12]; + v31 = rand(); + v32 = v4->_bonus_type - 1; + v33 = v31 % (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 + *(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 ( v5->field_11798 > 0 ) + { + v52 = -16 - (uint)v5; + v58 = (int *)&Dst; + v40 = (int)&v5->pSpecialEnchantments[1]; + do + { + switch ( v54 ) + { + case 2: + if ( !*(unsigned char *)v40 ) + goto LABEL_117; + v41 = *(unsigned char *)v40 == 1; + break; + case 3: + v43 = *(unsigned char *)v40; + if ( !*(unsigned char *)v40 || v43 == 1 ) + { +LABEL_117: + v39 += *((unsigned char *)&v5->pItems[0].uItemID + v40 + v52 + v5->pItems[v4->uItemID].uEquipType); + if ( *((unsigned char *)&v5->pItems[0].uItemID + v40 + v52 + v5->pItems[v4->uItemID].uEquipType) ) + { + v44 = v58; + ++v58; + *v44 = a2b; + } + goto LABEL_119; + } + v41 = v43 == 2; + break; + case 4: + v42 = *(unsigned char *)v40; + if ( *(unsigned char *)v40 == 1 || v42 == 2 ) + goto LABEL_117; + v41 = v42 == 3; + break; + default: + if ( v54 != 5 ) + goto LABEL_119; + v41 = *(unsigned char *)v40 == 3; + break; + } + if ( v41 ) + goto LABEL_117; +LABEL_119: + ++a2b; + v40 += 28; + } + while ( a2b < v5->field_11798 ); + } + v45 = rand(); + v4->uAdditionalValue = *(uint *)Dst; + v46 = v45 % v39 + 1; + a2c = *((unsigned char *)&v5->pItems[0].uItemID + 28 * (*(uint *)Dst + 1389) + v5->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->uAdditionalValue = v50; + a2c += *((unsigned char *)&v5->pItems[0].uItemID + 28 * (v50 + 1389) + v5->pItems[v48].uEquipType); + if ( a2c >= v46 ) + break; + } + } + ++v4->uAdditionalValue; +} + +//----- (004505CC) -------------------------------------------------------- +bool ItemGen::GenerateArtifact() +{ + ItemGen *v1; // edi@1 + signed int uNumArtifactsNotFound; // esi@1 + int v3; // eax@1 + bool result; // eax@6 + int v5[32]; // [sp+8h] [bp-A0h]@3 + char Dst[32]; // [sp+88h] [bp-20h]@1 + + auto a2 = this; + v1 = a2; + memset(Dst, 0, 0x20u); + uNumArtifactsNotFound = 0; + v3 = 500; + do + { + if ( !pParty->field_3C.pIsArtifactFound[v3] ) + v5[uNumArtifactsNotFound++] = v3; + ++v3; + } + while ( v3 < 529 ); + v1->Reset(); + if ( uNumArtifactsNotFound ) + { + v1->uItemID = v5[rand() % uNumArtifactsNotFound]; + pItemsTable->SetSpecialBonus(v1); + result = 1; + } + else + { + result = 0; + } + return result; +} +// 4505CC: using guessed type int var_A0[32]; \ No newline at end of file