Permalink
Browse files

Minor adjustments to Dragoon barb regeneration.

  • Loading branch information...
Viech committed Nov 19, 2015
1 parent 3837d11 commit 4f2f716f65a12fd38a7b2f24d99d36a2c6563d6b
Showing with 33 additions and 35 deletions.
  1. +1 −1 main/configs/weapon/level3upg.attr.cfg
  2. +7 −13 src/cgame/cg_rocket_draw.cpp
  3. +25 −21 src/sgame/sg_active.cpp
@@ -25,6 +25,6 @@ pounceJumpMagnitude 850
ballDmg 110
ballSpeed 1000.0
ballRadius 75
ballRegen 12500
ballRegen 12000
ballRegenCreep 8000
ballRegenBooster 4000
@@ -2220,8 +2220,7 @@ class BarbsHudElement : public HudElement
if ( newNumBarbs > numBarbs || ( newNumBarbs < numBarbs && numBarbs == maxBarbs ) )
{
t0 = cg.time;
// sin(-pi/2) is minimal
offset = -M_PI_2;
offset = -M_PI_2; // sin(-pi/2) is minimal
}
// change regeneration speed
else if ( interval != regenerationInterval )
@@ -2240,9 +2239,6 @@ class BarbsHudElement : public HudElement
offset = M_PI - asin( sinOld );
}
regenerationInterval = interval;

assert( fabs(GetSin() - sinOld ) < 0.001);
assert( GetCos() * cosOld > 0 );
}
}
numBarbs = newNumBarbs;
@@ -2253,15 +2249,13 @@ class BarbsHudElement : public HudElement
if (i < numBarbs ) // draw existing barbs
{
barb->SetProperty( "opacity", "1.0" );
barb->SetProperty( "color", "white" );
}
else if (i == numBarbs ) // draw regenerating barb
{
float opacity = GetSin() / 3 + 0.5;
float opacity = GetSin() / 8.0f + ( 1.0f / 8.0f ); // in [0, 0.125]
barb->SetProperty( "opacity", va( "%f", opacity ) );
barb->SetProperty( "color", "grey" );
}
else // hide remaining (nonexistent) barbs
else
{
barb->SetProperty( "opacity", "0.0" );
}
@@ -2282,10 +2276,10 @@ class BarbsHudElement : public HudElement

float GetParam()
{
float t = (cg.time - t0) / 1000.0;
// frequency in Hz; Interval is in ms
float f = 4 * 1000.0 / regenerationInterval;
return offset + t * 2 * M_PI * f;
float timeElapsed = ( cg.time - t0 ) / 1000.0f; // in s
float frequency = (float)LEVEL3_BOUNCEBALL_REGEN_CREEP
/ (float)regenerationInterval; // in Hz
return offset + 2.0f * M_PI * frequency * timeElapsed;
}

int numBarbs;
@@ -1043,27 +1043,6 @@ void ClientTimerActions( gentity_t *ent, int msec )
G_AddCreditsToScore( ent, HUMAN_BUILDER_SCOREINC );
}
}

// Regenerate Adv. Dragoon barbs
if ( client->ps.weapon == WP_ALEVEL3_UPG )
{
if ( client->ps.ammo < BG_Weapon( WP_ALEVEL3_UPG )->maxAmmo )
{
float interval = BG_GetBarbRegenerationInterval(ent->client->ps);
ent->barbRegeneration += ( level.time - ent->timestamp ) / interval;
if ( ent->barbRegeneration >= 1 )
{
ent->barbRegeneration -= 1;
client->ps.ammo++;
}
ent->timestamp = level.time;
}
else
{
ent->barbRegeneration = 0;
ent->timestamp = level.time;
}
}
}

/*
@@ -1744,6 +1723,29 @@ static void G_ReplenishAlienHealth( gentity_t *self )
}
}

static void G_ReplenishDragoonBarbs( gentity_t *self, int msec )
{
gclient_t *client = self->client;

if ( client->ps.weapon == WP_ALEVEL3_UPG )
{
if ( client->ps.ammo < BG_Weapon( WP_ALEVEL3_UPG )->maxAmmo )
{
float interval = BG_GetBarbRegenerationInterval(self->client->ps);
self->barbRegeneration += (float)msec / interval;
if ( self->barbRegeneration >= 1.0f )
{
self->barbRegeneration -= 1.0f;
client->ps.ammo++;
}
}
else
{
self->barbRegeneration = 0.0f;
}
}
}

/*
==============
ClientThink_real
@@ -1954,6 +1956,8 @@ void ClientThink_real( gentity_t *self )
// Replenish alien health
G_ReplenishAlienHealth( self );

G_ReplenishDragoonBarbs( self, msec );

// Throw human grenade
if ( BG_InventoryContainsUpgrade( UP_GRENADE, client->ps.stats ) &&
BG_UpgradeIsActive( UP_GRENADE, client->ps.stats ) )

0 comments on commit 4f2f716

Please sign in to comment.