Skip to content

Commit

Permalink
Inventory item spawn fixes
Browse files Browse the repository at this point in the history
Default player items and shared items are no longer capable of being duplicated regardless of item flags. Shared items now give a true copy of the item. Fixed incorrect effects playing from item copies. Dropped items can no longer be shared.
  • Loading branch information
Boondorl authored and RicardoLuis0 committed May 26, 2024
1 parent d02f79d commit 4c191f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
22 changes: 10 additions & 12 deletions wadsrc/static/zscript/actors/inventory/inventory.zs
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,18 @@ class Inventory : Actor
if (bSharingItem)
return;

class<Inventory> type = GetClass();
int skip = giver && giver.player ? giver.PlayerNumber() : -1;

for (int i; i < MAXPLAYERS; ++i)
{
if (!playerInGame[i] || i == skip)
continue;

let item = Inventory(Spawn(type));
if (!item)
let item = CreateLocalCopy(players[i].mo);
if (!item || item == self)
continue;

item.bSharingItem = true;
item.bDropped = item.bNeverLocal = true;
if (!item.CallTryPickup(players[i].mo))
{
item.Destroy();
Expand All @@ -293,14 +292,13 @@ class Inventory : Actor

if (!bQuiet)
{
PlayPickupSound(players[i].mo);
PrintPickupMessage(i == consoleplayer, item.PickupMessage());

item.PlayPickupSound(players[i].mo);
if (!bNoScreenFlash && players[i].PlayerState != PST_DEAD)
players[i].BonusCount = BONUSADD;
}
}

if (!bQuiet && consoleplayer != skip)
PrintPickupMessage(true, PickupMessage());
}

//===========================================================================
Expand Down Expand Up @@ -700,7 +698,7 @@ class Inventory : Actor
toucher.HasReceived(self);

// If the item can be shared, make sure every player gets a copy.
if (multiplayer && !deathmatch && ShouldShareItem(toucher))
if (multiplayer && !deathmatch && !bDropped && ShouldShareItem(toucher))
ShareItemWithPlayers(toucher);
}
return res, toucher;
Expand Down Expand Up @@ -869,21 +867,21 @@ class Inventory : Actor

if (!bQuiet)
{
PrintPickupMessage(localview, PickupMessage ());
PrintPickupMessage(localview, give.PickupMessage ());

// Special check so voodoo dolls picking up items cause the
// real player to make noise.
if (player != NULL)
{
PlayPickupSound (player.mo);
give.PlayPickupSound (player.mo);
if (!bNoScreenFlash && player.playerstate != PST_DEAD)
{
player.bonuscount = BONUSADD;
}
}
else
{
PlayPickupSound (toucher);
give.PlayPickupSound (toucher);
}
}

Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/actors/player/player.zs
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,7 @@ class PlayerPawn : Actor
{
item = Inventory(Spawn(ti));
item.bIgnoreSkill = true; // no skill multipliers here
item.bDropped = item.bNeverLocal = true; // Avoid possible copies.
item.Amount = di.Amount;
let weap = Weapon(item);
if (weap)
Expand Down

0 comments on commit 4c191f4

Please sign in to comment.