Mercurial > mm7
comparison Items.cpp @ 461:197461e5acec
moved shop generators to item.cpp
author | Gloval |
---|---|
date | Sun, 24 Feb 2013 20:47:01 +0400 |
parents | 4a42c2f97aa2 |
children | f7b91ef98ab2 |
comparison
equal
deleted
inserted
replaced
442:a812665688e4 | 461:197461e5acec |
---|---|
3 | 3 |
4 #include "Items.h" | 4 #include "Items.h" |
5 #include "MapInfo.h" | 5 #include "MapInfo.h" |
6 #include "FrameTableInc.h" | 6 #include "FrameTableInc.h" |
7 #include "Allocator.h" | 7 #include "Allocator.h" |
8 #include "GUIWindow.h" | |
9 #include "Events2D.h" | |
10 #include "Chest.h" | |
8 #include "LOD.h" | 11 #include "LOD.h" |
9 #include "Monsters.h" | 12 #include "Monsters.h" |
10 #include "Party.h" | 13 #include "Party.h" |
11 #include "FactionTable.h" | 14 #include "FactionTable.h" |
12 #include "StorylineTextTable.h" | 15 #include "StorylineTextTable.h" |
1839 } | 1842 } |
1840 else | 1843 else |
1841 return false; | 1844 return false; |
1842 | 1845 |
1843 } | 1846 } |
1847 //----- (004B8E3D) -------------------------------------------------------- | |
1848 void *__cdecl GenerateShopItems() | |
1849 { | |
1850 GUIWindow *v0; // eax@1 | |
1851 signed int v1; // edi@1 | |
1852 signed int v2; // esi@1 | |
1853 int v3; // ecx@3 | |
1854 int v4; // ebx@3 | |
1855 int v5; // ecx@3 | |
1856 bool v6; // ebp@5 | |
1857 int v7; // ecx@5 | |
1858 void *result; // eax@15 | |
1859 signed int v9; // [sp-Ch] [bp-14h]@7 | |
1860 | |
1861 v0 = window_SpeakInHouse; | |
1862 v1 = 0; | |
1863 v2 = (signed int)window_SpeakInHouse->ptr_1C; | |
1864 //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] ) | |
1866 { | |
1867 while ( v2 > 14 ) | |
1868 { | |
1869 if ( v2 <= 28 ) | |
1870 { | |
1871 v6 = v1 > 3; | |
1872 v7 = v6 + 2 * v2 - 30; | |
1873 v2 = (signed int)v0->ptr_1C; | |
1874 v4 = word_4F0498[5 * v7]; | |
1875 __debugbreak(); | |
1876 //things happen around word_4F0400 actually | |
1877 //v5 = *(short *)&aTooManyStation[2 * (5 * (v6 + 2 * v2) + rand() % 4) + 10]; | |
1878 goto LABEL_13; | |
1879 } | |
1880 if ( v2 <= 41 ) | |
1881 { | |
1882 v4 = word_4F0576[v2]; | |
1883 v9 = 22; //misc | |
1884 goto LABEL_12; | |
1885 } | |
1886 if ( v2 <= 53 ) | |
1887 { | |
1888 if ( v1 >= 6 ) | |
1889 { | |
1890 v4 = word_4F0578[v2]; | |
1891 v9 = 45; //reagent | |
1892 LABEL_12: | |
1893 v5 = v9; | |
1894 LABEL_13: | |
1895 pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[v2][v1]);//9 * (v1 + 12 * v2)]); | |
1896 v0 = window_SpeakInHouse; | |
1897 pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes = 1; //identified | |
1898 goto LABEL_14; | |
1899 } | |
1900 auto _t = (ItemGen *)&pParty->field_777C[v2][v1]; | |
1901 _t->Reset(); | |
1902 v0 = window_SpeakInHouse; | |
1903 pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uItemID = 220; //potion bottle | |
1904 } | |
1905 LABEL_14: | |
1906 v2 = (signed int)v0->ptr_1C; | |
1907 ++v1; | |
1908 //if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v0->ptr_1C]] ) | |
1909 if ( v1 >= (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)v0->ptr_1C - 1].uType] ) | |
1910 goto LABEL_15; | |
1911 } | |
1912 v3 = 5 * v2; | |
1913 v2 = (signed int)v0->ptr_1C; | |
1914 v4 = word_4F0404[v3 - 4]; | |
1915 v5 = word_4F0404[5 * v2 + rand() % 4 - 2]; | |
1916 goto LABEL_13; | |
1917 } | |
1918 LABEL_15: | |
1919 result = v0->ptr_1C; | |
1920 *(int *)&pParty->field_16154[4 * (int)result] = 0; | |
1921 return result; | |
1922 } | |
1923 | |
1924 //----- (004B8F94) -------------------------------------------------------- | |
1925 void sub_4B8F94() | |
1926 { | |
1927 GUIWindow *v0; // edi@1 | |
1928 signed int v1; // ebp@1 | |
1929 int v2; // ebx@1 | |
1930 signed int v3; // esi@1 | |
1931 int v4; // eax@3 | |
1932 int v5; // ebx@3 | |
1933 int v6; // ecx@3 | |
1934 bool v7; // eax@5 | |
1935 bool v8; // ST1C_4@5 | |
1936 int v9; // eax@5 | |
1937 int v10; // eax@10 | |
1938 void *result; // eax@15 | |
1939 signed int v12; // [sp-4h] [bp-18h]@7 | |
1940 | |
1941 v0 = window_SpeakInHouse; | |
1942 v1 = 0; | |
1943 v2 = (int)&window_SpeakInHouse->ptr_1C; | |
1944 v3 = (signed int)window_SpeakInHouse->ptr_1C; | |
1945 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] ) | |
1946 if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) | |
1947 { | |
1948 while ( v3 > 14 ) | |
1949 { | |
1950 if ( v3 <= 28 ) | |
1951 { | |
1952 v7 = v1 > 3; | |
1953 v8 = v7; | |
1954 v9 = 5 * (v7 + 2 * v3 - 30); | |
1955 v3 = (signed int)v0->ptr_1C; | |
1956 v5 = word_4F06D8[v9]; | |
1957 v6 = word_4F05AE[5 * (v8 + 2 * v3) + rand() % 4]; | |
1958 goto LABEL_13; | |
1959 } | |
1960 if ( v3 <= 41 ) | |
1961 { | |
1962 v5 = word_4F07B6[v3]; | |
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 | |
2045 { | |
2046 v3 = v1->mm7__vector_pItems; | |
2047 v23 = 140; | |
2048 do | |
2049 { | |
2050 if ( (v3->uItemID & 0x80000000u) == 0 ) | |
2051 goto LABEL_56; | |
2052 v4 = rand() % 5 + 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]; | |
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]; | |
2055 v7 = rand(); | |
2056 v8 = v6 - v5 + 1; | |
2057 v9 = v5 + v7 % v8; | |
2058 v19 = v5 + v7 % v8; | |
2059 if ( v9 < 7 ) | |
2060 { | |
2061 if ( v18 < 20 ) | |
2062 { | |
2063 v3->Reset(); | |
2064 goto LABEL_25; | |
2065 } | |
2066 if ( v18 < 60 ) | |
2067 { | |
2068 v10 = 0; | |
2069 v3->Reset(); | |
2070 if ( v19 == 1 ) | |
2071 { | |
2072 v10 = rand() % 51 + 50; | |
2073 } | |
2074 else | |
2075 { | |
2076 if ( v19 != 2 ) | |
2077 { | |
2078 if ( v19 == 3 ) | |
2079 { | |
2080 v10 = rand() % 301 + 200; | |
2081 } | |
2082 else | |
2083 { | |
2084 if ( v19 != 4 ) | |
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 } | |
2182 v3->uItemID = 198; | |
2183 goto LABEL_23; | |
2184 } | |
2185 v10 = rand() % 101 + 100; | |
2186 } | |
2187 v3->uItemID = 197; | |
2188 goto LABEL_23; | |
2189 } | |
2190 pItemsTable->GenerateItem(v9, 0, v3); | |
2191 goto LABEL_25; | |
2192 } | |
2193 v3->GenerateArtifact(); | |
2194 LABEL_55: | |
2195 v2 = v20; | |
2196 LABEL_56: | |
2197 ++v3; | |
2198 --v23; | |
2199 } | |
2200 while ( v23 ); | |
2201 v1 = v21 + 1; | |
2202 ++v21; | |
2203 } | |
2204 while ( (signed int)v21 < (signed int)&uNumChests ); | |
2205 } | |
2206 | |
2207 | |
2208 | |
2209 | |
1844 // 4505CC: using guessed type int var_A0[32]; | 2210 // 4505CC: using guessed type int var_A0[32]; |