Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit b488ba4

Browse files
committed
Ronin touch-ups; Commander can now perform somersaults
1 parent 40366ad commit b488ba4

File tree

11 files changed

+67
-30
lines changed

11 files changed

+67
-30
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

Ronin.rte/Actors/Brains/Commander/RoninCommander.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ AddActor = AHuman
3030
PresetName = Ronin Commander
3131
AddToGroup = Actors
3232
AddToGroup = Brains
33-
Description = Established Ronin Commander unit. Capable of remote-controlling units like any other commanding Brain. Double-tap Crouch to lunge out!
33+
Description = MultiLineText
34+
AddLine = Established Ronin Commander unit. Capable of remote-controlling units like any other commanding Brain.
35+
AddLine = Press Jump and then Crouch to perform a somersault, or double-tap Crouch to lunge out!
3436
Mass = 50
3537
GoldValue = 125
3638
Sharpness = 1
@@ -109,6 +111,7 @@ AddActor = AHuman
109111
PresetName = Ronin Commander Arm FG A
110112
SpriteFile = ContentFile
111113
FilePath = Ronin.rte/Actors/Brains/Commander/ArmFGA.bmp
114+
JointStrength = 300
112115
ParentOffset = Vector
113116
X = -1
114117
Y = -5
@@ -117,6 +120,7 @@ AddActor = AHuman
117120
PresetName = Ronin Commander Arm BG A
118121
SpriteFile = ContentFile
119122
FilePath = Ronin.rte/Actors/Brains/Commander/ArmBGA.bmp
123+
JointStrength = 300
120124
ParentOffset = Vector
121125
X = 4
122126
Y = -7
@@ -133,6 +137,7 @@ AddActor = AHuman
133137
ParentOffset = Vector
134138
X = -11
135139
Y = -10
140+
JointStrength = 400
136141
ParentOffset = Vector
137142
X = 1
138143
Y = 1
@@ -149,6 +154,7 @@ AddActor = AHuman
149154
ParentOffset = Vector
150155
X = -11
151156
Y = -10
157+
JointStrength = 400
152158
ParentOffset = Vector
153159
X = 4
154160
Y = 1

Ronin.rte/Actors/Brains/Commander/RoninCommander.lua

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ function Create(self)
22
self.updateTimer = Timer();
33

44
self.lungeTapDelay = 200;
5+
self.frontFlip = {input = {Controller.BODY_JUMP, Controller.BODY_CROUCH}, inputCounter = 0};
56
self.lungePower = 6;
67
self.tapTimer = Timer();
78

@@ -28,40 +29,70 @@ function Update(self)
2829
end
2930
end
3031
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);
3133

3234
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);
4356
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;
5757
self.tapTimer:Reset();
5858
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;
6172
end
62-
self.keyHeld = true;
63-
else
64-
self.keyHeld = false;
6573
end
6674
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();
6798
end
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)