MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / InitItems

Function InitItems

Source/items.cpp:2506–2550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2504}
2505
2506void InitItems()
2507{
2508 ActiveItemCount = 0;
2509 memset(dItem, 0, sizeof(dItem));
2510
2511 for (auto &item : Items) {
2512 item.clear();
2513 item.position = { 0, 0 };
2514 item._iAnimFlag = false;
2515 item._iSelFlag = 0;
2516 item._iIdentified = false;
2517 item._iPostDraw = false;
2518 }
2519
2520 for (uint8_t i = 0; i < MAXITEMS; i++) {
2521 ActiveItems[i] = i;
2522 }
2523
2524 if (!setlevel) {
2525 DiscardRandomValues(1);
2526 if (Quests[Q_ROCK].IsAvailable())
2527 SpawnRock();
2528 if (Quests[Q_ANVIL].IsAvailable())
2529 SpawnQuestItem(IDI_ANVIL, SetPiece.position.megaToWorld() + Displacement { 11, 11 }, 0, 1, false);
2530 if (sgGameInitInfo.bCowQuest != 0 && currlevel == 20)
2531 SpawnQuestItem(IDI_BROWNSUIT, { 25, 25 }, 3, 1, false);
2532 if (sgGameInitInfo.bCowQuest != 0 && currlevel == 19)
2533 SpawnQuestItem(IDI_GREYSUIT, { 25, 25 }, 3, 1, false);
2534 // In multiplayer items spawn during level generation to avoid desyncs
2535 if (gbIsMultiplayer) {
2536 if (Quests[Q_MUSHROOM].IsAvailable())
2537 SpawnQuestItem(IDI_FUNGALTM, { 0, 0 }, 5, 1, false);
2538 if (currlevel == Quests[Q_VEIL]._qlevel + 1 && Quests[Q_VEIL]._qactive != QUEST_NOTAVAIL)
2539 SpawnQuestItem(IDI_GLDNELIX, { 0, 0 }, 5, 1, false);
2540 }
2541 if (currlevel > 0 && currlevel < 16)
2542 AddInitItems();
2543 if (currlevel >= 21 && currlevel <= 23)
2544 SpawnNote();
2545 }
2546
2547 ShowUniqueItemInfoBox = false;
2548
2549 initItemGetRecords();
2550}
2551
2552void CalcPlrItemVals(Player &player, bool loadgfx)
2553{

Callers 1

LoadGameLevelFunction · 0.85

Calls 9

DiscardRandomValuesFunction · 0.85
SpawnRockFunction · 0.85
SpawnQuestItemFunction · 0.85
AddInitItemsFunction · 0.85
SpawnNoteFunction · 0.85
initItemGetRecordsFunction · 0.85
IsAvailableMethod · 0.80
megaToWorldMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected