Add coop_pickup_weapons, allow a weapon to be taken several times.

In coop a weapon can be picked up only once. That's annoying, because in
coop ammunition is sparse and not getting the ammunition that comes with
a weapons make things worse. When `coop_pickup_weapons` is set to `1` a
weapon may be picked up if:

1) The player doesn't have the weapon in their inventory.
2) No other player has already picked it up.
This commit is contained in:
Yamagi 2020-08-10 14:15:35 +02:00
parent cfd660abc3
commit 6820b0cad1
4 changed files with 7 additions and 1 deletions

View file

@ -23,6 +23,7 @@ edict_t *g_edicts;
cvar_t *deathmatch;
cvar_t *coop;
cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
cvar_t *coop_pickup_weapons;
cvar_t *dmflags;
cvar_t *skill;
cvar_t *fraglimit;

View file

@ -60,6 +60,7 @@
#define FL_TEAMSLAVE 0x00000400 /* not the first on the team */
#define FL_NO_KNOCKBACK 0x00000800
#define FL_POWER_ARMOR 0x00001000 /* power armor (if any) is active */
#define FL_COOP_TAKEN 0x00002000 /* Another client has already taken it */
#define FL_RESPAWN 0x80000000 /* used for item respawning */
#define FL_MECHANICAL 0x00002000 /* entity is mechanical, use sparks not blood */
@ -584,6 +585,7 @@ extern cvar_t *maxentities;
extern cvar_t *deathmatch;
extern cvar_t *coop;
extern cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
extern cvar_t *coop_pickup_weapons;
extern cvar_t *dmflags;
extern cvar_t *skill;
extern cvar_t *fraglimit;

View file

@ -259,7 +259,8 @@ Pickup_Weapon(edict_t *ent, edict_t *other)
if ((((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index])
{
if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)))
if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) &&
(!coop_pickup_weapons->value || (ent->flags & FL_COOP_TAKEN)))
{
return false; /* leave the weapon for others to pickup */
}
@ -301,6 +302,7 @@ Pickup_Weapon(edict_t *ent, edict_t *other)
if (coop->value)
{
ent->flags |= FL_RESPAWN;
ent->flags |= FL_COOP_TAKEN;
}
}
}

View file

@ -214,6 +214,7 @@ InitGame(void)
deathmatch = gi.cvar ("deathmatch", "0", CVAR_LATCH);
coop = gi.cvar ("coop", "0", CVAR_LATCH);
coop_baseq2 = gi.cvar ("coop_baseq2", "0", CVAR_LATCH);
coop_pickup_weapons = gi.cvar("coop_pickup_weapons", "0", 0);
skill = gi.cvar ("skill", "1", CVAR_LATCH);
maxentities = gi.cvar ("maxentities", "1024", CVAR_LATCH);
gamerules = gi.cvar ("gamerules", "0", CVAR_LATCH); //PGM