Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // GrimPlayerController
- //
- // Author: Andrew Spiering, November 2010
- //=============================================================================
- class GrimPlayerController extends GamePlayerController
- config(GrimGame);
- var GrimSplineMover mover;
- var Actor finalLocation;
- var bool useSplineMovement;
- var Vector lastLocation;
- var ForceFeedbackWaveform CameraShakeShortWaveForm, CameraShakeLongWaveForm;
- var bool bCurrentCamAnimIsDamageShake;
- var bool bCurrentCamAnimAffectsFOV;
- var transient bool bQuittingToMainMenu;
- //var bool bPressedJump;
- //var bool bDoubleJump;
- // Amount of rage Grim has... GRIM MAD!!!!
- var float rage;
- // Max amount of rage grim can have.
- var float maxRage;
- /** camera anim played when hit (blend strength depends on damage taken) */
- var CameraAnim DamageCameraAnim;
- var class<Camera> MatineeCamera${1}< ${3} >
- var vector PCCameraLoc;
- var rotator PCCameraRot;
- var int oldDistance;
- var float leeway; //if the Pawn is farther than this amount the constraint will Lerp it back
- var float lerpSpeed; //How fast the Pawn gets Lerp'd into position
- /// PLAYER CHEATS!!!!
- exec function GiveRage(float inRage)
- {
- AddRage(inRage);
- }
- //=============================================================================
- function bool FindNavMeshPath()
- {
- // Clear cache and constraints (ignore recycling for the moment)
- NavigationHandle.PathConstraintList = none;
- NavigationHandle.PathGoalList = none;
- // Create constraints
- class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle,finalLocation );
- class'NavMeshGoal_At'.static.AtActor( NavigationHandle, finalLocation );
- // Find path
- return NavigationHandle.FindPath();
- }
- //=============================================================================
- function InitializeMovement () {
- // $AS TODO: We need to look for the EndMission Actor :P this way we can set
- // the NavigationMesh to use that as the final desitnation.
- local GrimEndMissionActor A;
- ForEach AllActors(class'GrimEndMissionActor', A) {
- if (A != none)
- finalLocation = A;
- }
- if (!FindNavMeshPath()) {
- `log("We are so fucked");
- return;
- }
- NavigationHandle.SetFinalDestination(finalLocation.Location);
- `log("FindNavMeshPath returned TRUE");
- FlushPersistentDebugLines();
- NavigationHandle.DrawPathCache(,TRUE);
- }
- function UpdateLocation () {
- local bool reachTarget;
- if (finalLocation == none)
- return;
- reachTarget = Pawn.ReachedDestination(finalLocation);
- // $AS TODO: If we have reached the target then we need to figure out what
- // to do next... either we move on to the next one or we stop.
- if (reachTarget)
- return;
- if(NavigationHandle.GetNextMoveLocation(lastLocation, Pawn.GetCollisionRadius())) {
- lastLocation.Z = Pawn.Location.Z;
- //Enforce our Constraint
- if(VSize2D(Pawn.Location - lastLocation) > leeway) {
- //use Lerp
- lastLocation.X = Lerp(Pawn.Location.X, lastLocation.X, lerpSpeed);
- lastLocation.Y = Lerp(Pawn.Location.Y, lastLocation.Y, lerpSpeed);
- Pawn.SetLocation(lastLocation);
- }
- }
- }
- //=============================================================================
- simulated event PostBeginPlay()
- {
- super.PostBeginPlay();
- if (useSplineMovement) {
- mover = new class'GrimSplineMover';
- }
- InitializeMovement();
- `log("In the grim Controller");
- }
- //=============================================================================
- event PlayerTick( float DeltaTime ) {
- super.PlayerTick(DeltaTime);
- if (useSplineMovement) {
- mover.SetConstraint(Pawn);
- mover.Update(DeltaTime);
- }
- }
- //=============================================================================
- state PlayerWalking
- {
- ignores SeePlayer, HearNoise, Bump;
- event bool NotifyLanded(vector HitNormal, Actor FloorActor) {
- if (Global.NotifyLanded(HitNormal, FloorActor)) {
- return true;
- }
- return false;
- }
- //=============================================================================
- function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot) {
- local Rotator tempRot;
- if (Role == ROLE_Authority) {
- Pawn.SetRemoteViewPitch( Rotation.Pitch );
- }
- Pawn.Acceleration.X = 1 * PlayerInput.aForward;
- Pawn.Acceleration.Y = 1 * PlayerInput.aStrafe;
- Pawn.Acceleration.Z = 0;
- NewAccel = Pawn.Acceleration;
- tempRot.Pitch = Pawn.Rotation.Pitch;
- tempRot.Roll = 0;
- tempRot.Yaw = GrimCamera(PlayerCamera).inputs.Yaw;
- //if (Normal(Pawn.Acceleration) Dot Vect(0,1,0) > 0) {
- // tempRot.Yaw = 16384;
- // Pawn.SetRotation(tempRot);
- //}
- //else if(Normal(Pawn.Acceleration) Dot Vect(0,1,0) < 0) {
- // tempRot.Yaw = -16384;
- //}
- Pawn.SetRotation(tempRot);
- DeltaRot = Pawn.Rotation;
- CheckJumpOrDuck();
- Super.ProcessMove(DeltaTime,NewAccel,DoubleClickMove,DeltaRot);
- }
- //=============================================================================
- function PlayerMove( float DeltaTime ) {
- local vector X,Y,Z, NewAccel;
- local eDoubleClickDir DoubleClickMove;
- local rotator OldRotation;
- local bool bSaveJump;
- DoubleClickMove = DCLICK_None;
- if( Pawn == None ) {
- GotoState('Dead');
- }
- else {
- GetAxes(Pawn.Rotation,X,Y,Z);
- // Update rotation.
- OldRotation = Rotation;
- UpdateRotation( DeltaTime );
- bDoubleJump = false;
- if( bPressedJump && Pawn.CannotJumpNow() ) {
- bSaveJump = true;
- bPressedJump = false;
- }
- else {
- bSaveJump = false;
- }
- if( Role < ROLE_Authority ) {
- ReplicateMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
- }
- else {
- ProcessMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
- }
- GroundPitch = 0;
- bPressedJump = bSaveJump;
- }
- Super.PlayerMove(DeltaTime);
- }
- }
- //=============================================================================
- function SetCamCrap(Actor inCam) {
- GrimCamera(PlayerCamera).inputs = inCam.Rotation;
- }
- //=============================================================================
- function AddRage(float inAmount) {
- rage = FClamp(rage + inAmount, 0, maxRage);
- `log("GIME ME RAGE " $rage);
- // $AS - WE MIGHT WANT TO LET THE UI KNOW SOMETHING AWESOME HAPPEN!!!
- }
- //=============================================================================
- DefaultProperties
- {
- InputClass=class'GrimPlayerInput'
- CameraClass=class'GrimCamera'
- rage = 0;
- maxRage = 100;
- useSplineMovement = false;
- leeway = 10
- lerpSpeed = 0.5
- bDebugClientAdjustPosition = true;
- CheatClass=class'GrimCheatManager'
- }
Add Comment
Please, Sign In to add comment