Skip to content

Commit

Permalink
game, cgame: add weapon stat cvar
Browse files Browse the repository at this point in the history
TODO: rate of fire handled by bg_pmove. already found a way but quite buggy

also fixes startingammo RL using RG cvar

also player die using infinite weapon not dropping weapon

CHECK: nailgun may not accurate as in QL
  • Loading branch information
yumirak committed Mar 11, 2024
1 parent dd55907 commit f3d4d35
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 49 deletions.
4 changes: 4 additions & 0 deletions code/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,10 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.hgrenb2aSound );
}
break;
case EV_NAIL_BOUNCE:
DEBUGNAME("EV_NAIL_BOUNCE");
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.sfx_nghit );
break;

//#ifdef MISSIONPACK
case EV_PROXIMITY_MINE_STICK:
Expand Down
3 changes: 2 additions & 1 deletion code/game/bg_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,8 @@ char *eventnames[] = {
"EV_TAUNT_FOLLOWME",
"EV_TAUNT_GETFLAG",
"EV_TAUNT_GUARDBASE",
"EV_TAUNT_PATROL"
"EV_TAUNT_PATROL",
"EV_NAIL_BOUNCE",

};

Expand Down
3 changes: 2 additions & 1 deletion code/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ typedef enum {
EV_TAUNT_GETFLAG,
EV_TAUNT_GUARDBASE,
EV_TAUNT_PATROL,
EV_DAMAGEPLUM
EV_DAMAGEPLUM,
EV_NAIL_BOUNCE

} entity_event_t;

Expand Down
4 changes: 2 additions & 2 deletions code/game/g_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void ClientWeaponSpawn( gentity_t *ent )
if ( g_startingWeapons.integer & 2 ) {
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_MACHINEGUN );
if ( g_gametype.integer == GT_TEAM ) {
client->ps.ammo[WP_MACHINEGUN] = g_startingAmmo_mg.integer / 2;
client->ps.ammo[WP_MACHINEGUN] = g_startingAmmo_mg_team.integer;
} else {
client->ps.ammo[WP_MACHINEGUN] = g_startingAmmo_mg.integer;
}
Expand All @@ -525,7 +525,7 @@ void ClientWeaponSpawn( gentity_t *ent )
}
if ( g_startingWeapons.integer & 16 ) {
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_ROCKET_LAUNCHER );
client->ps.ammo[WP_ROCKET_LAUNCHER] = g_startingAmmo_rg.integer;
client->ps.ammo[WP_ROCKET_LAUNCHER] = g_startingAmmo_rl.integer;
}
if ( g_startingWeapons.integer & 32 ) {
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_LIGHTNING );
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void TossClientItems( gentity_t *self ) {
}

if ( weapon > WP_MACHINEGUN && weapon != WP_GRAPPLING_HOOK &&
self->client->ps.ammo[ weapon ] ) {
self->client->ps.ammo[ weapon ] > -1) { // don't drop unlimited ammo weapon
// find the item type for this weapon
item = BG_FindItemForWeapon( weapon );

Expand Down
42 changes: 41 additions & 1 deletion code/game/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ extern vmCvar_t g_startingWeapons; //bitmask
//
extern vmCvar_t g_startingAmmo_g;
extern vmCvar_t g_startingAmmo_mg;
extern vmCvar_t g_startingAmmo_mg_team;
extern vmCvar_t g_startingAmmo_sg;
extern vmCvar_t g_startingAmmo_gl;
extern vmCvar_t g_startingAmmo_rl;
Expand All @@ -780,7 +781,46 @@ extern vmCvar_t g_startingAmmo_pl;
extern vmCvar_t g_startingAmmo_cg;
extern vmCvar_t g_startingAmmo_hmg;
//

extern vmCvar_t g_damage_g;
extern vmCvar_t g_damage_mg;
extern vmCvar_t g_damage_mg_team;
extern vmCvar_t g_damage_sg;
extern vmCvar_t g_damage_gl;
extern vmCvar_t g_damage_rl;
extern vmCvar_t g_damage_lg;
extern vmCvar_t g_damage_rg;
extern vmCvar_t g_damage_pg;
extern vmCvar_t g_damage_bfg;
extern vmCvar_t g_damage_gh;
extern vmCvar_t g_damage_ng;
extern vmCvar_t g_damage_pl;
extern vmCvar_t g_damage_cg;
extern vmCvar_t g_damage_hmg;

extern vmCvar_t g_splashdamage_rl;
extern vmCvar_t g_splashdamage_gl;
extern vmCvar_t g_splashdamage_pg;
extern vmCvar_t g_splashdamage_bfg;
extern vmCvar_t g_splashdamage_pl;

extern vmCvar_t g_splashradius_rl;
extern vmCvar_t g_splashradius_gl;
extern vmCvar_t g_splashradius_pg;
extern vmCvar_t g_splashradius_bfg;
extern vmCvar_t g_splashradius_pl;

extern vmCvar_t g_velocity_bfg;
extern vmCvar_t g_velocity_gh;
extern vmCvar_t g_velocity_gl;
extern vmCvar_t g_velocity_pg;
extern vmCvar_t g_velocity_rl;

extern vmCvar_t g_nailbounce;
extern vmCvar_t g_nailbouncepercentage;
extern vmCvar_t g_nailcount;
extern vmCvar_t g_nailspeed;
extern vmCvar_t g_nailspread;
//

void trap_Print( const char *text );
void trap_Error( const char *text ) __attribute__((noreturn));
Expand Down
83 changes: 83 additions & 0 deletions code/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ vmCvar_t g_startingWeapons; //bitmask
//
vmCvar_t g_startingAmmo_g;
vmCvar_t g_startingAmmo_mg;
vmCvar_t g_startingAmmo_mg_team;
vmCvar_t g_startingAmmo_sg;
vmCvar_t g_startingAmmo_gl;
vmCvar_t g_startingAmmo_rl;
Expand All @@ -125,6 +126,47 @@ vmCvar_t g_startingAmmo_ng;
vmCvar_t g_startingAmmo_pl;
vmCvar_t g_startingAmmo_cg;
vmCvar_t g_startingAmmo_hmg;
//
vmCvar_t g_damage_g;
vmCvar_t g_damage_mg;
vmCvar_t g_damage_mg_team;
vmCvar_t g_damage_sg;
vmCvar_t g_damage_gl;
vmCvar_t g_damage_rl;
vmCvar_t g_damage_lg;
vmCvar_t g_damage_rg;
vmCvar_t g_damage_pg;
vmCvar_t g_damage_bfg;
vmCvar_t g_damage_gh;
vmCvar_t g_damage_ng;
vmCvar_t g_damage_pl;
vmCvar_t g_damage_cg;
vmCvar_t g_damage_hmg;

vmCvar_t g_splashdamage_rl;
vmCvar_t g_splashdamage_gl;
vmCvar_t g_splashdamage_pg;
vmCvar_t g_splashdamage_bfg;
vmCvar_t g_splashdamage_pl;

vmCvar_t g_splashradius_rl;
vmCvar_t g_splashradius_gl;
vmCvar_t g_splashradius_pg;
vmCvar_t g_splashradius_bfg;
vmCvar_t g_splashradius_pl;

vmCvar_t g_velocity_bfg;
vmCvar_t g_velocity_gh;
vmCvar_t g_velocity_gl;
vmCvar_t g_velocity_pg;
vmCvar_t g_velocity_rl;

vmCvar_t g_nailbounce;
vmCvar_t g_nailbouncepercentage;
vmCvar_t g_nailcount;
vmCvar_t g_nailspeed;
vmCvar_t g_nailspread;
//

static cvarTable_t gameCvarTable[] = {
// don't override the cheat state set by the system
Expand Down Expand Up @@ -226,6 +268,7 @@ static cvarTable_t gameCvarTable[] = {
//
{ &g_startingAmmo_g, "g_startingAmmo_g", "-1", 0 , 0, qtrue},
{ &g_startingAmmo_mg, "g_startingAmmo_mg", "100", 0, 0, qtrue},
{ &g_startingAmmo_mg, "g_startingAmmo_mg_team", "50", 0, 0, qtrue},
{ &g_startingAmmo_sg, "g_startingAmmo_sg", "10", 0, 0, qtrue},
{ &g_startingAmmo_gl, "g_startingAmmo_gl", "10", 0, 0, qtrue},
{ &g_startingAmmo_rl, "g_startingAmmo_rl", "10", 0, 0, qtrue},
Expand All @@ -238,6 +281,46 @@ static cvarTable_t gameCvarTable[] = {
{ &g_startingAmmo_pl, "g_startingAmmo_pl", "5", 0, 0, qtrue},
{ &g_startingAmmo_cg, "g_startingAmmo_cg", "100", 0, 0, qtrue},
{ &g_startingAmmo_hmg, "g_startingAmmo_hmg", "50", 0, 0, qtrue},
//
{ &g_damage_g, "g_damage_g", "50", 0 , 0, qtrue},
{ &g_damage_mg, "g_damage_mg", "7", 0, 0, qtrue},
{ &g_damage_mg_team, "g_damage_mg_team", "5", 0, 0, qtrue},
{ &g_damage_sg, "g_damage_sg", "10", 0, 0, qtrue},
{ &g_damage_gl, "g_damage_gl", "100", 0, 0, qtrue},
{ &g_damage_rl, "g_damage_rl", "100", 0, 0, qtrue},
{ &g_damage_lg, "g_damage_lg", "8", 0, 0, qtrue},
{ &g_damage_rg, "g_damage_rg", "100", 0, 0, qtrue},
{ &g_damage_pg, "g_damage_pg", "20", 0, 0, qtrue},
{ &g_damage_bfg, "g_damage_bfg", "100", 0, 0, qtrue},
{ &g_damage_gh, "g_damage_gh", "10", 0, 0, qtrue},
{ &g_damage_ng, "g_damage_ng", "20", 0, 0, qtrue},
{ &g_damage_pl, "g_damage_pl", "0", 0, 0, qtrue},
{ &g_damage_cg, "g_damage_cg", "8", 0, 0, qtrue},
{ &g_damage_hmg, "g_damage_hmg", "7", 0, 0, qtrue},

{ &g_splashdamage_gl, "g_splashdamage_gl", "100", 0, 0, qtrue},
{ &g_splashdamage_rl, "g_splashdamage_rl", "100", 0, 0, qtrue},
{ &g_splashdamage_pg, "g_splashdamage_pg", "15", 0, 0, qtrue},
{ &g_splashdamage_bfg, "g_splashdamage_bfg", "100", 0, 0, qtrue},
{ &g_splashdamage_pl, "g_splashdamage_pl", "100", 0, 0, qtrue},

{ &g_splashradius_gl, "g_splashradius_gl", "150", 0, 0, qtrue},
{ &g_splashradius_rl, "g_splashradius_rl", "100", 0, 0, qtrue},
{ &g_splashradius_pg, "g_splashradius_pg", "20", 0, 0, qtrue},
{ &g_splashradius_bfg, "g_splashradius_bfg", "120", 0, 0, qtrue},
{ &g_splashradius_pl, "g_splashradius_pl", "150", 0, 0, qtrue},

{ &g_velocity_gl, "g_velocity_gl", "700", 0, 0, qtrue},
{ &g_velocity_rl, "g_velocity_rl", "1000", 0, 0, qtrue},
{ &g_velocity_pg, "g_velocity_pg", "2000", 0, 0, qtrue},
{ &g_velocity_bfg, "g_velocity_bfg", "1800", 0, 0, qtrue},
{ &g_velocity_gh, "g_velocity_gh", "1800", 0, 0, qtrue},

{ &g_nailbounce, "g_nailbounce", "1", 0, 0, qtrue},
{ &g_nailbouncepercentage, "g_nailbouncepercentage", "65", 0, 0, qtrue},
{ &g_nailcount, "g_nailcount", "10", 0, 0, qtrue},
{ &g_nailspeed, "g_nailspeed", "1000", 0, 0, qtrue},
{ &g_nailspread, "g_nailspeed", "400", 0, 0, qtrue},

};

Expand Down
Loading

0 comments on commit f3d4d35

Please sign in to comment.