comparison Items.cpp @ 463:f7b91ef98ab2

shopgenerators done, except config tables
author Gloval
date Mon, 25 Feb 2013 08:30:49 +0400
parents 197461e5acec
children fcdaa804074f
comparison
equal deleted inserted replaced
462:37090bd974f9 463:f7b91ef98ab2
16 #include "texts.h" 16 #include "texts.h"
17 #include "mm7_data.h" 17 #include "mm7_data.h"
18 18
19 19
20 20
21 struct ITEM_VARIATION
22 {
23 unsigned __int16 treasure_level;
24 unsigned __int16 item_class[4];
25 };
26
27
28 char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12};
29
30 ITEM_VARIATION shopWeap_variation_ord[15] ={
31 { 0, { 0, 0, 0, 0 }},
32 { 1, { 23, 27, 20, 20 }},
33 { 1, { 23, 24, 28, 20 }},
34 { 2, { 23, 24, 25, 20 }},
35 { 2, { 27, 27, 26, 26 }},
36 { 4, { 24, 30, 25, 27 }},
37 { 4, { 24, 30, 25, 27 }},
38 { 3, { 30, 24, 20, 20 }},
39 { 2, { 20, 20, 20, 20 }},
40 { 3, { 27, 27, 26, 26 }},
41 { 3, { 28, 28, 25, 25 }},
42 { 2, { 23, 23, 24, 24 }},
43 { 3, { 23, 23, 26, 26 }},
44 { 2, { 30, 26, 26, 26 }},
45 { 2, { 28, 25, 28, 29 }}};
46
47 ITEM_VARIATION shopArmr_variation_ord[30] ={
48 { 1, { 35, 35, 38, 38 }},
49 { 1, { 31, 31, 31, 34 }},
50 { 1, { 35, 35, 38, 38 }},
51 { 1, { 31, 31, 32, 34 }},
52 { 2, { 35, 35, 38, 38 }},
53 { 2, { 31, 32, 32, 33 }},
54 { 2, { 35, 35, 38, 38 }},
55 { 2, { 31, 31, 32, 32 }},
56 { 4, { 35, 35, 38, 38 }},
57 { 4, { 31, 32, 33, 34 }},
58 { 4, { 35, 35, 38, 38 }},
59 { 4, { 31, 32, 33, 34 }},
60 { 3, { 35, 35, 38, 38 }},
61 { 3, { 31, 31, 31, 31 }},
62 { 2, { 35, 35, 38, 38 }},
63 { 2, { 31, 32, 34, 34 }},
64 { 3, { 35, 35, 38, 38 }},
65 { 3, { 31, 31, 32, 32 }},
66 { 3, { 35, 35, 38, 38 }},
67 { 3, { 32, 32, 32, 33 }},
68 { 3, { 35, 35, 38, 38 }},
69 { 3, { 31, 31, 31, 32 }},
70 { 3, { 35, 35, 38, 38 }},
71 { 3, { 33, 31, 32, 34 }},
72 { 3, { 35, 35, 38, 38 }},
73 { 3, { 33, 31, 32, 34 }},
74 { 4, { 35, 35, 38, 38 }},
75 { 4, { 33, 31, 32, 34 }}};
76
77
78
79 unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2};
80 unsigned __int16 shopAlch_treasure_lvl[13]= {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2};
81
82 ITEM_VARIATION shopWeap_variation_spc[15]={
83 { 0, { 0, 0, 0, 0 }},
84 { 2, { 25, 30, 20, 20}},
85 { 2, { 23, 24, 28, 20}},
86 { 3, { 23, 24, 25, 20}},
87 { 3, { 27, 27, 26, 26}},
88 { 5, { 23, 26, 28, 27}},
89 { 5, { 23, 26, 28, 27}},
90 { 4, { 30, 24, 20, 20}},
91 { 3, { 20, 20, 20, 20}},
92 { 4, { 27, 27, 26, 26}},
93 { 4, { 28, 28, 25, 25}},
94 { 4, { 23, 23, 24, 24}},
95 { 4, { 24, 24, 27, 20}},
96 { 4, { 30, 26, 26, 26}},
97 { 4, { 28, 25, 28, 29}}};
98
99
100
101 unsigned __int16 shopMagicSpc_treasure_lvl[14]= {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3};
21 102
22 103
23 ItemGen *ptr_50C9A4; 104 ItemGen *ptr_50C9A4;
24 105
25 struct ItemsTable *pItemsTable; // 005D29E0 106 struct ItemsTable *pItemsTable; // 005D29E0
140 } 221 }
141 222
142 //----- (00458260) -------------------------------------------------------- 223 //----- (00458260) --------------------------------------------------------
143 void ItemGen::UpdateTempBonus(__int64 uTimePlayed) 224 void ItemGen::UpdateTempBonus(__int64 uTimePlayed)
144 { 225 {
145 unsigned int v2; // eax@1 226 if ( this->uAttributes & ITEM_TEMP_BONUS )
146
147 v2 = this->uAttributes;
148 if ( v2 & ITEM_TEMP_BONUS )
149 { 227 {
150 if ( uTimePlayed > (signed __int64)this->uExpireTime ) 228 if ( uTimePlayed > (signed __int64)this->uExpireTime )
151 { 229 {
152 this->uEncantmentType = 0; 230 this->uEncantmentType = 0;
153 LOBYTE(v2) = v2 & 0xF7;
154 this->uSpecEnchantmentType = 0; 231 this->uSpecEnchantmentType = 0;
155 this->uAttributes = v2; 232 this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS);
156 } 233 }
157 } 234 }
158 } 235 }
159 236
160 //----- (0045814E) -------------------------------------------------------- 237 //----- (0045814E) --------------------------------------------------------
1314 } 1391 }
1315 1392
1316 1393
1317 //----- (00456442) -------------------------------------------------------- 1394 //----- (00456442) --------------------------------------------------------
1318 unsigned int ItemGen::GetValue() 1395 unsigned int ItemGen::GetValue()
1319 { 1396 {
1320 ItemGen *v1; // esi@1 1397 unsigned int uBaseValue; // edi@1
1321 unsigned int uBaseValue; // edi@1 1398 unsigned int bonus;
1322 int v3; // eax@4 1399
1323 int v4; // esi@5 1400 uBaseValue = pItemsTable->pItems[this->uItemID].uValue;
1324 unsigned int result; // eax@7 1401 if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) )
1325 1402 return uBaseValue;
1326 v1 = this; 1403 if (uEncantmentType )
1327 uBaseValue = pItemsTable->pItems[this->uItemID].uValue; 1404 return uBaseValue + 100 * _bonus_strength;;
1328 if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) 1405 if (uSpecEnchantmentType )
1329 return uBaseValue; 1406 {
1330 if ( v1->uEncantmentType ) 1407 bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel;
1331 { 1408 if ( bonus > 10 )
1332 v3 = 100 * v1->_bonus_strength; 1409 return uBaseValue + bonus;
1333 return uBaseValue + v3; 1410 else
1334 } 1411 return uBaseValue * bonus;
1335 v4 = v1->uSpecEnchantmentType; 1412 }
1336 if ( !v4 ) 1413 return uBaseValue;
1337 { 1414 }
1338 result = uBaseValue;
1339 }
1340 else
1341 {
1342 v3 = pItemsTable->pSpecialEnchantments[v4].iTreasureLevel;
1343 if ( (unsigned int)v3 > 0xA )
1344 return uBaseValue + v3;
1345 result = uBaseValue * v3;
1346 }
1347 return result;
1348 }
1349 1415
1350 //----- (00456499) -------------------------------------------------------- 1416 //----- (00456499) --------------------------------------------------------
1351 const char *ItemGen::GetDisplayName() 1417 const char *ItemGen::GetDisplayName()
1352 { 1418 {
1353 if (Identified()) 1419 if (Identified())
1815 } 1881 }
1816 1882
1817 //----- (004505CC) -------------------------------------------------------- 1883 //----- (004505CC) --------------------------------------------------------
1818 bool ItemGen::GenerateArtifact() 1884 bool ItemGen::GenerateArtifact()
1819 { 1885 {
1820 ItemGen *v1; // edi@1
1821 signed int uNumArtifactsNotFound; // esi@1 1886 signed int uNumArtifactsNotFound; // esi@1
1822 int v3; // eax@1 1887 int artifacts_list[32];
1823 bool result; // eax@6 1888
1824 int artifacts_list[32]; // [sp+8h] [bp-A0h]@3
1825 char Dst[32]; // [sp+88h] [bp-20h]@1
1826
1827 auto a2 = this;
1828 v1 = a2;
1829 memset(artifacts_list, 0,sizeof(artifacts_list)); 1889 memset(artifacts_list, 0,sizeof(artifacts_list));
1830 uNumArtifactsNotFound = 0; 1890 uNumArtifactsNotFound = 0;
1831 1891
1832 for (int i=500;i<529;++i) 1892 for (int i=500;i<529;++i)
1833 if ( !pParty->field_3C.pIsArtifactFound[i] ) 1893 if ( !pParty->field_3C.pIsArtifactFound[i] )
1843 else 1903 else
1844 return false; 1904 return false;
1845 1905
1846 } 1906 }
1847 //----- (004B8E3D) -------------------------------------------------------- 1907 //----- (004B8E3D) --------------------------------------------------------
1848 void *__cdecl GenerateShopItems() 1908 void GenerateStandartShopItems()
1849 { 1909 {
1850 GUIWindow *v0; // eax@1 1910 signed int item_count;
1851 signed int v1; // edi@1 1911 signed int shop_index;
1852 signed int v2; // esi@1 1912 int treasure_lvl;
1853 int v3; // ecx@3 1913 int item_class;
1854 int v4; // ebx@3 1914 int mdf;
1855 int v5; // ecx@3 1915
1856 bool v6; // ebp@5 1916 shop_index = (signed int)window_SpeakInHouse->ptr_1C;
1857 int v7; // ecx@5 1917 if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] )
1918 {
1919 for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count )
1920 {
1921 if (shop_index<=14) //weapon shop
1922 {
1923 treasure_lvl = shopWeap_variation_ord[shop_index].treasure_level;
1924 item_class =shopWeap_variation_ord[shop_index].item_class[rand() % 4];
1925 }
1926 else if (shop_index<=28) //armor shop
1927 {
1928 mdf =0;
1929 if (item_count > 3)
1930 ++mdf;// rechek offsets
1931 treasure_lvl = shopArmr_variation_ord[2*(shop_index-15)+mdf].treasure_level;
1932 item_class =shopArmr_variation_ord[2*(shop_index-15)+mdf].item_class[rand() % 4];
1933 }
1934 else if (shop_index<=41) //magic shop
1935 {
1936 treasure_lvl = shopMagic_treasure_lvl[shop_index-28];
1937 item_class = 22; //misc
1938 }
1939 else if (shop_index<=53) //alchemist shop
1940 {
1941 if (item_count<6)
1942 {
1943 pParty->StandartItemsInShops[shop_index][item_count].Reset();
1944 pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220; //potion bottle
1945 continue;
1946 }
1947 else
1948 {
1949 treasure_lvl = shopAlch_treasure_lvl[shop_index-41];
1950 item_class = 45; //reagent
1951 }
1952 }
1953 pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->StandartItemsInShops[shop_index][item_count]);
1954 pParty->StandartItemsInShops[shop_index][item_count].SetIdentified(); //identified
1955 }
1956 }
1957 pParty->InTheShopFlags[shop_index] = 0;
1958 }
1959
1960 //----- (004B8F94) --------------------------------------------------------
1961 void GenerateSpecialShopItems()
1962 {
1963 /*GUIWindow *v0; // edi@1
1964 signed int v1; // ebp@1
1965 int v2; // ebx@1
1966 signed int v3; // esi@1
1967 int v4; // eax@3
1968 int v5; // ebx@3
1969 int v6; // ecx@3
1970 bool v7; // eax@5
1971 bool v8; // ST1C_4@5
1972 int v9; // eax@5
1973 int v10; // eax@10
1858 void *result; // eax@15 1974 void *result; // eax@15
1859 signed int v9; // [sp-Ch] [bp-14h]@7 1975 signed int v12; // [sp-4h] [bp-18h]@7*/
1976
1977 signed int item_count;
1978 signed int shop_index;
1979 int treasure_lvl;
1980 int item_class;
1981 int mdf;
1982
1983 shop_index = (signed int)window_SpeakInHouse->ptr_1C;
1984 if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] )
1985 {
1986 for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count )
1987 {
1988 if (shop_index<=14) //weapon shop
1989 {
1990 treasure_lvl = shopWeap_variation_spc[shop_index].treasure_level;
1991 item_class = shopWeap_variation_spc[shop_index].item_class[rand() % 4];
1992 }
1993 else if (shop_index<=28) //armor shop
1994 {
1995 mdf =0;
1996 if (item_count > 3)
1997 ++mdf;
1998 treasure_lvl = shopArmr_variation_ord[2*(shop_index-15)+mdf].treasure_level;
1999 item_class =shopArmr_variation_ord[2*(shop_index-15)+mdf].item_class[rand() % 4];
2000 }
2001 else if (shop_index<=41) //magic shop
2002 {
2003 treasure_lvl = shopMagicSpc_treasure_lvl[shop_index-28];
2004 item_class = 22; //misc
2005 }
2006 else if (shop_index<=53) //alchemist shop
2007 {
2008 if (item_count<6)
2009 {
2010 pParty->SpecialItemsInShop[shop_index][item_count].Reset();
2011 pParty->SpecialItemsInShop[shop_index][item_count].uItemID = rand() % 32 + 740; //mscrool
2012 continue;
2013 }
2014 else
2015 {
2016 treasure_lvl = shopAlch_treasure_lvl[shop_index-41];
2017 item_class = 44; //potion
2018 }
2019 }
2020 pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->SpecialItemsInShop[shop_index][item_count]);
2021 pParty->SpecialItemsInShop[shop_index][item_count].SetIdentified(); //identified
2022 }
2023 }
2024 pParty->InTheShopFlags[shop_index] = 0;
2025
2026
2027
2028 /*
1860 2029
1861 v0 = window_SpeakInHouse; 2030 v0 = window_SpeakInHouse;
1862 v1 = 0; 2031 v1 = 0;
1863 v2 = (signed int)window_SpeakInHouse->ptr_1C; 2032 v2 = (int)&window_SpeakInHouse->ptr_1C;
2033 v3 = (signed int)window_SpeakInHouse->ptr_1C;
1864 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] ) 2034 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] )
1865 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) 2035 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] )
1866 { 2036 {
1867 while ( v2 > 14 ) 2037 while ( v3 > 14 )
1868 { 2038 {
1869 if ( v2 <= 28 ) 2039 if ( v3 <= 28 )
1870 { 2040 {
1871 v6 = v1 > 3; 2041 v7 = v1 > 3;
1872 v7 = v6 + 2 * v2 - 30; 2042 v8 = v7;
1873 v2 = (signed int)v0->ptr_1C; 2043 v9 = 5 * (v7 + 2 * v3 - 30);
1874 v4 = word_4F0498[5 * v7]; 2044 v3 = (signed int)v0->ptr_1C;
1875 __debugbreak(); 2045 v5 = word_4F06D8[v9];
1876 //things happen around word_4F0400 actually 2046 v6 = word_4F05AE[5 * (v8 + 2 * v3) + rand() % 4];
1877 //v5 = *(short *)&aTooManyStation[2 * (5 * (v6 + 2 * v2) + rand() % 4) + 10];
1878 goto LABEL_13; 2047 goto LABEL_13;
1879 } 2048 }
1880 if ( v2 <= 41 ) 2049 if ( v3 <= 41 )
1881 { 2050 {
1882 v4 = word_4F0576[v2]; 2051 v5 = word_4F07B6[v3];
1883 v9 = 22; //misc 2052 v12 = 22;
1884 goto LABEL_12; 2053 goto LABEL_12;
1885 } 2054 }
1886 if ( v2 <= 53 ) 2055 if ( v3 <= 53 )
1887 { 2056 {
1888 if ( v1 >= 6 ) 2057 if ( v1 >= 6 )
1889 { 2058 {
1890 v4 = word_4F0578[v2]; 2059 v5 = word_4F07B6[v3 + 1];
1891 v9 = 45; //reagent 2060 v12 = 44;
1892 LABEL_12: 2061 LABEL_12:
1893 v5 = v9; 2062 v6 = v12;
1894 LABEL_13: 2063 LABEL_13:
1895 pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[v2][v1]);//9 * (v1 + 12 * v2)]); 2064 pItemsTable->GenerateItem(v5, v6,&pParty->SpecialItemsInShop[v3][v1]);//(ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]);
1896 v0 = window_SpeakInHouse; 2065 v0 = window_SpeakInHouse;
1897 pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes = 1; //identified 2066 v2 = (int)&window_SpeakInHouse->ptr_1C;
2067 // pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1;
2068 pParty->SpecialItemsInShop[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes= 1;
1898 goto LABEL_14; 2069 goto LABEL_14;
1899 } 2070 }
1900 auto _t = (ItemGen *)&pParty->field_777C[v2][v1]; 2071 // auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724];
1901 _t->Reset(); 2072 auto _a =&pParty->SpecialItemsInShop[v3][v1];
1902 v0 = window_SpeakInHouse; 2073 _a->Reset();
1903 pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uItemID = 220; //potion bottle 2074 // v2 = (int)&v0->ptr_1C;
2075 //v10 = rand();
2076 // v0 = window_SpeakInHouse;
2077 // pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740;
2078 pParty->SpecialItemsInShop[(int)v0->ptr_1C][v1].uItemID= rand() % 32 + 740;
1904 } 2079 }
1905 LABEL_14: 2080 LABEL_14:
1906 v2 = (signed int)v0->ptr_1C; 2081 v3 = *(int *)v2;
1907 ++v1; 2082 ++v1;
1908 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v0->ptr_1C]] ) 2083 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * *(int *)v2]] )
1909 if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v0->ptr_1C - 1].uType] ) 2084 if ( v1 >= (unsigned __int8)uItemsAmountPerShopType[p2DEvents[*(int *)v2 - 1].uType] )
1910 goto LABEL_15; 2085 goto LABEL_15;
1911 } 2086 }
1912 v3 = 5 * v2; 2087 v4 = 5 * v3;
1913 v2 = (signed int)v0->ptr_1C; 2088 v3 = (signed int)v0->ptr_1C;
1914 v4 = word_4F0404[v3 - 4]; 2089 v5 = word_4F063E[v4];
1915 v5 = word_4F0404[5 * v2 + rand() % 4 - 2]; 2090 v6 = word_4F063E[5 * v3 + rand() % 4 + 1];
1916 goto LABEL_13; 2091 goto LABEL_13;
1917 } 2092 }
1918 LABEL_15: 2093 LABEL_15:
1919 result = v0->ptr_1C; 2094 result = v0->ptr_1C;
1920 *(int *)&pParty->field_16154[4 * (int)result] = 0; 2095 pParty->InTheShopFlags[(int)v0->ptr_1C] = 0;*/
1921 return result;
1922 } 2096 }
1923 2097
1924 //----- (004B8F94) -------------------------------------------------------- 2098
1925 void sub_4B8F94() 2099 //----- (00450218) --------------------------------------------------------
1926 { 2100 void __cdecl sub_450218_prolly_generate_chests_loot()
1927 GUIWindow *v0; // edi@1 2101 {
1928 signed int v1; // ebp@1 2102 unsigned int v0; // eax@1
1929 int v2; // ebx@1 2103 Chest *v1; // ebx@1
1930 signed int v3; // esi@1 2104 MapInfo *v2; // esi@1
1931 int v4; // eax@3 2105 ItemGen *v3; // ebx@2
1932 int v5; // ebx@3 2106 int v4; // ebp@4
1933 int v6; // ecx@3 2107 int v5; // edi@4
1934 bool v7; // eax@5 2108 int v6; // esi@4
1935 bool v8; // ST1C_4@5 2109 int v7; // eax@4
1936 int v9; // eax@5 2110 signed int v8; // esi@4
1937 int v10; // eax@10 2111 int v9; // edx@4
1938 void *result; // eax@15 2112 int v10; // esi@8
1939 signed int v12; // [sp-4h] [bp-18h]@7 2113 int v11; // ebp@25
1940 2114 int v12; // esi@25
1941 v0 = window_SpeakInHouse; 2115 signed int v13; // ebp@27
1942 v1 = 0; 2116 ItemGen *v14; // edi@28
1943 v2 = (int)&window_SpeakInHouse->ptr_1C; 2117 signed int v15; // edx@32
1944 v3 = (signed int)window_SpeakInHouse->ptr_1C; 2118 signed __int64 v16; // qtt@32
1945 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] ) 2119 int v17; // esi@34
1946 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) 2120 signed int v18; // [sp+10h] [bp-18h]@1
1947 { 2121 int v19; // [sp+14h] [bp-14h]@4
1948 while ( v3 > 14 ) 2122 MapInfo *v20; // [sp+18h] [bp-10h]@1
1949 { 2123 Chest *v21; // [sp+1Ch] [bp-Ch]@1
1950 if ( v3 <= 28 ) 2124 int v22; // [sp+20h] [bp-8h]@26
1951 { 2125 signed int v23; // [sp+24h] [bp-4h]@2
1952 v7 = v1 > 3; 2126
1953 v8 = v7; 2127 v18 = rand() % 100;
1954 v9 = 5 * (v7 + 2 * v3 - 30); 2128 v0 = pMapStats->GetMapInfo(pCurrentMapName);
1955 v3 = (signed int)v0->ptr_1C; 2129 v1 = pChests;
1956 v5 = word_4F06D8[v9]; 2130 v2 = &pMapStats->pInfos[v0];
1957 v6 = word_4F05AE[5 * (v8 + 2 * v3) + rand() % 4]; 2131 v21 = pChests;
1958 goto LABEL_13; 2132 v20 = &pMapStats->pInfos[v0];
1959 } 2133 do
1960 if ( v3 <= 41 ) 2134 {
1961 { 2135 v3 = v1->mm7__vector_pItems;
1962 v5 = word_4F07B6[v3]; 2136 v23 = 140;
1963 v12 = 22;
1964 goto LABEL_12;
1965 }
1966 if ( v3 <= 53 )
1967 {
1968 if ( v1 >= 6 )
1969 {
1970 v5 = word_4F07B6[v3 + 1];
1971 v12 = 44;
1972 LABEL_12:
1973 v6 = v12;
1974 LABEL_13:
1975 pItemsTable->GenerateItem(v5, v6,&pParty->Recipes_Item[v3][v1]);//(ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]);
1976 v0 = window_SpeakInHouse;
1977 v2 = (int)&window_SpeakInHouse->ptr_1C;
1978 // pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1;
1979 pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes= 1;
1980 goto LABEL_14;
1981 }
1982 // auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724];
1983 auto _a =&pParty->Recipes_Item[v3][v1];
1984 _a->Reset();
1985 // v2 = (int)&v0->ptr_1C;
1986 //v10 = rand();
1987 // v0 = window_SpeakInHouse;
1988 // pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740;
1989 pParty->Recipes_Item[(int)v0->ptr_1C][v1].uItemID= rand() % 32 + 740;
1990 }
1991 LABEL_14:
1992 v3 = *(int *)v2;
1993 ++v1;
1994 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * *(int *)v2]] )
1995 if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[*(int *)v2 - 1].uType] )
1996 goto LABEL_15;
1997 }
1998 v4 = 5 * v3;
1999 v3 = (signed int)v0->ptr_1C;
2000 v5 = word_4F063E[v4];
2001 v6 = word_4F063E[5 * v3 + rand() % 4 + 1];
2002 goto LABEL_13;
2003 }
2004 LABEL_15:
2005 result = v0->ptr_1C;
2006 pParty->field_16154[(int)v0->ptr_1C] = 0;
2007 }
2008
2009
2010 //----- (00450218) --------------------------------------------------------
2011 void __cdecl sub_450218_prolly_generate_chests_loot()
2012 {
2013 unsigned int v0; // eax@1
2014 Chest *v1; // ebx@1
2015 MapInfo *v2; // esi@1
2016 ItemGen *v3; // ebx@2
2017 int v4; // ebp@4
2018 int v5; // edi@4
2019 int v6; // esi@4
2020 int v7; // eax@4
2021 signed int v8; // esi@4
2022 int v9; // edx@4
2023 int v10; // esi@8
2024 int v11; // ebp@25
2025 int v12; // esi@25
2026 signed int v13; // ebp@27
2027 ItemGen *v14; // edi@28
2028 signed int v15; // edx@32
2029 signed __int64 v16; // qtt@32
2030 int v17; // esi@34
2031 signed int v18; // [sp+10h] [bp-18h]@1
2032 int v19; // [sp+14h] [bp-14h]@4
2033 MapInfo *v20; // [sp+18h] [bp-10h]@1
2034 Chest *v21; // [sp+1Ch] [bp-Ch]@1
2035 int v22; // [sp+20h] [bp-8h]@26
2036 signed int v23; // [sp+24h] [bp-4h]@2
2037
2038 v18 = rand() % 100;
2039 v0 = pMapStats->GetMapInfo(pCurrentMapName);
2040 v1 = pChests;
2041 v2 = &pMapStats->pInfos[v0];
2042 v21 = pChests;
2043 v20 = &pMapStats->pInfos[v0];
2044 do 2137 do
2045 { 2138 {
2046 v3 = v1->mm7__vector_pItems; 2139 if ( (v3->uItemID & 0x80000000u) == 0 )
2047 v23 = 140; 2140 goto LABEL_56;
2048 do 2141 v4 = rand() % 5 + 1;
2049 { 2142 v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2];
2050 if ( (v3->uItemID & 0x80000000u) == 0 ) 2143 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];
2051 goto LABEL_56; 2144 v7 = rand();
2052 v4 = rand() % 5 + 1; 2145 v8 = v6 - v5 + 1;
2053 v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; 2146 v9 = v5 + v7 % v8;
2054 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]; 2147 v19 = v5 + v7 % v8;
2055 v7 = rand(); 2148 if ( v9 < 7 )
2056 v8 = v6 - v5 + 1; 2149 {
2057 v9 = v5 + v7 % v8; 2150 if ( v18 < 20 )
2058 v19 = v5 + v7 % v8; 2151 {
2059 if ( v9 < 7 ) 2152 v3->Reset();
2060 { 2153 goto LABEL_25;
2061 if ( v18 < 20 ) 2154 }
2062 { 2155 if ( v18 < 60 )
2063 v3->Reset(); 2156 {
2064 goto LABEL_25; 2157 v10 = 0;
2065 } 2158 v3->Reset();
2066 if ( v18 < 60 ) 2159 if ( v19 == 1 )
2067 { 2160 {
2068 v10 = 0; 2161 v10 = rand() % 51 + 50;
2069 v3->Reset(); 2162 }
2070 if ( v19 == 1 ) 2163 else
2164 {
2165 if ( v19 != 2 )
2071 { 2166 {
2072 v10 = rand() % 51 + 50; 2167 if ( v19 == 3 )
2168 {
2169 v10 = rand() % 301 + 200;
2170 }
2171 else
2172 {
2173 if ( v19 != 4 )
2174 {
2175 if ( v19 == 5 )
2176 {
2177 v10 = rand() % 1001 + 1000;
2178 LABEL_15:
2179 v3->uItemID = 199;
2180 }
2181 else
2182 {
2183 if ( v19 == 6 )
2184 {
2185 v10 = rand() % 3001 + 2000;
2186 goto LABEL_15;
2187 }
2188 }
2189 LABEL_23:
2190 v3->SetIdentified();
2191 v3->uSpecEnchantmentType = v10;
2192 LABEL_25:
2193 v11 = v4 - 1;
2194 v12 = 0;
2195 if ( v11 > 0 )
2196 {
2197 v22 = v11;
2198 while ( 1 )
2199 {
2200 v13 = v12;
2201 if ( v12 >= 140 )
2202 goto LABEL_52;
2203 v14 = &v21->mm7__vector_pItems[v12];
2204 while ( v14->uItemID )
2205 {
2206 ++v13;
2207 ++v14;
2208 if ( v13 >= 140 )
2209 goto LABEL_52;
2210 }
2211 v16 = rand();
2212 v15 = v16 % 100;
2213 v18 = v16 % 100;
2214 if ( v15 < 20 )
2215 goto LABEL_52;
2216 if ( v15 >= 60 )
2217 {
2218 pItemsTable->GenerateItem(v19, 0, v14);
2219 goto LABEL_51;
2220 }
2221 v17 = 0;
2222 v14->Reset();
2223 if ( v19 == 1 )
2224 {
2225 v17 = rand() % 51 + 50;
2226 goto LABEL_48;
2227 }
2228 if ( v19 == 2 )
2229 {
2230 v17 = rand() % 101 + 100;
2231 LABEL_48:
2232 v14->uItemID = 197;
2233 goto LABEL_49;
2234 }
2235 if ( v19 == 3 )
2236 {
2237 v17 = rand() % 301 + 200;
2238 goto LABEL_44;
2239 }
2240 if ( v19 == 4 )
2241 {
2242 v17 = rand() % 501 + 500;
2243 LABEL_44:
2244 v14->uItemID = 198;
2245 goto LABEL_49;
2246 }
2247 if ( v19 == 5 )
2248 break;
2249 if ( v19 == 6 )
2250 {
2251 v17 = rand() % 3001 + 2000;
2252 LABEL_41:
2253 v14->uItemID = 199;
2254 }
2255 LABEL_49:
2256 v14->uSpecEnchantmentType = v17;
2257 LABEL_51:
2258 v12 = v13 + 1;
2259 LABEL_52:
2260 --v22;
2261 if ( !v22 )
2262 goto LABEL_55;
2263 }
2264 v17 = rand() % 1001 + 1000;
2265 goto LABEL_41;
2266 }
2267 goto LABEL_55;
2268 }
2269 v10 = rand() % 501 + 500;
2270 }
2271 v3->uItemID = 198;
2272 goto LABEL_23;
2273 }
2274 v10 = rand() % 101 + 100;
2275 }
2276 v3->uItemID = 197;
2277 goto LABEL_23;
2278 }
2279 pItemsTable->GenerateItem(v9, 0, v3);
2280 goto LABEL_25;
2281 }
2282 v3->GenerateArtifact();
2283 LABEL_55:
2284 v2 = v20;
2285 LABEL_56:
2286 ++v3;
2287 --v23;
2288 }
2289 while ( v23 );
2290 v1 = v21 + 1;
2291 ++v21;
2292 }
2293 while ( (signed int)v21 < (signed int)&uNumChests );
2294 }
2295
2296
2297
2298
2299 // 4505CC: using guessed type int var_A0[32];
2300 //----- (004B3703) --------------------------------------------------------
2301 int sub_4B3703( int _this )
2302 {
2303 signed int v1; // edi@1
2304 int v2; // eax@1
2305 int v3; // ecx@1
2306 signed int v4; // ebx@1
2307 int v5; // ecx@2
2308 int v6; // ecx@3
2309 int v7; // ecx@4
2310 int v8; // ecx@5
2311 int v9; // ecx@6
2312 signed int v10; // ebx@13
2313 signed int v11; // edi@14
2314 signed int v12; // esi@15
2315 unsigned int v13; // ecx@16
2316 int v14; // ecx@16
2317 int v15; // ecx@17
2318 int v16; // ecx@19
2319 int v17; // ecx@20
2320 int v18; // ecx@21
2321 signed int v19; // esi@32
2322 char *v20; // ecx@33
2323 int v21; // ecx@34
2324 int v22; // ecx@36
2325 int v23; // ecx@37
2326 int v24; // ecx@38
2327 int v25; // ecx@39
2328 int v26; // ecx@40
2329 int v27; // ecx@41
2330 int *v28; // esi@54
2331 unsigned int v29; // edx@56
2332 char *v30; // ecx@65
2333 int v31; // ecx@106
2334 int result; // eax@107
2335 int v33; // [sp-4h] [bp-2Ch]@23
2336 int v34; // [sp-4h] [bp-2Ch]@43
2337 int v35[5]; // [sp+Ch] [bp-1Ch]@8
2338 int a2; // [sp+20h] [bp-8h]@1
2339 int v37; // [sp+24h] [bp-4h]@1
2340
2341 //need fixing
2342 __debugbreak();
2343 v1 = 0;
2344 v2 = 0;
2345 v3 = _this - 1;
2346 a2 = 0;
2347 v37 = 0;
2348 dword_F8B1DC = 0;
2349 v4 = 2;
2350 if ( !v3 )
2351 {
2352 while ( 1 )
2353 {
2354 v19 = 1;
2355 do
2356 {
2357 v20 = (char *)window_SpeakInHouse->ptr_1C + 4 * (unsigned int)window_SpeakInHouse->ptr_1C + v19;
2358 /*if ( v1 )
2359 v21 = word_4F063E[(signed int)v20];
2360 else
2361 v21 = word_4F0404[(signed int)v20 - 4];//word_4F03FE[(signed int)v20];*/
2362 v22 = v21 - 23;
2363 if ( v22 )
2364 {
2365 v23 = v22 - 1;
2366 if ( v23 )
2367 {
2368 v24 = v23 - 1;
2369 if ( v24 )
2370 {
2371 v25 = v24 - 1;
2372 if ( v25 )
2373 {
2374 v26 = v25 - 1;
2375 if ( v26 )
2376 {
2377 v27 = v26 - 1;
2378 if ( v27 )
2379 {
2380 if ( v27 != v4 )
2381 goto LABEL_51;
2382 v34 = 36;
2383 }
2384 else
2385 {
2386 v34 = 42;
2387 }
2388 }
2389 else
2390 {
2391 v34 = 41;
2392 }
2393 }
2394 else
2395 {
2396 v34 = 40;
2397 }
2398 }
2399 else
2400 {
2401 v34 = 39;
2402 }
2073 } 2403 }
2074 else 2404 else
2075 { 2405 {
2076 if ( v19 != 2 ) 2406 v34 = 38;
2407 }
2408 }
2409 else
2410 {
2411 v34 = 37;
2412 }
2413 v37 = sub_4BE571(v34, v35, v37, 5);
2414 v2 = dword_F8B1DC;
2415 v4 = 2;
2416 LABEL_51:
2417 ++v19;
2418 }
2419 while ( v19 <= 4 );
2420 ++v1;
2421 if ( v1 >= v4 )
2422 goto LABEL_53;
2423 }
2424 }
2425 v5 = (int)(v3 - 1);
2426 if ( !v5 )
2427 {
2428 v10 = 0;
2429 while ( 1 )
2430 {
2431 v11 = 0;
2432 do
2433 {
2434 v12 = 1;
2435 do
2436 {
2437 v13 = v11 + 2 * (unsigned int)window_SpeakInHouse->ptr_1C - 30;
2438 v14 = v12 + 4 * v13 + v13;
2439 /* if ( v10 )
2440 v15 = word_4F06D8[v14];
2441 else
2442 v15 = word_4F0498[v14];*/
2443 v16 = v15 - 31;
2444 if ( v16 )
2445 {
2446 v17 = v16 - 1;
2447 if ( v17 )
2077 { 2448 {
2078 if ( v19 == 3 ) 2449 v18 = v17 - 1;
2450 if ( v18 )
2079 { 2451 {
2080 v10 = rand() % 301 + 200; 2452 if ( v18 != 1 )
2453 goto LABEL_28;
2454 v33 = 44;
2081 } 2455 }
2082 else 2456 else
2083 { 2457 {
2084 if ( v19 != 4 ) 2458 v33 = 47;
2085 {
2086 if ( v19 == 5 )
2087 {
2088 v10 = rand() % 1001 + 1000;
2089 LABEL_15:
2090 v3->uItemID = 199;
2091 }
2092 else
2093 {
2094 if ( v19 == 6 )
2095 {
2096 v10 = rand() % 3001 + 2000;
2097 goto LABEL_15;
2098 }
2099 }
2100 LABEL_23:
2101 v3->SetIdentified();
2102 v3->uSpecEnchantmentType = v10;
2103 LABEL_25:
2104 v11 = v4 - 1;
2105 v12 = 0;
2106 if ( v11 > 0 )
2107 {
2108 v22 = v11;
2109 while ( 1 )
2110 {
2111 v13 = v12;
2112 if ( v12 >= 140 )
2113 goto LABEL_52;
2114 v14 = &v21->mm7__vector_pItems[v12];
2115 while ( v14->uItemID )
2116 {
2117 ++v13;
2118 ++v14;
2119 if ( v13 >= 140 )
2120 goto LABEL_52;
2121 }
2122 v16 = rand();
2123 v15 = v16 % 100;
2124 v18 = v16 % 100;
2125 if ( v15 < 20 )
2126 goto LABEL_52;
2127 if ( v15 >= 60 )
2128 {
2129 pItemsTable->GenerateItem(v19, 0, v14);
2130 goto LABEL_51;
2131 }
2132 v17 = 0;
2133 v14->Reset();
2134 if ( v19 == 1 )
2135 {
2136 v17 = rand() % 51 + 50;
2137 goto LABEL_48;
2138 }
2139 if ( v19 == 2 )
2140 {
2141 v17 = rand() % 101 + 100;
2142 LABEL_48:
2143 v14->uItemID = 197;
2144 goto LABEL_49;
2145 }
2146 if ( v19 == 3 )
2147 {
2148 v17 = rand() % 301 + 200;
2149 goto LABEL_44;
2150 }
2151 if ( v19 == 4 )
2152 {
2153 v17 = rand() % 501 + 500;
2154 LABEL_44:
2155 v14->uItemID = 198;
2156 goto LABEL_49;
2157 }
2158 if ( v19 == 5 )
2159 break;
2160 if ( v19 == 6 )
2161 {
2162 v17 = rand() % 3001 + 2000;
2163 LABEL_41:
2164 v14->uItemID = 199;
2165 }
2166 LABEL_49:
2167 v14->uSpecEnchantmentType = v17;
2168 LABEL_51:
2169 v12 = v13 + 1;
2170 LABEL_52:
2171 --v22;
2172 if ( !v22 )
2173 goto LABEL_55;
2174 }
2175 v17 = rand() % 1001 + 1000;
2176 goto LABEL_41;
2177 }
2178 goto LABEL_55;
2179 }
2180 v10 = rand() % 501 + 500;
2181 } 2459 }
2182 v3->uItemID = 198;
2183 goto LABEL_23;
2184 } 2460 }
2185 v10 = rand() % 101 + 100; 2461 else
2462 {
2463 v33 = 46;
2464 }
2186 } 2465 }
2187 v3->uItemID = 197; 2466 else
2188 goto LABEL_23; 2467 {
2189 } 2468 v33 = 45;
2190 pItemsTable->GenerateItem(v9, 0, v3); 2469 }
2191 goto LABEL_25; 2470 v37 = sub_4BE571(v33, v35, v37, 5);
2192 } 2471 v2 = dword_F8B1DC;
2193 v3->GenerateArtifact(); 2472 LABEL_28:
2194 LABEL_55: 2473 ++v12;
2195 v2 = v20; 2474 }
2196 LABEL_56: 2475 while ( v12 <= 4 );
2197 ++v3; 2476 ++v11;
2198 --v23; 2477 }
2199 } 2478 while ( v11 < 2 );
2200 while ( v23 ); 2479 ++v10;
2201 v1 = v21 + 1; 2480 if ( v10 >= 2 )
2202 ++v21; 2481 goto LABEL_53;
2482 }
2203 } 2483 }
2204 while ( (signed int)v21 < (signed int)&uNumChests ); 2484 v6 = v5 - 1;
2205 } 2485 if ( v6 )
2206 2486 {
2207 2487 v7 = v6 - 1;
2208 2488 if ( v7 )
2209 2489 {
2210 // 4505CC: using guessed type int var_A0[32]; 2490 v8 = v7 - 17;
2491 if ( v8 )
2492 {
2493 v9 = v8 - 2;
2494 if ( v9 )
2495 {
2496 if ( v9 == 7 )
2497 {
2498 v37 = 2;
2499 v35[0] = 69;
2500 v35[1] = 60;
2501 }
2502 }
2503 else
2504 {
2505 v37 = 3;
2506 v35[0] = 67;
2507 v35[1] = 66;
2508 v35[2] = 58;
2509 }
2510 }
2511 else
2512 {
2513 v37 = 3;
2514 v35[0] = 70;
2515 v35[1] = 65;
2516 v35[2] = 62;
2517 }
2518 }
2519 else
2520 {
2521 v37 = 2;
2522 v35[0] = 71;
2523 v35[1] = 68;
2524 }
2525 }
2526 else
2527 {
2528 v37 = 2;
2529 v35[0] = 57;
2530 v35[1] = 59;
2531 }
2532 LABEL_53:
2533 if ( v37 > 0 )
2534 {
2535 v28 = v35;
2536 while ( 1 )
2537 {
2538 v29 = *v28;
2539 if ( *v28 <= 47 )
2540 break;
2541 if ( (signed int)v29 <= 66 )
2542 {
2543 if ( v29 == 66 )
2544 {
2545 v30 = pSkillNames[30];
2546 goto LABEL_106;
2547 }
2548 if ( v29 == 57 )
2549 {
2550 v30 = pSkillNames[21];
2551 goto LABEL_106;
2552 }
2553 if ( v29 == 58 )
2554 {
2555 v30 = pSkillNames[22];
2556 goto LABEL_106;
2557 }
2558 if ( v29 == 60 )
2559 {
2560 v30 = pSkillNames[24];
2561 goto LABEL_106;
2562 }
2563 if ( v29 == 62 )
2564 {
2565 v30 = pSkillNames[26];
2566 goto LABEL_106;
2567 }
2568 if ( v29 == 65 )
2569 {
2570 v30 = pSkillNames[29];
2571 goto LABEL_106;
2572 }
2573 goto LABEL_100;
2574 }
2575 switch ( v29 )
2576 {
2577 case 0x43u:
2578 v30 = pSkillNames[31];
2579 break;
2580 case 0x44u:
2581 v30 = pSkillNames[32];
2582 break;
2583 case 0x45u:
2584 v30 = pSkillNames[33];
2585 break;
2586 case 0x46u:
2587 v30 = pSkillNames[34];
2588 break;
2589 default:
2590 if ( v29 != 71 )
2591 goto LABEL_100;
2592 v30 = pSkillNames[35];
2593 break;
2594 }
2595 LABEL_106:
2596 pShopOptions[v2] = v30;
2597 v31 = a2++;
2598 dword_F8B1DC = v2 + 1;
2599 sub_4B36CC(v31, v29);
2600 ++v28;
2601 if ( a2 >= v37 )
2602 goto LABEL_107;
2603 v2 = dword_F8B1DC;
2604 }
2605 if ( *v28 == 47 )
2606 {
2607 v30 = pSkillNames[11];
2608 goto LABEL_106;
2609 }
2610 if ( (signed int)v29 > 40 )
2611 {
2612 if ( v29 == 41 )
2613 {
2614 v30 = pSkillNames[5];
2615 goto LABEL_106;
2616 }
2617 if ( v29 == 42 )
2618 {
2619 v30 = pSkillNames[6];
2620 goto LABEL_106;
2621 }
2622 if ( v29 == 44 )
2623 {
2624 v30 = pSkillNames[8];
2625 goto LABEL_106;
2626 }
2627 if ( v29 == 45 )
2628 {
2629 v30 = pSkillNames[9];
2630 goto LABEL_106;
2631 }
2632 if ( v29 == 46 )
2633 {
2634 v30 = pSkillNames[10];
2635 goto LABEL_106;
2636 }
2637 }
2638 else
2639 {
2640 if ( v29 == 40 )
2641 {
2642 v30 = pSkillNames[4];
2643 goto LABEL_106;
2644 }
2645 if ( v29 == 5 )
2646 {
2647 v30 = pSkillNames[23];
2648 goto LABEL_106;
2649 }
2650 if ( v29 == 36 )
2651 {
2652 v30 = pSkillNames[0];
2653 goto LABEL_106;
2654 }
2655 if ( v29 == 37 )
2656 {
2657 v30 = pSkillNames[1];
2658 goto LABEL_106;
2659 }
2660 if ( v29 == 38 )
2661 {
2662 v30 = pSkillNames[2];
2663 goto LABEL_106;
2664 }
2665 if ( v29 == 39 )
2666 {
2667 v30 = pSkillNames[3];
2668 goto LABEL_106;
2669 }
2670 }
2671 LABEL_100:
2672 v30 = pGlobalTXT_LocalizationStrings[127]; //"No Text!"
2673 goto LABEL_106;
2674 }
2675 LABEL_107:
2676 pDialogueWindow->_41D08F(a2, 1, 0, 2);
2677 result = pDialogueWindow->pNumPresenceButton;
2678 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
2679 return result;
2680 }