MCPcopy Create free account
hub / github.com/diasurgical/devilution / RndUItem

Function RndUItem

Source/items.cpp:1851–1891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1849}
1850
1851int 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
1893int RndAllItems()
1894{

Callers 2

SpawnItemFunction · 0.85
CreateRndItemFunction · 0.85

Calls 1

random_Function · 0.85

Tested by

no test coverage detected