XIDCine
Class GenFlash

source: C:\XIII\XIDCine\Classes\GenFlash.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--XIDCine.GenFlash
Direct Known Subclasses:None

class GenFlash
extends Engine.Info

//-=-=-=-=-=-=-=-=-=-=-=-=-=- // GenFlash // Created by iKi // Last Modification by iKi //-=-=-=-=-=-=-=-=-=-=-=-=-=-
Variables
 Actor ArrivalReference
 int IndexCurrentFlash
 float MemSpeedFactorLimit
 XIIIPlayerController PC
 XIIIPawn Player
 ZoneInfo PlayerZone
 Actor StartReference
 float alpha
 int count

States
FeedBackFlashEnd, FinExtroFlash, ExtroFlash, FinIntroFlash, IntroFlash

Function Summary
 void InitPlayerZone()


State FeedBackFlashEnd Function Summary


State FinExtroFlash Function Summary


State ExtroFlash Function Summary


State FinIntroFlash Function Summary


State IntroFlash Function Summary



Source Code


00001	//-=-=-=-=-=-=-=-=-=-=-=-=-=-
00002	// GenFlash
00003	//     Created by iKi
00004	// Last Modification by iKi
00005	//-=-=-=-=-=-=-=-=-=-=-=-=-=-
00006	
00007	#exec Texture Import File=Textures\flash_ico.tga Name=Flash_ico Mips=Off
00008	
00009	class GenFlash extends Info
00010		placeable;
00011	
00012	STRUCT structFlash
00013	{
00014	    VAR()			Actor	StartReference;
00015	    VAR()			Actor	ArrivalReference;
00016		VAR	TRANSIENT	bool	bMemDuck;
00017	};
00018	
00019	VAR(Flash)		structFlash Flash[4];			 // max number of flashes
00020	VAR(Flash)		Actor ViewFocus[4];
00021	VAR(Flash)		float FeedBackFlashEndDuration;
00022	VAR(Flash)		name EventBeginBeginFlash, EventBeginEndFlash,EventEndBeginFlash, EventEndEndFlash, EventPostFeedback;
00023	VAR TRANSIENT	float alpha;
00024	VAR TRANSIENT	int			IndexCurrentFlash;
00025	VAR TRANSIENT	XIIIPlayerController PC;
00026	VAR TRANSIENT	XIIIPawn Player;
00027	
00028	VAR	TRANSIENT	Vector	MemPos;
00029	VAR	TRANSIENT	Rotator	MemRot;
00030	VAR TRANSIENT	int count;
00031	VAR TRANSIENT	float MemSpeedFactorLimit;
00032	VAR TRANSIENT	ZoneInfo PlayerZone;
00033	VAR				bool bGod;
00034	
00035	EVENT PostBeginPlay()
00036	{
00037		Level.FlashManager=self;
00038	}
00039	
00040	EVENT BeginBeginFlash()
00041	{
00042		count++;
00043		GotoState('IntroFlash');
00044	}
00045	
00046	EVENT EndBeginFlash()
00047	{
00048		count++;
00049		GotoState('FinIntroFlash');
00050	}
00051	
00052	EVENT BeginEndFlash()
00053	{
00054		count++;
00055		IndexCurrentFlash=0;
00056		GotoState('ExtroFlash');
00057	}
00058	
00059	EVENT EndEndFlash()
00060	{
00061		count=0;
00062		GotoState('FinExtroFlash');
00063	}
00064	
00065	EVENT Trigger( actor Other, pawn EventInstigator )
00066	{
00067	// FOR DEBUG
00068		if ( EventInstigator.IsA('XIIIPlayerPawn') )
00069		{
00070			switch (count%2)
00071			{
00072			case 0:
00073				BeginBeginFlash();
00074				break;
00075			case 1:
00076				EndBeginFlash();
00077				break;
00078			}
00079		}
00080		else
00081		{
00082			switch (count)
00083			{
00084			case 0:
00085				BeginBeginFlash();
00086				break;
00087			case 1:
00088				EndBeginFlash();
00089				break;
00090			case 2:
00091				BeginEndFlash();
00092				break;
00093			case 3:
00094				EndEndFlash();
00095				break;
00096			}
00097		}
00098	
00099	}
00100	
00101	STATE IntroFlash
00102	{
00103		EVENT BeginState()
00104		{
00105			if (PC==none)
00106			{
00107				PC = XIIIGameInfo( Level.Game ).MapInfo.XIIIController;
00108				Player = XIIIPawn( PC.Pawn );
00109			}
00110			Flash[ IndexCurrentFlash ].bMemDuck = Player.bIsCrouched;
00111			if ( IndexCurrentFlash == 0 )
00112			{
00113				bGod = PC.bGodMode;
00114				PC.bGodMode = true;
00115				MemSpeedFactorLimit = Player.SpeedFactorLimit;
00116			}
00117			if ( ViewFocus[ IndexCurrentFlash ]==none )
00118				Disable( 'Tick' );
00119			SetTimer( 10, false );
00120		}
00121		EVENT Timer()
00122		{
00123			EndBeginFlash();
00124		}
00125		EVENT EndState()
00126		{
00127			SetTimer( 0, false );
00128	
00129		}
00130		EVENT Tick(float dt)
00131		{
00132			LOCAL rotator r;
00133			CONST rotationspeed=80;
00134	
00135			if ( PC.IsInState( 'NoControl' ) )
00136			{
00137				r=rotator(ViewFocus[ IndexCurrentFlash ].Location-(Player.Location+Player.EyePosition()))-PC.Rotation;
00138				r.Yaw=Clamp( ((r.Yaw+32768)&65535)-32768, -rotationspeed*dt*182,rotationspeed*dt*182 );
00139				r.Roll=Clamp( ((r.Roll+32768)&65535)-32768, -rotationspeed*dt*182,rotationspeed*dt*182 );
00140				r.Pitch=Clamp( ((r.Pitch+32768)&65535)-32768, -rotationspeed*dt*182,rotationspeed*dt*182 );
00141				PC.SetRotation(PC.Rotation+r);
00142				Player.SetRotation(PC.Rotation);
00143			}
00144		}
00145	begin:
00146		Sleep(0.2);
00147		if ( IndexCurrentFlash==0 )
00148			XIIIGameInfo( Level.Game ).MapInfo.SaveInventoryForFlash( Player );
00149	    Player = XIIIPawn( PC.Pawn ); // <= Fake Flash Player Pawn
00150		PC.GotoState('NoControl');
00151		Player.SetPhysics( PHYS_None );
00152		Player.SpeedFactorLimit = 1.0;
00153		Player.SetGroundSpeed( 1.0 );
00154		PC.StopFiring();
00155		Level.bCineFrame = false; // No frame with flashes
00156		PC.ConstantGlowFog =vect(1,1,1);
00157		PC.ConstantGlowScale =-3;
00158		Sleep(0.1);
00159		PC.ConstantGlowScale =0;
00160		Sleep(0.2);
00161		PC.ConstantGlowScale =-3;
00162		Sleep(0.1);
00163		PC.ConstantGlowScale =0;
00164		Sleep(0.5);
00165		PC.ConstantGlowScale =-3;
00166		Sleep(0.1);
00167		PC.ConstantGlowScale =0;
00168		Sleep(0.2);
00169		PC.ConstantGlowScale =-5;
00170		Sleep(0.1);
00171		PC.ConstantGlowScale =0;
00172		Sleep(0.5);
00173	
00174		PC.FilterColorWanted.R=255;
00175		PC.FilterColorWanted.G=255;
00176		PC.FilterColorWanted.B=255;
00177		PC.FilterColorSpeed=1;
00178	//	PC.ClientFlash( -3.2, vect(2550,2550,2550));
00179		PC.DesiredFlashScale=2.0;
00180		PC.ConstantGlowScale=-1.0;
00181		PC.ConstantGlowFog=vect(0.5,0.5,0.5);
00182	
00183		if ( /*EventBeginBeginFlash!='' &&*/ IndexCurrentFlash==0 || !(Level.Title~="Plage00") )
00184			TriggerEvent( EventBeginBeginFlash, none, none);
00185	}
00186	
00187	STATE FinIntroFlash
00188	{
00189		EVENT BeginState( )
00190		{
00191			LOCAL Actor RefDepart;
00192			LOCAL Actor RefArrivee;
00193	
00194			RefDepart = Flash[ IndexCurrentFlash ].StartReference;
00195			RefArrivee = Flash[ IndexCurrentFlash ].ArrivalReference;
00196	
00197			if (RefArrivee!=none)
00198			{
00199				if (RefDepart==none)
00200				{
00201					if ( IndexCurrentFlash == 0 )
00202					{
00203						MemPos = Player.Location;
00204						MemRot = PC.Rotation;
00205					}
00206					PC.SetLocation( RefArrivee.Location );
00207					Player.SetLocation( RefArrivee.Location );
00208					Player.ShouldCrouch(false);
00209					Player.EndCrouch(Player.CollisionHeight - Player.CrouchHeight);
00210					PC.SetRotation( RefArrivee.Rotation );
00211					Player.SetRotation( RefArrivee.Rotation );
00212				}
00213				else
00214				{
00215					if ( IndexCurrentFlash == 0 )
00216					{
00217						MemPos = Player.Location;
00218						MemRot = PC.Rotation;
00219					}
00220					PC.SetLocation( Player.Location + RefArrivee.Location - RefDepart.Location );
00221					Player.SetLocation( PC.Location );
00222	//				PC.SetRotation(RefArrivee.Rotation);
00223	//				Player.SetRotation(RefArrivee.Rotation);
00224				}
00225			}
00226			if ( Event != '' )
00227				TriggerEvent( Event, self, none );
00228		}
00229	begin:
00230		PC.GotoState( 'PlayerWalking' );
00231	//	if (Flash[IndexCurrentFlash].bMemDuck /*&& !PC.bWantsToCrouch*/)
00232	//	{
00233	//		sleep(1);
00234	//		PC.bAltDuck = 1;
00235	//		sleep(0.1);
00236	//		PC.bAltDuck = 0;
00237	//	}
00238	//	PC.bAltDuck = 0;
00239		PC.FilterColorWanted.R = 128;
00240		PC.FilterColorWanted.G = 128;
00241		PC.FilterColorWanted.B = 128;
00242		PC.FilterColorSpeed = 1;
00243		PC.ConstantGlowScale = 0;
00244		PC.ConstantGlowFog = vect( 0.5, 0.5, 0.5 );
00245		IndexCurrentFlash++;
00246		if ( EventEndBeginFlash!='' /*&& IndexCurrentFlash==0*/)
00247			TriggerEvent( EventEndBeginFlash, none, none);
00248	}
00249	
00250	STATE ExtroFlash
00251	{
00252		EVENT BeginState()
00253		{
00254			SetTimer( 10, false );
00255		}
00256		EVENT Timer()
00257		{
00258			EndEndFlash();
00259		}
00260		EVENT EndState()
00261		{
00262			SetTimer( 0, false );
00263	
00264		}
00265	begin:
00266		Sleep( 0.2 );
00267		PC.GotoState( 'NoControl' );
00268		Level.bCineFrame = false; // No frame with flashes
00269		PC.FilterColorWanted.R = 255;
00270		PC.FilterColorWanted.G = 255;
00271		PC.FilterColorWanted.B = 255;
00272		PC.FilterColorSpeed = 1;
00273		PC.DesiredFlashScale = 2.0;
00274		PC.ConstantGlowScale = -1.0;
00275		PC.ConstantGlowFog = vect( 0.5, 0.5, 0.5 );
00276		if ( EventBeginEndFlash!='')
00277			TriggerEvent( EventBeginEndFlash, none, none);
00278	}
00279	
00280	FUNCTION InitPlayerZone()
00281	{
00282		PlayerZone = PC.Pawn.region.Zone;
00283		PlayerZone.FlashEffectDesc.IsActivated = true;
00284		PlayerZone.FlashEffectDesc.Contrast = 0;
00285		PlayerZone.FlashEffectDesc.Brightness = 255;
00286		PlayerZone.FlashEffectDesc.NoGrey=True;
00287		PlayerZone.FlashEffectDesc.LayerColor.R = 192;
00288		PlayerZone.FlashEffectDesc.LayerColor.G = 192;
00289		PlayerZone.FlashEffectDesc.LayerColor.B = 192;
00290		PlayerZone.FlashEffectDesc.LayerSampling[0] = 1.0;
00291		PlayerZone.FlashEffectDesc.LayerBrightness = 255;
00292		PlayerZone.FlashEffectDesc.LayerSampling[3] = 1.0;
00293		PlayerZone.FlashEffectDesc.LayerSampling[6] = 1.0;
00294		PlayerZone.FlashEffectDesc.LayerSampling[7] = 1.0;
00295	}
00296	
00297	STATE FinExtroFlash
00298	{
00299	begin:
00300	//	Sleep(0.1);
00301	//	if( Flash[ IndexCurrentFlash ].bMemDuck && !Player.bIsCrouched /*&& (PC.bAltDuck==0)*/)
00302	//	{
00303	//		PC.bAltDuck = 1;
00304	//		Sleep( 0.01 );
00305	//	}
00306	
00307		XIIIGameInfo( Level.Game ).MapInfo.RestoreInventoryAfterFlash( Player );
00308		Player = XIIIPawn( PC.Pawn ); // Real Player Pawn
00309		Player.bCanCrouch = true;
00310	//	PC.PlayerInput.bForceCrouch = Flash[ IndexCurrentFlash ].bMemDuck;
00311		Sleep(0.1);
00312	//	PC.SetLocation( MemPos );
00313	//	while ( !Player.SetLocation( MemPos ) )
00314	//		sleep ( 0.03 );
00315		PC.SetRotation( MemRot );
00316		Player.SetRotation( MemRot );
00317		Player.Velocity=vect(0,0,0);
00318		Player.Acceleration=vect(0,0,0);
00319	//	if( Flash[ IndexCurrentFlash ].bMemDuck && !Player.bIsCrouched && ( PC.bAltDuck == 1) )
00320	//		PC.bAltDuck = 0;
00321		PC.FilterColorWanted.R = 128;
00322		PC.FilterColorWanted.G = 128;
00323		PC.FilterColorWanted.B = 128;
00324		PC.FilterColorSpeed = 1;
00325		PC.ConstantGlowScale = 0;
00326		PC.ConstantGlowFog = vect( 0.5, 0.5, 0.5 );
00327		PC.GotoState( 'PlayerWalking' );
00328	
00329	//	log("FinExtroFlash : CODE LATENT");
00330		Alpha=1;
00331		InitPlayerZone();
00332		TriggerEvent( EventEndEndFlash, none, none);
00333		sleep( 0.25 );
00334		PC.bGodMode = bGod;
00335		Player.SpeedFactorLimit = MemSpeedFactorLimit;
00336		Player.SetGroundSpeed( 1.0 );
00337	
00338		GotoState( 'FeedBackFlashEnd' );
00339	}
00340	
00341	STATE FeedBackFlashEnd
00342	{
00343		EVENT Tick( float dt )
00344		{
00345	//LOG(".....Player.SpeedFactorLimit ="@Player.SpeedFactorLimit@Player.GroundSpeed@Player.default.GroundSpeed);
00346			Alpha -= dt/FeedBackFlashEndDuration;
00347			if ( PlayerZone != PC.Pawn.region.Zone )
00348			{
00349				PlayerZone.FlashEffectDesc.IsActivated = false;
00350				InitPlayerZone();
00351			}
00352			if ( Alpha < 0 )
00353			{
00354				PlayerZone.FlashEffectDesc.IsActivated = false;
00355				if ( EventPostFeedback!='')
00356					TriggerEvent( EventPostFeedback, none, none);
00357				GotoState( '' );
00358				return;
00359			}
00360			PlayerZone.FlashEffectDesc.LayerColor.R = 255 * Alpha;
00361			PlayerZone.FlashEffectDesc.LayerColor.G = 255 * Alpha;
00362			PlayerZone.FlashEffectDesc.LayerColor.B = 255 * Alpha;
00363			PlayerZone.FlashEffectDesc.LayerSampling[0] = 1.0 - 0.6 * Alpha;
00364			PlayerZone.FlashEffectDesc.LayerSampling[1] = 1.0 - 0.6 * Alpha;
00365			PlayerZone.FlashEffectDesc.LayerSampling[2] = 1.0 - 0.45 * Alpha;
00366			PlayerZone.FlashEffectDesc.LayerSampling[3] = 1.0 - 0.45 * Alpha;
00367			PlayerZone.FlashEffectDesc.LayerSampling[4] = 1.0 - 0.25 * Alpha;
00368			PlayerZone.FlashEffectDesc.LayerSampling[5] = 1.0 - 0.25 * Alpha;
00369		}
00370	
00371		EVENT BeginState( )
00372		{
00373	//		log("FeedBackFlashEnd : BeginState");
00374	    PC.PlayerInput.bForceCrouch = false;
00375		}
00376	}
00377	
00378	
00379	
00380	
00381	defaultproperties
00382	{
00383	     FeedBackFlashEndDuration=3.000000
00384	     bAlwaysRelevant=True
00385	     Tag="FM"
00386	     Texture=Texture'XIDCine.Flash_ico'
00387	}

End Source Code