Fix !hide provide "mitigation" to noclip ghost bug

This commit is contained in:
Ryan Amos 2022-05-22 20:45:47 +01:00 committed by RaidMax
parent 1700b7da91
commit 83a469cae3

View File

@ -772,7 +772,9 @@ NoClipImpl()
if ( !IsAlive( self ) ) if ( !IsAlive( self ) )
{ {
self IPrintLnBold( "You are not alive" ); self IPrintLnBold( "You are not alive" );
return; // Due to bug when sometimes disabling noclip game thinks you're dead
// removing the return and allowing them to go back into noclip is probably better.
//return;
} }
self SetClientDvar( "sv_cheats", 1 ); self SetClientDvar( "sv_cheats", 1 );
@ -783,14 +785,16 @@ NoClipImpl()
self call [[level.overrideMethods["noclip"]]]( true ); self call [[level.overrideMethods["noclip"]]]( true );
self Hide(); self Hide();
self.isNoClipped = true;
self IPrintLnBold( "NoClip enabled" ); self IPrintLnBold( "NoClip enabled" );
} }
NoClipOffImpl() NoClipOffImpl()
{ {
if ( !IsAlive( self ) ) if ( !IsDefined( self.isNoClipped ) || !self.isNoClipped )
{ {
self IPrintLnBold( "You are not alive" ); self IPrintLnBold( "You are not no-clipped" );
return; return;
} }
@ -803,6 +807,16 @@ NoClipOffImpl()
self Show(); self Show();
self IPrintLnBold( "NoClip disabled" ); self IPrintLnBold( "NoClip disabled" );
if ( !IsAlive( self ) && self.isNoClipped )
{
// Sometimes you will bug exiting noclip where the game thinks you're dead
// but you're not. You will retain godmode but be able to run around and kill people.
// So, it's important to let the user know.
self IPrintLnBold( "^1You are bugged! ^4Swap team." );
}
self.isNoClipped = false;
} }
HideImpl() HideImpl()
@ -817,7 +831,7 @@ HideImpl()
self SetClientDvar( "cg_thirdperson", 1 ); self SetClientDvar( "cg_thirdperson", 1 );
self SetClientDvar( "sv_cheats", 0 ); self SetClientDvar( "sv_cheats", 0 );
if ( !IsDefined( self.savedHealth ) || self.health < 1000 ) if ( !IsDefined( self.savedHealth ) || self.health < 1000 )
{ {
self.savedHealth = self.health; self.savedHealth = self.health;
self.savedMaxHealth = self.maxhealth; self.savedMaxHealth = self.maxhealth;
@ -826,6 +840,8 @@ HideImpl()
self call [[level.overrideMethods["god"]]]( true ); self call [[level.overrideMethods["god"]]]( true );
self Hide(); self Hide();
self.isHidden = true;
self IPrintLnBold( "You are now ^5hidden ^7from other players" ); self IPrintLnBold( "You are now ^5hidden ^7from other players" );
} }
@ -850,6 +866,8 @@ UnhideImpl()
self call [[level.overrideMethods["god"]]]( false ); self call [[level.overrideMethods["god"]]]( false );
self Show(); self Show();
self.isHidden = false;
self IPrintLnBold( "You are now ^5visible ^7to other players" ); self IPrintLnBold( "You are now ^5visible ^7to other players" );
} }