## XIDMaps
Class Spads01

source: C:\XIII\XIDMaps\Classes\Spads01.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--XIII.MapInfo
                |
                +--XIDMaps.Map09_Spads
                   |
                   +--XIDMaps.Spads01

Direct Known Subclasses:None

class Spads01
extends XIDMaps.Map09_Spads

    //-----------------------------------------------------------
    // Spads01.
    // Created by iKi on Dec ??th 2001
    // Last Modification ELR Jul 03rd 2002
    // Last Modification iKI Jun 16th 2003
    //-----------------------------------------------------------

States
STA_Check

Function Summary
`void` | `FirstFrame()`
    //_____________________________________________________________________________
`void` | `SetGoalComplete(int N)`
    //_____________________________________________________________________________

State STA_Check Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	// Spads01.
    00003	// Created by iKi on Dec ??th 2001
    00004	// Last Modification ELR Jul 03rd 2002
    00005	// Last Modification iKI Jun 16th 2003
    00006	//-----------------------------------------------------------
    00007	class Spads01 extends Map09_Spads;
    00008
    00009	//VAR(Spads01SetUp)	Spads01LightPos SpotPos1, SpotPos2;
    00010	VAR(Spads01SetUp)	float fTimeBeforeSpotLightAlarm;
    00011	VAR					float TimeStamp;
    00012	VAR(Spads01SetUp)	BreakableMover Projo;
    00013	VAR(Spads01SetUp)	XIIIMover SurfaceLightCircleMover;
    00014	VAR(Spads01SetUp)	Projector DepthLightProjection;
    00015	VAR(Spads01SetUp)	XIIIMover LightBeamMover;
    00016	VAR					vector SpotOffset;
    00017	VAR					Spads01SpotLight Beam;
    00018	VAR					bool bSpotLighted;
    00019
    00020	//_____________________________________________________________________________
    00021	function FirstFrame()
    00022	{
    00023	    Local Spads01LightPos SP;
    00024	    local Float fTime;
    00025		LOCAL BOX BBox;
    00026
    00027		BBox = SurfaceLightCircleMover.GetBoundingBox();
    00028		SpotOffset = 0.5 * ( BBox.Min + BBox.Max ) - SurfaceLightCircleMover.Location;
    00029		log( "SpotOffset"@SpotOffset );
    00030	    Super.FirstFrame();
    00031
    00032	    TriggerEvent('helico', Self, none);
    00033	    TriggerEvent('sousmarin', Self, none);
    00034	/*
    00035	    if ( (SpotPos1 != none) && (SpotPos2 != none) )
    00036	    {
    00037	      if (SpotPos1.Location.z < SpotPos2.Location.z)
    00038	      {
    00039	        SP = SpotPos1;
    00040	        SpotPos1 = SpotPos2;
    00041	        SpotPos2 = SP;
    00042	      }
    00043	      // compute time to reach spot to optimize timer
    00044	      fTime = vSize( (SpotPos1.Location+SpotPos2.Location)/2.0 - XIIIPawn.Location) / XIIIPawn.Default.GroundSpeed;
    00045	      SetTimer2(fmax(fTime/1.5, 0.3), false);
    00046	    }
    00047	    else
    00048	      Log("### ERROR :: Missing SpotPosx in mapinfo.");*/
    00049		Beam=spawn(class'Spads01SpotLight',,,Projo.Location,Projo.Rotation);
    00050		Beam.SetBase(Projo);
    00051		GotoState( 'STA_Check' );
    00052	}
    00053
    00054	STATE STA_Check
    00055	{
    00056		EVENT BeginState()
    00057		{
    00058			SetTimer2( 0.1, true );
    00059		}
    00060
    00061		EVENT Tick( float dt)
    00062		{
    00063	//		LOG( SurfaceLightCircleMover.Location );
    00064			DepthLightProjection.DetachProjector(true);
    00065			Projo.SetRotation( Rotator( SurfaceLightCircleMover.Location + SpotOffset - Projo.Location ) );
    00066			DepthLightProjection.SetRotation( Projo.Rotation );
    00067			DepthLightProjection.SetLocation( SurfaceLightCircleMover.Location + SpotOffset+ 64*Vector( Projo.Rotation ) );
    00068			DepthLightProjection.AttachProjector( );
    00069
    00070			if ( Projo==none || DepthLightProjection==none || SurfaceLightCircleMover==none )
    00071			{
    00072				GotoState('');
    00073				return;
    00074			}
    00075
    00076			if ( Projo.bBroken )
    00077			{
    00078				DepthLightProjection.Destroy();
    00079				SurfaceLightCircleMover.Destroy();
    00080				Beam.Destroy();
    00081				GotoState('');
    00082				return;
    00083			}
    00084
    00085			if ( Normal(XIIIPawn.Location - Projo.Location) dot Vector(Projo.Rotation)>0.9987 /* cos(3°)*/)
    00086			{
    00087				if ( !bSpotLighted )
    00088				{
    00089					bSpotLighted=true;
    00090					TimeStamp=0;
    00091				}
    00092				else
    00093				{
    00094					TimeStamp+=dt;
    00095					if (TimeStamp>fTimeBeforeSpotLightAlarm)
    00096					{
    00097						TriggerEvent(event, Self, none);
    00098	//				  Level.Game.EndGame( XIIIController.PlayerReplicationInfo, "GoalIncomplete" );
    00099					  return;
    00100					}
    00101				}
    00102			}
    00103			else
    00104				bSpotLighted=false;
    00105		}
    00106	}
    00107
    00108
    00109
    00110	//_____________________________________________________________________________
    00111	/*event Timer2()
    00112	{
    00113	    Local float fTime;
    00114	    Local vector vT;
    00115
    00116	    if ( bSpotLighted )
    00117	    {
    00118	      Level.Game.EndGame( XIIIController.PlayerReplicationInfo, "GoalIncomplete" );
    00119	      return;
    00120	    }
    00121
    00122	    fTime = vSize( (SpotPos1.Location+SpotPos2.Location)/2.0 - XIIIPawn.Location) / XIIIPawn.Default.GroundSpeed;
    00123	//    Log("Timer2 running fTime="$fTime$" seconds / Nextcheck="$fmax(fTime/1.5, 0.3));
    00124	    // Check player in SpotLight
    00125	    SetTimer2(fmax(fTime/1.5, 0.3), false);
    00126	    // Project player pos on spot 'spine'
    00127
    00128	    vT = SpotPos2.Location + (SpotPos1.Location - SpotPos2.Location) * (XIIIPawn.Location.z - SpotPos2.Location.z) / (SpotPos1.Location.z - SpotPos2.Location.z);
    00129	    if ( vSize(XIIIPawn.Location - vT) < 240.0 )
    00130	    {
    00131	//      Log("-> SpotLight Alert !!!");
    00132	      bSpotLighted = true;
    00133	      SetTimer2(fmax(0.1, fTimeBeforeSpotLightAlarm), false);
    00134	    }
    00135
    00136	}*/
    00137
    00138	//_____________________________________________________________________________
    00139	function SetGoalComplete(int N)
    00140	{
    00141	    switch(N)
    00142	    {
    00143	      Case 98:
    00144	        Level.Game.EndGame( XIIIController.PlayerReplicationInfo, "GoalIncomplete" );
    00145	        break;
    00146	    }
    00147	    Super.SetGoalComplete(N);
    00148	}
    00149
    00150
    00151
    00152	defaultproperties
    00153	{
    00154	     fTimeBeforeSpotLightAlarm=1.000000
    00155	}

End Source Code