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

Commit b955d15

Browse files
committed
Review changes
1 parent 6ccf6d3 commit b955d15

File tree

10 files changed

+79
-87
lines changed

10 files changed

+79
-87
lines changed

Base.rte/AI/HumanAI.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ function Create(self)
66
self.AI = NativeHumanAI:Create(self);
77
--You can turn features on and off here
88
self.armSway = true;
9-
self.automaticEquip = false;
109
self.alternativeGib = true;
1110
self.visibleInventory = false;
1211
end

Base.rte/AI/HumanFunctions.lua

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ function HumanFunctions.DoAlternativeGib(actor)
5656
end
5757
end
5858
end
59-
60-
function HumanFunctions.DoAutomaticEquip(actor)
61-
--Equip a weapon automatically if the one held by a player is destroyed
62-
if actor.EquippedItem == nil and not actor.controller:IsState(Controller.WEAPON_FIRE) and actor:IsPlayerControlled() then
63-
actor:EquipFirearm(true);
64-
end
65-
end
6659

6760
function HumanFunctions.DoArmSway(actor, pushStrength)
6861
local aimAngle = actor:GetAimAngle(false);
@@ -181,4 +174,31 @@ function HumanFunctions.DoVisibleInventory(actor, showAll)
181174
end
182175
end
183176
end
177+
end
178+
--Lunge forward, preferably as result of some dedicated input. Returns horizontal direction of lunge. (TODO: move this into another table?)
179+
function HumanFunctions.Lunge(actor, power)
180+
local flip = 0;
181+
if actor.Status == Actor.STABLE then
182+
flip = actor.FlipFactor;
183+
if actor.controller:IsState(Controller.MOVE_RIGHT) then
184+
flip = 1;
185+
elseif actor.controller:IsState(Controller.MOVE_LEFT) then
186+
flip = -1;
187+
end
188+
--Different factors that affect the lunge
189+
local angVel = math.abs(actor.AngularVel * 0.1) + 1;
190+
local vel = (actor.Vel.Magnitude + angVel)^2 * 0.0005 + 1;
191+
local mass = math.abs(actor.Mass * 0.005) + 1;
192+
local aimAng = actor:GetAimAngle(false);
193+
local vertical = math.abs(math.cos(aimAng))/vel;
194+
local strength = power * math.min(actor.Health/actor.MaxHealth, 1);
195+
196+
local jumpVec = Vector((power + strength/vel) * flip, -(power * 0.5 + (strength * 0.3)) * vertical):RadRotate(aimAng * actor.FlipFactor);
197+
198+
actor.Vel = actor.Vel + jumpVec/mass;
199+
actor.AngularVel = actor.AngularVel - (1/angVel * vertical) * flip * math.cos(actor.RotAngle);
200+
actor.Status = Actor.UNSTABLE;
201+
actor.tapTimer:Reset();
202+
end
203+
return flip;
184204
end

Base.rte/AI/NativeHumanAI.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ function NativeHumanAI:CreateAttackBehavior(Owner)
737737
elseif Owner:EquipNamedDevice("Timed Explosive", true) then
738738
self.NextBehavior = coroutine.create(HumanBehaviors.ThrowTarget)
739739
self.NextBehaviorName = "ThrowTarget"
740-
elseif Owner.FirearmIsReady and HumanBehaviors.GetProjectileData(Owner).pen * 0.9 > (ToADoor(self.Target).Door or self.Target).Material.StructuralIntegrity then
740+
elseif Owner.FirearmIsReady and HumanBehaviors.GetProjectileData(Owner).pen * 0.9 > (self.Target.Door or self.Target).Material.StructuralIntegrity then
741741
self.NextBehavior = coroutine.create(HumanBehaviors.ShootTarget)
742742
self.NextBehaviorName = "ShootTarget"
743743
end

Base.rte/Activities/BunkerBreach.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function BunkerBreach:UpdateActivity()
283283
self.attackPos = targetActor.Pos;
284284

285285
self.CPUSpawnDelay = self.CPUSpawnDelay * 0.5;--* dist.Magnitude/searchRadius;
286-
286+
--TODO: Fix GetClosestTeamActor and use that instead
287287
local closestGuard = MovableMan:GetClosestEnemyActor(targetActor.Team, targetActor.Pos, searchRadius - dist.Magnitude, Vector());
288288
if closestGuard and math.random() > dist.Magnitude/searchRadius and closestGuard.AIMode == Actor.AIMODE_SENTRY and closestGuard:GetAlarmPoint() ~= Vector() then
289289
--Send a nearby alerted guard after the intruder

Base.rte/Effects/Pyro/Flame/Flame.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
function Create(self)
22
--Add flames to a global table that handles their stickyness
33
if self.ClassName == "PEmitter" and not string.find(self.PresetName, "Ground") then
4-
Flames = Flames or {};
5-
local id = #Flames + 1;
6-
Flames[id] = {particle = self, id = self.UniqueID};
4+
local id = #GlobalFlameManagement.Flames + 1;
5+
GlobalFlameManagement.Flames[id] = {particle = self, id = self.UniqueID};
76
if string.find(self.PresetName, "Short") then
8-
Flames[id].deleteDelay = self.Lifetime * RangeRand(0.1, 0.2);
9-
Flames[id].isShort = true;
7+
GlobalFlameManagement.Flames[id].deleteDelay = self.Lifetime * RangeRand(0.1, 0.2);
8+
GlobalFlameManagement.Flames[id].isShort = true;
109
end
11-
if GlobalFlameHandler == nil then
12-
GlobalFlameHandler = CreateMOPixel("Global Flame Handler", "Base.rte");
13-
MovableMan:AddParticle(GlobalFlameHandler);
10+
if GlobalFlameManagement.FlameHandler == nil then
11+
local handler = CreateMOPixel("Global Flame Handler", "Base.rte");
12+
MovableMan:AddParticle(handler);
13+
GlobalFlameManagement.FlameHandler = handler;
1414
end
1515
end
1616
end
Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,61 @@
11
--Global handler for flame particles - this eliminates the need to run a script on each of the particles
2+
GlobalFlameManagement = {FlameHandler = nil, Flames = {}};
3+
24
function Create(self)
35
self.shortFlame = CreatePEmitter("Flame Hurt Short Float", "Base.rte");
4-
print("GlobalFlameHandler:Create()");
56
end
67
--To-do: multiple flames close to each other should form a bigger flame
78
function Update(self)
89
self.PinStrength = 900001;
910
local flameCount = 0;
1011
local nearbyFlame = {};
11-
if #Flames ~= 0 then
12-
for i = 1, #Flames do
13-
if Flames[i] and Flames[i].particle and MovableMan:ValidMO(Flames[i].particle) then
12+
if #GlobalFlameManagement.Flames ~= 0 then
13+
--TODO: use 'pairs' instead?
14+
for i = 1, #GlobalFlameManagement.Flames do
15+
if GlobalFlameManagement.Flames[i] and GlobalFlameManagement.Flames[i].particle and MovableMan:ValidMO(GlobalFlameManagement.Flames[i].particle) then
1416

1517
flameCount = flameCount + 1;
1618

17-
local flame = Flames[i].particle;
19+
local flame = GlobalFlameManagement.Flames[i].particle;
1820
local ageRatio = flame.Age/flame.Lifetime;
1921
flame.ToSettle = false;
2022
flame.Throttle = flame.Throttle - TimerMan.DeltaTimeMS/flame.Lifetime;
2123

22-
if Flames[i].target and Flames[i].target.ID ~= rte.NoMOID and not Flames[i].target.ToDelete then
23-
flame.Vel = Flames[i].target.Vel;
24-
flame.Pos = Flames[i].target.Pos + Vector(Flames[i].stickOffset.X, Flames[i].stickOffset.Y):RadRotate(Flames[i].target.RotAngle - Flames[i].targetStickAngle);
25-
local actor = Flames[i].target:GetRootParent();
24+
if GlobalFlameManagement.Flames[i].target and GlobalFlameManagement.Flames[i].target.ID ~= rte.NoMOID and not GlobalFlameManagement.Flames[i].target.ToDelete then
25+
flame.Vel = GlobalFlameManagement.Flames[i].target.Vel;
26+
flame.Pos = GlobalFlameManagement.Flames[i].target.Pos + Vector(GlobalFlameManagement.Flames[i].stickOffset.X, GlobalFlameManagement.Flames[i].stickOffset.Y):RadRotate(GlobalFlameManagement.Flames[i].target.RotAngle - GlobalFlameManagement.Flames[i].targetStickAngle);
27+
local actor = GlobalFlameManagement.Flames[i].target:GetRootParent();
2628
if MovableMan:IsActor(actor) then
2729
actor = ToActor(actor);
28-
actor.Health = actor.Health - (Flames[i].target.DamageMultiplier + flame.Throttle)/(actor.Mass * 0.5 + Flames[i].target.Material.StructuralIntegrity * 0.75);
30+
actor.Health = actor.Health - (GlobalFlameManagement.Flames[i].target.DamageMultiplier + flame.Throttle)/(actor.Mass * 0.5 + GlobalFlameManagement.Flames[i].target.Material.StructuralIntegrity * 0.75);
2931
--Stop, drop and roll!
3032
flame.Lifetime = flame.Lifetime - math.abs(actor.AngularVel);
3133
end
3234
else
33-
Flames[i].target = nil;
35+
GlobalFlameManagement.Flames[i].target = nil;
3436
if math.random() > ageRatio then
3537
if flame.Vel.Magnitude > 1 then
3638
local checkPos = Vector(flame.Pos.X, flame.Pos.Y - 1) + flame.Vel * rte.PxTravelledPerFrame * math.random();
3739
local moCheck = SceneMan:GetMOIDPixel(checkPos.X, checkPos.Y);
3840
if moCheck ~= rte.NoMOID then
3941
local mo = MovableMan:GetMOFromID(moCheck);
4042
if mo and (flame.Team == Activity.NOTEAM or mo.Team ~= flame.Team) then
41-
Flames[i].target = ToMOSRotating(mo);
43+
GlobalFlameManagement.Flames[i].target = ToMOSRotating(mo);
4244

43-
Flames[i].isShort = true;
44-
Flames[i].deleteDelay = math.random(flame.Lifetime);
45+
GlobalFlameManagement.Flames[i].isShort = true;
46+
GlobalFlameManagement.Flames[i].deleteDelay = math.random(flame.Lifetime);
4547

46-
Flames[i].targetStickAngle = mo.RotAngle;
47-
Flames[i].stickOffset = SceneMan:ShortestDistance(mo.Pos, flame.Pos, SceneMan.SceneWrapsX) * 0.8;
48+
GlobalFlameManagement.Flames[i].targetStickAngle = mo.RotAngle;
49+
GlobalFlameManagement.Flames[i].stickOffset = SceneMan:ShortestDistance(mo.Pos, flame.Pos, SceneMan.SceneWrapsX) * 0.8;
4850

4951
flame.GlobalAccScalar = 0.9;
5052
end
51-
elseif flame.GlobalAccScalar < 0.5 and Flames[i].isShort and math.random() < 0.2 and SceneMan:GetTerrMatter(checkPos.X, checkPos.Y) ~= rte.airID then
52-
Flames[i].deleteDelay = math.random(flame.Lifetime);
53+
elseif flame.GlobalAccScalar < 0.5 and GlobalFlameManagement.Flames[i].isShort and math.random() < 0.2 and SceneMan:GetTerrMatter(checkPos.X, checkPos.Y) ~= rte.airID then
54+
GlobalFlameManagement.Flames[i].deleteDelay = math.random(flame.Lifetime);
5355
flame.GlobalAccScalar = 0.9;
5456
end
5557
end
56-
if not Flames[i].isShort then
58+
if not GlobalFlameManagement.Flames[i].isShort then
5759
--Combine two flames into one
5860
if flame.Throttle < 0 then
5961
for n = 1, #nearbyFlame do
@@ -69,8 +71,8 @@ function Update(self)
6971
newFlame.Pos = flame.Pos;
7072
newFlame.Vel = flame.Vel;
7173
MovableMan:AddParticle(newFlame);
72-
Flames[i].particle = newFlame;
73-
Flames[i].isShort = true;
74+
GlobalFlameManagement.Flames[i].particle = newFlame;
75+
GlobalFlameManagement.Flames[i].isShort = true;
7476
flame.ToDelete = true;
7577
flame = newFlame;
7678
]]--
@@ -88,22 +90,21 @@ function Update(self)
8890
MovableMan:AddParticle(particle);
8991
end
9092
end
91-
if Flames[i].deleteDelay and flame.Age > Flames[i].deleteDelay then
93+
if GlobalFlameManagement.Flames[i].deleteDelay and flame.Age > GlobalFlameManagement.Flames[i].deleteDelay then
9294
flame.ToDelete = true;
9395
end
9496
end
9597
end
9698
else
97-
Flames[i] = {};
99+
GlobalFlameManagement.Flames[i] = {};
98100
end
99101
end
100102
if flameCount == 0 then
101103
--Clear the global table
102-
Flames = {};
104+
GlobalFlameManagement.Flames = {};
103105
end
104106
end
105107
end
106108
function Destroy(self)
107-
GlobalFlameHandler = nil;
108-
print("GlobalFlameHandler:Destroy()");
109+
GlobalFlameManagement.FlameHandler = nil;
109110
end

Coalition.rte/Devices/Explosives/ClusterGrenade/ClusterPart.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ function Update(self)
77
--Bounce on the very first hit, and explode on the next
88
self.GibImpulseLimit = 1;
99
self.HitsMOs = self.HitsMOs or math.random() < 0.5;
10+
self:DisableScript("Coalition.rte/Devices/Explosives/ClusterGrenade/ClusterPart.lua");
1011
end
1112
end

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

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function Create(self)
44
self.lungeTapDelay = 200;
55
self.lungePower = 6;
66
self.tapTimer = Timer();
7+
self.dir = 0;
78

89
if not self:NumberValueExists("Identity") then
910
self.face = math.random(0, self.FrameCount - 2);
@@ -22,11 +23,8 @@ function Create(self)
2223
self.Head.Frame = self.face;
2324
end
2425
end
25-
self.analogSpin = 0;
26-
self.lastAnalogAngle = self:GetController().AnalogMove.AbsRadAngle;
2726
end
2827
function Update(self)
29-
self.analogSpin = self.analogSpin * 0.9;
3028
if self.updateTimer:IsPastSimMS(1000) then
3129
self.updateTimer:Reset();
3230
self.aggressive = self.Health < self.MaxHealth * 0.5;
@@ -42,51 +40,24 @@ function Update(self)
4240
if self:IsPlayerControlled() and self.Status < Actor.INACTIVE and self.FGLeg and self.BGLeg then
4341
local crouching = self.controller:IsState(Controller.BODY_CROUCH);
4442
if self.Status == Actor.UNSTABLE then
45-
local motion = (self.Vel.Magnitude * 0.5 + math.abs(self.AngularVel));
46-
local stillness = 1/(1 + motion);
47-
if crouching then
48-
self.AngularVel = self.AngularVel * (1 - stillness) - (self.RotAngle - (self:GetAimAngle(false) - math.pi * 0.5) * self.FlipFactor) * 2 * stillness;
43+
if self.dir == self.FlipFactor then
44+
local motion = (self.Vel.Magnitude * 0.5 + math.abs(self.AngularVel));
45+
local stillness = 1/(1 + motion);
46+
if crouching then
47+
self.AngularVel = self.AngularVel * (1 - stillness) - (self.RotAngle - (self:GetAimAngle(false) - math.pi * 0.5) * self.FlipFactor) * 2 * stillness;
48+
end
49+
else
50+
self.dir = 0;
4951
end
5052
elseif crouching then
5153
if not self.crouchHeld then
5254
if not self.tapTimer:IsPastSimMS(self.lungeTapDelay) and SceneMan.Scene.GlobalAcc.Magnitude > 10 then
53-
Lunge(self, 3);
54-
else
55-
self.tapTimer:Reset();
56-
end
55+
self.dir = HumanFunctions.Lunge(self, self.lungePower);
56+
end
57+
self.tapTimer:Reset();
5758
self.controller:SetState(Controller.BODY_CROUCH, false);
5859
end
59-
else
60-
self.analogSpin = self.analogSpin + math.sin(self.controller.AnalogMove.AbsRadAngle - self.lastAnalogAngle);
61-
if math.abs(self.analogSpin) > 2 then
62-
Lunge(self, 12);
63-
self.analogSpin = 0;
64-
end
6560
end
6661
self.crouchHeld = crouching;
6762
end
68-
self.lastAnalogAngle = self.controller.AnalogMove.AbsRadAngle;
69-
end
70-
71-
function Lunge(self, spin)
72-
local flip = self.FlipFactor;
73-
if self.controller:IsState(Controller.MOVE_RIGHT) then
74-
flip = 1;
75-
elseif self.controller:IsState(Controller.MOVE_LEFT) then
76-
flip = -1;
77-
end
78-
--Different factors that affect the lunge
79-
local angVel = math.abs(self.AngularVel * 0.1) + 1;
80-
local vel = (self.Vel.Magnitude + angVel)^2 * 0.0005 + 1;
81-
local mass = math.abs(self.Mass * 0.005) + 1;
82-
local aimAng = self:GetAimAngle(false);
83-
local vertical = math.abs(math.cos(aimAng))/vel;
84-
local strength = (self.lungePower/self.MaxHealth) * math.min(self.Health, self.MaxHealth);
85-
86-
local jumpVec = Vector((self.lungePower + strength/vel) * flip, -(self.lungePower * 0.5 + (strength * 0.3)) * vertical):RadRotate(aimAng * self.FlipFactor);
87-
88-
self.Vel = self.Vel + jumpVec/mass;
89-
self.AngularVel = self.AngularVel - (spin/angVel * vertical) * flip * math.cos(self.RotAngle);
90-
self.Status = Actor.UNSTABLE;
91-
self.tapTimer:Reset();
9263
end

Ronin.rte/Devices/Shared/Throwable.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ end
88
function OnCollideWithMO(self, mo, rootMO)
99
if self.thrown then
1010
local force = self.PrevVel * self.impactPower;
11-
mo:AddForce(force, Vector());
11+
mo:AddImpulseForce(force, Vector());
1212
if force.Magnitude * self.Sharpness > mo.Material.StructuralIntegrity then
1313
local woundName = mo:GetEntryWoundPresetName();
1414
if woundName ~= "" then

Ronin.rte/Devices/Weapons/RocketPropelledChainsaw/RPCShot.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Update(self)
2929
local dist = SceneMan:ShortestDistance(self.Pos, mo.Pos, SceneMan.SceneWrapsX);
3030
self:AddWound(CreateAEmitter(self:GetEntryWoundPresetName()), Vector(math.random(1 + self.length), 0), true);
3131

32-
mo:AddForce(self.Vel * self.Mass, Vector());
32+
mo:AddImpulseForce(self.Vel * self.Mass, Vector());
3333
self.Vel = (mo.Vel - dist:SetMagnitude(self.Vel.Magnitude):RadRotate(RangeRand(-1, 1))) * 0.5;
3434
self.AngularVel = self.AngularVel + math.random(10, 20) * (math.random() < 0.5 and 1 or -1);
3535
else

0 commit comments

Comments
 (0)