mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 05:21:16 +00:00
Add sv_coopsharekeys
- in coop, picking up a key will distribute it to all online players
This commit is contained in:
parent
22203cbc1a
commit
a04f909d06
4 changed files with 25 additions and 1 deletions
|
@ -573,6 +573,7 @@ CUSTOM_CVAR(Int, dmflags3, 0, CVAR_SERVERINFO | CVAR_NOINITCALL)
|
|||
}
|
||||
|
||||
CVAR(Flag, sv_noplayerclip, dmflags3, DF3_NO_PLAYER_CLIP);
|
||||
CVAR(Flag, sv_coopsharekeys, dmflags3, DF3_COOP_SHARE_KEYS);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -180,6 +180,7 @@ enum : unsigned
|
|||
enum : unsigned
|
||||
{
|
||||
DF3_NO_PLAYER_CLIP = 1 << 0, // Players can walk through and shoot through each other
|
||||
DF3_COOP_SHARE_KEYS = 1 << 1, // Keys will be given to all players in coop
|
||||
};
|
||||
|
||||
// [RH] Compatibility flags.
|
||||
|
|
|
@ -59,6 +59,28 @@ class Key : Inventory
|
|||
return false;
|
||||
}
|
||||
|
||||
override void AttachToOwner(Actor other)
|
||||
{
|
||||
Super.AttachToOwner(other);
|
||||
|
||||
if (multiplayer && !deathmatch && sv_coopsharekeys)
|
||||
{
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (playeringame[i])
|
||||
{
|
||||
let pmo = players[i].mo;
|
||||
|
||||
if (pmo == other)
|
||||
continue;
|
||||
|
||||
if (!pmo.FindInventory(GetClass()))
|
||||
pmo.GiveInventoryType(GetClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override bool ShouldStay ()
|
||||
{
|
||||
return !!multiplayer;
|
||||
|
|
|
@ -888,7 +888,7 @@ class PlayerPawn : Actor
|
|||
// inventory amount.
|
||||
let defitem = FindInventory (item.GetClass());
|
||||
|
||||
if (sv_cooplosekeys && defitem == NULL && item is 'Key')
|
||||
if ((sv_cooplosekeys && !sv_coopsharekeys) && defitem == NULL && item is 'Key')
|
||||
{
|
||||
item.Destroy();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue