Advertisement
Guest User

Engine.Inventory

a guest
May 22nd, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. simulated final function vector CalcDrawOffset()
  2. {
  3.     local vector DrawOffset, WeaponBob;
  4.     local Pawn PawnOwner;
  5.     local byte WeaponFOVFix;
  6.     local float WeaponFOVScaling;
  7.     local float FOVAngle, FOVScale;
  8.     local float ScreenWidth, ScreenHeight;
  9.  
  10.     PawnOwner = Pawn(Owner);
  11.     if (PawnOwner != None)
  12.     {
  13.         if (bCalcDrawOffsetFOV)
  14.         {
  15.             WeaponFOVFix = class'PlayerPawn'.default.WeaponFOVFix;
  16.             WeaponFOVScaling = FClamp(class'PlayerPawn'.default.WeaponFOVScaling, 0.0, 1.0);
  17.  
  18.             if (WeaponFOVFix == 0) // UT 436 method
  19.                 DrawOffset = ((0.9 / PawnOwner.FOVAngle * PlayerViewOffset) >> PawnOwner.ViewRotation);
  20.             else if (WeaponFOVFix == 2 && WeaponFOVScaling == 0.0 || PlayerPawn(Owner) == none || Level.NetMode == NM_DedicatedServer)
  21.                 DrawOffset = (0.01 * PlayerViewOffset) >> PawnOwner.ViewRotation;
  22.             else
  23.             {
  24.                 // TODO: use a more reliable method to retrieve screen width and height
  25.                 ScreenWidth = PlayerPawn(Owner).Player.Console.FrameX;
  26.                 ScreenHeight = PlayerPawn(Owner).Player.Console.FrameY;
  27.  
  28.                 if (WeaponFOVFix == 1)
  29.                 {
  30.                     FOVAngle = FClamp(PawnOwner.FOVAngle, 1.0, 179.0);
  31.                     FOVScale = ATan(Tan(FOVAngle / 360.0 * Pi) * ScreenHeight / FMax(ScreenWidth, 1.0) / 0.75) * 360.0 / Pi;
  32.                     FOVScale = FMin(FOVAngle, FMax(90.0, FOVScale));
  33.                     DrawOffset = ((0.9 / FOVScale * PlayerViewOffset) >> PawnOwner.ViewRotation);
  34.                 }
  35.                 else // mode 2
  36.                 {
  37.                     DrawOffset = 0.01 * PlayerViewOffset;
  38.                     FOVAngle = FClamp(PawnOwner.FOVAngle, 1.0, 179.0);
  39.                     FOVScale = FMin(1.0, 0.75 * ScreenWidth / (FMax(ScreenHeight, 1.0) * Tan(FOVAngle / 360 * Pi)));
  40.                     DrawOffset.X *= 1.0 - (1.0 - FOVScale) * WeaponFOVScaling;
  41.                     DrawOffset = DrawOffset >> PawnOwner.ViewRotation;
  42.                 }
  43.             }
  44.         }
  45.         else
  46.             DrawOffset = (0.01 * PlayerViewOffset) >> PawnOwner.ViewRotation;
  47.  
  48.         if ( (Level.NetMode == NM_DedicatedServer)
  49.             || ((Level.NetMode == NM_ListenServer) && (Owner.RemoteRole == ROLE_AutonomousProxy)) )
  50.             DrawOffset += (PawnOwner.BaseEyeHeight * vect(0,0,1));
  51.         else
  52.         {
  53.             DrawOffset += (PawnOwner.EyeHeight * vect(0,0,1));
  54.             WeaponBob = BobDamping * PawnOwner.WalkBob;
  55.             WeaponBob.Z = (0.45 + 0.55 * BobDamping) * PawnOwner.WalkBob.Z;
  56.             DrawOffset += WeaponBob;
  57.         }
  58.     }
  59.     return DrawOffset;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement