This post has been compromised due to a security issue

Tutorials and discussions about Mapping - Introduce your own ones!
Post Reply
User avatar
[did]Madis
Adept
Posts: 297
Joined: Tue Jun 03, 2008 2:48 pm
Personal rank: カニはとても美味しい

Re: Flashback effect

Post by [did]Madis »

Unreal Engine 2
Support Nuclear Races by visiting our ModDB profile
Image
Image
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Flashback effect

Post by JackGriffin »

If it's an Unreal engine game, just borrow the code for the actor that does it in your existing map. Most likely the changes won't be hard, if there are any to make.
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Flashback effect

Post by Feralidragon »

That's a native renderer effect people at that studio implemented in their own licensed UEngine copy. The only way to implement it in UT is also making it nativelly in a custom renderer afaik.

You can always ask Shadow to implement that in his SDK (if it's not implemented already).
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Flashback effect

Post by JackGriffin »

You could mimic that effect from within default Ued though, and get pretty close even without using their renderer I would think?
So long, and thanks for all the fish
BRiCk
Posts: 1
Joined: Sat Aug 27, 2011 2:55 pm

Re: Flashback effect

Post by BRiCk »

The code of the GenFlash, it is called from a MapInfo actor placed in your map

Code: Select all

//-=-=-=-=-=-=-=-=-=-=-=-=-=-
// GenFlash
//     Created by iKi
// Last Modification by iKi
//-=-=-=-=-=-=-=-=-=-=-=-=-=-

#exec Texture Import File=Textures\flash_ico.tga Name=Flash_ico Mips=Off

class GenFlash extends Info
	placeable;

STRUCT structFlash
{
    VAR()			Actor	StartReference;
    VAR()			Actor	ArrivalReference;
	VAR	TRANSIENT	bool	bMemDuck;
};

VAR(Flash)		structFlash Flash[4];			 // max number of flashes
VAR(Flash)		Actor ViewFocus[4];
VAR(Flash)		float FeedBackFlashEndDuration;
VAR(Flash)		name EventBeginBeginFlash, EventBeginEndFlash,EventEndBeginFlash, EventEndEndFlash, EventPostFeedback;
VAR TRANSIENT	float alpha;
VAR TRANSIENT	int			IndexCurrentFlash;
VAR TRANSIENT	XIIIPlayerController PC;
VAR TRANSIENT	XIIIPawn Player;

VAR	TRANSIENT	Vector	MemPos;
VAR	TRANSIENT	Rotator	MemRot;
VAR TRANSIENT	int count;
VAR TRANSIENT	float MemSpeedFactorLimit;
VAR TRANSIENT	ZoneInfo PlayerZone;
VAR				bool bGod;

EVENT PostBeginPlay()
{
	Level.FlashManager=self;
}

EVENT BeginBeginFlash()
{
	count++;
	GotoState('IntroFlash');
}

EVENT EndBeginFlash()
{
	count++;
	GotoState('FinIntroFlash');
}

EVENT BeginEndFlash()
{
	count++;
	IndexCurrentFlash=0;
	GotoState('ExtroFlash');
}

EVENT EndEndFlash()
{
	count=0;
	GotoState('FinExtroFlash');
}

EVENT Trigger( actor Other, pawn EventInstigator )
{
// FOR DEBUG
	if ( EventInstigator.IsA('XIIIPlayerPawn') )
	{
		switch (count%2)
		{
		case 0:
			BeginBeginFlash();
			break;
		case 1:
			EndBeginFlash();
			break;
		}
	}
	else
	{
		switch (count)
		{
		case 0:
			BeginBeginFlash();
			break;
		case 1:
			EndBeginFlash();
			break;
		case 2:
			BeginEndFlash();
			break;
		case 3:
			EndEndFlash();
			break;
		}
	}

}

STATE IntroFlash
{
	EVENT BeginState()
	{
		if (PC==none)
		{
			PC = XIIIGameInfo( Level.Game ).MapInfo.XIIIController;
			Player = XIIIPawn( PC.Pawn );
		}
		Flash[ IndexCurrentFlash ].bMemDuck = Player.bIsCrouched;
		if ( IndexCurrentFlash == 0 )
		{
			bGod = PC.bGodMode;
			PC.bGodMode = true;
			MemSpeedFactorLimit = Player.SpeedFactorLimit;
		}
		if ( ViewFocus[ IndexCurrentFlash ]==none )
			Disable( 'Tick' );
		SetTimer( 10, false );
	}
	EVENT Timer()
	{
		EndBeginFlash();
	}
	EVENT EndState()
	{
		SetTimer( 0, false );

	}
	EVENT Tick(float dt)
	{
		LOCAL rotator r;
		CONST rotationspeed=80;

		if ( PC.IsInState( 'NoControl' ) )
		{
			r=rotator(ViewFocus[ IndexCurrentFlash ].Location-(Player.Location+Player.EyePosition()))-PC.Rotation;
			r.Yaw=Clamp( ((r.Yaw+32768)&65535)-32768, -rotationspeed*dt*182,rotationspeed*dt*182 );
			r.Roll=Clamp( ((r.Roll+32768)&65535)-32768, -rotationspeed*dt*182,rotationspeed*dt*182 );
			r.Pitch=Clamp( ((r.Pitch+32768)&65535)-32768, -rotationspeed*dt*182,rotationspeed*dt*182 );
			PC.SetRotation(PC.Rotation+r);
			Player.SetRotation(PC.Rotation);
		}
	}
begin:
	Sleep(0.2);
	if ( IndexCurrentFlash==0 )
		XIIIGameInfo( Level.Game ).MapInfo.SaveInventoryForFlash( Player );
    Player = XIIIPawn( PC.Pawn ); // <= Fake Flash Player Pawn
	PC.GotoState('NoControl');
	Player.SetPhysics( PHYS_None );
	Player.SpeedFactorLimit = 1.0;
	Player.SetGroundSpeed( 1.0 );
	PC.StopFiring();
	Level.bCineFrame = false; // No frame with flashes
	PC.ConstantGlowFog =vect(1,1,1);
	PC.ConstantGlowScale =-3;
	Sleep(0.1);
	PC.ConstantGlowScale =0;
	Sleep(0.2);
	PC.ConstantGlowScale =-3;
	Sleep(0.1);
	PC.ConstantGlowScale =0;
	Sleep(0.5);
	PC.ConstantGlowScale =-3;
	Sleep(0.1);
	PC.ConstantGlowScale =0;
	Sleep(0.2);
	PC.ConstantGlowScale =-5;
	Sleep(0.1);
	PC.ConstantGlowScale =0;
	Sleep(0.5);

	PC.FilterColorWanted.R=255;
	PC.FilterColorWanted.G=255;
	PC.FilterColorWanted.B=255;
	PC.FilterColorSpeed=1;
//	PC.ClientFlash( -3.2, vect(2550,2550,2550));
	PC.DesiredFlashScale=2.0;
	PC.ConstantGlowScale=-1.0;
	PC.ConstantGlowFog=vect(0.5,0.5,0.5);

	if ( /*EventBeginBeginFlash!='' &&*/ IndexCurrentFlash==0 || !(Level.Title~="Plage00") )
		TriggerEvent( EventBeginBeginFlash, none, none);
}

STATE FinIntroFlash
{
	EVENT BeginState( )
	{
		LOCAL Actor RefDepart;
		LOCAL Actor RefArrivee;

		RefDepart = Flash[ IndexCurrentFlash ].StartReference;
		RefArrivee = Flash[ IndexCurrentFlash ].ArrivalReference;

		if (RefArrivee!=none)
		{
			if (RefDepart==none)
			{
				if ( IndexCurrentFlash == 0 )
				{
					MemPos = Player.Location;
					MemRot = PC.Rotation;
				}
				PC.SetLocation( RefArrivee.Location );
				Player.SetLocation( RefArrivee.Location );
				Player.ShouldCrouch(false);
				Player.EndCrouch(Player.CollisionHeight - Player.CrouchHeight);
				PC.SetRotation( RefArrivee.Rotation );
				Player.SetRotation( RefArrivee.Rotation );
			}
			else
			{
				if ( IndexCurrentFlash == 0 )
				{
					MemPos = Player.Location;
					MemRot = PC.Rotation;
				}
				PC.SetLocation( Player.Location + RefArrivee.Location - RefDepart.Location );
				Player.SetLocation( PC.Location );
//				PC.SetRotation(RefArrivee.Rotation);
//				Player.SetRotation(RefArrivee.Rotation);
			}
		}
		if ( Event != '' )
			TriggerEvent( Event, self, none );
	}
begin:
	PC.GotoState( 'PlayerWalking' );
//	if (Flash[IndexCurrentFlash].bMemDuck /*&& !PC.bWantsToCrouch*/)
//	{
//		sleep(1);
//		PC.bAltDuck = 1;
//		sleep(0.1);
//		PC.bAltDuck = 0;
//	}
//	PC.bAltDuck = 0;
	PC.FilterColorWanted.R = 128;
	PC.FilterColorWanted.G = 128;
	PC.FilterColorWanted.B = 128;
	PC.FilterColorSpeed = 1;
	PC.ConstantGlowScale = 0;
	PC.ConstantGlowFog = vect( 0.5, 0.5, 0.5 );
	IndexCurrentFlash++;
	if ( EventEndBeginFlash!='' /*&& IndexCurrentFlash==0*/)
		TriggerEvent( EventEndBeginFlash, none, none);
}

STATE ExtroFlash
{
	EVENT BeginState()
	{
		SetTimer( 10, false );
	}
	EVENT Timer()
	{
		EndEndFlash();
	}
	EVENT EndState()
	{
		SetTimer( 0, false );

	}
begin:
	Sleep( 0.2 );
	PC.GotoState( 'NoControl' );
	Level.bCineFrame = false; // No frame with flashes
	PC.FilterColorWanted.R = 255;
	PC.FilterColorWanted.G = 255;
	PC.FilterColorWanted.B = 255;
	PC.FilterColorSpeed = 1;
	PC.DesiredFlashScale = 2.0;
	PC.ConstantGlowScale = -1.0;
	PC.ConstantGlowFog = vect( 0.5, 0.5, 0.5 );
	if ( EventBeginEndFlash!='')
		TriggerEvent( EventBeginEndFlash, none, none);
}

FUNCTION InitPlayerZone()
{
	PlayerZone = PC.Pawn.region.Zone;
	PlayerZone.FlashEffectDesc.IsActivated = true;
	PlayerZone.FlashEffectDesc.Contrast = 0;
	PlayerZone.FlashEffectDesc.Brightness = 255;
	PlayerZone.FlashEffectDesc.NoGrey=True;
	PlayerZone.FlashEffectDesc.LayerColor.R = 192;
	PlayerZone.FlashEffectDesc.LayerColor.G = 192;
	PlayerZone.FlashEffectDesc.LayerColor.B = 192;
	PlayerZone.FlashEffectDesc.LayerSampling[0] = 1.0;
	PlayerZone.FlashEffectDesc.LayerBrightness = 255;
	PlayerZone.FlashEffectDesc.LayerSampling[3] = 1.0;
	PlayerZone.FlashEffectDesc.LayerSampling[6] = 1.0;
	PlayerZone.FlashEffectDesc.LayerSampling[7] = 1.0;
}

STATE FinExtroFlash
{
begin:
//	Sleep(0.1);
//	if( Flash[ IndexCurrentFlash ].bMemDuck && !Player.bIsCrouched /*&& (PC.bAltDuck==0)*/)
//	{
//		PC.bAltDuck = 1;
//		Sleep( 0.01 );
//	}

	XIIIGameInfo( Level.Game ).MapInfo.RestoreInventoryAfterFlash( Player );
	Player = XIIIPawn( PC.Pawn ); // Real Player Pawn
	Player.bCanCrouch = true;
//	PC.PlayerInput.bForceCrouch = Flash[ IndexCurrentFlash ].bMemDuck;
	Sleep(0.1);
//	PC.SetLocation( MemPos );
//	while ( !Player.SetLocation( MemPos ) )
//		sleep ( 0.03 );
	PC.SetRotation( MemRot );
	Player.SetRotation( MemRot );
	Player.Velocity=vect(0,0,0);
	Player.Acceleration=vect(0,0,0);
//	if( Flash[ IndexCurrentFlash ].bMemDuck && !Player.bIsCrouched && ( PC.bAltDuck == 1) )
//		PC.bAltDuck = 0;
	PC.FilterColorWanted.R = 128;
	PC.FilterColorWanted.G = 128;
	PC.FilterColorWanted.B = 128;
	PC.FilterColorSpeed = 1;
	PC.ConstantGlowScale = 0;
	PC.ConstantGlowFog = vect( 0.5, 0.5, 0.5 );
	PC.GotoState( 'PlayerWalking' );

//	log("FinExtroFlash : CODE LATENT");
	Alpha=1;
	InitPlayerZone();
	TriggerEvent( EventEndEndFlash, none, none);
	sleep( 0.25 );
	PC.bGodMode = bGod;
	Player.SpeedFactorLimit = MemSpeedFactorLimit;
	Player.SetGroundSpeed( 1.0 );

	GotoState( 'FeedBackFlashEnd' );
}
MapInfo
for your own objectives and goal, you have to subclass it and place it in your map. (you can also reuse an existing one)

Code: Select all

//=============================================================================
//
//=============================================================================
class MapInfo extends Info
    abstract;

#exec Texture Import File=Textures\mapinfo_ico.tga Name=MapInfo_ico Mips=Off
#exec OBJ LOAD FILE=XIIICine.utx PACKAGE=XIIICine

var bool DBObjectives;
var() bool bBriefing;                                   // Do we have a briefing
var() bool NextMapKeepInventory;                        // Keep the inventory (Weapons/items) in the next map
var bool bLevelComplete;
var bool bFirstTime;
var bool EndCartoonEffect;

var() array<xiiipawn> PotentialNMi;

var(Shadows) int MaxTraceDistance;
var(Shadows) int ShadowIntensity;
var(Shadows) float ShadowMaxDist;
var(Shadows) float ShadowTransDist;
var float checkTime;
var XIIIPlayerController XIIIController;
var XIIIPawn XIIIPawn;

// ELR Memorize things for flashbacks
//var FakeXIIIPawn FakePawn;              // The pawn that will own our inventory until we're back
var XIIIPawn FakePawn;              // The pawn that will own our inventory until we're back

var int WeaponBeforeFlash;              // the weapon id we had in hand when going into flash
var PowerUps SelectedItemBeforeFlash;   // the item we had selected when going into flash

// Goal handling
struct XIIIGoals
{
    var() string GoalText;
    var bool bCompleted;
    var() bool bPrimary;
    var() bool bAntiGoal;
};

var(Objectifs) localized array<XIIIGoals> Objectif;
var(Objectifs) localized array<string> MessageGameOver;
var(Objectifs) localized string MessageMissionSuccess;

var string sIncompleteGoal;

var(Equipement) array< class<Inventory> > InitialInv;   // Inventory to give at the map start
var() string NextMapLevelWithUnr;                       // Next map to launch of objectives complete
var() texture NextLoadScreen;

var() localized string TexteDuBriefing;
var(NextMap) array<name> InventoryToDestroyBeforeNextMap;
var(NextMap) string EndMapVideo;


// MLK: Following vars are used to record spoken dialogs & to be able to consult the in the menu
var array<info> DlgMgr;     // this map dialog managers

struct DialIndex
{
    var byte Lineind, Speakerind;
};

var DialIndex _Dial;
var array<DialIndex> DialogToSave; // The structure that would be saved on disk
var array<string> sAllSentences; // Sentences for this map, separated by "scene"
var array<string> Speakers; // (Pawn) this map speakers -PawnName-, separated by "none"

//-----------------------------------------------------------------------------
// For dynamic load referencing by hand
// Forces some pointers to load (JOB)
var(ForcedLoading) array<texture> ForcedTextures;
var(ForcedLoading) array<mesh> ForcedMeshes;
var(ForcedLoading) array<staticmesh> ForcedStaticMeshes;
var(ForcedLoading) array<class> ForcedClasses;

var float MemFOVBeforeFlash;

//_____________________________________________________________________________
event ParseDynamicLoading(LevelInfo MyLI)
{
    local int i;
    Log("ParseDynamicLoading Actor="$self);
    if ( ForcedTextures.Length > 0 )
      for ( i=0; i< ForcedTextures.Length; i++ )
        MyLI.ForcedTextures[MyLI.ForcedTextures.Length] = ForcedTextures[i];
    if ( ForcedMeshes.Length > 0 )
      for ( i=0; i< ForcedMeshes.Length; i++ )
        MyLI.ForcedMeshes[MyLI.ForcedMeshes.Length] = ForcedMeshes[i];
    if ( ForcedStaticMeshes.Length > 0 )
      for ( i=0; i< ForcedStaticMeshes.Length; i++ )
        MyLI.ForcedStaticMeshes[MyLI.ForcedStaticMeshes.Length] = ForcedStaticMeshes[i];
    if ( ForcedClasses.Length > 0 )
      for ( i=0; i< ForcedClasses.Length; i++ )
      {
        MyLI.ForcedClasses[MyLI.ForcedClasses.Length] = ForcedClasses[i];
        if ( class<Inventory>(ForcedClasses[i]) != none )
    			class<Inventory>(ForcedClasses[i]).Static.StaticParseDynamicLoading(MyLI);
      }
    if ( InitialInv.Length > 0 )
      for ( i=0; i< InitialInv.Length; i++ )
      {
        if ( InitialInv[i] != none )
        {
          MyLI.ForcedClasses[MyLI.ForcedClasses.Length] = InitialInv[i];
    			InitialInv[i].Static.StaticParseDynamicLoading(MyLI);
    		}
      }
}

//_____________________________________________________________________________
function PostBeginPlay()
{
    local int i;

    for (i = 0; i < Objectif.Length; i++)
    {
      if ( Objectif[i].bAntiGoal )
        Objectif[i].bCompleted = true;
      else
        Objectif[i].bCompleted = false;
    }

    // start the script
    SetTimer(checkTime, false);
    bLevelComplete = false;

    // MLK: Better here for compatibility, FirstFrame() is executed too late
    XIIIGameInfo(Level.Game).MapInfo = self;
}

//_____________________________________________________________________________
function Timer()
{
    if ( bFirstTime )
      FirstFrame();
    if (!bLevelComplete)
      TestGoalComplete();
}

//_____________________________________________________________________________
function FirstFrame()
{
    local int i;

//    for (i=0; i<MessageGameOver.Length; i++)
//      Log("#### MessageGameOver["$i$"]="$MessageGameOver[i]);

    XIIIGameInfo(Level.Game).MapInfo=self;
    XIIIController=FindPlayerController();
    XIIIPawn=XIIIPawn(XIIIController.Pawn);
    SetupInitialInventory(XIIIPawn);
    bFirstTime=false;
    for (i=0; i<Objectif.Length; i++)
    {
      if ( Objectif[i].bPrimary && (!Objectif[i].bCompleted || Objectif[i].bAntiGoal) )
        DisplayGoal(i, false);
    }

    if ( Level.Game.GoreLevel != 0 )
    {
// PARENTAL LOCL ON
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.blodspotA', Texture'XIIICine.effets.blodspotAPL' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.bloodheadshotA', Texture'XIIICine.effets.bloodheadshotAPL' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.bloodprojM', Texture'XIIICine.effets.bloodprojMPL' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.goutteblood', Texture'XIIICine.effets.gouttebloodPL' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.jikleblood', Texture'XIIICine.effets.jiklebloodPL' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.projectionblodA', Texture'XIIICine.effets.projectionblodAPL' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.vignetteblood', Texture'XIIICine.effets.vignettebloodPL' );
	}
	else
	{
// PARENTAL LOCL OFF
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.blodspotAPL', Texture'XIIICine.effets.blodspotA' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.bloodheadshotAPL', Texture'XIIICine.effets.bloodheadshotA' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.bloodprojMPL', Texture'XIIICine.effets.bloodprojM' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.gouttebloodPL', Texture'XIIICine.effets.goutteblood' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.jiklebloodPL', Texture'XIIICine.effets.jikleblood' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.projectionblodAPL', Texture'XIIICine.effets.projectionblodA' );
//		ReplaceATextureByAnOther( Texture'XIIICine.effets.vignettebloodPL', Texture'XIIICine.effets.vignetteblood' );
	}

    TriggerEvent('MapStart',self,none);
}

//_____________________________________________________________________________
function XIIIPlayerController FindPlayerController()
{
    local Controller C;
    for( C=Level.ControllerList; C!=None; C=C.nextController )
        if( C.IsA('XIIIPlayerController') )
        {
            return XIIIPlayerController(C);
        }
    return none;
}

//_____________________________________________________________________________
function Inventory GiveSomething(class<Inventory> ItemClass, XIIIPawn P)
{
  local Inventory NewItem;

  if( P.FindInventoryType(ItemClass)==None )
  {
    NewItem = Spawn(ItemClass,,,P.Location);
    if( NewItem != None )
      NewItem.GiveTo(P);
  }
  else
  {
    NewItem = P.FindInventoryType(ItemClass);
    if ( Ammunition(NewItem) != none )
      Ammunition(NewItem).AddAmmo(Class<Ammunition>(ItemClass).default.AmmoAmount);
//      Ammunition(NewItem).AmmoAmount += Class<Ammunition>(ItemClass).default.AmmoAmount;
  }
  return NewItem;
}

//_____________________________________________________________________________
function SetUpInitialInventory(XIIIPawn P)
{
    local int i;

    if ( P.IsPlayerPawn() )
      Log("### SetUpInitialInventory for "$P);
    for (i=0; i<InitialInv.Length; i++)
    {
      GiveSomething(InitialInv[i], P);
    }
    if ( P.IsPlayerPawn() )
      Log("### END SetUpInitialInventory");
}

//_____________________________________________________________________________
// Save the player's inventory to give him whatever we want in a flashback
function bool SaveInventoryForFlash(XIIIPawn P)
{
//    local FakeXIIIPawn FP;
    local XIIIPawn FP;
    local weapon W;
    local XIIIItems XI;

    if ( FakePawn != none )
      return true;

    // We do create the fake pawn that will hold the player's inventory
//    FP=Spawn(class'FakeXIIIPawn',,,P.Location);
    XIIIPawn.SetCollision(true, false, false);
    XIIIPawn.SetDrawType(DT_None);
    XIIIPawn.bIsInCine = true;
    class'XIIIPlayerPawn'.default.bCollideWorld = false;
//    class'XIIIPlayerPawn'.default.bCollideWhenPlacing = false;
    FP = Spawn(class'XIIIPlayerPawn',,,P.Location);
//    class'XIIIPlayerPawn'.default.bCollideWhenPlacing = true;
    class'XIIIPlayerPawn'.default.bCollideWorld = true;
    if ( FP != none )
    {
      Level.Game.AddDefaultInventory(FP);
      FP.SetRotation(XIIIPawn.Rotation);
      FakePawn = FP;
      XIIIWeapon(XIIIPawn.Weapon).UnFire(0); // ELR Make weapon react like if release fire (to disable grenad pb)
      XIIIController.UnPossess();
      XIIIController.Possess(FP);
      XIIIController.SetViewTarget(FP);
      MemFOVBeforeFlash = XIIIController.FOVAngle;
      XIIIController.FOVAngle = XIIIController.DefaultFOV;
      XIIIController.DesiredFOV = XIIIController.DefaultFOV;

//    [FRD] inscription a la basesoldierlist
  		level.game.BaseSoldierList.Length = level.game.BaseSoldierList.Length + 1;
      level.game.BaseSoldierList[level.game.BaseSoldierList.Length - 1] = FP;

      FP.SetRotation(XIIIPawn.Rotation);
      if ( XIIIPawn.bIsCrouched )
      {
        FP.ShouldCrouch(true);
        FP.StartCrouch(FP.CollisionHeight - FP.CrouchHeight);
        FP.EyeHeight = FP.BaseEyeHeight;
      }
      FP.bCollideWorld = true;
      FP.EyeHeight = FP.BaseEyeHeight;
      FP.SetCollision(true,true,true);
      Log("### Saving inventory before flash FakePawn="$FakePawn@"XIIIPawn="$XIIIPawn);
      return true;
    }
    // If unable to spawn playerpawn then
    Log("### BIG BUG ### COULD NOT SAVE INVENTORY BEFORE FLASH !!!");
    return false;
}

//_____________________________________________________________________________
// Restore the player's inventory after a flashback
function bool RestoreInventoryAfterFlash(XIIIPawn P)
{
	local int i;
    Log("### Restoring inventory before flash FakePawn="$FakePawn@"XIIIPawn="$XIIIPawn);
    if (FakePawn != none)
    {
		//    [FRD] suppression de la basesoldierlist
		for (i = 0; i <level.game.BaseSoldierList.Length; i++)
		{
			if (level.game.BaseSoldierList[i] == FakePawn )
			{
				level.game.BaseSoldierList.Remove(i,1);
				break;
			}
		}
		//
      XIIIController.UnPossess();
      XIIIController.Possess(XIIIPawn);
      XIIIController.SetViewTarget(XIIIPawn);
      XIIIController.FOVAngle = MemFOVBeforeFlash;
      XIIIController.DesiredFOV = MemFOVBeforeFlash;

      XIIIPawn.SetCollision(true, True, true);
      XIIIPawn.SetDrawType(DT_Mesh);
      XIIIPawn.bIsInCine = false;
      if ( XIIIPawn.bIsCrouched )
      {
        XIIIPawn.ShouldCrouch(true);
        XIIIPawn.StartCrouch(XIIIPawn.CollisionHeight - XIIIPawn.CrouchHeight);
        XIIIPawn.EyeHeight = XIIIPawn.BaseEyeHeight;
      }
      Log("   Restoring Weapon/Item Status WeaponMode ?"@XIIIController.bWeaponMode);
      if ( XIIIController.bWeaponMode )
      {
        Log("   WeaponMode, Weapon="$XIIIPawn.Weapon);
        if ( XIIIPawn.Weapon.HasAmmo() )
          XIIIPawn.Weapon.GotoState('Idle');
        else
        {
          XIIIController.NextWeapon();
          XIIIPawn.Weapon.gotoState('DownWeapon');
        }
      }
      else
      {
        Log("   ItemMode, Item="$XIIIPawn.SelectedItem);
        if ( XIIIPawn.SelectedItem != none )
          XIIIPawn.SelectedItem.GotoState('Idle');
        else
        {
          XIIIController.NextWeapon();
          XIIIPawn.ChangedWeapon();
        }
      }
      FakePawn.Destroy();
      FakePawn = none;
      return true;
    }
    return false;
}

//_____________________________________________________________________________
function PostRender(canvas C);

//_____________________________________________________________________________
function SetGoalComplete(int N)
{
    local string S;
    local string sGameOver;

    if (DBObjectives) Log("SetGoalComplete "$N);

    if ( Level.Game.bGameEnded )
      return;

    if ( N >= Objectif.Length )
      return;

    if ( Objectif[N].bAntiGoal && Objectif[N].bPrimary )
    {
      // too bad, game over.
      Objectif[N].bCompleted = false;
      sGameOver = sIncompleteGoal$MessageGameOver[N];
      Level.Game.EndGame( XIIIController.PlayerReplicationInfo, sGameOver );
      return;
    }

    Objectif[N].bCompleted = true;

    XIIIController.MyHUD.LocalizedMessage( class'XIIIGoalMessage', 1, XIIIController.PlayerReplicationInfo, none, self, Objectif[N].GoalText );
    TestGoalComplete();
    if ( bLevelComplete )
      DoTravel();
}

//_____________________________________________________________________________
FUNCTION DoTravel()
{
    LOCAL Inventory inv, inv2;
    LOCAL int i;

    Level.Game.EndGame( XIIIController.PlayerReplicationInfo, "GoalComplete" );

    Inv = XIIIPawn.Inventory;
    while ( Inv!=none )
    {
      Inv2 = Inv.Inventory; // Memorize next inventory
      if ( ( Inv.IsA('Keys') && !Inv.IsA('LockPick') ) || Inv.IsA('MagneticCard') )
        Inv.Destroy();
      if ( inv.IsA('Weapon') && (Weapon(inv).WHand == WHA_Deco) )
      {
        if ( XIIIPawn.Weapon == inv )
          XIIIPawn.Weapon = none;
        inv.Destroy();
      }
      Inv=Inv2;
    }

    for ( i=0; i<InventoryToDestroyBeforeNextMap.Length;i++)
    {
      while( true )
      {
        inv = XIIIPawn.FindInventoryKind( InventoryToDestroyBeforeNextMap[i] );
        if (inv == none)
          break;
        inv.Destroy();
      }
    }
}

//_____________________________________________________________________________
// Goal Become primary
function SetPrimaryGoal(int N)
{
    if (DBObjectives) Log("SetPrimaryGoal "$N);
    if ( !Objectif[N].bPrimary )
    {
      Objectif[N].bPrimary = true;
      DisplayGoal(N, true);
    }
}

//_____________________________________________________________________________
// Goal is not primary anymore
function SetSecondaryGoal(int N)
{
    if (DBObjectives) Log("SetSecondaryGoal "$N);
    if ( Objectif[N].bPrimary )
    {
      Objectif[N].bPrimary = false;
    }
}

//_____________________________________________________________________________
// Send goal to display
function DisplayGoal(int N, optional bool bDelay)
{
    if (DBObjectives) Log("Display Goal "$N$" delay="$bDelay);
//    XIIIController.ClientMessage( Objectif[N].GoalText, 'GoalType');
    if ( Objectif[N].bAntiGoal )
    {
      if (Objectif[N].GoalText != "")
      {
        if ( bDelay )
            XIIIController.MyHUD.LocalizedMessage( class'XIIIGoalMessage', 10, XIIIController.PlayerReplicationInfo, none, self, Objectif[N].GoalText );
          else
            XIIIController.MyHUD.LocalizedMessage( class'XIIIGoalMessage', 2, XIIIController.PlayerReplicationInfo, none, self, Objectif[N].GoalText );
      }
    }
    else if ( bDelay )
      XIIIController.MyHUD.LocalizedMessage( class'XIIIGoalMessage', 8, XIIIController.PlayerReplicationInfo, none, self, Objectif[N].GoalText );
    else
      XIIIController.MyHUD.LocalizedMessage( class'XIIIGoalMessage', 0, XIIIController.PlayerReplicationInfo, none, self, Objectif[N].GoalText );
}

//_____________________________________________________________________________
function TestGoalComplete()
{
    local int t, MissionEnd;

    if (DBObjectives) log("Testing goal");
    if (Objectif.Length > 0)
    {
      MissionEnd = 0;
      for (t = 0; t < Objectif.Length; t++)
      {
        if (Objectif[t].bCompleted) MissionEnd++;
      }

//      log("Objectives="$Objectif.Length$" MissionEnd="$MissionEnd);
      if (MissionEnd == Objectif.Length)
      {
        bLevelComplete = true;
      }
    }
    for (t = 0; t < Objectif.Length; t++)
      if (DBObjectives) log("  > Objective "$t$" Primary ? "$Objectif[t].bPrimary$" complete ?"$Objectif[t].bCompleted$" bAntiGoal ?"$Objectif[t].bAntiGoal);
}

//_____________________________________________________________________________
function CloseDoor(XIIIMover P, bool bLock)
{
    if ( !P.bClosed )
      P.PlayerTrigger(self, XIIIPawn);
    if ( bLock )
      p.BloqueePourLeJoueur = Les2Sens;
}

//_____________________________________________________________________________
// tell self that a pawn has been generated (to be taken into account if necessary)
function GeneratedPawn(Actor Generator, Pawn Other);




defaultproperties
{
     DBObjectives=True
     NextMapKeepInventory=True
     bFirstTime=True
     MaxTraceDistance=250
     ShadowIntensity=196
     ShadowMaxDist=1500.000000
     ShadowTransDist=1000.000000
     checkTime=0.100000
     MessageMissionSuccess="Level Completed"
     sIncompleteGoal="GoalIncomplete:"
     //Texture=Texture'XIII.MapInfo_ico'
}


STATE FeedBackFlashEnd
{
	EVENT Tick( float dt )
	{
//LOG(".....Player.SpeedFactorLimit ="@Player.SpeedFactorLimit@Player.GroundSpeed@Player.default.GroundSpeed);
		Alpha -= dt/FeedBackFlashEndDuration;
		if ( PlayerZone != PC.Pawn.region.Zone )
		{
			PlayerZone.FlashEffectDesc.IsActivated = false;
			InitPlayerZone();
		}
		if ( Alpha < 0 )
		{
			PlayerZone.FlashEffectDesc.IsActivated = false;
			if ( EventPostFeedback!='')
				TriggerEvent( EventPostFeedback, none, none);
			GotoState( '' );
			return;
		}
		PlayerZone.FlashEffectDesc.LayerColor.R = 255 * Alpha;
		PlayerZone.FlashEffectDesc.LayerColor.G = 255 * Alpha;
		PlayerZone.FlashEffectDesc.LayerColor.B = 255 * Alpha;
		PlayerZone.FlashEffectDesc.LayerSampling[0] = 1.0 - 0.6 * Alpha;
		PlayerZone.FlashEffectDesc.LayerSampling[1] = 1.0 - 0.6 * Alpha;
		PlayerZone.FlashEffectDesc.LayerSampling[2] = 1.0 - 0.45 * Alpha;
		PlayerZone.FlashEffectDesc.LayerSampling[3] = 1.0 - 0.45 * Alpha;
		PlayerZone.FlashEffectDesc.LayerSampling[4] = 1.0 - 0.25 * Alpha;
		PlayerZone.FlashEffectDesc.LayerSampling[5] = 1.0 - 0.25 * Alpha;
	}

	EVENT BeginState( )
	{
//		log("FeedBackFlashEnd : BeginState");
    PC.PlayerInput.bForceCrouch = false;
	}
}




defaultproperties
{
     FeedBackFlashEndDuration=3.000000
     bAlwaysRelevant=True
     Tag="FM"
     Texture=Texture'XIDCine.Flash_ico'
}
User avatar
Pandemonium
Average
Posts: 45
Joined: Sun Apr 27, 2008 8:16 pm
Personal rank: for h.exe = 0 to 665
Location: Germany

Re: Flashback effect

Post by Pandemonium »

You cannot just copy the code and recompile it. XIII is UnrealEngine 2.x, UT is UnrealEngine1. There are more than a few differences in the Playercontroller- and Gameinfo-classes and references.

-
User avatar
Shadow
Masterful
Posts: 743
Joined: Tue Jan 29, 2008 12:00 am
Personal rank: Mad Carpenter
Location: Germany
Contact:

Re: Flashback effect

Post by Shadow »

I'm open for mostly any sophisticated ideas, when I'm updating the Post Processing System I will consider implementing that kind of effect since I have to include a lot of other state-of-the-art effects like DOF, Blur, Framebuffer Distortion etc.

Anyone can use the chance to post new ideas for the SDK, so yeah do it! It's called UT COMMUNITY SDK ;P
Image
Post Reply