## XIII
Class CWndFocusTrigger

source: C:\XIII\XIII\Classes\CWndFocusTrigger.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Triggers
             |
             +--XIII.XIIITriggers
                |
                +--XIII.CWndFocusTrigger

Direct Known Subclasses:None

class CWndFocusTrigger
extends XIII.XIIITriggers

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`name` | `EventFinFocus` Number of times the trigger can occur
`Actor` | `Focus` the actor to focus.
`float` | `FocusDuration` duration of focus drawing.
`float` | `TriggerDistance` max Distance to trigger focus
`bool` | `bDanger` Use the vignette when zoomed.
`bool` | `bRequireSixSenseSkill` SixSenseSkill is requireed to trigger the Focus
`bool` | `bUseVignette` Use the vignette when zoomed.
`enum` | `eCWndFocusAppear` the actor to focus.
`enum` | `eCWndFocusSoundType` Number of times the trigger can occur
`sound` | `hCWndFocus[2]` Number of times the trigger can occur
`int` | `iTriggerCount` Number of times the trigger can occur
`float` | `zoomDistance` Number of times the trigger can occur
`float` | `zoomFOV` Number of times the trigger can occur
`bool` | `zoomFocus` Use the vignette when zoomed.

States
WaitEndFocus

State WaitEndFocus Function Summary

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class CWndFocusTrigger extends XIIITriggers;
    00005
    00006	var() bool bRequireSixSenseSkill; // SixSenseSkill is requireed to trigger the Focus
    00007	var() bool bUseVignette;          // Use the vignette when zoomed.
    00008	var() bool bDanger;
    00009	var() bool zoomFocus;
    00010
    00011	var() float TriggerDistance;      // max Distance to trigger focus
    00012	var() float FocusDuration;        // duration of focus drawing.
    00013	var() actor Focus;                // the actor to focus.
    00014	var() enum eCWndFocusAppear
    00015	{
    00016	  ECWFA_Zoom,
    00017	  ECWFA_Lines,
    00018	} CWndFocusAppearFX;              // appearance FX (only Zoom handled now)
    00019	var() int iTriggerCount;          // Number of times the trigger can occur
    00020	var() enum eCWndFocusSoundType
    00021	{
    00022	    CFSTYPE_None,
    00023	    CFSTYPE_Focus,
    00024	    CFSTYPE_FocusWarn,
    00025	} CWndFocusSoundType;
    00026	var() name EventFinFocus;
    00027	var sound hCWndFocus[2];
    00028	var() float zoomDistance;
    00029	var() float zoomFOV;
    00030
    00031	//____________________________________________________________________
    00032	event PostBeginPlay()
    00033	{
    00034	    DebugLog(self@"PostBeginPlay Focus="$Focus);
    00035	    if ( (Focus == none) || Focus.bDeleteMe )
    00036	    {
    00037	      Focus = none; // if it was bDeleteMe
    00038	      Destroy();
    00039	      return;
    00040	    }
    00041	    Super.PostBeginPlay();
    00042	}
    00043
    00044	//____________________________________________________________________
    00045	auto state() WaitForBeingSeen
    00046	{
    00047	    event BeginState()
    00048	    {
    00049	      SetTimer(1.0, false);
    00050	      if ( (focus.isa('gennmi') || focus.isa('GenPlongeurs')) && (focus.instigator != none) )
    00051	        focus=focus.instigator;
    00052	    }
    00053
    00054	    event Timer()
    00055	    { // Only called in solo mode
    00056	      local float fTime, fDist;
    00057	      local XIIIPlayerPawn XPP;
    00058	      local actor A;
    00059	      local vector HitLoc, HitNorm;
    00060	      local material HitMat;
    00061
    00062	//      DebugLog(self@"WaitForBeingSeen Timer Focus="$Focus@" bDeleted ?"$Focus.bDeleteMe);
    00063	      if ( (Focus == none) || Focus.bDeleteMe )
    00064	      { // check just in case Focus destroyed in-game
    00065	        Focus = none; // if it was bDeleteMe
    00066	        Destroy();
    00067	        return;
    00068	      }
    00069	      if ( (Level.Game == none) || (XIIIGameInfo(Level.Game).MapInfo == none) || (XIIIGameInfo(Level.Game).MapInfo.XIIIPawn == none) )
    00070	      {
    00071	        SetTimer(2.0, false);
    00072	        return;
    00073	      }
    00074	      XPP = XIIIPlayerPawn(XIIIGameInfo(Level.Game).MapInfo.XIIIPawn);
    00075	      if ( (XPP == none) || (XPP.Controller == none) )
    00076	      {
    00077	        SetTimer(2.0, false);
    00078	        return;
    00079	      }
    00080	      if ( bRequireSixSenseSkill && ((XPP.SSSk == none) || !XPP.SSSk.bImOn) )
    00081	      {
    00082	        SetTimer(2.0, false);
    00083	        return;
    00084	      }
    00085
    00086	      fDist = vSize(XPP.Location - Focus.Location);
    00087	      if ( (fDist < TriggerDistance) && ((Focus.Location - XPP.Location) dot vector(XPP.Controller.Rotation) > 0.757) )
    00088	      { // if player see me create focus
    00089	        A = Trace(HitLoc, HitNorm, Focus.Location, XPP.Location, true, vect(0,0,0), HitMat, TRACETYPE_DiscardIfCanSeeThrough);
    00090	        if ( (A == none) || (A == Focus) )
    00091	        {
    00092	//          Log("FOCUS PlayingSound type"@CWndFocusSoundType);
    00093	          if ( CWndFocusSoundType > 0 )
    00094	            XPP.PlaySound(hCWndFocus[CWndFocusSoundType-1]);
    00095	          else
    00096	            XPP.PlaySound(hCWndFocus[0]);
    00097
    00098	          // Long-lasting focuses disabled by events
    00099	          if ( EventFinFocus != '')
    00100	          {
    00101	            tag = EventFinFocus;
    00102	            FocusDuration = -1;
    00103	            XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[XIIIBaseHud(PlayerController(XPP.controller).MyHud).eNbHudCartoonFocus] = self;
    00104	            XIIIBaseHud(PlayerController(XPP.controller).MyHud).AddHudCartoonFocus(Focus, CWndFocusAppearFX, bUseVignette, FocusDuration, zoomFocus, zoomFOV, zoomDistance, bDanger);
    00105	            GotoState('WaitEndFocus');
    00106	            return;
    00107	          }
    00108	          else
    00109	          {
    00110	            XIIIBaseHud(PlayerController(XPP.controller).MyHud).AddHudCartoonFocus(Focus, CWndFocusAppearFX, bUseVignette, FocusDuration, zoomFocus, zoomFOV, zoomDistance, bDanger);
    00111
    00112	            iTriggerCount --;
    00113	            TriggerEvent( Event, Self, XPP );
    00114	            if ( iTriggerCount <= 0 )
    00115	              Destroy();
    00116	            else
    00117	              SetTimer(FocusDuration + 1.0, false);
    00118	            return;
    00119	          }
    00120	        }
    00121	      }
    00122	      fTime = (fDist-TriggerDistance) / XPP.GroundSpeed;
    00123	      fTime *= 0.666; // security factor
    00124	      fTime = fMax(0.5, fTime); // wait a min time
    00125	      SetTimer(fTime, false);
    00126	    }
    00127	}
    00128
    00129	//____________________________________________________________________
    00130	state() WaitForBeingTriggered
    00131	{
    00132	    event Trigger( actor Other, pawn EventInstigator )
    00133	    {
    00134	      GotoState('WaitForBeingSeen');
    00135	    }
    00136	}
    00137
    00138	//_____________________________________________________________________
    00139	state WaitEndFocus
    00140	{
    00141	    event Trigger(actor Other, pawn EventInstigator )
    00142	    {
    00143	      local XIIIPlayerPawn XPP;
    00144	      local int i,j;
    00145
    00146	      // on determine le cartoon focus a eliminer a partir des tableaux dans XIIIBaseHud
    00147	      XPP = XIIIPlayerPawn(XIIIGameInfo(Level.Game).MapInfo.XIIIPawn);
    00148	      while (XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[i] != self)
    00149	      {
    00150	        i ++;
    00151	      }
    00152	      //log(self@" ---> DESTRUCTION DE"@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[i]@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[i]);
    00153	      XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[i].RemoveMe();
    00154
    00155	      for (j=i;j<XIIIBaseHud(PlayerController(XPP.controller).MyHud).eNbHudCartoonFocus;j++)
    00156	      {
    00157	        XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[j] = XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[j + 1];
    00158	        XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[j] = XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[j + 1];
    00159	      }
    00160	      XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[XIIIBaseHud(PlayerController(XPP.controller).MyHud).eNbHudCartoonFocus] = none;
    00161	      XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[XIIIBaseHud(PlayerController(XPP.controller).MyHud).eNbHudCartoonFocus] = none;
    00162	      XIIIBaseHud(PlayerController(XPP.controller).MyHud).eNbHudCartoonFocus --;
    00163
    00164	      //log(self@" --->"@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[0]@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[1]@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tCartoonFocus[2]);
    00165	      //log(self@" --->"@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[0]@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[1]@XIIIBaseHud(PlayerController(XPP.controller).MyHud).tFocusTrigger[2]);
    00166
    00167	      Destroy();
    00168	    }
    00169	}
    00170
    00171
    00172	defaultproperties
    00173	{
    00174	     TriggerDistance=800.000000
    00175	     FocusDuration=3.000000
    00176	     iTriggerCount=1
    00177	     hCWndFocus(0)=Sound'XIIIsound.Interface__VignettesFx.VignettesFx__hFocus'
    00178	     hCWndFocus(1)=Sound'XIIIsound.Interface__VignettesFx.VignettesFx__hFocusWarning'
    00179	     zoomDistance=200.000000
    00180	     zoomFOV=50.000000
    00181	     bCollideActors=False
    00182	}

End Source Code