2001-07-23 20:52:47 +00:00
# include "defs.qh"
2001-07-17 05:58:10 +00:00
//some of this by Cyto 3-27-00
//other by CH
//Used for testing tolerence, prints out various stuff
//#define SHOW_CHEAT_LEVELS
//If defined any cheat cmd results in kicking
//#define ENABLE_CHEAT_CMDS
void ( ) Kick_My_Owner =
{
local string ip ;
local string oldname , nospeed ;
local float banned , off ;
2001-07-23 20:52:47 +00:00
banned = FALSE ;
2001-07-17 05:58:10 +00:00
//Don't kick if cheats are off
2001-07-23 20:52:47 +00:00
off = FALSE ;
2012-07-06 02:29:18 +00:00
nospeed = infokey ( nil , " nospeed " ) ;
2001-09-30 22:38:44 +00:00
if ( nospeed ) {
2001-07-17 05:58:10 +00:00
off = stof ( nospeed ) ;
}
if ( off ) return ;
oldname = self . owner . netname ;
2001-07-23 20:52:47 +00:00
sprint ( self . owner , PRINT_HIGH , " \n You have been <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> for <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> . \n If you were not cheating, I apologize. \n Have a nice day. \n " ) ;
2001-07-17 05:58:10 +00:00
ip = infokey ( self . owner , " ip " ) ;
2012-07-06 02:29:18 +00:00
if ( infokey ( nil , " infip " ) = = ip ) { // second infraction. ban.
2001-07-17 05:58:10 +00:00
localcmd ( " addip " ) ;
localcmd ( ip ) ;
localcmd ( " \n " ) ;
localcmd ( " localinfo infip \" \" " ) ;
2001-07-23 20:52:47 +00:00
banned = TRUE ;
2001-07-17 05:58:10 +00:00
} else {
localcmd ( " localinfo infip " ) ;
localcmd ( ip ) ;
localcmd ( " \n " ) ;
}
stuffcmd ( self . owner , " disconnect \n " ) ;
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , oldname ) ;
2001-07-17 05:58:10 +00:00
if ( banned )
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " was BANNED for cheating! \n " ) ;
2001-07-17 05:58:10 +00:00
else
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " was kicked for cheating. \n " ) ;
2001-07-17 05:58:10 +00:00
2001-11-10 06:35:43 +00:00
self . think = dont_think ;
2001-07-17 05:58:10 +00:00
dremove ( self ) ;
} ;
# define MAXPERCENT 35 //WK this looks good for wall strafing
//reasons for not checking
# define IMMUNE 1
# define GRAPPLE 2
# define FLYING 4
# define NOCLASS 16
# define BUILDING 32
# define DEAD 64
void ( ) TeamFortress_CheckForSpeed =
{
2001-10-18 13:30:35 +00:00
#if 0
2001-07-17 05:58:10 +00:00
local vector tempvec ;
2001-10-18 13:30:35 +00:00
local float dist ;
# endif
2001-10-18 20:10:39 +00:00
local float max , check , immune = 0 ;
2001-07-17 05:58:10 +00:00
local string nospeed ;
local float off ;
2001-07-23 20:52:47 +00:00
off = FALSE ;
2012-07-06 02:29:18 +00:00
nospeed = infokey ( nil , " nospeed " ) ;
2001-09-30 22:38:44 +00:00
if ( nospeed ) {
2001-07-17 05:58:10 +00:00
off = stof ( nospeed ) ;
}
if ( off ) return ;
2001-10-18 13:30:35 +00:00
max = self . owner . maxspeed ;
if ( ( self . owner . job & JOB_RUNNER ) & & ( self . owner . job & JOB_ACTIVE ) )
max = max + 200 ;
//make sure ok to check
if ( self . owner . immune_to_chec > time )
2004-04-12 05:37:50 +00:00
immune | = IMMUNE ; //its ok since IMMUNE becomes 1
2001-10-18 13:30:35 +00:00
if ( self . owner . hook_out )
2004-04-12 05:37:50 +00:00
immune | = GRAPPLE ;
2001-10-18 13:30:35 +00:00
//WK We should boot if they have no set speed and are moving
//if (self.owner.maxspeed == 0) // no set speed
if ( ! ( self . owner . flags & FL_ONGROUND ) ) //WK People in air immune
2004-04-12 05:37:50 +00:00
immune | = FLYING ;
2001-10-18 13:30:35 +00:00
if ( self . owner . playerclass = = PC_UNDEFINED )
2004-04-12 05:37:50 +00:00
immune | = NOCLASS ;
2001-10-18 13:30:35 +00:00
if ( self . owner . done_custom & CUSTOM_BUILDING )
2004-04-12 05:37:50 +00:00
immune | = BUILDING ;
2001-10-18 13:30:35 +00:00
if ( self . owner . health < = 0 )
2004-04-12 05:37:50 +00:00
immune | = DEAD ;
2001-10-18 13:30:35 +00:00
if ( self . owner . has_disconnected )
dremove ( self ) ;
if ( immune )
check = FALSE ;
else
check = TRUE ;
2001-07-17 05:58:10 +00:00
2001-10-18 13:30:35 +00:00
//WK Lowered percent chance of restuffing because stuffcmds()
// cause overflows
if ( ! self . lip | | ! ( self . has_camera ) | | ( random ( ) < = 0.1 ) ) {
// periodically reset ping and gotwalls.
2001-07-17 05:58:10 +00:00
self . has_camera = 0 ;
self . has_camera = stof ( infokey ( self . owner , " ping " ) ) / 20 ;
# ifdef ENABLE_CHEAT_CMDS
2001-10-18 13:30:35 +00:00
if ( ! self . lip | | ( random ( ) < = 0.1 ) ) {
2001-07-23 20:52:47 +00:00
stuffcmd ( self . owner , " alias aa_enabled \" impulse I_CHEAT_ONE;wait;impulse I_CHEAT_TWO;wait;impulse I_CHEAT_THREE \" \n " ) ;
2001-07-17 05:58:10 +00:00
stuffcmd ( self . owner , " alias +aa \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias -aa \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias aa_teamlock \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias aa_on \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias aa_off \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias +showradar \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias -showradar \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias cl_speed \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias cl_gotwalls \" aa_enabled \" \n " ) ;
stuffcmd ( self . owner , " alias fullbright \" aa_enabled \" \n " ) ;
self . lip = 1 ;
}
# endif
}
2001-10-18 13:30:35 +00:00
#if 0
2001-07-17 05:58:10 +00:00
// Ignore z part of vector
tempvec = self . oldorigin - self . owner . origin ;
tempvec_z = 0 ;
dist = vlen ( tempvec ) ;
if ( check & & ( max = = 0 ) & & ( dist > 100 ) ) { //Definitely cheating...
self . owner . cheat_level = self . owner . cheat_level + 700 ;
}
2001-07-24 04:37:00 +00:00
if ( check & & ( dist > ( max * ( 1 + ( MAXPERCENT / 100.0 ) ) ) ) ) // Maybe cheating.
2001-07-17 05:58:10 +00:00
self . owner . cheat_level = self . owner . cheat_level + 200 ;
if ( self . owner . cheat_level > = 900 & & self . has_sentry = = 0 & & dist > max ) {
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , self . owner . netname ) ;
bprint ( PRINT_HIGH , " may be cheating. (Current: " ) ;
bprint ( PRINT_HIGH , ftos ( dist ) ) ;
bprint ( PRINT_HIGH , " /Max: " ) ;
bprint ( PRINT_HIGH , ftos ( max ) ) ;
bprint ( PRINT_HIGH , " ) \n " ) ;
2001-07-17 05:58:10 +00:00
self . has_sentry = 10 ;
} else {
self . has_sentry = self . has_sentry - 1 ;
if ( self . has_sentry < = 0 )
self . has_sentry = 0 ;
}
if ( self . owner . cheat_level > = 1800 ) { //bye....
self . owner . cheat_level = 0 ; //WK Clear so we don't boot twice
self . think = Kick_My_Owner ;
self . nextthink = time + 0.1 ;
}
# ifdef SHOW_CHEAT_LEVELS
local string st ;
st = ftos ( max ) ;
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " Max: " ) ;
bprint ( PRINT_HIGH , st ) ;
bprint ( PRINT_HIGH , " Imm: " ) ;
2001-07-17 05:58:10 +00:00
st = ftos ( immune ) ;
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , st ) ;
bprint ( PRINT_HIGH , " Cht: " ) ;
2001-07-17 05:58:10 +00:00
st = ftos ( self . owner . cheat_level ) ;
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , st ) ;
bprint ( PRINT_HIGH , " Speed: ( " ) ;
2001-07-17 05:58:10 +00:00
st = ftos ( dist ) ;
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , st ) ;
bprint ( PRINT_HIGH , " / " ) ;
st = ftos ( max * ( 1 + ( MAXPERCENT / 100 ) ) ) ;
bprint ( PRINT_HIGH , st ) ;
bprint ( PRINT_HIGH , " ) \n " ) ;
2001-07-17 05:58:10 +00:00
# endif
self . oldorigin = self . owner . origin ;
2001-10-18 13:30:35 +00:00
# endif
2001-07-17 05:58:10 +00:00
self . nextthink = time + 1 ;
} ;
//This checks so that the impulse cmds were not by accident
//One, must be called before two, and two before three
void ( ) I_DID_CHEAT_ONE =
{
2001-07-23 20:52:47 +00:00
// bprint(PRINT_HIGH, "I did the cheat 1 cmd!\n");
2001-07-17 05:58:10 +00:00
if ( self . has_cheated = = 0 )
self . has_cheated = 1 ;
} ;
void ( ) I_DID_CHEAT_TWO =
{
2001-07-23 20:52:47 +00:00
// bprint(PRINT_HIGH, "I did the cheat 2 cmd!\n");
2001-07-17 05:58:10 +00:00
if ( self . has_cheated > = 1 ) {
self . has_cheated = 2 ;
} else {
self . has_cheated = 0 ;
}
} ;
void ( ) I_DID_CHEAT_THREE =
{
2001-07-23 20:52:47 +00:00
// bprint(PRINT_HIGH, "I did the cheat 3 cmd!\n");
2001-07-17 05:58:10 +00:00
if ( self . has_cheated = = 2 ) {
2001-07-23 20:52:47 +00:00
//bprint(PRINT_HIGH, "Making kick entity!\n");
2001-07-17 05:58:10 +00:00
local entity te ;
te = spawn ( ) ; //CH
te . nextthink = time + ( random ( ) * 5 ) + 5 ; //5-10 seconds
self . cheat_level = 0 ; //WK Clear so we don't boot twice
self . has_cheated = 0 ;
te . think = Kick_My_Owner ;
te . owner = self ;
te . classname = " kicktimer " ;
} else {
self . has_cheated = 0 ;
}
} ;