function Timer()
{
local Pawn CheckPawn;
local float ThreatLevel;
local vector DetectLocation;
local bool bSameTeam; //pawn is from the same team as instigator
DetectLocation = Location;
DetectLocation.Z += 25; // raise a detection poin half a meter up to prevent small objects on the ground bloking the trace
if( !bHidden && !bTriggered )
{
if( ArmingCountDown >= 0 )
{
ArmingCountDown -= 0.1;
if( ArmingCountDown <= 0 )
{
SetTimer(1.0,True);
}
}
else
{
// Check for enemies
if( !bEnemyDetected )
{
bAlwaysRelevant=false;
PlaySound(BeepSound,,0.5,,50.0);
foreach VisibleCollidingActors( class 'Pawn', CheckPawn, DetectionRadius, DetectLocation )
{
// don't trigger pipes on NPC -- PooSH
bSameTeam = KF_StoryNPC(CheckPawn) != none
|| (CheckPawn.PlayerReplicationInfo != none && CheckPawn.PlayerReplicationInfo.Team.TeamIndex == PlacedTeam);
if( CheckPawn == Instigator
|| (bSameTeam && KFGameType(Level.Game).FriendlyFireScale > 0) )
{
// Make the thing beep if someone on our team is within the detection radius
// This gives them a chance to get out of the way
ThreatLevel += 0.001;
}
else
{
if( CheckPawn.Health > 0 //don't trigger pipes by dead bodies -- PooSH
&& CheckPawn != Instigator && CheckPawn.Role == ROLE_Authority
&& !bSameTeam )
{
if( KFMonster(CheckPawn) != none )
{
ThreatLevel += KFMonster(CheckPawn).MotionDetectorThreat;
if( ThreatLevel >= ThreatThreshhold )
{
bEnemyDetected=true;
SetTimer(0.15,True);
}
}
else
{
bEnemyDetected=true;
SetTimer(0.15,True);
}
}
}
}
if( ThreatLevel >= ThreatThreshhold )
{
bEnemyDetected=true;
SetTimer(0.15,True);
}
else if( ThreatLevel > 0 )
{
SetTimer(0.5,True);
}
else
{
SetTimer(1.0,True);
}
}
// Play some fast beeps and blow up
else
{
bAlwaysRelevant=true;
Countdown--;
if( CountDown > 0 )
{
PlaySound(BeepSound,SLOT_Misc,2.0,,150.0);
}
else
{
Explode(DetectLocation, vector(Rotation));
}
}
}
}
else
{
Destroy();
}
}