| 1849 | } |
| 1850 | |
| 1851 | int RndUItem(int m) |
| 1852 | { |
| 1853 | int i, ri; |
| 1854 | int ril[512]; |
| 1855 | BOOL okflag; |
| 1856 | |
| 1857 | if (m != -1 && (monster[m].MData->mTreasure & 0x8000) != 0 && gbMaxPlayers == 1) |
| 1858 | return -1 - (monster[m].MData->mTreasure & 0xFFF); |
| 1859 | |
| 1860 | ri = 0; |
| 1861 | for (i = 0; AllItemsList[i].iLoc != ILOC_INVALID; i++) { |
| 1862 | okflag = TRUE; |
| 1863 | if (!AllItemsList[i].iRnd) |
| 1864 | okflag = FALSE; |
| 1865 | if (m != -1) { |
| 1866 | if (monster[m].mLevel < AllItemsList[i].iMinMLvl) |
| 1867 | okflag = FALSE; |
| 1868 | } else { |
| 1869 | if (2 * currlevel < AllItemsList[i].iMinMLvl) |
| 1870 | okflag = FALSE; |
| 1871 | } |
| 1872 | if (AllItemsList[i].itype == ITYPE_MISC) |
| 1873 | okflag = FALSE; |
| 1874 | if (AllItemsList[i].itype == ITYPE_GOLD) |
| 1875 | okflag = FALSE; |
| 1876 | if (AllItemsList[i].itype == ITYPE_0E) |
| 1877 | okflag = FALSE; |
| 1878 | if (AllItemsList[i].iMiscId == IMISC_BOOK) |
| 1879 | okflag = TRUE; |
| 1880 | if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) |
| 1881 | okflag = FALSE; |
| 1882 | if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) |
| 1883 | okflag = FALSE; |
| 1884 | if (okflag) { |
| 1885 | ril[ri] = i; |
| 1886 | ri++; |
| 1887 | } |
| 1888 | } |
| 1889 | |
| 1890 | return ril[random_(25, ri)]; |
| 1891 | } |
| 1892 | |
| 1893 | int RndAllItems() |
| 1894 | { |
no test coverage detected