## XIDCine
Class KelloAmbush

source: C:\XIII\XIDCine\Classes\KelloAmbush.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Triggers
             |
             +--XIDCine.KelloAmbush

Direct Known Subclasses:None

class KelloAmbush
extends Engine.Triggers

    //-----------------------------------------------------------
    // KelloAmbush
    // Created by iKi
    // Last Modification by iKi
    //-----------------------------------------------------------

Variables
`Actor` | `ActorsToPeer[4]`
`Name` | `EventsToCast[5]`
`float` | `LinearSpeed`
`float` | `Pauses[4]`
`float` | `RotationSpeed`

States
TheEnd, Pause_03, LetsLook_02, LetsMove_01, Waiting, Init

State TheEnd Function Summary

State Pause_03 Function Summary

State LetsLook_02 Function Summary

State LetsMove_01 Function Summary

State Waiting Function Summary

State Init Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	// KelloAmbush
    00003	// Created by iKi
    00004	// Last Modification by iKi
    00005	//-----------------------------------------------------------
    00006	class KelloAmbush extends Triggers;
    00007
    00008	#exec Texture Import File=Textures\Rock_ico.pcx Name=Rock_ico Mips=Off
    00009
    00010	VAR()				Actor					ActorsToPeer[4];
    00011	VAR()				float					Pauses[4];
    00012	VAR()				Name					EventsToCast[5];
    00013	VAR					int						ActorToPeerIndex;
    00014	VAR		TRANSIENT	XIIIPlayerController	PC;
    00015	VAR					Rotator					Roto;
    00016	VAR()				float					RotationSpeed;
    00017	VAR					float					ActualRotationSpeed;
    00018	VAR()				float					LinearSpeed;
    00019
    00020	CONST RotationAcceleration=250;
    00021
    00022	AUTO STATE Init
    00023	{
    00024		EVENT BeginState()
    00025		{
    00026			SetTimer(0.1,true);
    00027		}
    00028
    00029		EVENT Timer()
    00030		{
    00031			if (XIIIGameInfo(Level.Game).MapInfo!=none && XIIIGameInfo(Level.Game).MapInfo.XIIIController!=none)
    00032			{
    00033				PC=XIIIGameInfo(Level.Game).MapInfo.XIIIController;
    00034				SetTimer( 0, false );
    00035				GotoState( 'Waiting' );
    00036			}
    00037
    00038		}
    00039	}
    00040
    00041	STATE Waiting
    00042	{
    00043		EVENT Trigger( actor Other, Pawn EventInstigator )
    00044		{
    00045			GotoState( 'LetsMove_01' );
    00046		}
    00047	}
    00048
    00049	STATE LetsMove_01
    00050	{
    00051		EVENT BeginState()
    00052		{
    00053			PC.GotoState( 'NoControl' );
    00054			ActualRotationSpeed = 0;
    00055		}
    00056
    00057		EVENT Tick( float dt )
    00058		{
    00059			LOCAL Rotator r;
    00060			LOCAL Vector v;
    00061
    00062			v = Location-PC.Pawn.Location;
    00063			v.Z = 0;
    00064
    00065			ActualRotationSpeed= fMin( RotationSpeed, ActualRotationSpeed+RotationAcceleration*dt );
    00066			Roto=ROTATOR( ActorsToPeer[0].Location+vect(0,0,10)-PC.Pawn.Location );
    00067
    00068			r.Yaw   = Clamp( ( ( Roto.Yaw   - PC.Rotation.Yaw   + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt*182,ActualRotationSpeed*dt*182 );
    00069			r.Roll  = Clamp( ( ( Roto.Roll  - PC.Rotation.Roll  + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt*182,ActualRotationSpeed*dt*182 );
    00070			r.Pitch = Clamp( ( ( Roto.Pitch - PC.Rotation.Pitch + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt* 41,ActualRotationSpeed*dt* 41 );
    00071
    00072			log ( vSize( v ) );
    00073			if ( vSize(v)<1 && r.Yaw==0 )
    00074			{
    00075				TriggerEvent( event, Self, PC.Pawn );
    00076				GotoState( 'LetsLook_02' );
    00077				return;
    00078			}
    00079
    00080			PC.SetRotation( r + PC.Rotation );
    00081			PC.Pawn.Velocity = fMin( vSize(v)/dt, linearspeed ) * Normal( v );
    00082		}
    00083	}
    00084
    00085	STATE LetsLook_02
    00086	{
    00087		EVENT BeginState( )
    00088		{
    00089			Roto=Rotator( ActorsToPeer[ActorToPeerIndex].Location+vect(0,0,10)-PC.Pawn.Location );
    00090			if ( ActorToPeerIndex!=0 )
    00091				ActualRotationSpeed = 0;
    00092		}
    00093
    00094		EVENT Tick( float dt )
    00095		{
    00096			LOCAL Rotator r;
    00097
    00098			ActualRotationSpeed= fMin( RotationSpeed, ActualRotationSpeed+RotationAcceleration*dt );
    00099
    00100			r.Yaw   = Clamp( ( ( Roto.Yaw   - PC.Rotation.Yaw   + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt*182,ActualRotationSpeed*dt*182 );
    00101			r.Roll  = Clamp( ( ( Roto.Roll  - PC.Rotation.Roll  + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt*182,ActualRotationSpeed*dt*182 );
    00102			r.Pitch = Clamp( ( ( Roto.Pitch - PC.Rotation.Pitch + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt* 41,ActualRotationSpeed*dt* 41 );
    00103
    00104			PC.SetRotation( r + PC.Rotation );
    00105
    00106			if ( r.Yaw==0 )
    00107				GotoState( 'Pause_03' );
    00108		}
    00109	}
    00110
    00111	STATE Pause_03
    00112	{
    00113	Begin:
    00114		TriggerEvent( EventsToCast[ActorToPeerIndex], self, none );
    00115		sleep( Pauses[ActorToPeerIndex] );
    00116		ActorToPeerIndex++;
    00117		if ( ActorToPeerIndex==4)
    00118			GotoState( 'TheEnd' );
    00119		else
    00120			GotoState( 'LetsLook_02' );
    00121	}
    00122
    00123
    00124	STATE TheEnd
    00125	{
    00126		EVENT BeginState( )
    00127		{
    00128			Roto = ROTATOR( ActorsToPeer[0].Instigator.Location+vect(0,0,10)-PC.Pawn.Location );
    00129			ActualRotationSpeed = 0;
    00130		}
    00131
    00132		EVENT Tick( float dt )
    00133		{
    00134			LOCAL Rotator r;
    00135
    00136			ActualRotationSpeed= fMin( RotationSpeed, ActualRotationSpeed+RotationAcceleration*dt );
    00137
    00138			r.Yaw   = Clamp( ( ( Roto.Yaw   - PC.Rotation.Yaw   + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt*182,ActualRotationSpeed*dt*182 );
    00139			r.Roll  = Clamp( ( ( Roto.Roll  - PC.Rotation.Roll  + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt*182,ActualRotationSpeed*dt*182 );
    00140			r.Pitch = Clamp( ( ( Roto.Pitch - PC.Rotation.Pitch + 32768 ) & 65535 ) - 32768, -ActualRotationSpeed*dt* 41,ActualRotationSpeed*dt* 41 );
    00141
    00142			PC.SetRotation( r + PC.Rotation );
    00143
    00144			if ( r.Yaw==0 )
    00145			{
    00146				TriggerEvent( EventsToCast[ActorToPeerIndex], self, none );
    00147				PC.GotoState( 'PlayerWalking' );
    00148				PC.Pawn.Velocity = vect(0,0,0);
    00149				PC.Pawn.Acceleration = vect(0,0,0);
    00150				Destroy();
    00151				return;
    00152			}
    00153
    00154		}
    00155	}
    00156
    00157
    00158
    00159	defaultproperties
    00160	{
    00161	     Pauses(0)=1.500000
    00162	     Pauses(1)=1.500000
    00163	     Pauses(2)=1.500000
    00164	     Pauses(3)=1.500000
    00165	     RotationSpeed=145.000000
    00166	     LinearSpeed=600.000000
    00167	     InitialState="Init"
    00168	     Texture=Texture'XIDCine.Rock_ico'
    00169	     bDirectional=True
    00170	}

End Source Code