## XIII
Class XIIIPlayerInteraction

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

    Core.Object
       |
       +--Engine.Interactions
          |
          +--Engine.Interaction
             |
             +--XIII.XIIIPlayerInteraction

Direct Known Subclasses:XIIIMPBotInteraction

class XIIIPlayerInteraction
extends Engine.Interaction

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

Variables
`rotator` | `AdjustedAim` Crosshair drawn
`Texture` | `BreakTex` Breakable interaction icons
`Texture` | `CH` Crosshair drawn
`float` | `CrosshairAlpha` Crosshair drawn
`Texture` | `DecoWeaponTex` Grab 'decoration' that can be used as a weapon
`Texture` | `DotTex` Tyrol Points
`array` | `EasyInteractives` Crosshair drawn
`Actor` | `FiringTargetActor` just to avoid thousands class-castings
`Texture` | `GrabItemTex` Std Icon, normal = grab std pickup
`Texture` | `GrapplePointTex` HookPoint can be hooked
`Texture` | `HealTex` Tyrol Points
`LevelInfo` | `Level` Because non-accessible by Objects (only actors)
`XIIIPlayerController` | `MyPC` just to avoid thousands class-castings
`Texture` | `NoShootTex` Tyrol Points
`ClosedDoorTex,` | `OpenAbleDoorTex` doors interactions icons
`vector` | `StartTrace` Crosshair drawn
`TakePrisonnerTex,` | `StunTex` Pawns interactions icons
`float` | `TargDist` just to avoid thousands class-castings
`FiringTargHitNorm,` | `TargHitNorm` just to avoid thousands class-castings
`Actor` | `TargetActor` just to avoid thousands class-castings
`Texture` | `TyrolTex` Tyrol Points
`XIIIItems` | `XItem` just to avoid thousands class-castings
`XIIIWeapon` | `XWeap` just to avoid thousands class-castings
`bool` | `bCanBreak` Can break item
`bool` | `bCanClimbDoor` Can climb a door (previous bool is true)
`bool` | `bCanDoor` can interact w/ a door
`bool` | `bCanGrabCorpse` can take corpse (grab someone dead)
`bool` | `bCanHeal` Can Heal self
`bool` | `bCanHook` have a hookpoint in target and hook in hand
`bool` | `bCanPickup` Can pickup something
`bool` | `bCanSearchCorpse` can search corpse (some dead)
`bool` | `bCanStun` Can stun (someone alive)
`bool` | `bCanTakePrisonner` can take prisonner (grab someone alive)
`bool` | `bCanTrigger` have a targetable trigger
`bool` | `bCanUnLockDoor` door is locked
`bool` | `bCantDoor` non interactive door
`bool` | `bCheckedEasyInteractives` Crosshair drawn
`bool` | `bDBDrawLog` to display differently
`bool` | `bDebugTrace`
`bool` | `bEasyInteractOn` to display differently

Function Summary
`void` | `DrawAction(Canvas C, int NbIcons, int index, Texture Tex)`
    //____________________________________________________________________
`simulated` | `DrawFixWeaponCrosshair(Canvas C)`
    //_____________________________________________________________________________
`bool` | `DrawInteractions(Canvas C)`
    //____________________________________________________________________
`void` | `DrawItemCrosshair(Canvas C)`
    //_____________________________________________________________________________
`simulated` | `DrawWeaponCrosshair(Canvas C)`
    //_____________________________________________________________________________
`bool` | `KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta)`
    //_____________________________________________________________________________
`void` | `ResetInteractions()`
    //____________________________________________________________________
`void` | `SwitchLog()`
    //_____________________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class XIIIPlayerInteraction extends Interaction;
    00005
    00006	var bool bDebugTrace;
    00007
    00008	var LevelInfo Level;            // Because non-accessible by Objects (only actors)
    00009	var XIIIPlayerController MyPC;  // just to avoid thousands class-castings
    00010	var XIIIWeapon XWeap;
    00011	var XIIIItems XItem;
    00012	var actor TargetActor;
    00013	var actor FiringTargetActor;
    00014	var vector FiringTargHitLoc, TargHitLoc, FiringTargHitNorm, TargHitNorm;
    00015	var float TargDist;
    00016
    00017	var bool bCanPickup;            // Can pickup something
    00018	var bool bCanHook;              // have a hookpoint in target and hook in hand
    00019	var bool bCanTrigger;           // have a targetable trigger
    00020	var bool bCanDoor;              // can interact w/ a door
    00021	var bool bCanClimbDoor;         // Can climb a door (previous bool is true)
    00022	var bool bCanUnLockDoor;        // door is locked
    00023	var bool bCantDoor;             // non interactive door
    00024	var bool bCanSearchCorpse;      // can search corpse (some dead)
    00025	var bool bCanGrabCorpse;        // can take corpse    (grab someone dead)
    00026	var bool bCanTakePrisonner;     // can take prisonner (grab someone alive)
    00027	var bool bCanStun;              // Can stun (someone alive)
    00028	var bool bCanBreak;             // Can break item
    00029	var bool bCanHeal;              // Can Heal self
    00030	var bool bEasyInteractOn;       // to display differently
    00031	var bool bDBDrawLog;
    00032
    00033	var texture GrabItemTex;        // Std Icon, normal = grab std pickup
    00034	var texture DecoWeaponTex;      // Grab 'decoration' that can be used as a weapon
    00035	var texture GrapplePointTex;    // HookPoint can be hooked
    00036	var texture OpenDoorTex, ClimbDoorTex, NoOpenDoorTex, ClosedDoorTex, OpenAbleDoorTex;    // doors interactions icons
    00037	var texture SearchBodyTex, TakeCorpseTex, TakePrisonnerTex, StunTex;    // Pawns interactions icons
    00038	var texture BreakTex;           // Breakable interaction icons
    00039	var texture TyrolTex;           // Tyrol Points
    00040	var texture NoShootTex;
    00041	var texture DotTex;
    00042	var texture HealTex;
    00043	var texture CH;                 // Crosshair drawn
    00044
    00045	var rotator AdjustedAim;
    00046	var vector StartTrace;
    00047	var float CrosshairAlpha;
    00048
    00049	var array<Actor> EasyInteractives;
    00050	var bool bCheckedEasyInteractives;
    00051
    00052	CONST INTERACTIONDIST=160.0;
    00053	CONST STUNDIST=100.0;
    00054	CONST STUNWITHDECODIST=150.0;
    00055
    00056	//_____________________________________________________________________________
    00057	function bool KeyEvent( EInputKey Key, EInputAction Action, FLOAT Delta )
    00058	{
    00059	    if ( Action!=IST_Press )
    00060	      return false;
    00061	    else if (Key == IK_Escape)
    00062	    {
    00063	    	MyPC.ShowMenu();
    00064	    	return true;
    00065	    }
    00066	    else if( Key==IK_Home )
    00067	    {
    00068	      bDebugTrace = !bDebugTrace;
    00069	      return true;
    00070	    }
    00071	    else
    00072	      return false;
    00073	}
    00074
    00075	//_____________________________________________________________________________
    00076	// EndMap - Prevent before to change of map.
    00077	simulated event EndMap()
    00078	{
    00079	    if ( (MyPC != none) && !Level.bLonePlayer && (Level.NetMode != NM_StandAlone) )
    00080	    { // OnLine
    00081	      MyPC.StatUpdate();
    00082	    }
    00083	    XItem = none;
    00084	    XWeap = none;
    00085	    MyPC = none;
    00086	    TargetActor = none;
    00087	    FiringTargetActor = none;
    00088	    Level = none;
    00089	}
    00090
    00091	//_____________________________________________________________________________
    00092	function SwitchLog()
    00093	{
    00094	    bDBDrawLog = !bDBDrawLog;
    00095	}
    00096
    00097	//_____________________________________________________________________________
    00098	simulated event MyPCPostRender(Canvas C)
    00099	{
    00100	    local bool bDrawWeaponCrosshair, bDrawItemCrosshair;
    00101	    local XIIIWeapon XW;
    00102	    local vector X,Y,Z;
    00103	    local float XLength;
    00104	    local bool bZoomed;
    00105	    local int i, TraceType;
    00106	    local material HitMat;
    00107	    local Actor oldtarget;
    00108	    local actor A;
    00109	    local float BestEasyInteract;
    00110	    CONST AUTOAIMMAXDIST=3000;
    00111
    00112	    if ( (MyPC != none) && !bCheckedEasyInteractives )
    00113	    {
    00114	      bCheckedEasyInteractives = true;
    00115	      foreach MyPC.AllActors(class'Actor', A)
    00116	        if ( A.bEaseInteract )
    00117	          EasyInteractives[EasyInteractives.Length] = A;
    00118	      if ( EasyInteractives.Length > 0 )
    00119	        for ( i = 0; i<EasyInteractives.Length; i++ )
    00120	          DebugLog("SETUP EASY interaction WITH"@i@"-"@EasyInteractives[i]);
    00121	    }
    00122
    00123	    ResetInteractions();
    00124
    00125	    oldtarget = TargetActor;
    00126
    00127	    if ( (MyPc == none) || (MyPC.Pawn == none) || MyPC.Pawn.bIsDead || MyPC.bBehindView )
    00128	      return;
    00129
    00130
    00131	    if ( (MyPC.ViewTarget != MyPC.pawn)
    00132	      || MyPC.IsInState('CameraView') || MyPC.IsInState('NoControl')
    00133	      || MyPC.IsInState('NoMove') || MyPC.IsInState('GameEnded')
    00134	      )
    00135	      return;
    00136
    00137	    C.bNoSmooth = false;
    00138	    C.Style = 5; //ERenderStyle.STY_Alpha;
    00139
    00140	    GetAxes(MyPC.Rotation,X,Y,Z);
    00141
    00142	    FiringtargetActor = none;
    00143	    MyPC.OldBestTarget = MyPC.BestTarget;
    00144	    MyPC.BestTarget = none;
    00145	    if ( MyPC.bWeaponMode )
    00146	    {
    00147	      if ( (MyPC.Pawn != none) && (MyPC.Pawn.Weapon != none) && (XIIIWeapon(MyPC.Pawn.Weapon) != none) )
    00148	      {
    00149	        XWeap = XIIIWeapon(MyPC.Pawn.Weapon);
    00150	        TraceType = XIIIAmmo(XWeap.AmmoType).TraceType;
    00151	        if ( (XWeap.WHand == WHA_Fist) || (XWeap.WHand == WHA_Deco) )
    00152	          StartTrace = XWeap.Instigator.Location + XWeap.Instigator.EyePosition();
    00153	        else
    00154	          StartTrace = XWeap.GetFireStart(X,Y,Z)+16*X;
    00155	        AdjustedAim = MyPC.AdjustAimForDisplay(XWeap.AmmoType, StartTrace);
    00156	        if ( XWeap.ShouldDrawCrosshair(C) )
    00157	        {
    00158	          bDrawWeaponCrosshair = true;
    00159	        }
    00160	        else
    00161	        {
    00162	          if ( XWeap.bZoomed || MyPC.bZooming )
    00163	          {
    00164	            if ( XWeap.ZCrossHair != none )
    00165	            {
    00166	              bZoomed=true;
    00167	              XWeap.bDrawZoomedCrosshair = true;
    00168	            }
    00169	            else
    00170	              bDrawWeaponCrosshair = true;
    00171	          }
    00172	        }
    00173	        X = vector(AdjustedAim);
    00174	        FiringTargetActor = MyPC.BestTarget;
    00175	        FiringTargHitLoc = fMax(XWeap.TraceDist, INTERACTIONDIST) * X + StartTrace;
    00176	        XWeap.AmmoType.WarnTarget( FiringTargetActor, XWeap.Instigator, X);
    00177	      }
    00178	      // compute interaction TargetActor
    00179	      StartTrace = MyPC.Pawn.Location + MyPC.Pawn.EyePosition();
    00180
    00181	      TargetActor = MyPC.ReturnTrace(TargHitLoc, TargHitNorm, INTERACTIONDIST * X + StartTrace, StartTrace, true);
    00182	      if ( CamViewTrigger(oldtarget) != none && CamViewTrigger(TargetActor) == none)
    00183	        { CamViewTrigger(oldtarget).UnLookedAt(MyPC.Pawn); }
    00184	    }
    00185	    else if ( (MyPC.Pawn != none) && (MyPC.Pawn.SelectedItem != none) && (XIIIItems(MyPC.Pawn.SelectedItem) != none) )
    00186	    {
    00187	      XItem = XIIIItems(MyPC.Pawn.SelectedItem);
    00188	      if ( XItem.ShouldDrawCrosshair(C) )
    00189	        bDrawItemCrosshair = true;
    00190	      //if ( (Micro(XItem) != none) && (Micro(XItem).bZoomed || MyPC.bZooming) )      // creates a dependency with micro
    00191	      if ( XItem.IsA('Micro') && (!XItem.ShouldDrawCrosshair(C) || MyPC.bZooming) )   // creates no dependency with micro, and since micro.ShouldDrawCrosshair() = !micro.bZoomed
    00192	      {
    00193	        bDrawItemCrosshair = false;
    00194	        XItem.bDrawZoomedCrosshair = true;
    00195	        bZoomed = true;
    00196	      }
    00197
    00198	      // compute interaction TargetActor
    00199	      StartTrace = MyPC.Pawn.Location + MyPC.Pawn.EyePosition();
    00200	      if ( Hook(MyPC.Pawn.SelectedItem) != none )
    00201	        TargetActor = MyPC.ReturnTrace(TargHitLoc, TargHitNorm, 10000 * X + StartTrace, StartTrace, true);
    00202	      else
    00203	        TargetActor = MyPC.ReturnTrace(TargHitLoc, TargHitNorm, INTERACTIONDIST * X + StartTrace, StartTrace, true);
    00204	      if ( CamViewTrigger(oldtarget) != none && CamViewTrigger(TargetActor) == none)
    00205	        { CamViewTrigger(oldtarget).UnLookedAt(MyPC.Pawn); }
    00206	    }
    00207	    else // should never happen but ?
    00208	    {
    00209	      TargetActor = none;
    00210	    }
    00211	    if ( TargetActor == none )
    00212	    { // check w/ all EaseInteract actors
    00213	      if ( EasyInteractives.Length > 0 )
    00214	      {
    00215	        BestEasyInteract = 0.80;
    00216	        for ( i = 0; i<EasyInteractives.Length; i++ )
    00217	        {
    00218	          if ( EasyInteractives[i].bDeleteMe )
    00219	          {
    00220	            EasyInteractives.Remove(i, 1);
    00221	            i--;
    00222	          }
    00223	          else if ( EasyInteractives[i].LastRenderTime > Level.TimeSeconds - 0.2 )
    00224	          {
    00225	            TargDist = vSize(EasyInteractives[i].Location - MyPC.Pawn.Location - MyPC.Pawn.EyePosition());
    00226	            if ( TargDist < INTERACTIONDIST )
    00227	            {
    00228	              if ( vector(MyPC.Rotation) dot normal(EasyInteractives[i].Location - MyPC.Pawn.Location - MyPC.Pawn.EyePosition()) > BestEasyInteract )
    00229	              {
    00230	                if ( MyPC.FastTrace( EasyInteractives[i].Location , MyPC.Pawn.Location + MyPC.Pawn.EyePosition()) )
    00231	                {
    00232	                  BestEasyInteract = vector(MyPC.Rotation) dot normal(EasyInteractives[i].Location - MyPC.Pawn.Location - MyPC.Pawn.EyePosition());
    00233	                  TargetActor = EasyInteractives[i];
    00234	                  bEasyInteractOn = true;
    00235	                }
    00236	              }
    00237	            }
    00238	          }
    00239	        }
    00240	      }
    00241	      if ( TargetActor != none )
    00242	      {
    00243	        TargDist = vSize(TargetActor.Location - MyPC.Pawn.Location - MyPC.Pawn.EyePosition());
    00244	        bEasyInteractOn = true;
    00245
} 00246 } 00247 else 00248 TargDist = vSize(TargHitLoc - StartTrace); 00249 00250 if ( bDBDrawLog ) 00251 Log(" we do have "$FiringTargetActor$"["$vSize(FiringTargHitLoc - StartTrace)$"] & "$TargetActor$"["$TargDist$"] in crosshair"); //$", TarHitLoc="$TargHitLoc$" bWeaponMode="$MyPC.bWeaponMode); 00252 00253 // if ( bDebugTrace && (TargetActor != none) ) 00254 // TargetActor.Spawn(class'BulletDustEmitter',,, TargHitLoc+TargHitNorm, Rotator(TargHitNorm)); 00255 00256 if ( !bZoomed && (TargetActor != none) && !TargetActor.bDeleteMe && !MyPC.IsInState('MayClimbDoor') && !MyPC.IsInState('ClimbDoor') && !MyPC.IsInState('ClimbToHookNavPoint') ) 00257 { 00258 if ( DrawInteractions(C) ) 00259 { 00260 bDrawWeaponCrosshair = false; 00261 bDrawItemCrosshair = false; 00262 } 00263 } 00264 if ( bDrawWeaponCrosshair ) 00265 { 00266 // if ( MyPC.bFixedCrosshair ) 00267 DrawFixWeaponCrosshair(C); 00268 // else 00269 // DrawWeaponCrosshair(C); 00270 } 00271 if ( bDrawItemCrosshair ) 00272 DrawItemCrosshair(C); 00273 } 00274 00275 /* 00276 //_____________________________________________________________________________ 00277 simulated function DrawWeaponCrosshair(Canvas C) 00278 { 00279 local int XLength; 00280 local vector vT; 00281 local float fSize; 00282 00283 if ( MyPC.MyHud.bHideHud ) 00284 return; 00285 00286 if ( MyPC.iCrosshairMode == 0 ) 00287 return; 00288 00289 fSize = MyPC.fCrosshairSize; 00290 C.bUseBorder = false; 00291 00292 if ( ((XIIIPawn(FiringTargetActor) != none) && (!XIIIPawn(FiringTargetActor).bIsDead || XIIIPawn(FiringTargetActor).GameOver != GO_Never) ) 00293 || ((XIIIMover(FiringTargetActor) != none) && XIIIMover(FiringTargetActor).IsBreakableByPlayer()) ) 00294 { 00295 if ( MyPC.iCrosshairMode == 1 ) 00296 CrosshairAlpha = fMin(1.0, CrosshairAlpha + 0.25); 00297 else 00298 CrosshairAlpha = 1.0; 00299 if ( (XIIIPawn(FiringTargetActor) != none) && (XIIIPawn(FiringTargetActor).GameOver != GO_Never) ) 00300 { 00301 fSize=MyPC.fCrosshairSize/2.0; 00302 CH = NoShootTex; 00303 C.SetDrawColor(255,255,255,0*CrosshairAlpha); 00304 } 00305 else 00306 { 00307 CH = XWeap.Crosshair; 00308 C.SetDrawColor(255,0,0,255*CrosshairAlpha); 00309 } 00310 C.Style = 3; //ERenderStyle.STY_Translucent; 00311 C.bNoSmooth = true; 00312 XLength = 34.0*fSize; 00313 if ( MyPC.bFloatingCrosshair ) 00314 { 00315 vT = WorldToScreen(FiringTargHitLoc); 00316 vT.X = fClamp( vT.X, C.CLipX*1.2/3, C.CLipX*1.8/3); 00317 vT.Y = fClamp( vT.Y, C.CLipY*1.2/3, C.CLipY*1.8/3); 00318 } 00319 else 00320 vT = vect(1,0,0)*C.ClipX/2 + vect(0,1,0)*C.ClipY/2; 00321 XLength = 32.0*fSize; 00322 if ( CH != none ) 00323 { 00324 C.SetPos(vT.x - XLength*0.5, vT.y - XLength*0.5); 00325 C.DrawTile(CH, XLength, XLength, 0, 0, CH.USize, CH.VSize); 00326 C.SetDrawColor(255,255,255,255*CrosshairAlpha); 00327 C.bNoSmooth = false; 00328 C.SetPos(vT.x- XLength/2, vT.y - XLength/2); 00329 C.DrawTile(CH, XLength, XLength, 0, 0, CH.USize, CH.VSize); 00330 } 00331 XLength = 32.0*2.0; 00332 C.bNoSmooth = false; 00333 C.SetDrawColor(255,255,255,255); 00334 C.SetPos(vT.x - XLength/16, vT.y - XLength/16); 00335 C.DrawTile(DotTex, XLength/8, XLength/8, 0, 0, DotTex.USize, DotTex.VSize); // minimal cost 00336 if ( (XIIIPawn(FiringTargetActor) != none) && (XIIIPawn(FiringTargetActor).PlayerReplicationInfo != none) ) 00337 { 00338 C.Font = C.smallfont; //font'Policef16'; // ELR Must be intializeed to avoid crash 00339 if ( MyPC.PlayerReplicationInfo.Team != none ) 00340 { 00341 if ( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.Team.TeamIndex == MyPC.PlayerReplicationInfo.Team.TeamIndex ) 00342 { 00343 C.SetDrawColor(128,255,128,128); 00344 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName@"("$int(Pawn(FiringTargetActor).HealthPercent())$"%)"); 00345 } 00346 else 00347 { 00348 C.SetDrawColor(255,128,128,128); 00349 if (XIIIGameInfo(level.game)!=none && XIIIGameInfo(level.game).bRocketArena) 00350 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName@"("$int(Pawn(FiringTargetActor).HealthPercent())$"%)"); 00351 else 00352 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName); 00353 } 00354 } 00355 else 00356 { 00357 C.SetDrawColor(255,128,128,128); 00358 if (XIIIGameInfo(level.game)!=none && XIIIGameInfo(level.game).bRocketArena) 00359 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName@"("$int(Pawn(FiringTargetActor).HealthPercent())$"%)"); 00360 else 00361 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName); 00362 } 00363 } 00364 else if ( (XIIIPawn(FiringTargetActor) != none) && Pawn(FiringTargetActor).bBoss ) 00365 { 00366 C.Font = C.smallfont; //font'Policef16'; // ELR Must be intializeed to avoid crash 00367 C.SetDrawColor(255,255,128,196); 00368 C.DrawText( Pawn(FiringTargetActor).PawnName@"("$int(Pawn(FiringTargetActor).HealthPercent())$"%)"); 00369 } 00370 } 00371 else 00372 { 00373 if ( MyPC.iCrosshairMode == 1 ) 00374 { 00375 // Don't change CH, use the old one for fading away 00376 if ( CH == NoShootTex ) 00377 fSize=MyPC.fCrosshairSize/2.0; 00378 CrosshairAlpha = fMax(0.0, CrosshairAlpha - 0.25); 00379 } 00380 else 00381 { 00382 CH = XWeap.Crosshair; 00383 CrosshairAlpha = 1.0; 00384 } 00385 C.bNoSmooth = false; 00386 XLength = 32 * fSize; 00387 if ( MyPC.bFloatingCrosshair ) 00388 vT = WorldToScreen(StartTrace + vector(AdjustedAim)*3000); 00389 else 00390 vT = vect(1,0,0)*C.ClipX/2 + vect(0,1,0)*C.ClipY/2; 00391 if ( CrosshairAlpha > 0.0 && (CH != none) ) 00392 { 00393 C.SetDrawColor(255,255,255,255*CrosshairAlpha); 00394 vT.X = fClamp( vT.X, C.CLipX*1.2/3, C.CLipX*1.8/3); 00395 vT.Y = fClamp( vT.Y, C.CLipY*1.2/3, C.CLipY*1.8/3); 00396 C.SetPos(vT.x - XLength/2, vT.y - XLength/2); 00397 C.DrawTile(CH, XLength, XLength, 0, 0, CH.USize, CH.VSize); // minimal cost 00398 } 00399 XLength = 32 * 2.0; 00400 C.SetDrawColor(255,255,255,255); 00401 C.SetPos(vT.x - XLength/16, vT.y - XLength/16); 00402 C.DrawTile(DotTex, XLength/8, XLength/8, 0, 0, DotTex.USize, DotTex.VSize); // minimal cost 00403 } 00404 } 00405 */ 00406 00407 //_____________________________________________________________________________ 00408 simulated function DrawFixWeaponCrosshair(Canvas C) 00409 { 00410 local int XLength; 00411 local vector vT; 00412 local float fSize; 00413 00414 if ( MyPC.MyHud.bHideHud ) 00415 return; 00416 00417 if ( MyPC.iCrosshairMode == 0 ) 00418 return; 00419 00420 fSize=MyPC.fCrosshairSize; 00421 // CH = XWeap.Crosshair; 00422 C.bUseBorder = false; 00423 00424 if ( ((XIIIPawn(FiringTargetActor) != none) && (!XIIIPawn(FiringTargetActor).bIsDead || XIIIPawn(FiringTargetActor).GameOver != GO_Never) ) 00425 || ((XIIIMover(FiringTargetActor) != none) && XIIIMover(FiringTargetActor).IsBreakableByPlayer()) ) 00426 { 00427 if ( MyPC.iCrosshairMode == 1 ) 00428 CrosshairAlpha = fMin(1.0, CrosshairAlpha + 0.15); 00429 else 00430 CrosshairAlpha = 1.0; 00431 if ( (XIIIPawn(FiringTargetActor) != none) && (XIIIPawn(FiringTargetActor).GameOver != GO_Never) ) 00432 { 00433 fSize=MyPC.fCrosshairSize/2.0; 00434 CH = NoShootTex; 00435 C.SetDrawColor(255,255,255,0*CrosshairAlpha); 00436 } 00437 else 00438 { 00439 CH = XWeap.Crosshair; 00440 C.SetDrawColor(255,0,0,255*CrosshairAlpha); 00441 } 00442 C.Style = 5; // 5 = alpha // 3 = ERenderStyle.STY_Translucent; 00443 C.bNoSmooth = true; 00444 // XLength = 34.0*fSize; 00445 // vT = WorldToScreen(FiringTargHitLoc); 00446 // vT.X = fClamp( vT.X, C.CLipX*1.2/3, C.CLipX*1.8/3); 00447 // vT.Y = fClamp( vT.Y, C.CLipY*1.2/3, C.CLipY*1.8/3); 00448 vT = vect(1.0, 0, 0)*C.CLipX/2.0 + vect(0, 1.0, 0)*C.CLipY/2.0; 00449 XLength = 34.0*fSize; 00450 if ( CH != none ) 00451 { 00452 C.SetPos(vT.x - XLength*0.5, vT.y - XLength*0.5); 00453 C.DrawTile(CH, XLength, XLength, 0, 0, CH.USize, CH.VSize); 00454 C.SetDrawColor(255,255,255,255*CrosshairAlpha); 00455 C.bNoSmooth = false; 00456 XLength = 32.0*fSize; 00457 C.SetPos(vT.x- XLength/2, vT.y - XLength/2); 00458 C.DrawTile(CH, XLength, XLength, 0, 0, CH.USize, CH.VSize); 00459 } 00460 XLength = 32.0*2.0; 00461 C.bNoSmooth = false; 00462 C.SetDrawColor(255,255,255,255); 00463 C.SetPos(vT.x - XLength/16, vT.y - XLength/16); 00464 C.DrawTile(DotTex, XLength/8, XLength/8, 0, 0, DotTex.USize, DotTex.VSize); // minimal cost 00465 if ( (XIIIPawn(FiringTargetActor) != none) && (XIIIPawn(FiringTargetActor).PlayerReplicationInfo != none) ) 00466 { 00467 C.Font = C.smallfont; //font'Policef16'; // ELR Must be intializeed to avoid crash 00468 if ( MyPC.PlayerReplicationInfo.Team != none ) 00469 { 00470 if ( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.Team.TeamIndex == MyPC.PlayerReplicationInfo.Team.TeamIndex ) 00471 { 00472 C.SetDrawColor(128,255,128,128); 00473 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName@"("$int(Pawn(FiringTargetActor).HealthPercent())$"%)"); 00474 } 00475 else 00476 { 00477 C.SetDrawColor(255,128,128,128); 00478 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName); 00479 } 00480 } 00481 else 00482 { 00483 C.SetDrawColor(255,128,128,128); 00484 C.DrawText( XIIIPawn(FiringTargetActor).PlayerReplicationInfo.PlayerName); 00485 } 00486 } 00487 else if ( (XIIIPawn(FiringTargetActor) != none) && Pawn(FiringTargetActor).bBoss ) 00488 { 00489 C.Font = C.smallfont; //font'Policef16'; // ELR Must be intializeed to avoid crash 00490 C.SetDrawColor(255,255,128,196); 00491 C.DrawText( Pawn(FiringTargetActor).PawnName@"("$int(Pawn(FiringTargetActor).HealthPercent())$"%)"); 00492 } 00493 } 00494 else 00495 { 00496 if ( MyPC.iCrosshairMode == 1 ) 00497 { 00498 // Don't change CH, use the old one for fading away 00499 if ( CH == NoShootTex ) 00500 fSize=MyPC.fCrosshairSize/2.0; 00501 CrosshairAlpha = fMax(0.0, CrosshairAlpha - 0.15); 00502 } 00503 else 00504 { 00505 CH = XWeap.Crosshair; 00506 CrosshairAlpha = 1.0; 00507 } 00508 C.bNoSmooth = false; 00509 XLength = 32 * fSize; 00510 // vT = WorldToScreen(StartTrace + vector(AdjustedAim)*3000); 00511 vT = vect(1.0, 0, 0)*C.CLipX/2.0 + vect(0, 1.0, 0)*C.CLipY/2.0; 00512 if ( CrosshairAlpha > 0.0 && (CH != none) ) 00513 { 00514 C.SetDrawColor(255,255,255,255*CrosshairAlpha); 00515 vT.X = fClamp( vT.X, C.CLipX*1.2/3, C.CLipX*1.8/3); 00516 vT.Y = fClamp( vT.Y, C.CLipY*1.2/3, C.CLipY*1.8/3); 00517 C.SetPos(vT.x - XLength/2, vT.y - XLength/2); 00518 C.DrawTile(CH, XLength, XLength, 0, 0, CH.USize, CH.VSize); // minimal cost 00519 } 00520 XLength = 32 * 2.0; 00521 C.SetDrawColor(255,255,255,255); 00522 C.SetPos(vT.x - XLength/16, vT.y - XLength/16); 00523 C.DrawTile(DotTex, XLength/8, XLength/8, 0, 0, DotTex.USize, DotTex.VSize); // minimal cost 00524 } 00525 } 00526 00527 //_____________________________________________________________________________ 00528 function DrawItemCrosshair(Canvas C) 00529 { 00530 local texture CH; 00531 local float XLength; 00532 00533 if ( XItem.IsA('Med') && XIIIPawn(MyPC.Pawn).IsWounded() ) 00534 { 00535 C.SetDrawColor(255,255,255,128); 00536 XLength = 24 * MyPC.fCrosshairSize; 00537 C.SetPos(0.503 * C.ClipX - XLength/2.0, 0.504 * C.ClipY - XLength/2.0); 00538 C.DrawTile(HealTex, XLength, XLength, 0, 0, HealTex.USize, HealTex.VSize); 00539 } 00540 else if ( XItem.Crosshair != none ) 00541 { 00542 C.SetDrawColor(255,255,255,255); 00543 CH = XItem.Crosshair; 00544 XLength = 32 * MyPC.fCrosshairSize; 00545 C.SetPos(0.503 * C.ClipX - XLength/2.0, 0.504 * C.ClipY - XLength/2.0); 00546 C.DrawTile(CH, XLength, XLength, 0, 0, CH.USize, CH.VSize); 00547 } 00548 else 00549 { 00550 C.SetDrawColor(255,255,255,255); 00551 XLength = 32 * 2.0; 00552 C.SetPos(0.503 * C.ClipX - XLength/16.0, 0.504 * C.ClipY - XLength/16.0); 00553 C.DrawTile(DotTex, XLength/8, XLength/8, 0, 0, DotTex.USize, DotTex.VSize); // minimal cost 00554 } 00555 } 00556 00557 //____________________________________________________________________ 00558 function DrawAction(Canvas C, int NbIcons, int index, texture Tex) 00559 { 00560 C.SetPos(0.5 * C.ClipX - (NbIcons-index*2)*(Tex.USize/2.0), 0.5 * C.ClipY - (Tex.VSize/2.0)); 00561 C.DrawIcon(Tex, 1.0); 00562 } 00563 00564 //____________________________________________________________________ 00565 function ResetInteractions() 00566 { 00567 bEasyInteractOn = false; 00568 bCanPickup = false; 00569 bCanHook = false; 00570 bCanTrigger = false; 00571 bCanDoor = false; 00572 bCanClimbDoor = false; 00573 bCanUnLockDoor = false; 00574 bCantDoor = false; 00575 bCanSearchCorpse = false; 00576 bCanGrabCorpse = false; 00577 bCanTakePrisonner = false; 00578 bCanStun = false; 00579 bCanBreak = false; 00580 bCanHeal = false; 00581 if ( (TargetActor != none) && TargetActor.bDeleteMe ) 00582 TargetActor = none; 00583 } 00584 00585 //____________________________________________________________________ 00586 function bool DrawInteractions(Canvas C) 00587 { 00588 local int Index, NbIconsDrawn; 00589 local bool bHaveDrawnSomething; 00590 local PowerUps PwrU; 00591 local vector vFocusLoc; 00592 local float XL, YL; 00593 local float XP1, YP1, XP2, YP2; 00594 00595 NbIconsDrawn=0; 00596 bHaveDrawnSomething = false; 00597 00598 // Decide of interactions. 00599 // PICKUP 00600 if ( (Pickup(TargetActor) != none) && (TargetActor != MyPC.Pawn.Base) && (TargDist < INTERACTIONDIST) && Level.bLonePlayer ) 00601 { 00602 if ( (XIIIDecoPickup(TargetActor) == none) || !XIIIPawn(MyPC.Pawn).LHand.bActive ) 00603 { 00604 bCanPickup = true; 00605 NbIconsDrawn ++; 00606 if ( MyPC.bAutoPickup && (XIIIDecoPickup(TargetActor) == none) ) 00607 { 00608 MyPC.Grab(); 00609 if ( (TargetActor == none) || TargetActor.bDeleteMe ) 00610 { 00611 bCanPickup = false; 00612 NbIconsDrawn --; 00613 TargetActor = none; 00614 } 00615 } 00616 } 00617 } 00618 // HOOK 00619 if ( (HookPoint(TargetActor) != none) && MyPC.AllowHooking() ) 00620 { bCanHook = true; NbIconsDrawn ++; } 00621 // TRIGGER 00622 if ( (XIIITriggers(TargetActor) != none) && (TargDist < INTERACTIONDIST) && XIIITriggers(TargetActor).bCanBeLocked && Level.bLonePlayer ) 00623 { 00624 if ( ( Level.Game != none) && (Level.Game.DetailLevel > 1) && CamViewTrigger(TargetActor) != none ) 00625 { 00626 CamViewTrigger(TargetActor).LookedAt(MyPC.Pawn); 00627 } 00628 else 00629 { 00630 bCanTrigger = true; 00631 if ( MagneticPassTrigger(TargetActor) != none ) 00632 { bCanDoor = true; NbIconsDrawn ++; } 00633 else 00634 { NbIconsDrawn ++; } 00635 } 00636 } 00637 // DOOR 00638 if ( (TargetActor != none) && (TargetActor != MyPC.Pawn.Base) && Level.bLonePlayer ) // don't interact with our base (close door we had climbed on...) 00639 { 00640 if ( (XIIIPorte(TargetActor) != none) && (TargDist < INTERACTIONDIST) && !XIIIPorte(TargetActor).bNoInteractionIcon ) 00641 { 00642 if ( TargetActor.IsInState('Locked') || !TargetActor.IsInState('PlayerTriggerToggle') ) 00643 { bCanDoor = true; bCanUnLockDoor = true; NbIconsDrawn ++; } 00644 else 00645 { 00646 if ( XIIIPorte(TargetActor).CanBeOperated(MyPC.Pawn) ) 00647 { 00648 bCanDoor = true; 00649 NbIconsDrawn ++; 00650 } 00651 else 00652 { bCantDoor = true; NbIconsDrawn ++; } 00653 } 00654 if ( MyPC.TryClimbDoor(TargetActor, TargHitLoc, TargHitNorm) ) 00655 { bCanClimbDoor = true; NbIconsDrawn ++; } 00656 } 00657 else if ( PorteDecors(TargetActor) != none && (TargDist < INTERACTIONDIST) ) 00658 { } //bCantDoor = true; NbIconsDrawn ++; } 00659 // else if ( (BreakAbleMover(TargetActor) != none) && !XIIIMover(TargetActor).bNoInteractionIcon && (TargDist < 180) && MyPC.bWeaponMode ) 00660 else if ( TargetActor.IsA('BreakAbleMover') && !XIIIMover(TargetActor).bNoInteractionIcon && (TargDist < INTERACTIONDIST) ) 00661 { 00662 if ( XIIIMover(TargetActor).IsBreakableByPlayer() ) 00663 { bCanBreak = true; NbIconsDrawn ++; } 00664 } 00665 // else if ( (UnBreakable(TargetActor)!=none) && !XIIIMover(TargetActor).bNoInteractionIcon && (TargDist < INTERACTIONDIST) ) 00666 else if ( (UnBreakable(TargetActor)!=none) && (TargDist < INTERACTIONDIST) ) 00667 { /* bCantBreak = true; NbIconsDrawn ++; // ELR Don't do anything */ } 00668 else if ( TargetActor.IsA('XIIIMovable') && !XIIIMover(TargetActor).bNoInteractionIcon && (TargDist < INTERACTIONDIST) ) 00669 { bCanDoor = true; NbIconsDrawn ++; } 00670 else if ( (XIIIMover(TargetActor) != none) && !XIIIMover(TargetActor).bNoInteractionIcon && (TargDist < INTERACTIONDIST) ) 00671 { 00672 bCanDoor = true; 00673 if ( !TargetActor.IsInState('PlayerTriggerToggle') ) 00674 { bCanUnLockDoor = true; NbIconsDrawn ++; } 00675 else 00676 NbIconsDrawn ++; 00677 } 00678 } 00679 00680 if ( (XIIIPawn(TargetActor) != none) && Level.bLonePlayer ) 00681 { 00682 if ( XIIIPawn(TargetActor).bSearchable && (TargDist < INTERACTIONDIST) ) 00683 { 00684 if ( XIIIPawn(TargetActor).inventory != none ) 00685 { 00686 bCanSearchCorpse = true; 00687 NbIconsDrawn ++; 00688 if ( MyPC.bAutoPickup ) 00689 { 00690 MyPC.SearchPawn(XIIIPawn(TargetActor)); 00691 } 00692 } 00693 if ( XIIIPawn(MyPC.Pawn).CanGrabCorpse(XIIIPawn(TargetActor)) ) 00694 { 00695 bCanGrabCorpse = true; 00696 NbIconsDrawn ++; 00697 } 00698 } 00699 else if ( (TargetActor != none) && !XIIIPawn(TargetActor).bIsDead ) 00700 { 00701 if ( (TargDist < STUNDIST) && XIIIPawn(MyPC.Pawn).CanTakePrisonner(XIIIPawn(TargetActor)) && (XIIIPawn(TargetActor).GetDamageSide(TargHitLoc) >= 6) ) 00702 { 00703 bCanTakePrisonner = true; 00704 NbIconsDrawn ++; 00705 } 00706 if ( (TargDist < STUNWITHDECODIST) && (XIIIPawn(MyPC.Pawn).CanStun(XIIIPawn(TargetActor))) 00707 && ( (XIIIPawn(TargetActor).GetDamageSide(TargHitLoc) >= 6) || (DecoWeapon(XIIIPawn(MyPC.Pawn).Weapon)!=none) ) 00708 ) 00709 { 00710 bCanStun = true; 00711 NbIconsDrawn ++; 00712 } 00713 } 00714 } 00715 00716 // Draw interactions 00717 Index = 0; 00718 C.SetDrawColor(255,255,255,255); 00719 if ( bCanPickup ) 00720 { 00721 if ( XIIIDecoPickup(TargetActor) != none ) 00722 DrawAction(C, NbIconsDrawn, index, DecoWeaponTex); 00723 else 00724 DrawAction(C, NbIconsDrawn, index, GrabItemTex); 00725 index ++; 00726 bHaveDrawnSomething = true; 00727 } 00728 if ( bCanHook ) 00729 { 00730 if ( (Hook(XItem) != none) && (HookPoint(TargetActor) != none) ) 00731 { 00732 if ( VSize(TargetActor.Location - MyPC.Pawn.Location) + 50.0 > HookPoint(TargetActor).RopeLength ) 00733 C.SetDrawColor(255,0,0,255); 00734 } 00735 else 00736 C.SetDrawColor(255,255,255,255); 00737 DrawAction(C, NbIconsDrawn, index, GrapplePointTex); 00738 C.SetDrawColor(255,255,255,255); 00739 index ++; 00740 bHaveDrawnSomething = true; 00741 } 00742 if ( bCanTrigger ) 00743 { 00744 if ( TyrolTrigger(TargetActor) != none ) 00745 { 00746 DrawAction(C, NbIconsDrawn, index, TyrolTex); 00747 index ++; 00748 bHaveDrawnSomething = true; 00749 } 00750 else if ( !bCanDoor ) 00751 { 00752 DrawAction(C, NbIconsDrawn, index, GrabItemTex); 00753 index ++; 00754 bHaveDrawnSomething = true; 00755 } 00756 } 00757 if ( bCanDoor ) 00758 { 00759 if ( bCanTrigger ) 00760 { 00761 // Must be a MagneticPasstrigger or doortrigger 00762 DrawAction(C, NbIconsDrawn, index, MagneticPasstrigger(TargetActor).Icon); 00763 index ++; 00764 bHaveDrawnSomething = true; 00765 } 00766 else if ( bCanUnLockDoor ) 00767 { 00768 PwrU = MyPC.TryInteractWithDoor(TargetActor); 00769 if ( PwrU != none ) 00770 DrawAction(C, NbIconsDrawn, index, OpenAbleDoorTex); 00771 else 00772 DrawAction(C, NbIconsDrawn, index, ClosedDoorTex); 00773 index ++; 00774 bHaveDrawnSomething = true; 00775 } 00776 else 00777 { 00778 DrawAction(C, NbIconsDrawn, index, OpenDoorTex); 00779 index ++; 00780 bHaveDrawnSomething = true; 00781 } 00782 if ( bCanClimbDoor ) 00783 { 00784 DrawAction(C, NbIconsDrawn, index, ClimbDoorTex); 00785 index ++; 00786 bHaveDrawnSomething = true; 00787 } 00788 } 00789 if ( bCantDoor ) 00790 { 00791 DrawAction(C, NbIconsDrawn, index, NoOpenDoorTex); 00792 index ++; 00793 bHaveDrawnSomething = true; 00794 } 00795 if ( bCanSearchCorpse ) 00796 { 00797 DrawAction(C, NbIconsDrawn, index, SearchBodyTex); 00798 index ++; 00799 bHaveDrawnSomething = true; 00800 } 00801 if ( bCanGrabCorpse ) 00802 { 00803 DrawAction(C, NbIconsDrawn, index, TakeCorpseTex); 00804 index ++; 00805 bHaveDrawnSomething = true; 00806 } 00807 if ( bCanStun ) 00808 { 00809 DrawAction(C, NbIconsDrawn, index, StunTex); 00810 index ++; 00811 bHaveDrawnSomething = true; 00812 } 00813 if ( bCanTakePrisonner ) 00814 { 00815 DrawAction(C, NbIconsDrawn, index, TakePrisonnerTex); 00816 index ++; 00817 bHaveDrawnSomething = true; 00818 } 00819 if ( bCanBreak ) 00820 { 00821 DrawAction(C, NbIconsDrawn, index, BreakTex); 00822 index ++; 00823 bHaveDrawnSomething = true; 00824 } 00825 /* 00826 if ( !bHaveDrawnSomething ) 00827 { 00828 Log("bHaveDrawnNothing"); 00829 if ( !MyPC.bWeaponMode && MyPC.Pawn.SelectedItem.IsA('Med') ) 00830 { 00831 Log(" Drawing Heal"); 00832 DrawAction(C, 0, 1, HealTex); 00833 bHaveDrawnSomething = true; 00834 } 00835 } 00836 */ 00837 if ( bHaveDrawnSomething ) 00838 { 00839 if ( (bEasyInteractOn || TargetActor.bEaseInteract) && !XIIIBaseHud(MYPC.MyHud).IsFocusing(TargetActor) ) 00840 { 00841 vFocusLoc = WorldToScreen(TargetActor.Location); 00842 XL = 32; 00843 YL = 32; 00844 XP1 = int(vFocusLoc.X - XL); 00845 XP2 = int(vFocusLoc.X + XL); 00846 YP1 = int(vFocusLoc.Y - YL); 00847 YP2 = int(vFocusLoc.Y + YL); 00848 C.DrawColor = C.Static.MakeColor(0,0,0,0); 00849 C.BorderColor = C.Static.MakeColor(0,0,0,255); 00850 C.bUseBorder = true; 00851 // outer outline 00852 C.SetPos(XP1 - 2, YP1 - 2); 00853 C.DrawRect(XIIIBaseHUD(MyPC.MyHud).FondDlg, (XP2 - XP1)+4, (YP2 - YP1)+4); 00854 // inner outline 00855 C.SetPos(XP1, YP1); 00856 C.BorderColor = C.Static.MakeColor(255,255,255,255); 00857 C.DrawRect(XIIIBaseHUD(MyPC.MyHud).FondDlg, (XP2 - XP1), (YP2 - YP1)); 00858 C.bUseBorder = false; 00859 } 00860 } 00861 return bHaveDrawnSomething; 00862 } 00863 00864 00865 00866 defaultproperties 00867 { 00868 GrabItemTex=Texture'XIIIMenu.HUD.Hand_SearchBody' 00869 DecoWeaponTex=Texture'XIIIMenu.HUD.Hand_DecoWeapon' 00870 GrapplePointTex=Texture'XIIIMenu.HUD.Hand_GrapplePoint' 00871 OpenDoorTex=Texture'XIIIMenu.HUD.Hand_SearchBody' 00872 ClimbDoorTex=Texture'XIIIMenu.HUD.Hand_ClimbDoor' 00873 NoOpenDoorTex=Texture'XIIIMenu.HUD.Hand_UnOpenable' 00874 ClosedDoorTex=Texture'XIIIMenu.HUD.Hand_UnOpenable' 00875 OpenAbleDoorTex=Texture'XIIIMenu.HUD.Hand_ClosedDoor' 00876 SearchBodyTex=Texture'XIIIMenu.HUD.Hand_SearchBody' 00877 TakeCorpseTex=Texture'XIIIMenu.HUD.Hand_TakeCorpse' 00878 TakePrisonnerTex=Texture'XIIIMenu.HUD.Hand_TakePrisonner' 00879 StunTex=Texture'XIIIMenu.HUD.Hand_Stun' 00880 BreakTex=Texture'XIIIMenu.HUD.Hand_Break' 00881 TyrolTex=Texture'XIIIMenu.HUD.Hand_TyrolPoint' 00882 NoShootTex=Texture'XIIIMenu.HUD.MireNoshoot' 00883 DotTex=Texture'XIIIMenu.HUD.Miredot' 00884 HealTex=Texture'XIIIMenu.HUD.life2A' 00885 bVisible=True 00886 }

End Source Code