Mercurial > mm7
comparison Items.cpp @ 2287:4e3236a4ea63
GenerateItemsInChest cleaned up a bit, unified the two switches
author | Grumpy7 |
---|---|
date | Sat, 15 Mar 2014 23:42:51 +0100 |
parents | 288e0b29a493 |
children | 406605240b0a |
comparison
equal
deleted
inserted
replaced
2286:288e0b29a493 | 2287:4e3236a4ea63 |
---|---|
1860 | 1860 |
1861 | 1861 |
1862 //----- (00450218) -------------------------------------------------------- | 1862 //----- (00450218) -------------------------------------------------------- |
1863 void GenerateItemsInChest() | 1863 void GenerateItemsInChest() |
1864 { | 1864 { |
1865 unsigned int v0; // eax@1 | 1865 unsigned int mapType; // eax@1 |
1866 MapInfo *v2; // esi@1 | 1866 MapInfo *currMapInfo; // esi@1 |
1867 ItemGen *v3; // ebx@2 | 1867 ItemGen *currItem; // ebx@2 |
1868 int v4; // ebp@4 | 1868 int additionaItemCount; // ebp@4 |
1869 int v5; // edi@4 | 1869 int treasureLevelBot; // edi@4 |
1870 int v6; // esi@4 | 1870 int treasureLevelTop; // esi@4 |
1871 signed int v8; // esi@4 | 1871 signed int treasureLevelRange; // esi@4 |
1872 int v9; // edx@4 | 1872 int resultTreasureLevel; // edx@4 |
1873 int v10; // esi@8 | 1873 int goldAmount; // esi@8 |
1874 int v11; // ebp@25 | 1874 int v11; // ebp@25 |
1875 int v12; // esi@25 | 1875 int v12; // esi@25 |
1876 ItemGen *v14; // edi@28 | 1876 signed int whatToGenerateProb; // [sp+10h] [bp-18h]@1 |
1877 signed int v18; // [sp+10h] [bp-18h]@1 | 1877 |
1878 | 1878 mapType = pMapStats->GetMapInfo(pCurrentMapName); |
1879 v18 = rand() % 100; //main random | 1879 currMapInfo = &pMapStats->pInfos[mapType]; |
1880 v0 = pMapStats->GetMapInfo(pCurrentMapName); | |
1881 // v1 = pChests; | |
1882 v2 = &pMapStats->pInfos[v0]; | |
1883 //v21 = pChests; | |
1884 //v20 = &pMapStats->pInfos[v0]; | |
1885 for(int i=1; i<20;++i) | 1880 for(int i=1; i<20;++i) |
1881 { | |
1882 for(int j=0; j<140;++j) | |
1886 { | 1883 { |
1887 for(int j=0; j<140;++j) | 1884 |
1885 currItem = &pChests[i].igChestItems[j]; | |
1886 if ( currItem->uItemID < 0 ) | |
1888 { | 1887 { |
1889 | 1888 additionaItemCount = rand() % 5; //additional items in chect |
1890 v3 = &pChests[i].igChestItems[j]; | 1889 treasureLevelBot = byte_4E8168[abs(currItem->uItemID)-1][2*currMapInfo->Treasure_prob]; |
1891 if ( v3->uItemID < 0 ) | 1890 treasureLevelTop = byte_4E8168[abs(currItem->uItemID)-1][2*currMapInfo->Treasure_prob+1]; |
1891 treasureLevelRange = treasureLevelTop - treasureLevelBot + 1; | |
1892 resultTreasureLevel = treasureLevelBot + rand() % treasureLevelRange; //treasure level | |
1893 if (resultTreasureLevel<7) | |
1892 { | 1894 { |
1893 v4 = rand() % 5; //additional items in chect | 1895 v11 = 0; |
1894 v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob]; | 1896 do |
1895 v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1]; | 1897 { |
1896 v8 = v6 - v5 + 1; | 1898 whatToGenerateProb = rand() % 100; |
1897 v9 = v5 + rand() % v8; //treasure level | 1899 if (whatToGenerateProb<20) |
1898 if (v9<7) | |
1899 { | 1900 { |
1900 if (v18<20) | 1901 currItem->Reset(); |
1901 { | 1902 } |
1902 v3->Reset(); | 1903 else if (whatToGenerateProb<60) //generate gold |
1903 } | 1904 { |
1904 else if (v18<60) //generate gold | 1905 goldAmount=0; |
1905 { | 1906 currItem->Reset(); |
1906 v10=0; | 1907 switch (resultTreasureLevel) |
1907 v3->Reset(); | 1908 { |
1908 switch (v9) | 1909 case 1: //small gold |
1909 { | 1910 goldAmount = rand() % 51 + 50; |
1910 case 1: //small gold | 1911 currItem->uItemID = 197; |
1911 v10 = rand() % 51 + 50; | 1912 break; |
1912 v3->uItemID = 197; | 1913 case 2://small gold |
1913 break; | 1914 goldAmount = rand() % 101 + 100; |
1914 case 2://small gold | 1915 currItem->uItemID = 197; |
1915 v10 = rand() % 101 + 100; | 1916 break; |
1916 v3->uItemID = 197; | 1917 case 3: //medium |
1917 break; | 1918 goldAmount = rand() % 301 + 200; |
1918 case 3: //medium | 1919 currItem->uItemID = 198; |
1919 v10 = rand() % 301 + 200; | 1920 break; |
1920 v3->uItemID = 198; | 1921 case 4: //medium |
1921 break; | 1922 goldAmount = rand() % 501 + 500; |
1922 case 4: //medium | 1923 currItem->uItemID = 198; |
1923 v10 = rand() % 501 + 500; | 1924 break; |
1924 v3->uItemID = 198; | 1925 case 5: //big |
1925 break; | 1926 goldAmount = rand() % 1001 + 1000; |
1926 case 5: //big | 1927 currItem->uItemID = 199; |
1927 v10 = rand() % 1001 + 1000; | 1928 break; |
1928 v3->uItemID = 199; | 1929 case 6: //big |
1929 break; | 1930 goldAmount = rand() % 3001 + 2000; |
1930 case 6: //big | 1931 currItem->uItemID = 199; |
1931 v10 = rand() % 3001 + 2000; | 1932 break; |
1932 v3->uItemID = 199; | 1933 } |
1933 break; | 1934 currItem->SetIdentified(); |
1934 } | 1935 currItem->uSpecEnchantmentType = goldAmount; |
1935 v3->SetIdentified(); | 1936 } |
1936 v3->uSpecEnchantmentType = v10; | |
1937 } | |
1938 else | 1937 else |
1939 { | 1938 { |
1940 pItemsTable->GenerateItem(v9, 0, v3); | 1939 pItemsTable->GenerateItem(resultTreasureLevel, 0, currItem); |
1941 } | 1940 } |
1942 | |
1943 v12 = 0; | 1941 v12 = 0; |
1944 //generate more items | 1942 while ( !(pChests[i].igChestItems[v12].uItemID==0) &&(v12<140)) |
1945 for (v11=0; v11<v4; ++v11) | 1943 { |
1946 { | 1944 ++v12; |
1947 | |
1948 if ( v12 >= 140 ) | |
1949 break; | |
1950 while ( !(pChests[i].igChestItems[v12].uItemID==0) &&(v12<140)) | |
1951 { | |
1952 ++v12; | |
1953 } | |
1954 v14=&pChests[i].igChestItems[v12]; | |
1955 v18 = rand() % 100; | |
1956 if (v18<20) | |
1957 { | |
1958 v3->Reset(); | |
1959 } | |
1960 else if (v18<60) //generate gold | |
1961 { | |
1962 v10=0; | |
1963 v3->Reset(); | |
1964 switch (v9) | |
1965 { | |
1966 case 1: //small gold | |
1967 v10 = rand() % 51 + 50; | |
1968 v14->uItemID = 197; | |
1969 break; | |
1970 case 2://small gold | |
1971 v10 = rand() % 101 + 100; | |
1972 v14->uItemID = 197; | |
1973 break; | |
1974 case 3: //medium | |
1975 v10 = rand() % 301 + 200; | |
1976 v14->uItemID = 198; | |
1977 break; | |
1978 case 4: //medium | |
1979 v10 = rand() % 501 + 500; | |
1980 v14->uItemID = 198; | |
1981 break; | |
1982 case 5: //big | |
1983 v10 = rand() % 1001 + 1000; | |
1984 v14->uItemID = 199; | |
1985 break; | |
1986 case 6: //big | |
1987 v10 = rand() % 3001 + 2000; | |
1988 v14->uItemID = 199; | |
1989 break; | |
1990 } | |
1991 v14->SetIdentified(); | |
1992 v14->uSpecEnchantmentType = v10; | |
1993 } | |
1994 else | |
1995 { | |
1996 pItemsTable->GenerateItem(v9, 0, v14); | |
1997 } | |
1998 ++v12; | |
1999 } | |
2000 } | 1945 } |
1946 if (v12 >= 140) | |
1947 break; | |
1948 currItem=&pChests[i].igChestItems[v12]; | |
1949 v11++; | |
1950 } while (v11 < additionaItemCount + 1); // + 1 because it's the item at pChests[i].igChestItems[j] and the additional ones | |
1951 } | |
2001 else | 1952 else |
2002 v3->GenerateArtifact(); | 1953 currItem->GenerateArtifact(); |
2003 } | 1954 } |
2004 } | 1955 } |
2005 } | 1956 } |
2006 | 1957 |
2007 } | 1958 } |
2008 | 1959 |
2009 | 1960 |
2010 | 1961 |
2011 | 1962 |
2012 // 4505CC: using guessed type int var_A0[32]; | 1963 // 4505CC: using guessed type int var_A0[32]; |