Add back the disruptor / desintegrator.

Make the disruptor and it's ammo available by 'give disruptor' and 'give
rounds'. If g_disruptor is set 0 (the defaults) neither the weapon, nor
the ammo is spawned in, if set to 1 it behaves like a normal weapon.
Based upon an idea by @NeonKnightOA submitted in PR #18.

This was requested in issue #17.
This commit is contained in:
Yamagi Burmeister 2019-06-11 13:13:19 +02:00
parent 90420227db
commit 9989340968
5 changed files with 59 additions and 8 deletions

View file

@ -339,6 +339,14 @@ Pickup_Bandolier(edict_t *ent, edict_t *other)
other->client->pers.max_flechettes = 250;
}
if (g_disruptor->value)
{
if (other->client->pers.max_rounds < 150)
{
other->client->pers.max_rounds = 150;
}
}
item = FindItem("Bullets");
if (item)
@ -423,6 +431,14 @@ Pickup_Pack(edict_t *ent, edict_t *other)
other->client->pers.max_flechettes = 200;
}
if (g_disruptor->value)
{
if (other->client->pers.max_rounds < 200)
{
other->client->pers.max_rounds = 200;
}
}
item = FindItem("Bullets");
if (item)
@ -528,6 +544,21 @@ Pickup_Pack(edict_t *ent, edict_t *other)
}
}
item = FindItem("Rounds");
if (item)
{
index = ITEM_INDEX(item);
other->client->pers.inventory[index] += item->quantity;
if (other->client->pers.inventory[index] >
other->client->pers.max_rounds)
{
other->client->pers.inventory[index] =
other->client->pers.max_rounds;
}
}
if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
{
SetRespawn(ent, ent->item->quantity);
@ -1017,8 +1048,10 @@ Add_Ammo(edict_t *ent, gitem_t *item, int count)
return false;
}
if (item->tag == AMMO_BULLETS)
{
printf("1\n");
max = ent->client->pers.max_bullets;
}
else if (item->tag == AMMO_SHELLS)
@ -1053,6 +1086,11 @@ Add_Ammo(edict_t *ent, gitem_t *item, int count)
{
max = ent->client->pers.max_tesla;
}
else if (item->tag == AMMO_DISRUPTOR)
{
printf("2\n");
max = ent->client->pers.max_rounds;
}
else
{
gi.dprintf("undefined ammo type\n");
@ -1937,11 +1975,14 @@ SpawnItem(edict_t *ent, gitem_t *item)
return;
}
if ((!strcmp(ent->classname, "ammo_disruptor")) ||
(!strcmp(ent->classname, "weapon_disintegrator")))
if (!g_disruptor->value)
{
G_FreeEdict(ent);
return;
if ((!strcmp(ent->classname, "ammo_disruptor")) ||
(!strcmp(ent->classname, "weapon_disintegrator")))
{
G_FreeEdict(ent);
return;
}
}
if (ent->spawnflags > 1)
@ -2578,7 +2619,7 @@ gitem_t itemlist[] = {
0,
1,
"Rounds",
IT_NOT_GIVEABLE,
IT_WEAPON,
WEAP_DISRUPTOR,
NULL,
1,
@ -2797,10 +2838,10 @@ gitem_t itemlist[] = {
3,
15,
NULL,
IT_NOT_GIVEABLE,
IT_AMMO,
0,
NULL,
0,
AMMO_DISRUPTOR
},
/* QUAKED item_quad (.3 .3 1) (-16 -16 -16) (16 16 16) TRIGGER_SPAWN */

View file

@ -67,6 +67,8 @@ cvar_t *huntercam;
cvar_t *strong_mines;
cvar_t *randomrespawn;
cvar_t *g_disruptor;
void SpawnEntities(char *mapname, char *entities, char *spawnpoint);
void ClientThink(edict_t *ent, usercmd_t *cmd);
qboolean ClientConnect(edict_t *ent, char *userinfo);

View file

@ -102,7 +102,8 @@ typedef enum
AMMO_FLECHETTES,
AMMO_TESLA,
AMMO_PROX
AMMO_PROX,
AMMO_DISRUPTOR
} ammo_t;
/* Maximum debris / gibs per frame */
@ -617,6 +618,8 @@ extern cvar_t *huntercam;
extern cvar_t *strong_mines;
extern cvar_t *randomrespawn;
extern cvar_t *g_disruptor;
/* this is for the count of monsters */
#define ENT_SLOTS_LEFT \
(ent->monsterinfo.monster_slots - \

View file

@ -833,6 +833,8 @@ InitClientPersistant(gclient_t *client)
client->pers.max_prox = 50;
client->pers.max_tesla = 50;
client->pers.max_flechettes = 200;
client->pers.max_flechettes = 200;
client->pers.max_rounds = 100;
client->pers.connected = true;
}

View file

@ -241,6 +241,9 @@ InitGame(void)
/* dm map list */
sv_maplist = gi.cvar ("sv_maplist", "", 0);
/* disruptor availability */
g_disruptor = gi.cvar ("g_disruptor", "0", 0);
/* items */
InitItems ();