summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2015-06-29 00:52:09 +0200
committerPaweł Redman <pawel.redman@gmail.com>2015-06-29 16:40:28 +0200
commit0918eb3bcdefd0d6ee4bd573b761454c99f032f6 (patch)
treedd1bd0bfe5348ad3b4860f11b7d3dcbb6db9ca3c /src/cgame
parent93d2e4414ee25e417ee0d2ca0248448002ea4d5b (diff)
Initial implementation of new grenades.
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_draw.c52
-rw-r--r--src/cgame/cg_event.c8
-rw-r--r--src/cgame/cg_local.h3
-rw-r--r--src/cgame/cg_main.c6
-rw-r--r--src/cgame/cg_weapons.c36
5 files changed, 87 insertions, 18 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 0ee4042..4e2ba77 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -315,7 +315,7 @@ static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color, qboolean p
ps = &cg.snap->ps;
//if the build timer pie is showing don't show this
- if( ( cent->currentState.weapon == WP_ABUILD ) && ps->stats[ STAT_MISC ] )
+ if( ( cent->currentState.weapon == WP_ABUILD ) && ps->stats[ STAT_BUILD_TIMER ] )
return;
value = ps->persistant[ PERS_CREDIT ];
@@ -454,7 +454,7 @@ static void CG_DrawPlayerClipsRing( rectDef_t *rect, vec4_t backColor,
{
playerState_t *ps = &cg.snap->ps;
centity_t *cent;
- float buildTime = ps->stats[ STAT_MISC ];
+ float buildTime = ps->stats[ STAT_BUILD_TIMER ];
float progress;
float maxDelay;
weapon_t weapon;
@@ -502,7 +502,7 @@ static void CG_DrawPlayerBuildTimerRing( rectDef_t *rect, vec4_t backColor,
{
playerState_t *ps = &cg.snap->ps;
// centity_t *cent;
- float buildTime = ps->stats[ STAT_MISC ];
+ float buildTime = ps->stats[ STAT_BUILD_TIMER ];
float progress;
vec4_t color;
@@ -764,7 +764,11 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, vec4_t color )
int valueMarked = -1;
qboolean bp = qfalse;
- switch( BG_PrimaryWeapon( cg.snap->ps.stats ) )
+ if( cg.snap->ps.weapon == WP_GRENADE )
+ {
+ value = cg.snap->ps.stats[ STAT_GRENADES ];
+ }
+ else switch( BG_PrimaryWeapon( cg.snap->ps.stats ) )
{
case WP_NONE:
case WP_BLASTER:
@@ -932,7 +936,7 @@ static void CG_DrawPlayerBuildTimer( rectDef_t *rect, vec4_t color )
ps = &cg.snap->ps;
- if( ps->stats[ STAT_MISC ] <= 0 )
+ if( ps->stats[ STAT_BUILD_TIMER ] <= 0 )
return;
switch( BG_PrimaryWeapon( ps->stats ) )
@@ -945,7 +949,7 @@ static void CG_DrawPlayerBuildTimer( rectDef_t *rect, vec4_t color )
return;
}
- index = 8 * ( ps->stats[ STAT_MISC ] - 1 ) / MAXIMUM_BUILD_TIME;
+ index = 8 * ( ps->stats[ STAT_BUILD_TIMER ] - 1 ) / MAXIMUM_BUILD_TIME;
if( index > 7 )
index = 7;
else if( index < 0 )
@@ -970,6 +974,10 @@ static void CG_DrawPlayerClipsValue( rectDef_t *rect, vec4_t color )
int value;
playerState_t *ps = &cg.snap->ps;
+ if( cg.snap->ps.weapon == WP_GRENADE )
+ {
+ return;
+ }
switch( BG_PrimaryWeapon( ps->stats ) )
{
case WP_NONE:
@@ -1106,12 +1114,16 @@ static float CG_ChargeProgress( void )
min = 0;
max = LEVEL1_WARP_TIME;
}
-
else if( cg.snap->ps.weapon == WP_LUCIFER_CANNON || cg.snap->ps.weapon == WP_FLAMER )
{
min = LCANNON_CHARGE_TIME_MIN;
max = LCANNON_CHARGE_TIME_MAX;
}
+ else if( cg.snap->ps.weapon == WP_GRENADE )
+ {
+ min = 0;
+ max = GRENADE_FUSE_TIME;
+ }
if( max - min <= 0.0f )
return 0.0f;
@@ -1186,14 +1198,17 @@ static void CG_DrawPlayerChargeBar( rectDef_t *rect, vec4_t ref_color,
color[ 3 ] = ref_color[ 3 ] * cg.chargeMeterAlpha;
// Flash red for Lucifer Cannon warning
- if( (cg.snap->ps.weapon == WP_FLAMER ) &&
-
- cg.snap->ps.stats[ STAT_MISC ] >= LCANNON_CHARGE_TIME_WARN &&
- ( cg.time & 128 ) )
- {
- color[ 0 ] = 1.0f;
- color[ 1 ] = 0.0f;
- color[ 2 ] = 0.0f;
+ if( cg.time & 128 )
+ {
+ if( ( cg.snap->ps.weapon == WP_LUCIFER_CANNON &&
+ cg.snap->ps.stats[ STAT_MISC ] >= LCANNON_CHARGE_TIME_WARN ) ||
+ ( cg.snap->ps.weapon == WP_GRENADE &&
+ cg.snap->ps.stats[ STAT_MISC ] >= GRENADE_TIME_WARN ) )
+ {
+ color[ 0 ] = 1.0f;
+ color[ 1 ] = 0.0f;
+ color[ 2 ] = 0.0f;
+ }
}
x = rect->x;
@@ -2745,7 +2760,12 @@ void CG_DrawWeaponIcon( rectDef_t *rect, vec4_t color )
return;
}
- if( ps->clips == 0 && !BG_Weapon( weapon )->infiniteAmmo )
+ if( weapon == WP_GRENADE && ps->stats[ STAT_GRENADES ] <= 0 )
+ {
+ color[ 0 ] = 1.0f;
+ color[ 1 ] = color[ 2 ] = 0.0f;
+ }
+ else if( weapon != WP_GRENADE && ps->clips == 0 && !BG_Weapon( weapon )->infiniteAmmo )
{
float ammoPercent = (float)ps->ammo / (float)maxAmmo;
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index eaf925e..b3a8396 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -1007,6 +1007,14 @@ void CG_EntityEvent( centity_t *cent, vec3_t position )
}
break;
+ case EV_GRENADE_PRIME:
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.grenadePrimeSound );
+ break;
+
+ case EV_GRENADE_TICK:
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.grenadeTickSound );
+ break;
+
//
// missile impacts
//
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 4642f64..7721e45 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1367,6 +1367,9 @@ typedef struct
qhandle_t warpParticle;
qhandle_t brightenShaders[ NUM_BRIGHTEN_SHADERS ];
+
+ sfxHandle_t grenadePrimeSound;
+ sfxHandle_t grenadeTickSound;
} cgMedia_t;
typedef struct
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 158c0b5..2761922 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -461,7 +461,8 @@ static void CG_SetUIVars( void )
BG_Upgrade( i )->purchasable )
strcat( carriageCvar, va( "U%d ", i ) );
}
- strcat( carriageCvar, "$" );
+
+ strcat( carriageCvar, va( "G%d $", cg.snap->ps.stats[ STAT_GRENADES ] ) );
trap_Cvar_Set( "ui_carriage", carriageCvar );
@@ -777,6 +778,9 @@ static void CG_RegisterSounds( void )
cgs.media.warpEnterSound = trap_S_RegisterSound( "sound/player/level1/warp1.wav", qfalse );
cgs.media.warpExitSound = trap_S_RegisterSound( "sound/player/level1/warp2.wav", qfalse );
cgs.media.warpingSound = trap_S_RegisterSound( "sound/player/level1/warping.wav", qfalse );
+
+ cgs.media.grenadePrimeSound = trap_S_RegisterSound( "sound/weapons/grenade/prime.wav", qfalse );
+ cgs.media.grenadeTickSound = trap_S_RegisterSound( "sound/weapons/grenade/tick.wav", qfalse );
}
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index 4f2ef13..7fb68c9 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1401,6 +1401,32 @@ void CG_AddViewWeapon( playerState_t *ps )
hand.origin );
}
+ // Grenade animations
+ // too tired to do this the right way...
+ if( weapon == WP_GRENADE )
+ {
+ float dx = 8.0f, dy = -5.0f, dz = -5.0f;
+
+ if( ps->stats[ STAT_GRENADES ] <= 0 )
+ {
+ return;
+ }
+
+ if( ps->stats[ STAT_MISC ] > 0 )
+ {
+ dx -= 4.0f * ps->stats[ STAT_MISC ] / 100;
+ dz += 2.0f * ps->stats[ STAT_MISC ] / 100;
+ }
+ else if( ps->weaponTime > 0 )
+ {
+ dz -= 0.015f * ps->weaponTime;
+ }
+
+ VectorMA( hand.origin, dx, cg.refdef.viewaxis[ 0 ], hand.origin );
+ VectorMA( hand.origin, dy, cg.refdef.viewaxis[ 1 ], hand.origin );
+ VectorMA( hand.origin, dz, cg.refdef.viewaxis[ 2 ], hand.origin );
+ }
+
AnglesToAxis( angles, hand.axis );
// map torso animations to weapon animations
@@ -1517,10 +1543,18 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color )
if( !BG_InventoryContainsWeapon( i, cg.snap->ps.stats ) )
continue;
- if( !ps->ammo && !ps->clips && !BG_Weapon( i )->infiniteAmmo )
+ if( i == WP_GRENADE && ps->stats[ STAT_GRENADES ] <= 0 )
+ {
+ colinfo[ numItems ] = 1;
+ }
+ else if( i != WP_GRENADE && !ps->ammo && !ps->clips && !BG_Weapon( i )->infiniteAmmo )
+ {
colinfo[ numItems ] = 1;
+ }
else
+ {
colinfo[ numItems ] = 0;
+ }
if( i == cg.weaponSelect )
selectedItem = numItems;