Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loot system fixes and tweaks #2930

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,7 @@ void CheckInvSwap(Player &player, inv_body_loc bLoc, int idx, uint16_t wCI, int
{
auto &item = Items[MAXITEMS];
memset(&item, 0, sizeof(item));
item.dwBuff = dwBuff;
RecreateItem(item, idx, wCI, seed, 0, (dwBuff & CF_HELLFIRE) != 0);
qndel marked this conversation as resolved.
Show resolved Hide resolved

player.HoldItem = item;
Expand Down Expand Up @@ -1785,6 +1786,7 @@ int SyncPutItem(Player &player, Point position, int idx, uint16_t icreateinfo, i
if (idx == IDI_EAR) {
RecreateEar(item, icreateinfo, iseed, id, dur, mdur, ch, mch, ivalue, ibuff);
} else {
item.dwBuff = ibuff;
RecreateItem(item, idx, icreateinfo, iseed, ivalue, (ibuff & CF_HELLFIRE) != 0);
if (id != 0)
item._iIdentified = true;
Expand All @@ -1798,7 +1800,6 @@ int SyncPutItem(Player &player, Point position, int idx, uint16_t icreateinfo, i
item._iMinMag = minMag;
item._iMinDex = minDex;
item._iAC = ac;
item.dwBuff = ibuff;
}

item.position = position;
Expand Down
14 changes: 10 additions & 4 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 @@ -3408,10 +3412,12 @@ void SpawnItem(Monster &monster, Point position, bool sendmsg)
GetSuperItemSpace(position, ii);
int uper = monster._uniqtype != 0 ? 15 : 1;

int8_t mLevel = monster.MData->mLevel;
int8_t mLevel = monster.mLevel;
if (!gbIsHellfire && monster.MType->mtype == MT_DIABLO)
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 @@ -4965,6 +4971,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 @@ -4976,7 +4983,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,
qndel marked this conversation as resolved.
Show resolved Hide resolved
// clang-format on
};

Expand Down
2 changes: 1 addition & 1 deletion Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,7 @@ void DeltaLoadLevel()
sgLevels[currlevel].item[i].wValue,
sgLevels[currlevel].item[i].dwBuff);
} else {
item.dwBuff = sgLevels[currlevel].item[i].dwBuff;
RecreateItem(
item,
sgLevels[currlevel].item[i].wIndx,
Expand All @@ -2220,7 +2221,6 @@ void DeltaLoadLevel()
item._iMinMag = sgLevels[currlevel].item[i].bMinMag;
item._iMinDex = sgLevels[currlevel].item[i].bMinDex;
item._iAC = sgLevels[currlevel].item[i].bAC;
item.dwBuff = sgLevels[currlevel].item[i].dwBuff;
}
int x = sgLevels[currlevel].item[i].x;
int y = sgLevels[currlevel].item[i].y;
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