# HG changeset patch # User Gloval # Date 1362595600 -14400 # Node ID f8a4a2e0b4c95c6a41c5f2aec0aa0344fde02e52 # Parent f54481c85df81e141e1d61dad41ff6d833c0c6da fixed random iten generator, chest generator diff -r f54481c85df8 -r f8a4a2e0b4c9 Items.cpp --- a/Items.cpp Wed Mar 06 00:09:49 2013 +0400 +++ b/Items.cpp Wed Mar 06 22:46:40 2013 +0400 @@ -925,7 +925,7 @@ memset(&uChanceByTreasureLvlSumm, 0, 24); for(i=0;i<6;++i) { - for (j=0;j<800;++j) + for (j=1;j 0 ) { do - v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6]; + { + v57 += pItems[out_item->uItemID + 1].uChanceByTreasureLvl[v6]; + ++out_item->uItemID; + } while ( v57 < v18 ); } @@ -2019,204 +2022,162 @@ //----- (00450218) -------------------------------------------------------- -void sub_450218_prolly_generate_chests_loot() +void GenerateItemsInChest() { - 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 + 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]; - for(int i=0; i<20;++i) - { - for(int j=0; j<140;++j) - { - v3 = &pChests[i].igChestItems[j]; - if ( v3->uItemID < 0 ) - { - 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; - /* switch (v9) - { - default: - - }*/ - + v18 = rand() % 100; //main random + v0 = pMapStats->GetMapInfo(pCurrentMapName); + // v1 = pChests; + v2 = &pMapStats->pInfos[v0]; + //v21 = pChests; + //v20 = &pMapStats->pInfos[v0]; + for(int i=1; i<20;++i) + { + for(int j=0; j<140;++j) + { - if ( v9 < 7 ) - { - if ( v18 < 20 ) - { - v3->Reset(); - goto LABEL_25; - } - if ( v18 < 60 ) - { - v10 = 0; - v3->Reset(); - if ( v19 == 1 ) - { - v10 = rand() % 51 + 50; - } - else - { - if ( v19 != 2 ) - { - if ( v19 == 3 ) - { - 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 ) - { - v22 = v11; - while ( 1 ) - { - v13 = v12; - if ( v12 >= 140 ) - goto LABEL_52; - v14 = &v21->igChestItems[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; - } - v10 = rand() % 501 + 500; - } - v3->uItemID = 198; - goto LABEL_23; - } - v10 = rand() % 101 + 100; - } - v3->uItemID = 197; - goto LABEL_23; - } - pItemsTable->GenerateItem(v9, 0, v3); - goto LABEL_25; - } - v3->GenerateArtifact(); - -LABEL_55: - v2 = v20; -LABEL_56: ; + v3 = &pChests[i].igChestItems[j]; + if ( v3->uItemID < 0 ) + { + v4 = rand() % 5; //additional items in chect + v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob]; + v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1]; + v8 = v6 - v5 + 1; + v9 = v5 + rand() % v8; //treasure level + if (v9<7) + { + if (v18<20) + { + v3->Reset(); + } + else if (v18<60) //generate gold + { + v10=0; + v3->Reset(); + switch (v9) + { + case 1: //small gold + v10 = rand() % 51 + 50; + v3->uItemID = 197; + break; + case 2://small gold + v10 = rand() % 101 + 100; + v3->uItemID = 197; + break; + case 3: //medium + v10 = rand() % 301 + 200; + v3->uItemID = 198; + break; + case 4: //medium + v10 = rand() % 501 + 500; + v3->uItemID = 198; + break; + case 5: //big + v10 = rand() % 1001 + 1000; + v3->uItemID = 199; + break; + case 6: //big + v10 = rand() % 3001 + 2000; + v3->uItemID = 199; + break; + } + v3->SetIdentified(); + v3->uSpecEnchantmentType = v10; + } + else + { + pItemsTable->GenerateItem(v9, 0, v3); + } + + v12 = 0; + //generate more items + for (v11=0; v11= 140 ) + break; + while ( !(pChests[i].igChestItems[v12].uItemID==0) &&(v12<140)) + { + ++v12; + } + v14=&pChests[i].igChestItems[v12]; + v18 = rand() % 100; + if (v18<20) + { + v3->Reset(); + } + else if (v18<60) //generate gold + { + v10=0; + v3->Reset(); + switch (v9) + { + case 1: //small gold + v10 = rand() % 51 + 50; + v14->uItemID = 197; + break; + case 2://small gold + v10 = rand() % 101 + 100; + v14->uItemID = 197; + break; + case 3: //medium + v10 = rand() % 301 + 200; + v14->uItemID = 198; + break; + case 4: //medium + v10 = rand() % 501 + 500; + v14->uItemID = 198; + break; + case 5: //big + v10 = rand() % 1001 + 1000; + v14->uItemID = 199; + break; + case 6: //big + v10 = rand() % 3001 + 2000; + v14->uItemID = 199; + break; + } + v14->SetIdentified(); + v14->uSpecEnchantmentType = v10; + } + else + { + pItemsTable->GenerateItem(v9, 0, v14); + } + ++v12; + } + } + else + v3->GenerateArtifact(); } - } - } - - } + } + } + + } diff -r f54481c85df8 -r f8a4a2e0b4c9 Items.h --- a/Items.h Wed Mar 06 00:09:49 2013 +0400 +++ b/Items.h Wed Mar 06 22:46:40 2013 +0400 @@ -289,6 +289,7 @@ void GenerateStandartShopItems(); void GenerateSpecialShopItems(); +void GenerateItemsInChest(); extern const char uItemsAmountPerShopType[]; // weak extern ItemGen *ptr_50C9A4; diff -r f54481c85df8 -r f8a4a2e0b4c9 Party.cpp --- a/Party.cpp Wed Mar 06 00:09:49 2013 +0400 +++ b/Party.cpp Wed Mar 06 22:46:40 2013 +0400 @@ -752,6 +752,7 @@ uFlags = 0; memset(_autonote_bits, 0, 12); memset(_quest_bits, 0, 64); + memset(pIsArtifactFound, 0, 29); _449B7E_toggle_bit(_quest_bits, 1, 1); _449B7E_toggle_bit(_quest_bits, 2, 1); _449B7E_toggle_bit(_quest_bits, 3, 1); diff -r f54481c85df8 -r f8a4a2e0b4c9 mm7_2.cpp --- a/mm7_2.cpp Wed Mar 06 00:09:49 2013 +0400 +++ b/mm7_2.cpp Wed Mar 06 22:46:40 2013 +0400 @@ -11212,7 +11212,7 @@ signed int v20; // [sp+18h] [bp-44h]@14 int v21[16]; // [sp+1Ch] [bp-40h]@17 - sub_450218_prolly_generate_chests_loot(); + GenerateItemsInChest(); //v0 = pGameLoadingUI_ProgressBar; pGameLoadingUI_ProgressBar->Progress(); pParty->uFlags |= 2u; diff -r f54481c85df8 -r f8a4a2e0b4c9 mm7_data.h --- a/mm7_data.h Wed Mar 06 00:09:49 2013 +0400 +++ b/mm7_data.h Wed Mar 06 22:46:40 2013 +0400 @@ -2053,7 +2053,7 @@ // int __cdecl crt_deconstruct_44C42C(); void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); -void sub_450218_prolly_generate_chests_loot(); + signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); int __fastcall sub_45063B(struct MapInfo *a1, int a2); void RespawnGlobalDecorations();