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

Function RndItem

Source/items.cpp:1815–1849  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813}
1814
1815int RndItem(int m)
1816{
1817 int i, ri;
1818 int ril[512];
1819
1820 if ((monster[m].MData->mTreasure & 0x8000) != 0)
1821 return -1 - (monster[m].MData->mTreasure & 0xFFF);
1822
1823 if (monster[m].MData->mTreasure & 0x4000)
1824 return 0;
1825
1826 if (random_(24, 100) > 40)
1827 return 0;
1828
1829 if (random_(24, 100) > 25)
1830 return 1;
1831
1832 ri = 0;
1833 for (i = 0; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
1834 if (AllItemsList[i].iRnd == 2 && monster[m].mLevel >= AllItemsList[i].iMinMLvl) {
1835 ril[ri] = i;
1836 ri++;
1837 }
1838 if (AllItemsList[i].iRnd && monster[m].mLevel >= AllItemsList[i].iMinMLvl) {
1839 ril[ri] = i;
1840 ri++;
1841 }
1842 if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
1843 ri--;
1844 if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
1845 ri--;
1846 }
1847
1848 return ril[random_(24, ri)] + 1;
1849}
1850
1851int RndUItem(int m)
1852{

Callers 1

SpawnItemFunction · 0.85

Calls 1

random_Function · 0.85

Tested by

no test coverage detected