@@ -2,6 +2,7 @@ function Create(self)
2
2
self .updateTimer = Timer ();
3
3
4
4
self .lungeTapDelay = 200 ;
5
+ self .frontFlip = {input = {Controller .BODY_JUMP , Controller .BODY_CROUCH }, inputCounter = 0 };
5
6
self .lungePower = 6 ;
6
7
self .tapTimer = Timer ();
7
8
@@ -28,40 +29,70 @@ function Update(self)
28
29
end
29
30
end
30
31
self .Frame = (self .face == 2 and self .Vel .Y > (SceneMan .GlobalAcc .Y * 0.15 )) and 3 or self .face ;
32
+ local crouching = self .controller :IsState (Controller .BODY_CROUCH );
31
33
32
34
if self :IsPlayerControlled () and self .Status < Actor .DYING and self .FGLeg and self .BGLeg then
33
- if self .Status == Actor .UNSTABLE and not self .tapTimer :IsPastSimMS (500 ) then
34
- self .AngularVel = self .AngularVel / (1 + self .Health * 0.001 );
35
- elseif self .controller :IsState (Controller .BODY_CROUCH ) then
36
- if self .keyHeld == false then
37
- if not self .tapTimer :IsPastSimMS (self .lungeTapDelay ) and SceneMan .Scene .GlobalAcc .Magnitude > 10 then
38
- local flip = self .FlipFactor ;
39
- if self .controller :IsState (Controller .MOVE_RIGHT ) then
40
- flip = 1 ;
41
- elseif self .controller :IsState (Controller .MOVE_LEFT ) then
42
- flip = - 1 ;
35
+ if self .Status == Actor .UNSTABLE then
36
+ if not crouching then
37
+ local motion = self .Vel .Magnitude * 0.5 + math.abs (self .AngularVel );
38
+ if self .AngularVel ~= 0 then
39
+ self .AngularVel = self .AngularVel * (1 - 0.1 / motion );
40
+ end
41
+ if self .tapTimer :IsPastSimMS (500 ) and math.cos (self .RotAngle ) > 0.9 and motion < 20 then
42
+ self .tapTimer :Reset ();
43
+ self .Status = Actor .STABLE ;
44
+ self .AngularVel = self .AngularVel * 0.5 ;
45
+ end
46
+ end
47
+ else
48
+ -- Track the key combo input (jump -> crouch) to trigger frontflip
49
+ if self .controller :IsState (self .frontFlip .input [self .frontFlip .inputCounter + 1 ]) then
50
+ if (self .frontFlip .inputCounter == 0 or not self .tapTimer :IsPastSimMS (self .lungeTapDelay )) then
51
+ self .frontFlip .inputCounter = self .frontFlip .inputCounter + 1 ;
52
+ if self .frontFlip .inputCounter == # self .frontFlip .input then
53
+ Lunge (self , 8 );
54
+ self .frontFlip .inputCounter = 0 ;
55
+ -- AudioMan:PlaySound("Ronin.rte/Actors/Brains/Commander/Sounds/Jump.wav", self.Pos);
43
56
end
44
- -- Different factors that affect the lunge
45
- local vel = (self .Vel .Magnitude ^ 2 ) * 0.0005 + 1 ;
46
- local ang = math.abs (self .AngularVel * 0.05 ) + 1 ;
47
- local mass = math.abs (self .Mass * 0.005 ) + 1 ;
48
- local aimAng = self :GetAimAngle (false );
49
- local vertical = math.abs (math.cos (aimAng ))/ vel ;
50
- local strength = (self .lungePower / self .MaxHealth ) * math.min (self .Health , self .MaxHealth );
51
-
52
- local jumpVec = Vector ((self .lungePower + strength / vel ) * flip , - (self .lungePower * 0.5 + (strength * 0.3 )) * vertical ):RadRotate (aimAng * self .FlipFactor );
53
-
54
- self .Vel = self .Vel + jumpVec / mass ;
55
- self .AngularVel = self .AngularVel - 4 / ang * flip * vertical ;
56
- self .Status = Actor .UNSTABLE ;
57
57
self .tapTimer :Reset ();
58
58
else
59
- self .tapTimer :Reset ();
60
- end
59
+ self .frontFlip .inputCounter = 0 ;
60
+ end
61
+ elseif crouching then
62
+ if not self .keyHeld then
63
+ if not self .tapTimer :IsPastSimMS (self .lungeTapDelay ) and SceneMan .Scene .GlobalAcc .Magnitude > 10 then
64
+ Lunge (self , 0 );
65
+ else
66
+ self .tapTimer :Reset ();
67
+ end
68
+ end
69
+ self .keyHeld = true ;
70
+ else
71
+ self .keyHeld = false ;
61
72
end
62
- self .keyHeld = true ;
63
- else
64
- self .keyHeld = false ;
65
73
end
66
74
end
75
+ end
76
+
77
+ function Lunge (self , spin )
78
+ local flip = self .FlipFactor ;
79
+ if self .controller :IsState (Controller .MOVE_RIGHT ) then
80
+ flip = 1 ;
81
+ elseif self .controller :IsState (Controller .MOVE_LEFT ) then
82
+ flip = - 1 ;
83
+ end
84
+ -- Different factors that affect the lunge
85
+ local vel = (self .Vel .Magnitude ^ 2 ) * 0.0005 + 1 ;
86
+ local ang = math.abs (self .AngularVel * 0.05 ) + 1 ;
87
+ local mass = math.abs (self .Mass * 0.005 ) + 1 ;
88
+ local aimAng = self :GetAimAngle (false );
89
+ local vertical = math.abs (math.cos (aimAng ))/ vel ;
90
+ local strength = (self .lungePower / self .MaxHealth ) * math.min (self .Health , self .MaxHealth );
91
+
92
+ local jumpVec = Vector ((self .lungePower + strength / vel ) * flip , - (self .lungePower * 0.5 + (strength * 0.3 )) * vertical ):RadRotate (aimAng * self .FlipFactor );
93
+
94
+ self .Vel = self .Vel + jumpVec / mass ;
95
+ self .AngularVel = self .AngularVel - (2 / ang * vertical + spin ) * flip ;
96
+ self .Status = Actor .UNSTABLE ;
97
+ self .tapTimer :Reset ();
67
98
end
0 commit comments