Core.Object | +--Engine.Actor | +--Engine.Controller | +--Engine.AIController | +--XIII.MitraillGuardController
MitraillTop
GunnedTurret
int
TeamID
XIIIPawn
XIIITarget
float
fAcquireTimer
fTraceAccuracy
void
Timer()
SeePlayer(Pawn SeenPlayer)
Tick(float DT)
00001 //----------------------------------------------------------- 00002 // 00003 //----------------------------------------------------------- 00004 class MitraillGuardController extends AIController; 00005 00006 var XIIIPawn XIIITarget; // the current target 00007 var MitraillTop GunnedTurret; // the controlled turret. 00008 var float fAcquireTimer; // time to recognize player & shoot. 00009 //var bool bAware; // Player already seen, target faster. 00010 var float fTraceAccuracy; // Accuracy of the shoot, more accurate w/ time 00011 var int TeamID; 00012 00013 //_____________________________________________________________________________ 00014 auto state Gunning 00015 { 00016 function Tick(float DT) 00017 { 00018 local rotator R; 00019 local vector X,Y,Z; 00020 00021 if ( XIIITarget == none ) 00022 { 00023 GunnedTurret.TrySetRotation(Rotation); 00024 bFire = 0.0; 00025 } 00026 else 00027 { 00028 if( ( !FastTrace(XIIITarget.Location, GunnedTurret.Location) ) || ( XIIITarget.bIsDead ) ) 00029 { 00030 XIIITarget = none; 00031 GunnedTurret.TrySetRotation(Rotation); 00032 bFire = 0.0; 00033 return; 00034 } 00035 X = XIIITarget.Location - Location; 00036 Z = vect(0,0,1); 00037 Y = Z cross X; 00038 R = OrthoRotation(X,Y,Z); 00039 if ( GunnedTurret.TrySetRotation(R) ) 00040 { 00041 if ( bFire == 0.0 ) 00042 { 00043 bFire = 1.0; 00044 GunnedTurret.Fire(); 00045 } 00046 else 00047 { 00048 // Log("fTraceAccuracy="$fTraceAccuracy); 00049 GunnedTurret.TraceAccuracy = fTraceAccuracy; 00050 fTraceAccuracy = (fTraceAccuracy * (1/DT) + 5.0) / (1/DT + 1); 00051 } 00052 } 00053 else 00054 bFire = 0.0; 00055 } 00056 SetRotation(GunnedTurret.Rotation); 00057 } 00058 00059 function SeePlayer(Pawn SeenPlayer) 00060 { 00061 // log(SeenPlayer.Controller.PlayerReplicationInfo.Team.TeamIndex@GunnedTurret.TeamID); 00062 00063 if( SeenPlayer.Controller.PlayerReplicationInfo.Team.TeamIndex == GunnedTurret.TeamID ) 00064 return; 00065 00066 if ( (XIIITarget == none) && (vSize(SeenPlayer.Location - GunnedTurret.Location) < GunnedTurret.TraceDist) ) 00067 { 00068 fAcquireTimer = GunnedTurret.fGuardReactionDelay + frand() * 1.0; 00069 /* if ( bAware ) 00070 fAcquireTimer /= 2.0; */ 00071 SetTimer(fAcquireTimer, false); 00072 XIIITarget = XIIIPawn(SeenPlayer); 00073 fTraceAccuracy = 120.0; 00074 } 00075 } 00076 00077 function Timer() 00078 { 00079 if ( (XIIITarget != none) && FastTrace(XIIITarget.Location, GunnedTurret.Location) ) 00080 { 00081 // bAware=true; 00082 Enable('tick'); 00083 } 00084 else 00085 { 00086 XIIITarget = none; 00087 Disable('tick'); 00088 } 00089 } 00090 00091 Begin: 00092 Disable('Tick'); 00093 Sleep(0.5); 00094 GunnedTurret = MitraillTop(Pawn.ControlledActor); 00095 } 00096 00097 00098 00099 defaultproperties 00100 { 00101 }