- Fixed BombZone detection logic for planting the C4

- Fixed counting of players during events such as escape, disconnect and team switching
- Fixed flashbang nades not tracing against players correctly
- Fixed the C4 bomb planting logic which regressed a couple engine revisions ago
This commit is contained in:
Marco Cawthorne 2018-12-05 15:05:56 +01:00
parent ebce90e265
commit cdec0d9e79
11 changed files with 93 additions and 60 deletions

View file

@ -89,18 +89,9 @@ Run whenever a client quits
*/
void ClientDisconnect( void ) {
// We were part of the session
if( self.iInGame == TRUE ) {
if ( self.team == TEAM_T ) {
if ( self.health > 0 ) {
iAlivePlayers_T--;
}
} else if ( self.team == TEAM_CT ) {
if ( self.health > 0 ) {
iAlivePlayers_CT--;
}
}
}
self.health = 0;
Rules_CountPlayers();
Rules_DeathCheck();
Effect_RemoveSpray( self );
}
@ -140,11 +131,6 @@ Funtion that can interrupt client commands before physics are run
=================
*/
void SV_RunClientCommand( void ) {
// The individual zones will just override this behavior
self.fInBombZone = FALSE;
self.fInBuyZone = FALSE;
self.fInHostageZone = FALSE;
if (clienttype(self) == CLIENTTYPE_BOT) {
((CBot)self).RunAI();
}
@ -155,8 +141,14 @@ void SV_RunClientCommand( void ) {
input_impulse = 0;
}
Input_Handle();
// The individual zones will just override this behavior
self.fInBombZone = FALSE;
self.fInBuyZone = FALSE;
self.fInHostageZone = FALSE;
QPhysics_Run( self );
Input_Handle();
}
/*

View file

@ -39,14 +39,15 @@ void func_escapezone_touch( void ) {
if ( ( other.classname == "player" ) && ( other.team == TEAM_T ) ) {
entity eOld = self;
self = other;
Spawn_MakeSpectator();
self.classname = "player";
forceinfokey( self, "*dead", "0" );
iAlivePlayers_T--;
self.health = 0;
Rules_CountPlayers();
self = eOld;
if ( iAlivePlayers_T == 0 ) {
Rules_RoundOver( TEAM_T, 2500, FALSE );
}

View file

@ -139,32 +139,15 @@ void Player_Death( int iHitBody ) {
self.health = 0;
forceinfokey( self, "*dead", "1" );
forceinfokey( self, "*team", ftos( self.team ) );
if ( self.team == TEAM_T ) {
iAlivePlayers_T--;
} else if ( self.team == TEAM_CT ) {
iAlivePlayers_CT--;
} else if ( self.team == TEAM_VIP ) {
iAlivePlayers_CT--; // For consistency
Rules_CountPlayers();
if ( self.team == TEAM_VIP ) {
Rules_RoundOver( TEAM_T, 2500, FALSE );
return;
}
if ( ( iAlivePlayers_T == 0 ) && ( iAlivePlayers_CT == 0 ) ) {
if ( iBombPlanted == TRUE ) {
Rules_RoundOver( TEAM_T, 3600, FALSE );
} else {
Rules_RoundOver( FALSE, 0, FALSE );
}
} else {
if ( ( self.team == TEAM_T ) && ( iAlivePlayers_T == 0 ) ) {
if ( iBombPlanted == FALSE ) {
Rules_RoundOver( TEAM_CT, 3600, FALSE );
}
} else if ( ( self.team == TEAM_CT ) && ( iAlivePlayers_CT == 0 ) ) {
Rules_RoundOver( TEAM_T, 3600, FALSE );
}
}
Rules_DeathCheck();
}
/*

View file

@ -275,6 +275,43 @@ void Rules_SwitchTeams( void ) {
iAlivePlayers_T = iCTW;
}
void Rules_CountPlayers(void)
{
iAlivePlayers_T = 0;
iAlivePlayers_CT = 0;
for (entity eFind = world; (eFind = find(eFind, classname, "player")); ) {
if (eFind.health > 0) {
if ( eFind.team == TEAM_T) {
iAlivePlayers_T++;
} else if (eFind.team == TEAM_CT) {
iAlivePlayers_CT++;
} else if (eFind.team == TEAM_VIP) {
iAlivePlayers_CT++;
}
}
}
}
void Rules_DeathCheck(void)
{
if ( ( iAlivePlayers_T == 0 ) && ( iAlivePlayers_CT == 0 ) ) {
if ( iBombPlanted == TRUE ) {
Rules_RoundOver( TEAM_T, 3600, FALSE );
} else {
Rules_RoundOver( FALSE, 0, FALSE );
}
} else {
if ( ( self.team == TEAM_T ) && ( iAlivePlayers_T == 0 ) ) {
if ( iBombPlanted == FALSE ) {
Rules_RoundOver( TEAM_CT, 3600, FALSE );
}
} else if ( ( self.team == TEAM_CT ) && ( iAlivePlayers_CT == 0 ) ) {
Rules_RoundOver( TEAM_T, 3600, FALSE );
}
}
}
/*
=================
SPAWN: info_map_parameters

View file

@ -136,6 +136,7 @@ void Spawn_RespawnClient( float fTeam ) {
self.classname = "player";
self.health = self.max_health = 100;
forceinfokey( self, "*dead", "0" );
Rules_CountPlayers();
self.takedamage = DAMAGE_YES;
self.solid = SOLID_SLIDEBOX;
@ -181,7 +182,7 @@ void Spawn_CreateClient( float fCharModel ) {
} else if( fCharModel < 5 ) {
forceinfokey( self, "*team", "0" );
self.team = TEAM_T;
iAlivePlayers_T++;
Rules_CountPlayers();
Weapon_AddItem( WEAPON_KNIFE );
if ( autocvar_fcs_knifeonly == FALSE ) {
@ -193,7 +194,7 @@ void Spawn_CreateClient( float fCharModel ) {
}
} else {
self.team = TEAM_CT;
iAlivePlayers_CT++;
Rules_CountPlayers();
Weapon_AddItem( WEAPON_KNIFE );
if ( autocvar_fcs_knifeonly == FALSE ) {
@ -266,11 +267,9 @@ void CSEv_GamePlayerSpawn_f( float fChar ) {
// Hey, we are alive and are trying to switch teams, so subtract us from the Alive_Team counter.
if ( self.health > 0 ) {
if ( self.team == TEAM_T ) {
iAlivePlayers_T--;
} else if ( self.team == TEAM_CT ) {
iAlivePlayers_CT--;
}
self.health = 0;
Rules_CountPlayers();
Rules_DeathCheck();
}
self.fSlotMelee = 0;
@ -314,7 +313,7 @@ void CSEv_GamePlayerSpawn_f( float fChar ) {
forceinfokey( self, "*team", ftos( self.team ) );
break;
}
self.frags = 0;
self.fDeaths = 0;
forceinfokey( self, "*deaths", "0" );

View file

@ -213,7 +213,7 @@ void WeaponC4BOMB_Draw( void ) {
void WeaponC4BOMB_Release( void ) {
#ifdef SSQC
self.fBombProgress = 0;
self.fAttackFinished = time + 1.0;
print("C4 Bomb Release\n");
#else
// TODO: This does not happen, yet
View_PlayAnimation( ANIM_C4_IDLE );
@ -223,25 +223,31 @@ void WeaponC4BOMB_Release( void ) {
void WeaponC4BOMB_PrimaryFire( void ) {
#ifdef SSQC
vector source;
source = self.origin + self.view_ofs;
makevectors( self.v_angle );
traceline( self.origin + self.view_ofs, self.origin + self.view_ofs + ( v_forward * 64 ), FALSE, self );
other = world;
traceline( source, source + ( v_forward * 64 ), MOVE_OTHERONLY, self );
// If we aren't aiming at a place or look in the wrong location... stop it
if ( trace_fraction == 1 || self.fInBombZone == FALSE ) {
Animation_ReloadWeapon( self );
WeaponC4BOMB_Release();
self.fAttackFinished = time + 1.0;
return;
}
// Play the sequence at the start
if ( self.fBombProgress == 0 ) {
self.fBombProgress = time + 3.0f;
self.fAttackFinished = self.fBombProgress;
Client_SendEvent( self, EV_WEAPON_PRIMARYATTACK );
Animation_ShootWeapon( self );
}
// 3 seconds have passed, plant the bomb
if ( self.fBombProgress <= time ) {
if ( self.fBombProgress <= time ) {
self.fBombProgress = 0;
WeaponC4BOMB_Drop( trace_endpos, trace_plane_normal );
}
#else

View file

@ -106,7 +106,8 @@ void WeaponFLASHBANG_Throw( void ) {
float fDot;
for ( entity eFind = world; ( eFind = find( eFind, classname, "player" ) ); ) {
traceline( self.origin + '0 0 32', eFind.origin, FALSE, self );
other = world;
traceline( self.origin + '0 0 32', eFind.origin, MOVE_OTHERONLY, self );
if ( trace_fraction == 1 ) {
makevectors ( eFind.angles );
vNorm = normalize ( self.origin - eFind.origin );

View file

@ -133,8 +133,9 @@ void Weapon_PrimaryAttack( float fWeapon ) {
if ( self.fAttackFinished > time ) {
return;
}
if ( !( self.flags & FL_SEMI_TOGGLED ) )
if ( !( self.flags & FL_SEMI_TOGGLED ) ) {
return;
}
#endif
#ifdef CSQC
if ( fWeaponEventPlayer != player_localentnum || autocvar_cl_thirdperson == TRUE ) {
@ -253,6 +254,8 @@ void Weapon_Release( void ) {
WeaponHEGRENADE_Release();
} else if ( self.weapon == WEAPON_SMOKEGRENADE ) {
WeaponSMOKEGRENADE_Release();
} else if ( self.weapon == WEAPON_C4BOMB ) {
WeaponC4BOMB_Release();
}
}
@ -556,6 +559,17 @@ void CSEv_PlayerSwitchWeapon_f( float fWeapon ) {
if ( ( Weapon_AlreadyExists( fWeapon ) == FALSE ) && ( fWeapon != WEAPON_KNIFE ) ) {
return;
}
if (wptTable[fWeapon].iSlot == SLOT_GRENADE) {
if (fWeapon == WEAPON_HEGRENADE && !(self.iAmmo_HEGRENADE)) {
return;
} else if (fWeapon == WEAPON_FLASHBANG && !(self.iAmmo_FLASHBANG)) {
return;
} else if (fWeapon == WEAPON_SMOKEGRENADE && !(self.iAmmo_SMOKEGRENADE)) {
return;
} else if (fWeapon == WEAPON_C4BOMB && !(self.fSlotGrenade & WEAPON_C4BOMB)) {
return;
}
}
if ( fWeapon != self.weapon ) {
Weapon_Draw( fWeapon );
}

Binary file not shown.

Binary file not shown.

Binary file not shown.