Guest User

Untitled

a guest
Jan 4th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // GrimPlayerController
  3. //
  4. // Author: Andrew Spiering, November 2010
  5. //=============================================================================
  6.  
  7. class GrimPlayerController extends GamePlayerController
  8.     config(GrimGame);
  9.  
  10. var GrimSplineMover mover;
  11. var Actor finalLocation;
  12. var bool useSplineMovement;
  13. var Vector lastLocation;
  14. var ForceFeedbackWaveform CameraShakeShortWaveForm, CameraShakeLongWaveForm;
  15. var bool bCurrentCamAnimIsDamageShake;
  16. var bool bCurrentCamAnimAffectsFOV;
  17. var transient bool bQuittingToMainMenu;
  18.  
  19. //var   bool bPressedJump;
  20. //var   bool bDoubleJump;
  21.  
  22. // Amount of rage Grim has... GRIM MAD!!!!
  23. var float rage;
  24. // Max amount of rage grim can have.
  25. var float maxRage;
  26.  
  27. /** camera anim played when hit (blend strength depends on damage taken) */
  28. var CameraAnim DamageCameraAnim;
  29. var class<Camera> MatineeCamera${1}< ${3} >
  30.  
  31. var vector PCCameraLoc;
  32. var rotator PCCameraRot;
  33. var int oldDistance;
  34.  
  35.  
  36. var float leeway;                //if the Pawn is farther than this amount the constraint will Lerp it back
  37. var float lerpSpeed;             //How fast the Pawn gets Lerp'd into position
  38.  
  39. /// PLAYER CHEATS!!!!
  40. exec function GiveRage(float inRage)
  41. {
  42.   AddRage(inRage);
  43. }
  44.  
  45. //=============================================================================
  46. function bool FindNavMeshPath()
  47. {
  48.   // Clear cache and constraints (ignore recycling for the moment)
  49.   NavigationHandle.PathConstraintList = none;
  50.   NavigationHandle.PathGoalList = none;
  51.  
  52.   // Create constraints
  53.   class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle,finalLocation );
  54.   class'NavMeshGoal_At'.static.AtActor( NavigationHandle, finalLocation );
  55.  
  56.   // Find path
  57.   return NavigationHandle.FindPath();
  58. }
  59.  
  60. //=============================================================================
  61. function InitializeMovement () {
  62.   // $AS TODO: We need to look for the EndMission Actor :P this way we can set
  63.   // the NavigationMesh to use that as the final desitnation.
  64.   local GrimEndMissionActor A;
  65.  
  66.   ForEach AllActors(class'GrimEndMissionActor', A) {
  67.     if (A != none)
  68.       finalLocation = A;
  69.   }
  70.  
  71.   if (!FindNavMeshPath()) {
  72.     `log("We are so fucked");
  73.     return;
  74.   }
  75.  
  76.   NavigationHandle.SetFinalDestination(finalLocation.Location);
  77.  
  78.   `log("FindNavMeshPath returned TRUE");
  79.   FlushPersistentDebugLines();
  80.   NavigationHandle.DrawPathCache(,TRUE);
  81.  
  82. }
  83.  
  84. function UpdateLocation () {
  85.   local bool reachTarget;
  86.  
  87.   if (finalLocation == none)
  88.     return;
  89.  
  90.   reachTarget = Pawn.ReachedDestination(finalLocation);
  91.  
  92.   // $AS TODO: If we have reached the target then we need to figure out what
  93.   // to do next... either we move on to the next one or we stop.
  94.   if (reachTarget)
  95.     return;
  96.  
  97.   if(NavigationHandle.GetNextMoveLocation(lastLocation, Pawn.GetCollisionRadius())) {
  98.     lastLocation.Z = Pawn.Location.Z;
  99.  
  100.     //Enforce our Constraint
  101.     if(VSize2D(Pawn.Location - lastLocation) > leeway) {
  102.       //use Lerp
  103.       lastLocation.X = Lerp(Pawn.Location.X, lastLocation.X, lerpSpeed);
  104.       lastLocation.Y = Lerp(Pawn.Location.Y, lastLocation.Y, lerpSpeed);       
  105.       Pawn.SetLocation(lastLocation);
  106.       }
  107.   }
  108. }
  109.  
  110. //=============================================================================
  111. simulated event PostBeginPlay()
  112. {
  113.   super.PostBeginPlay();
  114.  
  115.   if (useSplineMovement) {
  116.     mover = new class'GrimSplineMover';
  117.   }
  118.  
  119.   InitializeMovement();
  120.  
  121.   `log("In the grim Controller");
  122. }
  123.  
  124. //=============================================================================
  125. event PlayerTick( float DeltaTime ) {
  126.   super.PlayerTick(DeltaTime);
  127.  
  128.   if (useSplineMovement) {
  129.     mover.SetConstraint(Pawn);
  130.     mover.Update(DeltaTime);
  131.   }
  132. }
  133.  
  134. //=============================================================================
  135. state PlayerWalking
  136. {
  137.   ignores SeePlayer, HearNoise, Bump;
  138.  
  139.   event bool NotifyLanded(vector HitNormal, Actor FloorActor) {
  140.     if (Global.NotifyLanded(HitNormal, FloorActor)) {
  141.       return true;
  142.     }
  143.     return false;
  144.   }
  145.  
  146.   //=============================================================================
  147.   function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot) {
  148.     local Rotator tempRot;
  149.     if (Role == ROLE_Authority) {
  150.       Pawn.SetRemoteViewPitch( Rotation.Pitch );
  151.     }
  152.  
  153.     Pawn.Acceleration.X = 1 * PlayerInput.aForward;
  154.     Pawn.Acceleration.Y = 1 * PlayerInput.aStrafe;
  155.     Pawn.Acceleration.Z = 0;
  156.  
  157.     NewAccel = Pawn.Acceleration;
  158.  
  159.     tempRot.Pitch = Pawn.Rotation.Pitch;
  160.     tempRot.Roll = 0;
  161.  
  162.     tempRot.Yaw = GrimCamera(PlayerCamera).inputs.Yaw;
  163.  
  164.     //if (Normal(Pawn.Acceleration) Dot Vect(0,1,0) > 0) {
  165.     //  tempRot.Yaw = 16384;
  166.     //  Pawn.SetRotation(tempRot);
  167.     //}
  168.     //else if(Normal(Pawn.Acceleration) Dot Vect(0,1,0) < 0) {
  169.     //  tempRot.Yaw = -16384;
  170.    
  171.     //}
  172.  
  173.     Pawn.SetRotation(tempRot);
  174.  
  175.     DeltaRot = Pawn.Rotation;
  176.     CheckJumpOrDuck();
  177.  
  178.     Super.ProcessMove(DeltaTime,NewAccel,DoubleClickMove,DeltaRot);
  179.   }
  180.  
  181.   //=============================================================================
  182.   function PlayerMove( float DeltaTime ) {
  183.     local vector            X,Y,Z, NewAccel;
  184.     local eDoubleClickDir   DoubleClickMove;
  185.     local rotator           OldRotation;
  186.     local bool              bSaveJump;
  187.  
  188.     DoubleClickMove = DCLICK_None;
  189.  
  190.     if( Pawn == None ) {
  191.       GotoState('Dead');
  192.     }
  193.     else {
  194.       GetAxes(Pawn.Rotation,X,Y,Z);
  195.  
  196.             // Update rotation.
  197.             OldRotation = Rotation;
  198.  
  199.  
  200.  
  201.             UpdateRotation( DeltaTime );
  202.             bDoubleJump = false;
  203.             if( bPressedJump && Pawn.CannotJumpNow() ) {
  204.                 bSaveJump = true;
  205.                 bPressedJump = false;
  206.             }
  207.             else {
  208.                 bSaveJump = false;
  209.             }
  210.  
  211.       if( Role < ROLE_Authority ) {
  212.         ReplicateMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
  213.       }
  214.       else {
  215.         ProcessMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
  216.       }
  217.  
  218.       GroundPitch = 0;
  219.       bPressedJump = bSaveJump;
  220.     }
  221.         Super.PlayerMove(DeltaTime);
  222.     }
  223. }
  224.  
  225. //=============================================================================
  226. function SetCamCrap(Actor inCam) {
  227.   GrimCamera(PlayerCamera).inputs = inCam.Rotation;
  228. }
  229.  
  230. //=============================================================================
  231. function AddRage(float inAmount) {
  232.   rage = FClamp(rage + inAmount, 0, maxRage);
  233.   `log("GIME ME RAGE " $rage);
  234.   // $AS - WE MIGHT WANT TO LET THE UI KNOW SOMETHING AWESOME HAPPEN!!!
  235. }
  236.  
  237.  
  238. //=============================================================================
  239. DefaultProperties
  240. {
  241.   InputClass=class'GrimPlayerInput'
  242.   CameraClass=class'GrimCamera'
  243.   rage = 0;
  244.   maxRage = 100;
  245.   useSplineMovement = false;
  246.   leeway = 10
  247.   lerpSpeed = 0.5
  248.   bDebugClientAdjustPosition = true;
  249.   CheatClass=class'GrimCheatManager'
  250. }
Add Comment
Please, Sign In to add comment