Guest User

Untitled

a guest
Jul 30th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class LTTGMouseInput extends PlayerInput;
  2.  
  3. var bool bRotCam;
  4. var LTTGCamera Camera;
  5. var int DesiredZoom, DesiredPitch;
  6. var Actor SelectedUnit;
  7. var LTTGHud MouseHud;
  8. var PrivateWrite IntPoint MousePosition; // Stored mouse position. Set to private write as we don't want other classes to modify it, but still allow other classes to access it.
  9.  
  10.  
  11. event PlayerInput(float DeltaTime)
  12. {
  13.         Camera = LTTGCamera(PlayerCamera);
  14.         if (Camera.CamZ < 900) //CamZ must be lower initially then lowest CamZ (1000 right now)
  15.         {
  16.         Mouseposition.X = MyHUD.SizeX/2;
  17.         Mouseposition.Y = MyHUD.SizeY/2;
  18.         }
  19.     // Add the aMouseX & aMouseY to the mouse position and clamp it within the viewport width/height
  20.     MousePosition.X = Clamp(MousePosition.X + aMouseX, 0, myHUD.SizeX);
  21.     MousePosition.Y = Clamp(MousePosition.Y - aMouseY, 0, myHUD.SizeY);
  22.  
  23.          CamControl();
  24.          SmoothZoom(DeltaTime);
  25.          SmoothRotation(DeltaTime);
  26.      super.PlayerInput(DeltaTime);
  27. }
  28.  
  29. /**********************************************************************
  30. **              Horizontal/Vertical Scroll Cam System                **
  31. **********************************************************************/
  32. function CamControl()
  33. {
  34.         // SlowLimit/FastLimit = Scroll Activation from Margin Distance for Fast/Slow speed
  35.         // SlowScrollSpeed = Scroll Speed at SlowLimit  / FastScrollSpeed = Scroll Speed at FastLimit
  36.         local int SlowLimit, FastLimit, FastScrollSpeed, SlowScrollSpeed, ScrollLimitX, ScrollLimitY;
  37.         local int MaxPitch, MinPitch, RotAngle;
  38.  
  39.  
  40.         SlowLimit = 75;
  41.         FastLimit = 5;
  42.         SlowScrollSpeed = Camera.CamZ/110;
  43.         FastScrollSpeed = Camera.CamZ/45;
  44.         ScrollLimitX = 12000;
  45.         ScrollLimitY = 12000;
  46.  
  47.         MaxPitch = 58500;
  48.         MinPitch = 49152;
  49.         RotAngle = 500;
  50.  
  51.         if (!bRotCam)
  52.         {
  53.                 if (Camera.CamY > -ScrollLimitY)
  54.                 {
  55.                         if ( (MousePosition.X < SlowLimit) && (MousePosition.X > FastLimit) )
  56.                                 Camera.CamY -= SlowScrollSpeed;
  57.                         if ( MousePosition.X <= FastLimit)
  58.                                 Camera.CamY -= FastScrollSpeed;
  59.                 }
  60.  
  61.                 if (Camera.CamY < ScrollLimitY)
  62.                 {
  63.                         if ( (MousePosition.X > (myHUD.SizeX - SlowLimit)) &&  (MousePosition.X < (myHUD.SizeX - FastLimit) ))
  64.                                 Camera.CamY += SlowScrollSpeed;
  65.                         if ( (MousePosition.X >= (myHUD.SizeX - FastLimit)) )
  66.                                 Camera.CamY += FastScrollSpeed;
  67.                 }
  68.  
  69.                 if (Camera.CamX > -ScrollLimitX)
  70.                 {
  71.                         if ( (MousePosition.Y > (myHUD.SizeY - SlowLimit)) &&  (MousePosition.Y < (myHUD.SizeX - FastLimit) ) )
  72.                                 Camera.CamX -= SlowScrollSpeed;
  73.                         if ( MousePosition.Y >= (myHUD.SizeY - FastLimit ) )
  74.                                 Camera.CamX -= FastScrollSpeed;
  75.                 }
  76.  
  77.                 if (Camera.CamX < ScrollLimitX)
  78.                 {
  79.                         if ( (MousePosition.Y < SlowLimit) && (MousePosition.Y > FastLimit) )
  80.                                 Camera.CamX += SlowScrollSpeed;
  81.                         if ( (MousePosition.Y <= FastLimit))
  82.                                 Camera.CamX += FastScrollSpeed;
  83.                 }
  84.         }
  85.  
  86.         if(bRotCam)
  87.         {
  88.  
  89.              if(MousePosition.Y < MyHUD.SizeY/2)
  90.              {
  91.                 if (DesiredPitch < MaxPitch)
  92.                 {
  93.                         DesiredPitch += RotAngle;
  94.                 }
  95.                 if (DesiredPitch >= MaxPitch)
  96.                 {
  97.                         DesiredPitch = MaxPitch;
  98.                         }
  99.             }
  100.  
  101.             if(MousePosition.Y > MyHUD.SizeY/2)
  102.             {
  103.                 if (DesiredPitch > MinPitch)
  104.                 {
  105.                         DesiredPitch -= RotAngle;
  106.                 }
  107.                 if (DesiredPitch <= MinPitch)
  108.                 {
  109.                         DesiredPitch = MinPitch;
  110.                         }
  111.  
  112.                 }
  113.           }
  114.  
  115.  
  116. }
  117.  
  118. /**********************************************************************
  119. **                Zoom in/out Camera System                          **
  120. **********************************************************************/
  121.  
  122.  
  123.  
  124. exec function IncreaseCamZ()
  125. {
  126.         if (DesiredZoom < 4000)
  127.                 DesiredZoom += DesiredZoom * 1 / 10;
  128. }
  129.  
  130.  
  131. exec function DecreaseCamZ()
  132. {
  133.         if (DesiredZoom > 1000)
  134.                 DesiredZoom -= DesiredZoom * 1 / 10;
  135. }
  136.  
  137.  
  138. function SmoothZoom(float DeltaTime)
  139. {
  140.         Camera.CamZ += (DesiredZoom - Camera.CamZ) * DeltaTime *2;
  141. }
  142.  
  143. /**********************************************************************
  144. **                     Pitch Camera System                          **
  145. **********************************************************************/
  146.  
  147. exec function RotPCamTrue()
  148. {
  149.      If(!bRotCam)
  150.      {
  151.          bRotCam = True;
  152.       }
  153.  
  154. }
  155.  
  156. exec function RotPCamFalse()
  157. {
  158.      if(bRotCam)
  159.      {
  160.          bRotCam = False;
  161.      }
  162. }
  163.  
  164. function SmoothRotation(float DeltaTime)
  165. {
  166.         Camera.RotP += (DesiredPitch - Camera.RotP) * DeltaTime *4;
  167. }
  168.  
  169. /**********************************************************************
  170. **                     Awesome Unit Selection                       **
  171. **********************************************************************/
  172.  
  173. exec function Selection()
  174. {
  175.     SelectedUnit = MouseHud.traceHit;
  176. }
  177.  
  178.  
  179.  
  180.  
  181. /***********************************************************
  182. ** default Properties                                     **
  183. ***********************************************************/
  184.  
  185. defaultproperties
  186. {
  187.         DesiredZoom = 1500;
  188.         DesiredPitch = 55000;
  189. }
Add Comment
Please, Sign In to add comment