diff options
Diffstat (limited to 'src/game/g_active.c')
-rw-r--r-- | src/game/g_active.c | 201 |
1 files changed, 171 insertions, 30 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index 57f58fe..2c18f00 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -428,7 +428,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) if( ( client->pers.teamSelection == PTE_ALIENS && G_SearchSpawnQueue( &level.alienSpawnQueue, ent-g_entities ) ) || ( client->pers.teamSelection == PTE_HUMANS && - G_SearchSpawnQueue( &level.humanSpawnQueue, ent-g_entities ) ) ) + G_SearchSpawnQueue( &level.alienSpawnQueue, ent-g_entities ) ) ) { client->ps.pm_flags |= PMF_QUEUED; } @@ -521,8 +521,12 @@ ClientInactivityTimer Returns qfalse if the client is dropped ================= */ -qboolean ClientInactivityTimer( gclient_t *client ) +qboolean ClientInactivityTimer( gentity_t *ent ) { + gclient_t *client; + + client = ent->client; + if( ! g_inactivity.integer ) { // give everyone some time, so if the operator sets g_inactivity during @@ -542,6 +546,22 @@ qboolean ClientInactivityTimer( gclient_t *client ) { if( level.time > client->inactivityTime ) { + if( g_inactivityMode.integer == 1 ) + { + char buf[ MAX_STRING_CHARS ]; + + Com_sprintf( buf, sizeof( buf ), + "%s^7 moved from %s to spectators due to inactivity\n", + client->pers.netname, + ( client->pers.teamSelection == PTE_ALIENS ) ? "aliens" : "humans" ); + trap_SendServerCommand( -1, va( "print \"%s\"", buf ) ); + G_LogOnlyPrintf( "Inactivity: %s", buf ); + + G_ChangeTeam( ent, PTE_NONE ); + client->inactivityTime = level.time + g_inactivity.integer * 1000; + client->inactivityWarning = qfalse; + return qtrue; + } trap_DropClient( client - level.clients, "Dropped due to inactivity" ); return qfalse; } @@ -549,13 +569,77 @@ qboolean ClientInactivityTimer( gclient_t *client ) if( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) { client->inactivityWarning = qtrue; - trap_SendServerCommand( client - level.clients, "cp \"Ten seconds until inactivity drop!\n\"" ); + if( g_inactivityMode.integer == 1 ) + trap_SendServerCommand( client - level.clients, "cp \"Ten seconds until inactivity spectate!\n\"" ); + else + trap_SendServerCommand( client - level.clients, "cp \"Ten seconds until inactivity drop!\n\"" ); } } return qtrue; } +static void ClientSpreeDecay( gentity_t *ent, int msec ) +{ + gclient_t *client; + + client = ent->client; + client->pers.spreeTime1000 += msec; + + while( client->pers.spreeTime1000 >= 1000 ) + { + client->pers.spreeTime1000 -= 1000; + + // spree decay + if( ent->client->pers.statscounters.spreefeeds ) + { + ent->client->pers.statscounters.spreefeeds -= SPREE_FEED_FADE; + if( ent->client->pers.statscounters.spreefeeds < 0 ) + ent->client->pers.statscounters.spreefeeds = 0; + } + if( ent->client->pers.statscounters.spreekills > 1 ) + { + ent->client->pers.statscounters.spreekills -= 2; + } + if( ent->client->pers.statscounters.spreebleeds || + ent->client->pers.bleeder ) + { + if( ent->client->pers.bleeder ) + ent->client->pers.statscounters.spreebleeds -= 10; + else + ent->client->pers.statscounters.spreebleeds -= 4; + if( ent->client->pers.statscounters.spreebleeds < 0 ) + ent->client->pers.statscounters.spreebleeds = 0; + if( ent->client->pers.bleeder ) + { + if( !ent->client->pers.statscounters.spreebleeds ) + { + ent->client->pers.bleeder = qfalse; + trap_SendServerCommand( -1, + va( "print \"%s^7 has been ^2forgiven ^7by their base\n\"", ent->client->pers.netname ) ); + if( client->sess.sessionTeam != TEAM_SPECTATOR || + client->sess.spectatorState != SPECTATOR_SCOREBOARD ) + trap_SendServerCommand( ent-g_entities, "cp \"^2Your base has forgiven you\"" ); + if( level.bleeders ) + level.bleeders--; + } + else if( client->sess.sessionTeam != TEAM_SPECTATOR && + ent->client->ps.stats[ STAT_HEALTH ] <= 0 ) + { + int spreeLength; + + spreeLength = ent->client->pers.statscounters.spreebleeds / 10; + trap_SendServerCommand( ent-g_entities, + va( "cp \"^3Bleeding made you an enemy of your own base!\n\n^7for %d:%02d\n\n^1Respawn delayed %d seconds\"", + spreeLength / 60, spreeLength % 60, + ( ent->client->respawnTime - level.time) / 1000 ) ); + } + } + } + + } +} + /* ================== ClientTimerActions @@ -568,9 +652,9 @@ void ClientTimerActions( gentity_t *ent, int msec ) gclient_t *client; usercmd_t *ucmd; int aForward, aRight; - qboolean walking = qfalse, stopped = qfalse, - crouched = qfalse, jumping = qfalse, - strafing = qfalse; + int staminaLarmour = STAMINA_LARMOUR_TAKE; + int staminaSprint = STAMINA_SPRINT_TAKE; + int timestep10000; ucmd = &ent->client->pers.cmd; @@ -582,43 +666,38 @@ void ClientTimerActions( gentity_t *ent, int msec ) client->time1000 += msec; client->time10000 += msec; - if( aForward == 0 && aRight == 0 ) - stopped = qtrue; - else if( aForward <= 64 && aRight <= 64 ) - walking = qtrue; - - if( aRight > 0 ) - strafing = qtrue; - - if( ucmd->upmove > 0 ) - jumping = qtrue; - else if( ent->client->ps.pm_flags & PMF_DUCKED ) - crouched = qtrue; + if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && + g_modHumanStamina.integer > 0 ) + { + staminaLarmour = staminaLarmour * 100 / g_modHumanStamina.integer; + staminaSprint = staminaSprint * 100 / g_modHumanStamina.integer; + } while ( client->time100 >= 100 ) { client->time100 -= 100; //if not trying to run then not trying to sprint - if( walking || stopped ) + if( aForward <= 64 ) client->ps.stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; if( BG_InventoryContainsUpgrade( UP_JETPACK, client->ps.stats ) && BG_UpgradeIsActive( UP_JETPACK, client->ps.stats ) ) client->ps.stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; - if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && !crouched ) + if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && + !( client->ps.stats[ STAT_STATE ] & PMF_DUCKED ) ) { //subtract stamina if( BG_InventoryContainsUpgrade( UP_LIGHTARMOUR, client->ps.stats ) ) - client->ps.stats[ STAT_STAMINA ] -= STAMINA_LARMOUR_TAKE; + client->ps.stats[ STAT_STAMINA ] -= staminaLarmour; else - client->ps.stats[ STAT_STAMINA ] -= STAMINA_SPRINT_TAKE; + client->ps.stats[ STAT_STAMINA ] -= staminaSprint; if( client->ps.stats[ STAT_STAMINA ] < -MAX_STAMINA ) client->ps.stats[ STAT_STAMINA ] = -MAX_STAMINA; } - if( walking || crouched ) + if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) ) { //restore stamina client->ps.stats[ STAT_STAMINA ] += STAMINA_WALK_RESTORE; @@ -626,7 +705,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( client->ps.stats[ STAT_STAMINA ] > MAX_STAMINA ) client->ps.stats[ STAT_STAMINA ] = MAX_STAMINA; } - else if( stopped ) + else if( aForward <= 5 && aRight <= 5 ) { //restore stamina faster client->ps.stats[ STAT_STAMINA ] += STAMINA_STOP_RESTORE; @@ -769,6 +848,13 @@ void ClientTimerActions( gentity_t *ent, int msec ) { int remainingStartupTime = MEDKIT_STARTUP_TIME - ( level.time - client->lastMedKitTime ); + if( level.vampireDeath ) + { + ent->client->medKitHealthToRestore = 0; + trap_SendServerCommand( ent-g_entities, + "print \"Medkit is disabled during Vampire Sudden Death\n\"" ); + } + if( remainingStartupTime < 0 ) { if( ent->health < ent->client->ps.stats[ STAT_MAX_HEALTH ] && @@ -830,7 +916,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) //replenish alien health if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS && - level.surrenderTeam != PTE_ALIENS ) + level.surrenderTeam != PTE_ALIENS && !level.vampireDeath ) { int entityList[ MAX_GENTITIES ]; vec3_t range = { LEVEL4_REGEN_RANGE, LEVEL4_REGEN_RANGE, LEVEL4_REGEN_RANGE }; @@ -866,7 +952,32 @@ void ClientTimerActions( gentity_t *ent, int msec ) !level.paused && ( ent->lastDamageTime + ALIEN_REGEN_DAMAGE_TIME ) < level.time ) { - ent->health += BG_FindRegenRateForClass( client->ps.stats[ STAT_PCLASS ] ) * modifier; + float dist_mod = 1.0f; + float hadd; + + if( g_modAlienRegenRange.integer ) + { + float om; + + om = G_BuildableRangeClosest( client->ps.origin, CREEP_BASESIZE * 2, BA_A_OVERMIND ); + if( om > 0.0 ) + { + dist_mod = ( ( CREEP_BASESIZE * 2 ) - om ) / ( CREEP_BASESIZE * 2 ) + 0.25; + if( dist_mod < 0.25 ) + dist_mod = 0.25; + if( dist_mod > 1.0 ) + dist_mod = 1.0; + } + else + { + dist_mod = 0.10f; + } + } + + hadd = (float)(BG_FindRegenRateForClass( client->ps.stats[ STAT_PCLASS ] ) * modifier * dist_mod); + if( hadd < 1.0 && hadd >= 0.5 ) + hadd = 1.0; + ent->health += hadd; // if completely healed, cancel retribution if( ent->health >= client->ps.stats[ STAT_MAX_HEALTH ] ) @@ -884,10 +995,12 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( ent->client->ps.stats[ STAT_HEALTH ] > 0 && ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { ent->client->pers.statscounters.timealive++; + ent->client->pers.karma += 1; level.alienStatsCounters.timealive++; if( G_BuildableRange( ent->client->ps.origin, 900, BA_A_OVERMIND ) ) { ent->client->pers.statscounters.timeinbase++; + ent->client->pers.karma -= 1; level.alienStatsCounters.timeinbase++; } if( BG_ClassHasAbility( ent->client->ps.stats[ STAT_PCLASS ], SCA_WALLCLIMBER ) ) @@ -904,10 +1017,12 @@ void ClientTimerActions( gentity_t *ent, int msec ) else if( ent->client->ps.stats[ STAT_HEALTH ] > 0 && ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { ent->client->pers.statscounters.timealive++; + ent->client->pers.karma += 1; level.humanStatsCounters.timealive++; if( G_BuildableRange( ent->client->ps.origin, 900, BA_H_REACTOR ) ) { ent->client->pers.statscounters.timeinbase++; + ent->client->pers.karma -= 1; level.humanStatsCounters.timeinbase++; } if( BG_InventoryContainsUpgrade( UP_JETPACK, client->ps.stats ) ) @@ -943,7 +1058,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) BG_DeactivateUpgrade( UP_JETPACK, client->ps.stats ); } else if( client->jetpackfuel < 10.0f && client->jetpackfuel > 0.0f) { client->jetpackfuel = client->jetpackfuel - mod_jetpackConsume.value; - trap_SendServerCommand( client - level.clients, "cp \"^3Fuel ^1Low!!!!!^7\nLand now.\"" ); + trap_SendServerCommand( client - level.clients, "cp \"^3Fuel ^1Low!^7\nLand now.\"" ); } else { client->jetpackfuel = client->jetpackfuel - mod_jetpackConsume.value; } @@ -961,9 +1076,23 @@ void ClientTimerActions( gentity_t *ent, int msec ) } } - while( client->time10000 >= 10000 ) + timestep10000 = 10000; + if( g_modAlienRate.integer > 0 ) + { + timestep10000 = timestep10000 * 100 / g_modAlienRate.integer; + if( timestep10000 < 1000 ) + timestep10000 = 1000; + } + if( g_modBuildableHealth.integer > 0 ) + { + timestep10000 = timestep10000 * 100 / g_modBuildableHealth.integer; + if( timestep10000 < 1000 ) + timestep10000 = 1000; + } + + while( client->time10000 >= timestep10000 ) { - client->time10000 -= 10000; + client->time10000 -= timestep10000; if( client->ps.weapon == WP_ALEVEL3_UPG ) { @@ -1500,6 +1629,9 @@ void ClientThink_real( gentity_t *ent ) return; } + //spree decay + ClientSpreeDecay( ent, msec ); + if( client->pers.teamSelection != PTE_NONE && client->pers.joinedATeam ) G_UpdatePTRConnection( client ); @@ -1514,7 +1646,7 @@ void ClientThink_real( gentity_t *ent ) } // check for inactivity timer, but never drop the local client of a non-dedicated server - if( !ClientInactivityTimer( client ) ) + if( !ClientInactivityTimer( ent ) ) return; // calculate where ent is currently seeing all the other active clients @@ -1567,6 +1699,15 @@ void ClientThink_real( gentity_t *ent ) client->ps.gravity = g_gravity.value; + if( client->pers.bubbleTime && client->pers.bubbleTime < level.time ) + { + gentity_t *bubble; + + client->pers.bubbleTime = level.time + 500; + bubble = G_TempEntity( client->ps.origin, EV_PLAYER_TELEPORT_OUT ); + bubble->s.clientNum = ent->s.clientNum; + } + if( BG_InventoryContainsUpgrade( UP_MEDKIT, client->ps.stats ) && BG_UpgradeIsActive( UP_MEDKIT, client->ps.stats ) ) { |