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-03-30 13:55:02 +02:00
parent 7ca55afffe
commit 1a6dea5a0b
5 changed files with 16 additions and 3 deletions

View File

@ -113,6 +113,14 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
spawned in maps (in fact, some official Ground Zero maps contain spawned in maps (in fact, some official Ground Zero maps contain
these entities). This cvar is set to 0 by default. these entities). This cvar is set to 0 by default.
* **coop_pickup_weapons**: In coop a weapon can be picked up only once.
For example, if the player already has the shotgun they cannot pickup
a second shotgun found at a later time, thus not getting the ammo that
comes with it. This breaks the balacing. If set to `1` a weapon can be
picked up if a) the player doesn't have it or b) it wasn't already
picked up by another player. Defaults to `0`.
## Audio ## Audio
* **al_device**: OpenAL device to use. In most cases there's no need to * **al_device**: OpenAL device to use. In most cases there's no need to

View File

@ -40,6 +40,7 @@ edict_t *g_edicts;
cvar_t *deathmatch; cvar_t *deathmatch;
cvar_t *coop; cvar_t *coop;
cvar_t *coop_pickup_weapons;
cvar_t *dmflags; cvar_t *dmflags;
cvar_t *skill; cvar_t *skill;
cvar_t *fraglimit; cvar_t *fraglimit;

View File

@ -72,6 +72,7 @@
#define FL_TEAMSLAVE 0x00000400 /* not the first on the team */ #define FL_TEAMSLAVE 0x00000400 /* not the first on the team */
#define FL_NO_KNOCKBACK 0x00000800 #define FL_NO_KNOCKBACK 0x00000800
#define FL_POWER_ARMOR 0x00001000 /* power armor (if any) is active */ #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_RESPAWN 0x80000000 /* used for item respawning */
#define FRAMETIME 0.1 #define FRAMETIME 0.1
@ -507,6 +508,7 @@ extern edict_t *g_edicts;
extern cvar_t *maxentities; extern cvar_t *maxentities;
extern cvar_t *deathmatch; extern cvar_t *deathmatch;
extern cvar_t *coop; extern cvar_t *coop;
extern cvar_t *coop_pickup_weapons;
extern cvar_t *dmflags; extern cvar_t *dmflags;
extern cvar_t *skill; extern cvar_t *skill;
extern cvar_t *fraglimit; extern cvar_t *fraglimit;

View File

@ -184,7 +184,8 @@ Pickup_Weapon(edict_t *ent, edict_t *other)
if ((((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) && if ((((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) &&
other->client->pers.inventory[index]) 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 */ return false; /* leave the weapon for others to pickup */
} }
@ -223,14 +224,14 @@ Pickup_Weapon(edict_t *ent, edict_t *other)
if (coop->value) if (coop->value)
{ {
ent->flags |= FL_RESPAWN; ent->flags |= FL_RESPAWN;
ent->flags |= FL_COOP_TAKEN;
} }
} }
} }
if ((other->client->pers.weapon != ent->item) && if ((other->client->pers.weapon != ent->item) &&
(other->client->pers.inventory[index] == 1) && (other->client->pers.inventory[index] == 1) &&
(!deathmatch->value || (!deathmatch->value || (other->client->pers.weapon == FindItem("blaster"))))
(other->client->pers.weapon == FindItem("blaster"))))
{ {
other->client->newweapon = ent->item; other->client->newweapon = ent->item;
} }

View File

@ -232,6 +232,7 @@ InitGame(void)
maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO); maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO);
deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH); deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH);
coop = gi.cvar("coop", "0", CVAR_LATCH); coop = gi.cvar("coop", "0", CVAR_LATCH);
coop_pickup_weapons = gi.cvar("coop_pickup_weapons", "0", 0);
skill = gi.cvar("skill", "1", CVAR_LATCH); skill = gi.cvar("skill", "1", CVAR_LATCH);
maxentities = gi.cvar("maxentities", "1024", CVAR_LATCH); maxentities = gi.cvar("maxentities", "1024", CVAR_LATCH);