Inventory item spawn fixes

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.
This commit is contained in:
Boondorl 2024-05-17 20:03:44 -04:00 committed by Ricardo Luís Vaz Silva
parent d02f79d4be
commit 4c191f4bf5
2 changed files with 11 additions and 12 deletions

View file

@ -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();
@ -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());
}
//===========================================================================
@ -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;
@ -869,13 +867,13 @@ 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;
@ -883,7 +881,7 @@ class Inventory : Actor
}
else
{
PlayPickupSound (toucher);
give.PlayPickupSound (toucher);
}
}

View file

@ -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)