Skip to content

Commit

Permalink
allow all uniques to drop
Browse files Browse the repository at this point in the history
  • Loading branch information
qndel committed Sep 24, 2021
1 parent c44ae7b commit 265e1a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,11 @@ _unique_items CheckUnique(Item &item, int lvl, int uper, bool recreate)
if (numu == 0)
return UITEM_INVALID;

AdvanceRndSeed();
// two algorithms to keep old items compatible
if ((item.dwBuff & CF_NEW_UNIQ) != 0)
numu = GenerateRnd(numu) + 1;
else
AdvanceRndSeed();
uint8_t itemData = 0;
while (numu > 0) {
if (uok[itemData])
Expand Down Expand Up @@ -3414,7 +3418,7 @@ void SpawnItem(Monster &monster, Point position, bool sendmsg)
mLevel -= 15;
if (mLevel > CF_LEVEL)
mLevel = CF_LEVEL;

item.dwBuff |= CF_NEW_UNIQ;
SetupAllItems(item, idx, AdvanceRndSeed(), mLevel, uper, onlygood, false, false);

if (sendmsg)
Expand Down Expand Up @@ -4968,6 +4972,7 @@ std::string DebugSpawnUniqueItem(std::string itemName)
for (auto &flag : UniqueItemFlags)
flag = true;
UniqueItemFlags[uniqueIndex] = false;
item.dwBuff |= CF_NEW_UNIQ;
SetupAllItems(item, uniqueBaseIndex, AdvanceRndSeed(), uniqueItem.UIMinLvl, 1, false, false, false);
for (auto &flag : UniqueItemFlags)
flag = false;
Expand All @@ -4979,7 +4984,6 @@ std::string DebugSpawnUniqueItem(std::string itemName)
std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](unsigned char c) { return std::tolower(c); });
if (tmp.find(itemName) != std::string::npos)
break;
return "Impossible to generate!";
}

item._iIdentified = true;
Expand Down
1 change: 1 addition & 0 deletions Source/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ enum icreateinfo_flag {
enum icreateinfo_flag2 {
// clang-format off
CF_HELLFIRE = 1,
CF_NEW_UNIQ = 2,
// clang-format on
};

Expand Down
1 change: 1 addition & 0 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ void UnPackItem(const ItemPack *is, Item *id, bool isHellfire)
SDL_SwapLE32(is->dwBuff));
} else {
memset(&item, 0, sizeof(item));
item.dwBuff = is->dwBuff;
RecreateItem(item, idx, SDL_SwapLE16(is->iCreateInfo), SDL_SwapLE32(is->iSeed), SDL_SwapLE16(is->wValue), isHellfire);
item._iMagical = static_cast<item_quality>(is->bId >> 1);
item._iIdentified = (is->bId & 1) != 0;
Expand Down

0 comments on commit 265e1a3

Please sign in to comment.