2001-07-17 05:58:10 +00:00
/*======================================================
OPTIMIZE . QC Custom TeamFortress v2 .1
( c ) Craig Hauser 10 / 4 / 00
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
This has the optimizations that I have done , basically if
I saw something similar being run in multi places I made
a function and put it here .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
2001-07-23 20:52:47 +00:00
# include "defs.qh"
2001-07-17 05:58:10 +00:00
float ( float t1 , float t2 ) Teammate ;
float ( entity targ , entity check ) visible2 ;
float ( entity targ , entity check ) visible2x ;
void ( entity targ , entity inflictor , entity attacker , float damage , float T_flags , float T_AttackType ) TF_T_Damage ;
//checks client passed into and returns true if valid used for sents etc
//entity looking at, entity thats looking, (0-1) checks visible, (0-range) checks range, (0-1) do special tesla checks, (0-1) should check for ceasefire
float ( entity targ , entity checker , float chkvis , float chkrng , float istesla , float chkcease ) Pharse_Client =
{
if ( targ . classname ! = " player " )
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
# ifdef QUAKE_WORLD // culled by KK. was QUAKE_WORLD
if ( chkcease )
if ( infokey ( world , " ceasefire " ) = = " on " )
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
# endif
2001-07-23 20:52:47 +00:00
if ( targ . playerclass = = PC_UNDEFINED )
return FALSE ;
if ( targ . done_custom & CUSTOM_BUILDING )
return FALSE ;
2001-07-17 05:58:10 +00:00
if ( targ . health < = 0 )
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
if ( targ . has_disconnected )
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
if ( teamplay )
{
if ( Teammate ( targ . team_no , checker . team_no ) )
{
if ( istesla )
{
2001-07-23 20:52:47 +00:00
if ( ! ( checker . tf_items & NIT_SECURITY_CAMERA ) ) //CH Cyto's idea
return FALSE ;
2001-07-17 05:58:10 +00:00
} else
{
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
}
}
if ( Teammate ( targ . undercover_team , checker . team_no ) )
{
if ( istesla )
{
//- OfN jammer only for scanner -// nope
2001-07-23 20:52:47 +00:00
if ( ! ( checker . tf_items & NIT_AUTOID ) | | targ . cutf_items & CUTF_JAMMER )
//if (!(checker.tf_items & NIT_AUTOID))
return FALSE ;
2001-07-17 05:58:10 +00:00
}
else
{
2001-07-23 20:52:47 +00:00
if ( ! ( checker . classname = = " building_sensor " & & checker . num_mines & IMPROVED_FOUR ) )
return FALSE ;
2001-07-17 05:58:10 +00:00
2001-07-23 20:52:47 +00:00
// - OfN return FALSE;
2001-07-17 05:58:10 +00:00
}
}
}
if ( targ = = checker . real_owner )
{
if ( istesla )
{
2001-07-23 20:52:47 +00:00
if ( ! ( checker . tf_items & NIT_SECURITY_CAMERA ) ) //CH Cyto's idea
return FALSE ;
2001-07-17 05:58:10 +00:00
} else
{
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
}
}
if ( targ . is_feigning )
{
if ( istesla )
{
2001-07-23 20:52:47 +00:00
if ( ! ( checker . tf_items & NIT_AUTOID ) )
return FALSE ;
2001-07-17 05:58:10 +00:00
}
else //if (checker.classname != "monster_army") - OfN soldiers cant detect feigning spies now
{
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
}
}
2001-07-23 20:52:47 +00:00
if ( targ . flags & FL_NOTARGET )
return FALSE ;
if ( targ . items & IT_INVISIBILITY & & ( checker . classname ! = " building_sensor " ) ) //|| checker.classname != "monster_army"))
return FALSE ;
if ( targ . job & JOB_THIEF & & ( targ . job & JOB_ACTIVE | | targ . job & JOB_FULL_HIDE ) )
2001-07-17 05:58:10 +00:00
{
if ( istesla )
{
//- OfN jammer only for scanner -// nope
2001-07-23 20:52:47 +00:00
if ( ! ( checker . tf_items & NIT_AUTOID ) | | targ . cutf_items & CUTF_JAMMER )
//if (!(checker.tf_items & NIT_AUTOID))
return FALSE ;
2001-07-17 05:58:10 +00:00
}
else if ( checker . classname ! = " building_sensor " ) // && checker.classname != "monster_army" && checker.classname != "monster_demon1")
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
}
2001-07-23 20:52:47 +00:00
if ( chkvis & & checker . classname = = " building_sentrygun " & & ! ( checker . tf_items & NIT_TURRET ) ) // - OfN - hackish fix for sentry gun targetting
2001-07-17 05:58:10 +00:00
{
if ( ! visible2x ( targ , checker ) ) // - OfN - hackish fix for sentry gun targetting
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
}
else if ( chkvis )
if ( ! visible2 ( targ , checker ) )
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
if ( chkrng )
{
local float r ;
r = vlen ( targ . origin - checker . origin ) ;
if ( r > chkrng )
2001-07-23 20:52:47 +00:00
return FALSE ;
2001-07-17 05:58:10 +00:00
}
2001-07-23 20:52:47 +00:00
return TRUE ;
2001-07-17 05:58:10 +00:00
} ;
//gives entity passed into number of frags passed
//entity gets frag, entity gave frag, give this many frags, (0-1) log frags, 1=real_frag 2=frag, (0-1) checks real_frag, (0-1) check frag vamp (takes from targ)
void ( entity atk , entity targ , float numfrags , float fraggetlog , float howgive , float chkreal , float chkvamp ) Give_Frags_Out =
{
/*
local string st ;
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " atk: " ) ;
bprint ( PRINT_HIGH , atk . classname ) ;
bprint ( PRINT_HIGH , " targ: " ) ;
bprint ( PRINT_HIGH , targ . classname ) ;
bprint ( PRINT_HIGH , " Frag: " ) ;
2001-07-17 05:58:10 +00:00
st = ftos ( numfrags ) ;
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , st ) ;
bprint ( PRINT_HIGH , " log: " ) ;
2001-07-17 05:58:10 +00:00
if ( fraggetlog )
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " yes " ) ;
2001-07-17 05:58:10 +00:00
else
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " no " ) ;
bprint ( PRINT_HIGH , " howgive: " ) ;
2001-07-17 05:58:10 +00:00
if ( howgive = = 1 )
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " real_frags " ) ;
2001-07-17 05:58:10 +00:00
else if ( howgive = = 2 )
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " frags " ) ;
2001-07-17 05:58:10 +00:00
else
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " ERROR " ) ;
bprint ( PRINT_HIGH , " real: " ) ;
2001-07-17 05:58:10 +00:00
if ( chkreal )
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " yes " ) ;
2001-07-17 05:58:10 +00:00
else
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " no " ) ;
bprint ( PRINT_HIGH , " vamp: " ) ;
2001-07-17 05:58:10 +00:00
if ( chkvamp )
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " yes " ) ;
2001-07-17 05:58:10 +00:00
else
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " no " ) ;
bprint ( PRINT_HIGH , " \n " ) ;
2001-07-17 05:58:10 +00:00
*/
if ( atk . classname = = " monster_army " )
{
atk . frags = atk . frags + numfrags ;
atk . real_frags = atk . real_frags ;
}
else
{
if ( howgive = = 2 )
atk . frags = atk . frags + numfrags ;
else if ( howgive = = 1 )
atk . real_frags = atk . real_frags + numfrags ;
else
2001-07-23 20:52:47 +00:00
bprint ( PRINT_HIGH , " Error in Give_Frags_Out! \n " ) ;
2001-07-17 05:58:10 +00:00
# ifdef QUAKE_WORLD
if ( fraggetlog )
{
logfrag ( targ , atk ) ;
}
# endif
if ( chkvamp )
{
2001-07-23 20:52:47 +00:00
if ( teamplay & TEAMPLAY_VAMPIRE )
2001-07-17 05:58:10 +00:00
{
targ . real_frags = targ . real_frags - numfrags ;
2001-07-23 20:52:47 +00:00
if ( ! ( toggleflags & TFLAG_TEAMFRAGS ) )
2001-07-17 05:58:10 +00:00
targ . frags = targ . real_frags ;
}
}
if ( chkreal )
{
2001-07-23 20:52:47 +00:00
if ( ! ( toggleflags & TFLAG_TEAMFRAGS ) )
2001-07-17 05:58:10 +00:00
{
atk . frags = atk . real_frags ;
}
}
}
} ;
//replaces det guns
//classname to find, entity checking, (0-1) check for ownership
void ( string search , entity person , float chkown ) Find_And_Dmg =
{
local entity te ;
te = find ( world , classname , search ) ;
while ( te )
{
if ( chkown )
{
if ( te . real_owner = = person )
TF_T_Damage ( te , world , world , te . health + 100 , 0 , 0 ) ;
}
else
{
TF_T_Damage ( te , world , world , te . health + 100 , 0 , 0 ) ;
}
te = find ( te , classname , search ) ;
}
} ;
float ( ) isMelee =
{
2001-07-23 20:52:47 +00:00
if ( self . current_weapon = = WEAP_AXE | | self . current_weapon = = WEAP_SPANNER | | self . current_weapon = = WEAP_MEDIKIT )
return TRUE ;
2001-07-17 05:58:10 +00:00
else
2001-07-23 20:52:47 +00:00
return FALSE ;
} ;