Skip to content

Commit

Permalink
case normalization, jetpack stuff
Browse files Browse the repository at this point in the history
git-svn-id: svn://forre.st/ubp@1018 470744a7-cac9-478e-843e-5ec1b25c69e8
  • Loading branch information
forrest authored and forrestv committed Dec 19, 2011
1 parent a65492d commit 535018a
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 10 deletions.
46 changes: 36 additions & 10 deletions src/game/g_active.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,21 @@ void ClientTimerActions( gentity_t *ent, int msec )
else if( ent->client->ps.pm_flags & PMF_DUCKED )
crouched = qtrue;

if( BG_InventoryContainsUpgrade( UP_JETPACK, client->ps.stats ) && BG_UpgradeIsActive( UP_JETPACK, client->ps.stats ) ) {
if( !client->jetpackWasActive ) {
client->jetpackWasActive = qtrue;
if( jumping ) {
if( client->jetpackfuel >= 20 ) {
vec3_t dir = {0, 0, 1};
G_Knockback( ent, dir, 500. );
client->jetpackfuel -= 20;
}
}
}
} else {
client->jetpackWasActive = qfalse;
}

while ( client->time100 >= 100 )
{
client->time100 -= 100;
Expand Down Expand Up @@ -938,25 +953,36 @@ void ClientTimerActions( gentity_t *ent, int msec )
}

//my new jetpack code
if( g_fueledjetpack.integer == 1 ) {
if( g_fueledjetpack.integer ) {
//if we have jetpack and its on
if( BG_InventoryContainsUpgrade( UP_JETPACK, client->ps.stats ) && BG_UpgradeIsActive( UP_JETPACK, client->ps.stats ) ) {
//check if fuels 0 if so deactivate it if not give a 10 second fuel low warning and take JETPACK_USE_RATE from fuel
if( client->jetpackfuel <= 0.0f ) {
BG_DeactivateUpgrade( UP_JETPACK, client->ps.stats );
} else if( client->jetpackfuel < 10.0f && client->jetpackfuel > 0.0f) {
client->jetpackfuel = client->jetpackfuel - JETPACK_USE_RATE;
trap_SendServerCommand( client - level.clients, "cp \"^3Fuel ^1Low!!!!!^7\nLand now.\"" );
//} else if( client->jetpackfuel < 10.0f && client->jetpackfuel > 0.0f) {
// client->jetpackfuel = client->jetpackfuel - JETPACK_USE_RATE;
// trap_SendServerCommand( client - level.clients, "cp \"^3Fuel ^1Low!!!!!^7\nLand now.\"" );
} else {
client->jetpackfuel = client->jetpackfuel - JETPACK_USE_RATE;
if(client->jetpackfuel <= 0) client->jetpackfuel = 0;
}
//if jetpack isnt active regenerate fuel and give a message when its full
trap_SendServerCommand( client - level.clients, va( "cp \" ^3Fuel: %s%d%%\"",
( client->jetpackfuel*100/JETPACK_MAX_FUEL > 20 ? "^2" : "^1" ),
(int)(client->jetpackfuel*100/JETPACK_MAX_FUEL)
) );
} else if( BG_InventoryContainsUpgrade( UP_JETPACK, client->ps.stats ) && !BG_UpgradeIsActive( UP_JETPACK, client->ps.stats ) ) {
if( client->jetpackfuel > ( JETPACK_MAX_FUEL - 10.0f ) && client->jetpackfuel <= JETPACK_MAX_FUEL ) {
client->jetpackfuel = client->jetpackfuel + JETPACK_REGEN_RATE;
trap_SendServerCommand( client - level.clients, "cp \"^3Fuel Status:^2Full!!!!!^7\n\"" );
} else if( client->jetpackfuel < JETPACK_MAX_FUEL )
//if( client->jetpackfuel > ( JETPACK_MAX_FUEL - 10.0f ) && client->jetpackfuel <= JETPACK_MAX_FUEL ) {
// client->jetpackfuel = client->jetpackfuel + JETPACK_REGEN_RATE;
// trap_SendServerCommand( client - level.clients, "cp \"^3Fuel Status:^2Full!!!!!^7\n\"" );
//} else
if( client->jetpackfuel < JETPACK_MAX_FUEL )
client->jetpackfuel = client->jetpackfuel + JETPACK_REGEN_RATE;
if(client->jetpackfuel >= JETPACK_MAX_FUEL) client->jetpackfuel = JETPACK_MAX_FUEL;
trap_SendServerCommand( client - level.clients, va( "cp \" ^3Fuel: %s%d%%\"",
( client->jetpackfuel*100/JETPACK_MAX_FUEL > 20 ? "^2" : "^1" ),
(int)(client->jetpackfuel*100/JETPACK_MAX_FUEL)
) );
}
}
}
Expand Down Expand Up @@ -1635,8 +1661,8 @@ void ClientThink_real( gentity_t *ent )
}

//switch jetpack off if no reactor
if( !level.reactorPresent )
BG_DeactivateUpgrade( UP_JETPACK, client->ps.stats );
//if( !level.reactorPresent )
// BG_DeactivateUpgrade( UP_JETPACK, client->ps.stats );
}

// set up for pmove
Expand Down
39 changes: 39 additions & 0 deletions src/game/g_buildable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2069,6 +2069,44 @@ void HArmoury_Think( gentity_t *self )
}


void HArmoury_Touch( gentity_t *self, gentity_t *other, trace_t *trace )
{
gclient_t *client = other->client;
int i;
int maxAmmo, maxClips;

if( !self->spawned || self->health <= 0 )
return;

if( !self->powered )
return;

if( !client )
return;

client->jetpackfuel = JETPACK_MAX_FUEL;

for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
{
if( BG_InventoryContainsWeapon( i, other->client->ps.stats ) &&
!BG_FindInfinteAmmoForWeapon( i ) &&
!BG_WeaponIsFull( i, client->ps.stats,
client->ps.ammo, client->ps.powerups ) )
{
BG_FindAmmoForWeapon( i, &maxAmmo, &maxClips );

if( BG_FindUsesEnergyForWeapon( i ) )
{
if( BG_InventoryContainsUpgrade( UP_BATTPACK, client->ps.stats ) )
maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
}

BG_PackAmmoArray( i, client->ps.ammo, client->ps.powerups,
maxAmmo, maxClips );
}
}

}


//==================================================================================
Expand Down Expand Up @@ -3773,6 +3811,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
built->think = HArmoury_Think;
built->die = HSpawn_Die;
built->use = HArmoury_Activate;
built->touch = HArmoury_Touch;
break;

case BA_H_DCC:
Expand Down
15 changes: 15 additions & 0 deletions src/game/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,24 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
// don't let text be too long for malicious reasons
char text[ MAX_SAY_TEXT ];
char location[ 64 ];
int upper = 0, lower = 0, pos;

// Bail if the text is blank.
if( ! chatText[0] )
return;

for(pos = 0; chatText[pos]; pos++) {
if(chatText[pos] >= 'A' && chatText[pos] <= 'Z') upper++;
else if(chatText[pos] >= 'a' && chatText[pos] <= 'z') lower++;
}

if(upper > lower) {
for(pos = 0; chatText[pos]; pos++) {
if(chatText[pos] >= 'A' && chatText[pos] <= 'Z') chatText[pos] += 'a' - 'A';
else if(chatText[pos] >= 'a' && chatText[pos] <= 'z') chatText[pos] += 'A' - 'a';
}
}

// Flood limit. If they're talking too fast, determine that and return.
if( g_floodMinTime.integer )
if ( G_Flood_Limited( ent ) )
Expand Down Expand Up @@ -3379,6 +3392,8 @@ if( !ent->client->pers.override ) {
G_GiveClientMaxAmmo( ent, buyingEnergyAmmo );
else
{
if( upgrade == UP_JETPACK )
ent->client->jetpackfuel = JETPACK_MAX_FUEL;
//add to inventory
BG_AddUpgradeToInventory( upgrade, ent->client->ps.stats );
}
Expand Down
1 change: 1 addition & 0 deletions src/game/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ struct gclient_s
qboolean charging;

float jetpackfuel;
qboolean jetpackWasActive;

vec3_t hovelOrigin; // player origin before entering hovel

Expand Down

0 comments on commit 535018a

Please sign in to comment.