Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LTTGMouseInput extends PlayerInput;
- var bool bRotCam;
- var LTTGCamera Camera;
- var int DesiredZoom, DesiredPitch;
- var Actor SelectedUnit;
- var LTTGHud MouseHud;
- 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.
- event PlayerInput(float DeltaTime)
- {
- Camera = LTTGCamera(PlayerCamera);
- if (Camera.CamZ < 900) //CamZ must be lower initially then lowest CamZ (1000 right now)
- {
- Mouseposition.X = MyHUD.SizeX/2;
- Mouseposition.Y = MyHUD.SizeY/2;
- }
- // Add the aMouseX & aMouseY to the mouse position and clamp it within the viewport width/height
- MousePosition.X = Clamp(MousePosition.X + aMouseX, 0, myHUD.SizeX);
- MousePosition.Y = Clamp(MousePosition.Y - aMouseY, 0, myHUD.SizeY);
- CamControl();
- SmoothZoom(DeltaTime);
- SmoothRotation(DeltaTime);
- super.PlayerInput(DeltaTime);
- }
- /**********************************************************************
- ** Horizontal/Vertical Scroll Cam System **
- **********************************************************************/
- function CamControl()
- {
- // SlowLimit/FastLimit = Scroll Activation from Margin Distance for Fast/Slow speed
- // SlowScrollSpeed = Scroll Speed at SlowLimit / FastScrollSpeed = Scroll Speed at FastLimit
- local int SlowLimit, FastLimit, FastScrollSpeed, SlowScrollSpeed, ScrollLimitX, ScrollLimitY;
- local int MaxPitch, MinPitch, RotAngle;
- SlowLimit = 75;
- FastLimit = 5;
- SlowScrollSpeed = Camera.CamZ/110;
- FastScrollSpeed = Camera.CamZ/45;
- ScrollLimitX = 12000;
- ScrollLimitY = 12000;
- MaxPitch = 58500;
- MinPitch = 49152;
- RotAngle = 500;
- if (!bRotCam)
- {
- if (Camera.CamY > -ScrollLimitY)
- {
- if ( (MousePosition.X < SlowLimit) && (MousePosition.X > FastLimit) )
- Camera.CamY -= SlowScrollSpeed;
- if ( MousePosition.X <= FastLimit)
- Camera.CamY -= FastScrollSpeed;
- }
- if (Camera.CamY < ScrollLimitY)
- {
- if ( (MousePosition.X > (myHUD.SizeX - SlowLimit)) && (MousePosition.X < (myHUD.SizeX - FastLimit) ))
- Camera.CamY += SlowScrollSpeed;
- if ( (MousePosition.X >= (myHUD.SizeX - FastLimit)) )
- Camera.CamY += FastScrollSpeed;
- }
- if (Camera.CamX > -ScrollLimitX)
- {
- if ( (MousePosition.Y > (myHUD.SizeY - SlowLimit)) && (MousePosition.Y < (myHUD.SizeX - FastLimit) ) )
- Camera.CamX -= SlowScrollSpeed;
- if ( MousePosition.Y >= (myHUD.SizeY - FastLimit ) )
- Camera.CamX -= FastScrollSpeed;
- }
- if (Camera.CamX < ScrollLimitX)
- {
- if ( (MousePosition.Y < SlowLimit) && (MousePosition.Y > FastLimit) )
- Camera.CamX += SlowScrollSpeed;
- if ( (MousePosition.Y <= FastLimit))
- Camera.CamX += FastScrollSpeed;
- }
- }
- if(bRotCam)
- {
- if(MousePosition.Y < MyHUD.SizeY/2)
- {
- if (DesiredPitch < MaxPitch)
- {
- DesiredPitch += RotAngle;
- }
- if (DesiredPitch >= MaxPitch)
- {
- DesiredPitch = MaxPitch;
- }
- }
- if(MousePosition.Y > MyHUD.SizeY/2)
- {
- if (DesiredPitch > MinPitch)
- {
- DesiredPitch -= RotAngle;
- }
- if (DesiredPitch <= MinPitch)
- {
- DesiredPitch = MinPitch;
- }
- }
- }
- }
- /**********************************************************************
- ** Zoom in/out Camera System **
- **********************************************************************/
- exec function IncreaseCamZ()
- {
- if (DesiredZoom < 4000)
- DesiredZoom += DesiredZoom * 1 / 10;
- }
- exec function DecreaseCamZ()
- {
- if (DesiredZoom > 1000)
- DesiredZoom -= DesiredZoom * 1 / 10;
- }
- function SmoothZoom(float DeltaTime)
- {
- Camera.CamZ += (DesiredZoom - Camera.CamZ) * DeltaTime *2;
- }
- /**********************************************************************
- ** Pitch Camera System **
- **********************************************************************/
- exec function RotPCamTrue()
- {
- If(!bRotCam)
- {
- bRotCam = True;
- }
- }
- exec function RotPCamFalse()
- {
- if(bRotCam)
- {
- bRotCam = False;
- }
- }
- function SmoothRotation(float DeltaTime)
- {
- Camera.RotP += (DesiredPitch - Camera.RotP) * DeltaTime *4;
- }
- /**********************************************************************
- ** Awesome Unit Selection **
- **********************************************************************/
- exec function Selection()
- {
- SelectedUnit = MouseHud.traceHit;
- }
- /***********************************************************
- ** default Properties **
- ***********************************************************/
- defaultproperties
- {
- DesiredZoom = 1500;
- DesiredPitch = 55000;
- }
Add Comment
Please, Sign In to add comment