## XIDPawn
Class CameraDeSurveillance

source: C:\XIII\XIDPawn\Classes\CameraDeSurveillance.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Decoration
             |
             +--XIDPawn.CameraDeSurveillance

Direct Known Subclasses:None

class CameraDeSurveillance
extends Engine.Decoration

    //-----------------------------------------------------------
    // Camera de surveillance
    // On utilise le timer pour les seuils de detection du perso
    // On utilise le tick pour tourner.
    //-----------------------------------------------------------

Variables
`TriggerAlarme` | `AlarmeObjectToRing`
`int` | `AlertLevel`
`CamRStatic,` | `CamJStatic`
`TimeBetweenWarnAndAlert,` | `DistanceDetection`
`CurTgt,` | `NextTgt`
`Texture` | `NoiseTex`
`XIIIPlayerPawn` | `PawnToDetect`
`float` | `RotationSpeed`
`Texture` | `TVScreen`
`SurveillCamTarget` | `Target1,Target2`
`float` | `TimeMoved`
`float` | `scale`

States
SurveillCamMoving, SurveillCamFixedOrientation, StartingState

Function Summary
`Bool` | `CanISee(XIIIPlayerPawn P)`
    //_____________________________________________________________________________
`simulated` | `DrawScreenBackground(Canvas C, float x, float y, float width, float height)`
    //_____________________________________________________________________________
`simulated` | `RenderScreenOverlays(Canvas C)`
    //_____________________________________________________________________________
`void` | `Timer()`
    //_____________________________________________________________________________

State SurveillCamMoving Function Summary
`void` | `Tick(float DeltaTime)`
`void` | `BeginState()`

State SurveillCamFixedOrientation Function Summary
`void` | `BeginState()`

State StartingState Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	// Camera de surveillance
    00003	// On utilise le timer pour les seuils de detection du perso
    00004	// On utilise le tick pour tourner.
    00005	//-----------------------------------------------------------
    00006	class CameraDeSurveillance extends Decoration;
    00007
    00008	//#EXEC OBJ LOAD FILE=MeshObjetsPickup.usx PACKAGE=MeshObjetsPickup
    00009
    00010	var() TriggerAlarme AlarmeObjectToRing;
    00011	var() float TimeBeforeWarn, TimeBetweenWarnAndAlert, DistanceDetection;
    00012	var() SurveillCamTarget Target1,Target2;
    00013	var() float RotationSpeed;
    00014	var int AlertLevel;
    00015	var XIIIPlayerPawn PawnToDetect;
    00016	var SurveillCamTarget CurTgt, NextTgt;
    00017	var float TimeMoved;
    00018	var Texture NoiseTex;
    00019	var texture TVScreen;
    00020	var StaticMesh CamVStatic, CamRStatic, CamJStatic;
    00021	var float scale;
    00022
    00023	//_____________________________________________________________________________
    00024	simulated event Trigger( Actor other, Pawn instigator )
    00025	{
    00026	    scale = 0.0;
    00027	}
    00028
    00029	//_____________________________________________________________________________
    00030	// ELR Render Overlay
    00031	simulated event RenderOverlays( canvas C )
    00032	{
    00033	    local float x,y;
    00034	    local eDrawType DT_mem;
    00035
    00036	    // WARN NO Level.Game on clients on-line
    00037	    if ( (level.game != none) && XIIIGameInfo(level.game).bRocketArena )
    00038	    {
    00039	      x = 320-160;
    00040	      y = 240-120+40;
    00041	    }
    00042	    else
    00043	    {
    00044	      x = 50;
    00045	      y = 50;
    00046	    }
    00047
    00048	    if ( ((Level.Game != none) && (Level.Game.DetailLevel < 2)) || (XIIIPlayerController(Instigator.controller).bRenderPortal))
    00049	    {
    00050	      RenderScreenOverlays( C );
    00051	      return;
    00052	    }
    00053
    00054	    scale = XIIIPlayerController(Instigator.controller).fCamViewPercent;
    00055	    if (scale < 0.01)
    00056	      return;
    00057	    //scale += 0.01;
    00058	    //if (scale > 1)
    00059	    //  scale = 1;
    00060	    C.SetPos(x-4,y-4);
    00061	    C.DrawTile(texture'XIIIMenu.Blanc',320*scale+8,240*scale+8,0,0,1,1);
    00062
    00063	    XIIIPlayerController(Instigator.controller).bRenderPortal = true;
    00064	    DT_mem = DrawType;
    00065	    SetDrawType(DT_none);
    00066	    XIIIPlayerController(Instigator.controller).bBehindView = true;
    00067	    C.DrawPortal(x,y,320*scale,240*scale,self,location,rotation);
    00068	    XIIIPlayerController(Instigator.controller).bBehindView = false;
    00069	    SetDrawType(DT_mem);
    00070	    XIIIPlayerController(Instigator.controller).bRenderPortal = false;
    00071	}
    00072
    00073	//_____________________________________________________________________________
    00074	simulated function RenderScreenOverlays( canvas C )
    00075	{
    00076	    C.SetPos(0.0, 0.0);
    00077	    C.SetDrawColor(255,255,255,128);
    00078	    C.Style = ERenderStyle.STY_Alpha;
    00079	    C.DrawTile(NoiseTex,C.ClipX,C.ClipY,0,0,NoiseTex.USize*(Frand()+2),NoiseTex.VSize*(Frand()+2));
    00080	    DrawScreenBackground(C, -1,-1,C.ClipX,C.ClipY);
    00081	}
    00082
    00083	//_____________________________________________________________________________
    00084	simulated function DrawScreenBackground(Canvas C, float x, float y, float width, float height)
    00085	{
    00086	    C.SetDrawColor(255,255,255,255);
    00087	    C.SetPos(x+width*0.5, y);
    00088	    C.DrawTile(TVScreen, 0.5*width+1, 0.5*height+2, 01, 01, (TVScreen.USize-2), (TVScreen.VSize-2));
    00089	    C.SetPos(x, y);
    00090	    C.DrawTile(TVScreen, 0.5*width+2, 0.5*height+2, -01, 01, -(TVScreen.USize-2), (TVScreen.VSize-2));
    00091	    C.SetPos(x, y + 0.5 * height);
    00092	    C.DrawTile(TVScreen, 0.5*width+2, 0.5*height+1, -01, -01, -(TVScreen.USize-2), -(TVScreen.VSize-2));
    00093	    C.SetPos(x+0.5*width, y+0.5*height);
    00094	    C.DrawTile(TVScreen, 0.5*width+1, 0.5*height+1, 01, -01, (TVScreen.USize-2),-(TVScreen.VSize-2));
    00095	}
    00096
    00097	//_____________________________________________________________________________
    00098	function Bool CanISee(XIIIPlayerPawn P)
    00099	{
    00100	    if ( FastTrace(P.Location, Location)
    00101	      || FastTrace(P.Location+P.EyeHeight*vect(0,0,0.8), Location)
    00102	      || FastTrace(P.Location-P.EyeHeight*vect(0,0,0.8), Location) )
    00103	    {
    00104	      if ( ((normal(P.Location-Location) dot vector(rotation)) > 0.707 )
    00105	        && (vSize(P.Location-Location) < DistanceDetection) )
    00106	        return true;
    00107	    }
    00108	    return false;
    00109	}
    00110
    00111	//_____________________________________________________________________________
    00112	function Timer()
    00113	{
    00114	    Local actor HitActor;
    00115	    Local vector HitLoc, HitNorm;
    00116
    00117	    if ( AlertLevel==0 )
    00118	    {
    00119	      // Check here if player is visible then switch alertlevel
    00120	      foreach DynamicActors( class'XIIIPlayerPawn', PawnToDetect)
    00121	      {
    00122	        if ( ( PawnToDetect!=none) && CanISee(PawnToDetect) )
    00123	        {
    00124	          AlertLevel=1;
    00125	          StaticMesh = CamJStatic;
    00126	          SetTimer(TimeBeforeWarn,false);
    00127	          break;
    00128	        }
    00129	      }
    00130	    }
    00131	    else if ( AlertLevel==1 )
    00132	    {
    00133	      if ( (PawnToDetect!=none) && CanISee(PawnToDetect) )
    00134	      {
    00135	        AlertLevel=2;
    00136	        StaticMesh = CamRStatic;
    00137	        SetTimer(TimeBetweenWarnAndAlert, false);
    00138	      }
    00139	      else
    00140	      {
    00141	        AlertLevel=0;
    00142	        StaticMesh = CamVStatic;
    00143	        SetTimer(0.5, True);
    00144	      }
    00145	    }
    00146	    else
    00147	    {
    00148	      if ( (PawnToDetect!=none) && CanISee(PawnToDetect) )
    00149	      {
    00150	        // Touch alarm here
    00151	        if (AlarmeObjectToRing!=none)
    00152	        {
    00153	          XIIIPlayerController(PawnToDetect.controller).MyInteraction.TargetActor = AlarmeObjectToRing;
    00154	          AlarmeObjectToRing.Trigger(self, PawnToDetect);
    00155	        }
    00156	        AlertLevel=2;
    00157	        StaticMesh = CamRStatic;
    00158	        SetTimer(TimeBetweenWarnAndAlert, false);
    00159	      }
    00160	      else
    00161	      {
    00162	        AlertLevel=0;
    00163	        StaticMesh = CamVStatic;
    00164	        SetTimer(0.5, True);
    00165	      }
    00166	    }
    00167	}
    00168
    00169	//_____________________________________________________________________________
    00170	// FUCK Have to put all this here because it doesn't worked in PostBeginPlay...
    00171	auto state StartingState
    00172	{
    00173	Begin:
    00174	  AlertLevel=0;
    00175	  if ( DistanceDetection > 0 )
    00176	  {
    00177	    SetTimer(0.5, true);
    00178	    StaticMesh = CamVStatic;
    00179	  }
    00180	  if ( (Target1==none) || (Target2==none) )
    00181	    gotostate('SurveillCamFixedOrientation');
    00182	  else
    00183	    gotostate('SurveillCamMoving');
    00184	}
    00185
    00186	//_____________________________________________________________________________
    00187	state SurveillCamFixedOrientation
    00188	{
    00189	    Function BeginState()
    00190	    { // Set the camera rotation
    00191	      if ( Target1!=none )
    00192	        SetRotation(rotator(Target1.Location-Location));
    00193	      if ( Target2!=none )
    00194	        SetRotation(rotator(Target2.Location-Location));
    00195	      // No else, just keep our rotation
    00196	    }
    00197	}
    00198
    00199	//_____________________________________________________________________________
    00200	state SurveillCamMoving
    00201	{
    00202	    Function BeginState()
    00203	    { // Set the camera rotation
    00204	      CurTgt=Target1;
    00205	      NextTgt=target2;
    00206	      SetRotation(rotator(CurTgt.Location-Location));
    00207	    }
    00208	    function Tick(float DeltaTime)
    00209	    {
    00210	      local vector vTgt;
    00211
    00212	      if (AlertLevel == 0)
    00213	      {
    00214	        vTgt = (TimeMoved/RotationSpeed)*NextTgt.Location + (1-(TimeMoved/RotationSpeed))*CurTgt.Location;
    00215	        SetRotation(rotator(vTgt-Location));
    00216	        TimeMoved -= DeltaTime;
    00217	        if (TimeMoved<=0.0)
    00218	        {
    00219	          if (CurTgt == Target1)
    00220	          {
    00221	            CurTgt=Target2;
    00222	            NextTgt=target1;
    00223	            gotostate(GetStateName(), 'TwotoOne');
    00224	          }
    00225	          else
    00226	          {
    00227	            CurTgt=Target1;
    00228	            NextTgt=target2;
    00229	            gotostate(GetStateName(), 'OnetoTwo');
    00230	          }
    00231	        }
    00232	      }
    00233	    }
    00234	Begin:
    00235	  disable('tick');
    00236	  sleep(Target1.TimeToStayOnMe);
    00237
TimeMoved=RotationSpeed; 00238 enable('tick'); 00239 OnetoTwo: 00240 disable('tick'); 00241 sleep(Target1.TimeToStayOnMe); 00242 TimeMoved=RotationSpeed; 00243 enable('tick'); 00244 goto('DoNothing'); 00245 TwotoOne: 00246 disable('tick'); 00247 sleep(Target2.TimeToStayOnMe); 00248 TimeMoved=RotationSpeed; 00249 enable('tick'); 00250 goto('DoNothing'); 00251 DoNothing: 00252 } 00253 00254 // NoiseTex=Texture'XIIIHual2.H2AnimTele01' 00255 // DrawType=DT_Mesh 00256 // Mesh=VertMesh'XIIIDeco.cameraM' 00257 // CamVTex=texture'XIIIMeshobjets.CameraV' 00258 // CamRTex=texture'XIIIMeshobjets.CameraR' 00259 // CamNTex=texture'XIIIMeshobjets.CameraN' 00260 // CamJTex=texture'XIIIMeshobjets.CameraJ' 00261 00262 00263 defaultproperties 00264 { 00265 TimeBeforeWarn=2.000000 00266 TimeBetweenWarnAndAlert=2.000000 00267 DistanceDetection=5000.000000 00268 RotationSpeed=2.000000 00269 NoiseTex=Texture'XIIICine.Bruit' 00270 TVScreen=Texture'XIIIMenu.HUD.tv_cacheA' 00271 CamVStatic=StaticMesh'MeshObjetsPickup.camera_vert' 00272 CamRStatic=StaticMesh'MeshObjetsPickup.camera_rouge' 00273 CamJStatic=StaticMesh'MeshObjetsPickup.camera_jaune' 00274 bStatic=False 00275 bStasis=False 00276 bInteractive=False 00277 bCollideActors=True 00278 bProjTarget=True 00279 DrawType=DT_StaticMesh 00280 StaticMesh=StaticMesh'MeshObjetsPickup.Camera' 00281 bDirectional=True 00282 }

End Source Code