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

Function SpawnItem

Source/items.cpp:2090–2131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2088}
2089
2090void SpawnItem(int m, int x, int y, BOOL sendmsg)
2091{
2092 int ii, onlygood, idx;
2093
2094 if (monster[m]._uniqtype || ((monster[m].MData->mTreasure & 0x8000) && gbMaxPlayers != 1)) {
2095 idx = RndUItem(m);
2096 if (idx < 0) {
2097 SpawnUnique(-(idx + 1), x, y);
2098 return;
2099 }
2100 onlygood = 1;
2101 } else if (quests[QTYPE_BLKM]._qactive != 2 || quests[QTYPE_BLKM]._qvar1 != QS_MUSHGIVEN) {
2102 idx = RndItem(m);
2103 if (!idx)
2104 return;
2105 if (idx > 0) {
2106 idx--;
2107 onlygood = 0;
2108 } else {
2109 SpawnUnique(-(idx + 1), x, y);
2110 return;
2111 }
2112 } else {
2113 idx = IDI_BRAIN;
2114 quests[QTYPE_BLKM]._qvar1 = QS_BRAINSPAWNED;
2115 }
2116
2117 if (numitems < MAXITEMS) {
2118 ii = itemavail[0];
2119 GetSuperItemSpace(x, y, ii);
2120 itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2121 itemactive[numitems] = ii;
2122 if (monster[m]._uniqtype) {
2123 SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 15, onlygood, FALSE, FALSE);
2124 } else {
2125 SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 1, onlygood, FALSE, FALSE);
2126 }
2127 numitems++;
2128 if (sendmsg)
2129 NetSendCmdDItem(FALSE, ii);
2130 }
2131}
2132
2133void CreateItem(int uid, int x, int y)
2134{

Callers 3

MonstStartKillFunction · 0.85
M2MStartKillFunction · 0.85
M_DoTalkFunction · 0.85

Calls 7

RndUItemFunction · 0.85
SpawnUniqueFunction · 0.85
RndItemFunction · 0.85
GetSuperItemSpaceFunction · 0.85
SetupAllItemsFunction · 0.85
GetRndSeedFunction · 0.85
NetSendCmdDItemFunction · 0.85

Tested by

no test coverage detected