Mercurial > mm7
diff Items.cpp @ 463:f7b91ef98ab2
shopgenerators done, except config tables
author | Gloval |
---|---|
date | Mon, 25 Feb 2013 08:30:49 +0400 |
parents | 197461e5acec |
children | fcdaa804074f |
line wrap: on
line diff
--- a/Items.cpp Sun Feb 24 20:47:46 2013 +0400 +++ b/Items.cpp Mon Feb 25 08:30:49 2013 +0400 @@ -18,6 +18,87 @@ +struct ITEM_VARIATION + { + unsigned __int16 treasure_level; + unsigned __int16 item_class[4]; + }; + + +char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12}; + +ITEM_VARIATION shopWeap_variation_ord[15] ={ + { 0, { 0, 0, 0, 0 }}, + { 1, { 23, 27, 20, 20 }}, + { 1, { 23, 24, 28, 20 }}, + { 2, { 23, 24, 25, 20 }}, + { 2, { 27, 27, 26, 26 }}, + { 4, { 24, 30, 25, 27 }}, + { 4, { 24, 30, 25, 27 }}, + { 3, { 30, 24, 20, 20 }}, + { 2, { 20, 20, 20, 20 }}, + { 3, { 27, 27, 26, 26 }}, + { 3, { 28, 28, 25, 25 }}, + { 2, { 23, 23, 24, 24 }}, + { 3, { 23, 23, 26, 26 }}, + { 2, { 30, 26, 26, 26 }}, + { 2, { 28, 25, 28, 29 }}}; + +ITEM_VARIATION shopArmr_variation_ord[30] ={ + { 1, { 35, 35, 38, 38 }}, + { 1, { 31, 31, 31, 34 }}, + { 1, { 35, 35, 38, 38 }}, + { 1, { 31, 31, 32, 34 }}, + { 2, { 35, 35, 38, 38 }}, + { 2, { 31, 32, 32, 33 }}, + { 2, { 35, 35, 38, 38 }}, + { 2, { 31, 31, 32, 32 }}, + { 4, { 35, 35, 38, 38 }}, + { 4, { 31, 32, 33, 34 }}, + { 4, { 35, 35, 38, 38 }}, + { 4, { 31, 32, 33, 34 }}, + { 3, { 35, 35, 38, 38 }}, + { 3, { 31, 31, 31, 31 }}, + { 2, { 35, 35, 38, 38 }}, + { 2, { 31, 32, 34, 34 }}, + { 3, { 35, 35, 38, 38 }}, + { 3, { 31, 31, 32, 32 }}, + { 3, { 35, 35, 38, 38 }}, + { 3, { 32, 32, 32, 33 }}, + { 3, { 35, 35, 38, 38 }}, + { 3, { 31, 31, 31, 32 }}, + { 3, { 35, 35, 38, 38 }}, + { 3, { 33, 31, 32, 34 }}, + { 3, { 35, 35, 38, 38 }}, + { 3, { 33, 31, 32, 34 }}, + { 4, { 35, 35, 38, 38 }}, + { 4, { 33, 31, 32, 34 }}}; + + + +unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2}; +unsigned __int16 shopAlch_treasure_lvl[13]= {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2}; + +ITEM_VARIATION shopWeap_variation_spc[15]={ + { 0, { 0, 0, 0, 0 }}, +{ 2, { 25, 30, 20, 20}}, +{ 2, { 23, 24, 28, 20}}, +{ 3, { 23, 24, 25, 20}}, +{ 3, { 27, 27, 26, 26}}, +{ 5, { 23, 26, 28, 27}}, +{ 5, { 23, 26, 28, 27}}, +{ 4, { 30, 24, 20, 20}}, +{ 3, { 20, 20, 20, 20}}, +{ 4, { 27, 27, 26, 26}}, +{ 4, { 28, 28, 25, 25}}, +{ 4, { 23, 23, 24, 24}}, +{ 4, { 24, 24, 27, 20}}, +{ 4, { 30, 26, 26, 26}}, +{ 4, { 28, 25, 28, 29}}}; + + + +unsigned __int16 shopMagicSpc_treasure_lvl[14]= {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; ItemGen *ptr_50C9A4; @@ -142,17 +223,13 @@ //----- (00458260) -------------------------------------------------------- void ItemGen::UpdateTempBonus(__int64 uTimePlayed) { - unsigned int v2; // eax@1 - - v2 = this->uAttributes; - if ( v2 & ITEM_TEMP_BONUS ) + if ( this->uAttributes & ITEM_TEMP_BONUS ) { if ( uTimePlayed > (signed __int64)this->uExpireTime ) { this->uEncantmentType = 0; - LOBYTE(v2) = v2 & 0xF7; this->uSpecEnchantmentType = 0; - this->uAttributes = v2; + this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS); } } } @@ -1316,36 +1393,25 @@ //----- (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 + { + unsigned int uBaseValue; // edi@1 + unsigned int bonus; - 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; -} + uBaseValue = pItemsTable->pItems[this->uItemID].uValue; + if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) + return uBaseValue; + if (uEncantmentType ) + return uBaseValue + 100 * _bonus_strength;; + if (uSpecEnchantmentType ) + { + bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel; + if ( bonus > 10 ) + return uBaseValue + bonus; + else + return uBaseValue * bonus; + } + return uBaseValue; + } //----- (00456499) -------------------------------------------------------- const char *ItemGen::GetDisplayName() @@ -1817,15 +1883,9 @@ //----- (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 + int artifacts_list[32]; - auto a2 = this; - v1 = a2; memset(artifacts_list, 0,sizeof(artifacts_list)); uNumArtifactsNotFound = 0; @@ -1845,366 +1905,776 @@ } //----- (004B8E3D) -------------------------------------------------------- - void *__cdecl GenerateShopItems() +void GenerateStandartShopItems() + { + signed int item_count; + signed int shop_index; + int treasure_lvl; + int item_class; + int mdf; + + shop_index = (signed int)window_SpeakInHouse->ptr_1C; + if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) + { + for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) + { + if (shop_index<=14) //weapon shop + { + treasure_lvl = shopWeap_variation_ord[shop_index].treasure_level; + item_class =shopWeap_variation_ord[shop_index].item_class[rand() % 4]; + } + else if (shop_index<=28) //armor shop + { + mdf =0; + if (item_count > 3) + ++mdf;// rechek offsets + treasure_lvl = shopArmr_variation_ord[2*(shop_index-15)+mdf].treasure_level; + item_class =shopArmr_variation_ord[2*(shop_index-15)+mdf].item_class[rand() % 4]; + } + else if (shop_index<=41) //magic shop + { + treasure_lvl = shopMagic_treasure_lvl[shop_index-28]; + item_class = 22; //misc + } + else if (shop_index<=53) //alchemist shop + { + if (item_count<6) + { + pParty->StandartItemsInShops[shop_index][item_count].Reset(); + pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220; //potion bottle + continue; + } + else + { + treasure_lvl = shopAlch_treasure_lvl[shop_index-41]; + item_class = 45; //reagent + } + } + pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->StandartItemsInShops[shop_index][item_count]); + pParty->StandartItemsInShops[shop_index][item_count].SetIdentified(); //identified + } + } + pParty->InTheShopFlags[shop_index] = 0; + } + +//----- (004B8F94) -------------------------------------------------------- +void GenerateSpecialShopItems() { - GUIWindow *v0; // eax@1 - signed int v1; // edi@1 - signed int v2; // esi@1 - int v3; // ecx@3 - int v4; // ebx@3 - int v5; // ecx@3 - bool v6; // ebp@5 - int v7; // ecx@5 + /*GUIWindow *v0; // edi@1 + signed int v1; // ebp@1 + int v2; // ebx@1 + signed int v3; // esi@1 + int v4; // eax@3 + int v5; // ebx@3 + int v6; // ecx@3 + bool v7; // eax@5 + bool v8; // ST1C_4@5 + int v9; // eax@5 + int v10; // eax@10 void *result; // eax@15 - signed int v9; // [sp-Ch] [bp-14h]@7 + signed int v12; // [sp-4h] [bp-18h]@7*/ + + signed int item_count; + signed int shop_index; + int treasure_lvl; + int item_class; + int mdf; + + shop_index = (signed int)window_SpeakInHouse->ptr_1C; + if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) + { + for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) + { + if (shop_index<=14) //weapon shop + { + treasure_lvl = shopWeap_variation_spc[shop_index].treasure_level; + item_class = shopWeap_variation_spc[shop_index].item_class[rand() % 4]; + } + else if (shop_index<=28) //armor shop + { + mdf =0; + if (item_count > 3) + ++mdf; + treasure_lvl = shopArmr_variation_ord[2*(shop_index-15)+mdf].treasure_level; + item_class =shopArmr_variation_ord[2*(shop_index-15)+mdf].item_class[rand() % 4]; + } + else if (shop_index<=41) //magic shop + { + treasure_lvl = shopMagicSpc_treasure_lvl[shop_index-28]; + item_class = 22; //misc + } + else if (shop_index<=53) //alchemist shop + { + if (item_count<6) + { + pParty->SpecialItemsInShop[shop_index][item_count].Reset(); + pParty->SpecialItemsInShop[shop_index][item_count].uItemID = rand() % 32 + 740; //mscrool + continue; + } + else + { + treasure_lvl = shopAlch_treasure_lvl[shop_index-41]; + item_class = 44; //potion + } + } + pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->SpecialItemsInShop[shop_index][item_count]); + pParty->SpecialItemsInShop[shop_index][item_count].SetIdentified(); //identified + } + } + pParty->InTheShopFlags[shop_index] = 0; + + + +/* v0 = window_SpeakInHouse; v1 = 0; - v2 = (signed int)window_SpeakInHouse->ptr_1C; + v2 = (int)&window_SpeakInHouse->ptr_1C; + v3 = (signed int)window_SpeakInHouse->ptr_1C; //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] ) - if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) + if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) { - while ( v2 > 14 ) + while ( v3 > 14 ) { - if ( v2 <= 28 ) + if ( v3 <= 28 ) { - v6 = v1 > 3; - v7 = v6 + 2 * v2 - 30; - v2 = (signed int)v0->ptr_1C; - v4 = word_4F0498[5 * v7]; - __debugbreak(); - //things happen around word_4F0400 actually - //v5 = *(short *)&aTooManyStation[2 * (5 * (v6 + 2 * v2) + rand() % 4) + 10]; + v7 = v1 > 3; + v8 = v7; + v9 = 5 * (v7 + 2 * v3 - 30); + v3 = (signed int)v0->ptr_1C; + v5 = word_4F06D8[v9]; + v6 = word_4F05AE[5 * (v8 + 2 * v3) + rand() % 4]; goto LABEL_13; } - if ( v2 <= 41 ) + if ( v3 <= 41 ) { - v4 = word_4F0576[v2]; - v9 = 22; //misc + v5 = word_4F07B6[v3]; + v12 = 22; goto LABEL_12; } - if ( v2 <= 53 ) + if ( v3 <= 53 ) { if ( v1 >= 6 ) { - v4 = word_4F0578[v2]; - v9 = 45; //reagent + v5 = word_4F07B6[v3 + 1]; + v12 = 44; LABEL_12: - v5 = v9; + v6 = v12; LABEL_13: - pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[v2][v1]);//9 * (v1 + 12 * v2)]); + pItemsTable->GenerateItem(v5, v6,&pParty->SpecialItemsInShop[v3][v1]);//(ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]); v0 = window_SpeakInHouse; - pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes = 1; //identified + v2 = (int)&window_SpeakInHouse->ptr_1C; + // pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1; + pParty->SpecialItemsInShop[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes= 1; goto LABEL_14; } - auto _t = (ItemGen *)&pParty->field_777C[v2][v1]; - _t->Reset(); - v0 = window_SpeakInHouse; - pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uItemID = 220; //potion bottle + // auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]; + auto _a =&pParty->SpecialItemsInShop[v3][v1]; + _a->Reset(); + // v2 = (int)&v0->ptr_1C; + //v10 = rand(); + // v0 = window_SpeakInHouse; + // pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740; + pParty->SpecialItemsInShop[(int)v0->ptr_1C][v1].uItemID= rand() % 32 + 740; } LABEL_14: - v2 = (signed int)v0->ptr_1C; + v3 = *(int *)v2; ++v1; - //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v0->ptr_1C]] ) - if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v0->ptr_1C - 1].uType] ) + //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * *(int *)v2]] ) + if ( v1 >= (unsigned __int8)uItemsAmountPerShopType[p2DEvents[*(int *)v2 - 1].uType] ) goto LABEL_15; } - v3 = 5 * v2; - v2 = (signed int)v0->ptr_1C; - v4 = word_4F0404[v3 - 4]; - v5 = word_4F0404[5 * v2 + rand() % 4 - 2]; + v4 = 5 * v3; + v3 = (signed int)v0->ptr_1C; + v5 = word_4F063E[v4]; + v6 = word_4F063E[5 * v3 + rand() % 4 + 1]; goto LABEL_13; } LABEL_15: result = v0->ptr_1C; - *(int *)&pParty->field_16154[4 * (int)result] = 0; - return result; + pParty->InTheShopFlags[(int)v0->ptr_1C] = 0;*/ } - //----- (004B8F94) -------------------------------------------------------- - void sub_4B8F94() - { - GUIWindow *v0; // edi@1 - signed int v1; // ebp@1 - int v2; // ebx@1 - signed int v3; // esi@1 - int v4; // eax@3 - int v5; // ebx@3 - int v6; // ecx@3 - bool v7; // eax@5 - bool v8; // ST1C_4@5 - int v9; // eax@5 - int v10; // eax@10 - void *result; // eax@15 - signed int v12; // [sp-4h] [bp-18h]@7 - v0 = window_SpeakInHouse; - v1 = 0; - v2 = (int)&window_SpeakInHouse->ptr_1C; - v3 = (signed int)window_SpeakInHouse->ptr_1C; - //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] ) - if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) - { - while ( v3 > 14 ) - { - if ( v3 <= 28 ) - { - v7 = v1 > 3; - v8 = v7; - v9 = 5 * (v7 + 2 * v3 - 30); - v3 = (signed int)v0->ptr_1C; - v5 = word_4F06D8[v9]; - v6 = word_4F05AE[5 * (v8 + 2 * v3) + rand() % 4]; - goto LABEL_13; - } - if ( v3 <= 41 ) - { - v5 = word_4F07B6[v3]; - v12 = 22; - goto LABEL_12; - } - if ( v3 <= 53 ) - { - if ( v1 >= 6 ) - { - v5 = word_4F07B6[v3 + 1]; - v12 = 44; -LABEL_12: - v6 = v12; -LABEL_13: - pItemsTable->GenerateItem(v5, v6,&pParty->Recipes_Item[v3][v1]);//(ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]); - v0 = window_SpeakInHouse; - v2 = (int)&window_SpeakInHouse->ptr_1C; - // pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1; - pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes= 1; - goto LABEL_14; - } - // auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]; - auto _a =&pParty->Recipes_Item[v3][v1]; - _a->Reset(); - // v2 = (int)&v0->ptr_1C; - //v10 = rand(); - // v0 = window_SpeakInHouse; - // pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740; - pParty->Recipes_Item[(int)v0->ptr_1C][v1].uItemID= rand() % 32 + 740; - } -LABEL_14: - v3 = *(int *)v2; - ++v1; - //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * *(int *)v2]] ) - if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[*(int *)v2 - 1].uType] ) - goto LABEL_15; - } - v4 = 5 * v3; - v3 = (signed int)v0->ptr_1C; - v5 = word_4F063E[v4]; - v6 = word_4F063E[5 * v3 + rand() % 4 + 1]; - goto LABEL_13; - } -LABEL_15: - result = v0->ptr_1C; - pParty->field_16154[(int)v0->ptr_1C] = 0; - } +//----- (00450218) -------------------------------------------------------- +void __cdecl sub_450218_prolly_generate_chests_loot() + { + unsigned int v0; // eax@1 + Chest *v1; // ebx@1 + MapInfo *v2; // esi@1 + ItemGen *v3; // ebx@2 + int v4; // ebp@4 + int v5; // edi@4 + int v6; // esi@4 + int v7; // eax@4 + signed int v8; // esi@4 + int v9; // edx@4 + int v10; // esi@8 + int v11; // ebp@25 + int v12; // esi@25 + signed int v13; // ebp@27 + ItemGen *v14; // edi@28 + signed int v15; // edx@32 + signed __int64 v16; // qtt@32 + int v17; // esi@34 + signed int v18; // [sp+10h] [bp-18h]@1 + int v19; // [sp+14h] [bp-14h]@4 + MapInfo *v20; // [sp+18h] [bp-10h]@1 + Chest *v21; // [sp+1Ch] [bp-Ch]@1 + int v22; // [sp+20h] [bp-8h]@26 + signed int v23; // [sp+24h] [bp-4h]@2 - - //----- (00450218) -------------------------------------------------------- - void __cdecl sub_450218_prolly_generate_chests_loot() + v18 = rand() % 100; + v0 = pMapStats->GetMapInfo(pCurrentMapName); + v1 = pChests; + v2 = &pMapStats->pInfos[v0]; + v21 = pChests; + v20 = &pMapStats->pInfos[v0]; + do { - unsigned int v0; // eax@1 - Chest *v1; // ebx@1 - MapInfo *v2; // esi@1 - ItemGen *v3; // ebx@2 - int v4; // ebp@4 - int v5; // edi@4 - int v6; // esi@4 - int v7; // eax@4 - signed int v8; // esi@4 - int v9; // edx@4 - int v10; // esi@8 - int v11; // ebp@25 - int v12; // esi@25 - signed int v13; // ebp@27 - ItemGen *v14; // edi@28 - signed int v15; // edx@32 - signed __int64 v16; // qtt@32 - int v17; // esi@34 - signed int v18; // [sp+10h] [bp-18h]@1 - int v19; // [sp+14h] [bp-14h]@4 - MapInfo *v20; // [sp+18h] [bp-10h]@1 - Chest *v21; // [sp+1Ch] [bp-Ch]@1 - int v22; // [sp+20h] [bp-8h]@26 - signed int v23; // [sp+24h] [bp-4h]@2 - - v18 = rand() % 100; - v0 = pMapStats->GetMapInfo(pCurrentMapName); - v1 = pChests; - v2 = &pMapStats->pInfos[v0]; - v21 = pChests; - v20 = &pMapStats->pInfos[v0]; + v3 = v1->mm7__vector_pItems; + v23 = 140; do { - v3 = v1->mm7__vector_pItems; - v23 = 140; - do + if ( (v3->uItemID & 0x80000000u) == 0 ) + goto LABEL_56; + v4 = rand() % 5 + 1; + v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; + v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; + v7 = rand(); + v8 = v6 - v5 + 1; + v9 = v5 + v7 % v8; + v19 = v5 + v7 % v8; + if ( v9 < 7 ) { - if ( (v3->uItemID & 0x80000000u) == 0 ) - goto LABEL_56; - v4 = rand() % 5 + 1; - v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; - v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; - v7 = rand(); - v8 = v6 - v5 + 1; - v9 = v5 + v7 % v8; - v19 = v5 + v7 % v8; - if ( v9 < 7 ) + if ( v18 < 20 ) + { + v3->Reset(); + goto LABEL_25; + } + if ( v18 < 60 ) { - if ( v18 < 20 ) + v10 = 0; + v3->Reset(); + if ( v19 == 1 ) { - v3->Reset(); - goto LABEL_25; + v10 = rand() % 51 + 50; } - if ( v18 < 60 ) + else { - v10 = 0; - v3->Reset(); - if ( v19 == 1 ) + if ( v19 != 2 ) { - v10 = rand() % 51 + 50; - } - else - { - if ( v19 != 2 ) + if ( v19 == 3 ) { - if ( v19 == 3 ) + v10 = rand() % 301 + 200; + } + else + { + if ( v19 != 4 ) { - v10 = rand() % 301 + 200; - } - else - { - if ( v19 != 4 ) + if ( v19 == 5 ) + { + v10 = rand() % 1001 + 1000; +LABEL_15: + v3->uItemID = 199; + } + else + { + if ( v19 == 6 ) + { + v10 = rand() % 3001 + 2000; + goto LABEL_15; + } + } +LABEL_23: + v3->SetIdentified(); + v3->uSpecEnchantmentType = v10; +LABEL_25: + v11 = v4 - 1; + v12 = 0; + if ( v11 > 0 ) { - if ( v19 == 5 ) + v22 = v11; + while ( 1 ) { - v10 = rand() % 1001 + 1000; -LABEL_15: - v3->uItemID = 199; - } - else - { + v13 = v12; + if ( v12 >= 140 ) + goto LABEL_52; + v14 = &v21->mm7__vector_pItems[v12]; + while ( v14->uItemID ) + { + ++v13; + ++v14; + if ( v13 >= 140 ) + goto LABEL_52; + } + v16 = rand(); + v15 = v16 % 100; + v18 = v16 % 100; + if ( v15 < 20 ) + goto LABEL_52; + if ( v15 >= 60 ) + { + pItemsTable->GenerateItem(v19, 0, v14); + goto LABEL_51; + } + v17 = 0; + v14->Reset(); + if ( v19 == 1 ) + { + v17 = rand() % 51 + 50; + goto LABEL_48; + } + if ( v19 == 2 ) + { + v17 = rand() % 101 + 100; +LABEL_48: + v14->uItemID = 197; + goto LABEL_49; + } + if ( v19 == 3 ) + { + v17 = rand() % 301 + 200; + goto LABEL_44; + } + if ( v19 == 4 ) + { + v17 = rand() % 501 + 500; +LABEL_44: + v14->uItemID = 198; + goto LABEL_49; + } + if ( v19 == 5 ) + break; if ( v19 == 6 ) { - v10 = rand() % 3001 + 2000; - goto LABEL_15; + v17 = rand() % 3001 + 2000; +LABEL_41: + v14->uItemID = 199; } +LABEL_49: + v14->uSpecEnchantmentType = v17; +LABEL_51: + v12 = v13 + 1; +LABEL_52: + --v22; + if ( !v22 ) + goto LABEL_55; } -LABEL_23: - v3->SetIdentified(); - v3->uSpecEnchantmentType = v10; -LABEL_25: - v11 = v4 - 1; - v12 = 0; - if ( v11 > 0 ) - { - v22 = v11; - while ( 1 ) - { - v13 = v12; - if ( v12 >= 140 ) - goto LABEL_52; - v14 = &v21->mm7__vector_pItems[v12]; - while ( v14->uItemID ) - { - ++v13; - ++v14; - if ( v13 >= 140 ) - goto LABEL_52; - } - v16 = rand(); - v15 = v16 % 100; - v18 = v16 % 100; - if ( v15 < 20 ) - goto LABEL_52; - if ( v15 >= 60 ) - { - pItemsTable->GenerateItem(v19, 0, v14); - goto LABEL_51; - } - v17 = 0; - v14->Reset(); - if ( v19 == 1 ) - { - v17 = rand() % 51 + 50; - goto LABEL_48; - } - if ( v19 == 2 ) - { - v17 = rand() % 101 + 100; -LABEL_48: - v14->uItemID = 197; - goto LABEL_49; - } - if ( v19 == 3 ) - { - v17 = rand() % 301 + 200; - goto LABEL_44; - } - if ( v19 == 4 ) - { - v17 = rand() % 501 + 500; -LABEL_44: - v14->uItemID = 198; - goto LABEL_49; - } - if ( v19 == 5 ) - break; - if ( v19 == 6 ) - { - v17 = rand() % 3001 + 2000; -LABEL_41: - v14->uItemID = 199; - } -LABEL_49: - v14->uSpecEnchantmentType = v17; -LABEL_51: - v12 = v13 + 1; -LABEL_52: - --v22; - if ( !v22 ) - goto LABEL_55; - } - v17 = rand() % 1001 + 1000; - goto LABEL_41; - } - goto LABEL_55; + v17 = rand() % 1001 + 1000; + goto LABEL_41; } - v10 = rand() % 501 + 500; + goto LABEL_55; } - v3->uItemID = 198; - goto LABEL_23; + v10 = rand() % 501 + 500; } - v10 = rand() % 101 + 100; + v3->uItemID = 198; + goto LABEL_23; } - v3->uItemID = 197; - goto LABEL_23; + v10 = rand() % 101 + 100; } - pItemsTable->GenerateItem(v9, 0, v3); - goto LABEL_25; + v3->uItemID = 197; + goto LABEL_23; } - v3->GenerateArtifact(); -LABEL_55: - v2 = v20; -LABEL_56: - ++v3; - --v23; + pItemsTable->GenerateItem(v9, 0, v3); + goto LABEL_25; } - while ( v23 ); - v1 = v21 + 1; - ++v21; + v3->GenerateArtifact(); +LABEL_55: + v2 = v20; +LABEL_56: + ++v3; + --v23; } - while ( (signed int)v21 < (signed int)&uNumChests ); + while ( v23 ); + v1 = v21 + 1; + ++v21; } + while ( (signed int)v21 < (signed int)&uNumChests ); + } -// 4505CC: using guessed type int var_A0[32]; \ No newline at end of file +// 4505CC: using guessed type int var_A0[32]; + //----- (004B3703) -------------------------------------------------------- + int sub_4B3703( int _this ) + { + signed int v1; // edi@1 + int v2; // eax@1 + int v3; // ecx@1 + signed int v4; // ebx@1 + int v5; // ecx@2 + int v6; // ecx@3 + int v7; // ecx@4 + int v8; // ecx@5 + int v9; // ecx@6 + signed int v10; // ebx@13 + signed int v11; // edi@14 + signed int v12; // esi@15 + unsigned int v13; // ecx@16 + int v14; // ecx@16 + int v15; // ecx@17 + int v16; // ecx@19 + int v17; // ecx@20 + int v18; // ecx@21 + signed int v19; // esi@32 + char *v20; // ecx@33 + int v21; // ecx@34 + int v22; // ecx@36 + int v23; // ecx@37 + int v24; // ecx@38 + int v25; // ecx@39 + int v26; // ecx@40 + int v27; // ecx@41 + int *v28; // esi@54 + unsigned int v29; // edx@56 + char *v30; // ecx@65 + int v31; // ecx@106 + int result; // eax@107 + int v33; // [sp-4h] [bp-2Ch]@23 + int v34; // [sp-4h] [bp-2Ch]@43 + int v35[5]; // [sp+Ch] [bp-1Ch]@8 + int a2; // [sp+20h] [bp-8h]@1 + int v37; // [sp+24h] [bp-4h]@1 + + //need fixing + __debugbreak(); + v1 = 0; + v2 = 0; + v3 = _this - 1; + a2 = 0; + v37 = 0; + dword_F8B1DC = 0; + v4 = 2; + if ( !v3 ) + { + while ( 1 ) + { + v19 = 1; + do + { + v20 = (char *)window_SpeakInHouse->ptr_1C + 4 * (unsigned int)window_SpeakInHouse->ptr_1C + v19; + /*if ( v1 ) + v21 = word_4F063E[(signed int)v20]; + else + v21 = word_4F0404[(signed int)v20 - 4];//word_4F03FE[(signed int)v20];*/ + v22 = v21 - 23; + if ( v22 ) + { + v23 = v22 - 1; + if ( v23 ) + { + v24 = v23 - 1; + if ( v24 ) + { + v25 = v24 - 1; + if ( v25 ) + { + v26 = v25 - 1; + if ( v26 ) + { + v27 = v26 - 1; + if ( v27 ) + { + if ( v27 != v4 ) + goto LABEL_51; + v34 = 36; + } + else + { + v34 = 42; + } + } + else + { + v34 = 41; + } + } + else + { + v34 = 40; + } + } + else + { + v34 = 39; + } + } + else + { + v34 = 38; + } + } + else + { + v34 = 37; + } + v37 = sub_4BE571(v34, v35, v37, 5); + v2 = dword_F8B1DC; + v4 = 2; +LABEL_51: + ++v19; + } + while ( v19 <= 4 ); + ++v1; + if ( v1 >= v4 ) + goto LABEL_53; + } + } + v5 = (int)(v3 - 1); + if ( !v5 ) + { + v10 = 0; + while ( 1 ) + { + v11 = 0; + do + { + v12 = 1; + do + { + v13 = v11 + 2 * (unsigned int)window_SpeakInHouse->ptr_1C - 30; + v14 = v12 + 4 * v13 + v13; + /* if ( v10 ) + v15 = word_4F06D8[v14]; + else + v15 = word_4F0498[v14];*/ + v16 = v15 - 31; + if ( v16 ) + { + v17 = v16 - 1; + if ( v17 ) + { + v18 = v17 - 1; + if ( v18 ) + { + if ( v18 != 1 ) + goto LABEL_28; + v33 = 44; + } + else + { + v33 = 47; + } + } + else + { + v33 = 46; + } + } + else + { + v33 = 45; + } + v37 = sub_4BE571(v33, v35, v37, 5); + v2 = dword_F8B1DC; +LABEL_28: + ++v12; + } + while ( v12 <= 4 ); + ++v11; + } + while ( v11 < 2 ); + ++v10; + if ( v10 >= 2 ) + goto LABEL_53; + } + } + v6 = v5 - 1; + if ( v6 ) + { + v7 = v6 - 1; + if ( v7 ) + { + v8 = v7 - 17; + if ( v8 ) + { + v9 = v8 - 2; + if ( v9 ) + { + if ( v9 == 7 ) + { + v37 = 2; + v35[0] = 69; + v35[1] = 60; + } + } + else + { + v37 = 3; + v35[0] = 67; + v35[1] = 66; + v35[2] = 58; + } + } + else + { + v37 = 3; + v35[0] = 70; + v35[1] = 65; + v35[2] = 62; + } + } + else + { + v37 = 2; + v35[0] = 71; + v35[1] = 68; + } + } + else + { + v37 = 2; + v35[0] = 57; + v35[1] = 59; + } +LABEL_53: + if ( v37 > 0 ) + { + v28 = v35; + while ( 1 ) + { + v29 = *v28; + if ( *v28 <= 47 ) + break; + if ( (signed int)v29 <= 66 ) + { + if ( v29 == 66 ) + { + v30 = pSkillNames[30]; + goto LABEL_106; + } + if ( v29 == 57 ) + { + v30 = pSkillNames[21]; + goto LABEL_106; + } + if ( v29 == 58 ) + { + v30 = pSkillNames[22]; + goto LABEL_106; + } + if ( v29 == 60 ) + { + v30 = pSkillNames[24]; + goto LABEL_106; + } + if ( v29 == 62 ) + { + v30 = pSkillNames[26]; + goto LABEL_106; + } + if ( v29 == 65 ) + { + v30 = pSkillNames[29]; + goto LABEL_106; + } + goto LABEL_100; + } + switch ( v29 ) + { + case 0x43u: + v30 = pSkillNames[31]; + break; + case 0x44u: + v30 = pSkillNames[32]; + break; + case 0x45u: + v30 = pSkillNames[33]; + break; + case 0x46u: + v30 = pSkillNames[34]; + break; + default: + if ( v29 != 71 ) + goto LABEL_100; + v30 = pSkillNames[35]; + break; + } +LABEL_106: + pShopOptions[v2] = v30; + v31 = a2++; + dword_F8B1DC = v2 + 1; + sub_4B36CC(v31, v29); + ++v28; + if ( a2 >= v37 ) + goto LABEL_107; + v2 = dword_F8B1DC; + } + if ( *v28 == 47 ) + { + v30 = pSkillNames[11]; + goto LABEL_106; + } + if ( (signed int)v29 > 40 ) + { + if ( v29 == 41 ) + { + v30 = pSkillNames[5]; + goto LABEL_106; + } + if ( v29 == 42 ) + { + v30 = pSkillNames[6]; + goto LABEL_106; + } + if ( v29 == 44 ) + { + v30 = pSkillNames[8]; + goto LABEL_106; + } + if ( v29 == 45 ) + { + v30 = pSkillNames[9]; + goto LABEL_106; + } + if ( v29 == 46 ) + { + v30 = pSkillNames[10]; + goto LABEL_106; + } + } + else + { + if ( v29 == 40 ) + { + v30 = pSkillNames[4]; + goto LABEL_106; + } + if ( v29 == 5 ) + { + v30 = pSkillNames[23]; + goto LABEL_106; + } + if ( v29 == 36 ) + { + v30 = pSkillNames[0]; + goto LABEL_106; + } + if ( v29 == 37 ) + { + v30 = pSkillNames[1]; + goto LABEL_106; + } + if ( v29 == 38 ) + { + v30 = pSkillNames[2]; + goto LABEL_106; + } + if ( v29 == 39 ) + { + v30 = pSkillNames[3]; + goto LABEL_106; + } + } +LABEL_100: + v30 = pGlobalTXT_LocalizationStrings[127]; //"No Text!" + goto LABEL_106; + } +LABEL_107: + pDialogueWindow->_41D08F(a2, 1, 0, 2); + result = pDialogueWindow->pNumPresenceButton; + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; + return result; + }