Advertisement
Guest User

Engine.Weapon

a guest
May 22nd, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. simulated event RenderOverlays( canvas Canvas )
  2. {
  3.     local rotator NewRot;
  4.     local bool bPlayerOwner;
  5.     local int Hand;
  6.     local PlayerPawn PlayerOwner;
  7.     local float FOVScale;
  8.     local float RectWidth, RectHeight;
  9.  
  10.     if ( bHideWeapon || (Owner == None) )
  11.         return;
  12.  
  13.     PlayerOwner = PlayerPawn(Owner);
  14.  
  15.     if ( PlayerOwner != None )
  16.     {
  17.         if ( PlayerOwner.DesiredFOV != PlayerOwner.DefaultFOV )
  18.             return;
  19.         bPlayerOwner = true;
  20.         Hand = PlayerOwner.Handedness;
  21.  
  22.         if (  (Level.NetMode == NM_Client) && (Hand == 2) )
  23.         {
  24.             bHideWeapon = true;
  25.             return;
  26.         }
  27.     }
  28.  
  29.     if ( !bPlayerOwner || (PlayerOwner.Player == None) )
  30.         Pawn(Owner).WalkBob = vect(0,0,0);
  31.  
  32.     if ( (bMuzzleFlash > 0) && bDrawMuzzleFlash && Level.bHighDetailMode && (MFTexture != None) )
  33.     {
  34.         FOVScale = 1.0;
  35.         RectWidth = Canvas.ClipX;
  36.         if (class'PlayerPawn'.default.WeaponFOVFix > 0)
  37.         {
  38.             FOVScale /= Tan(FClamp(Canvas.Viewport.Actor.FOVAngle, 1.0, 179.0) / 360.0 * Pi);
  39.             RectHeight = RectWidth * 0.75; // (RectWidth / RectHeight) must always be 4:3 for correct evaluations below
  40.         }
  41.         else
  42.             RectHeight = Canvas.ClipY; // Using old UT 436 method
  43.  
  44.         MuzzleScale = Default.MuzzleScale * RectWidth/640.0 * FMin(1.0, FOVScale);
  45.  
  46.         if ( !bSetFlashTime )
  47.         {
  48.             bSetFlashTime = true;
  49.             FlashTime = Level.TimeSeconds + FlashLength;
  50.         }
  51.         else if ( FlashTime < Level.TimeSeconds )
  52.             bMuzzleFlash = 0;
  53.         if ( bMuzzleFlash > 0 )
  54.         {
  55.             if ( Hand == 0 )
  56.                 Canvas.SetPos(
  57.                     Canvas.ClipX/2 - 0.5 * MuzzleScale * FlashS + RectWidth * (-0.2 * Default.FireOffset.Y * FlashO) * FOVScale,
  58.                     Canvas.ClipY/2 - 0.5 * MuzzleScale * FlashS + RectHeight * (FlashY + FlashC) * FOVScale);
  59.             else
  60.                 Canvas.SetPos(
  61.                     Canvas.ClipX/2 - 0.5 * MuzzleScale * FlashS + RectWidth * (Hand * Default.FireOffset.Y * FlashO) * FOVScale,
  62.                     Canvas.ClipY/2 - 0.5 * MuzzleScale * FlashS + RectHeight * FlashY * FOVScale);
  63.  
  64.             Canvas.Style = 3;
  65.             Canvas.DrawIcon(MFTexture, MuzzleScale);
  66.             Canvas.Style = 1;
  67.         }
  68.     }
  69.     else
  70.         bSetFlashTime = false;
  71.  
  72.     SetLocation( Owner.Location + CalcDrawOffset() );
  73.     NewRot = Pawn(Owner).ViewRotation;
  74.  
  75.     if ( Hand == 0 )
  76.         newRot.Roll = -2 * Default.Rotation.Roll;
  77.     else
  78.         newRot.Roll = Default.Rotation.Roll * Hand;
  79.  
  80.     SetRotation(newRot);
  81.     Canvas.DrawActor(self, false);
  82. }
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement