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

Commit d97a9f6

Browse files
committed
Correct physics constants getter calls (followup to /cortex-command-community/Cortex-Command-Community-Project-Source@9b4805d53eedbe9e568f1d3f0f9b6075438677ec)
1 parent 4571ec0 commit d97a9f6

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

Base.rte/AI/HumanBehaviors.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function HumanBehaviors.GetGrenadeAngle(AimPoint, TargetVel, StartPos, muzVel)
257257
Dist = SceneMan:ShortestDistance(StartPos, AimPoint, false)
258258
end
259259

260-
Dist = Dist / FrameMan.PPM -- convert from pixels to meters
260+
Dist = Dist / GetPPM() -- convert from pixels to meters
261261
local velSqr = math.pow(muzVel, 2)
262262
local gravity = SceneMan.GlobalAcc.Y * 0.67 -- underestimate gravity
263263
local root = math.sqrt(velSqr*velSqr - gravity*(gravity*Dist.X*Dist.X+2*-Dist.Y*velSqr))
@@ -1715,8 +1715,8 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
17151715
-- predict jetpack movement when jumping and there is a target (check one direction)
17161716
local jetStrength = AI.jetImpulseFactor / Owner.Mass
17171717
local t = math.min(0.4, Owner.JetTimeLeft*0.001)
1718-
local PixelVel = Owner.Vel * (FrameMan.PPM * t)
1719-
local Accel = SceneMan.GlobalAcc * FrameMan.PPM
1718+
local PixelVel = Owner.Vel * (GetPPM() * t)
1719+
local Accel = SceneMan.GlobalAcc * GetPPM()
17201720

17211721
-- a burst use 10x more fuel
17221722
if Owner.Jetpack:CanTriggerBurst() then
@@ -1779,8 +1779,8 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
17791779
-- predict jetpack movement...
17801780
local jetStrength = AI.jetImpulseFactor / Owner.Mass
17811781
local t = math.min(0.4, Owner.JetTimeLeft*0.001)
1782-
local PixelVel = Owner.Vel * (FrameMan.PPM * t)
1783-
local Accel = SceneMan.GlobalAcc * FrameMan.PPM
1782+
local PixelVel = Owner.Vel * (GetPPM() * t)
1783+
local Accel = SceneMan.GlobalAcc * GetPPM()
17841784

17851785
-- a burst use 10x more fuel
17861786
if Owner.Jetpack:CanTriggerBurst() then
@@ -2162,16 +2162,16 @@ function HumanBehaviors.GetProjectileData(Owner)
21622162
PrjDat.rng = math.huge
21632163
elseif PrjDat.drg < 1 then -- AirResistance
21642164
PrjDat.rng = 0
2165-
local threshold = PrjDat.thr * FrameMan.PPM * TimerMan.DeltaTimeSecs -- AirThreshold in pixels/frame
2166-
local vel = PrjDat.vel * FrameMan.PPM * TimerMan.DeltaTimeSecs -- muzzle velocity in pixels/frame
2165+
local threshold = PrjDat.thr * GetPPM() * TimerMan.DeltaTimeSecs -- AirThreshold in pixels/frame
2166+
local vel = PrjDat.vel * GetPPM() * TimerMan.DeltaTimeSecs -- muzzle velocity in pixels/frame
21672167
for _ = 0, math.ceil(lifeTime/TimerMan.DeltaTimeMS) do
21682168
PrjDat.rng = PrjDat.rng + vel
21692169
if vel > threshold then
21702170
vel = vel * PrjDat.drg
21712171
end
21722172
end
21732173
else -- no AirResistance
2174-
PrjDat.rng = PrjDat.vel * FrameMan.PPM * TimerMan.DeltaTimeSecs * (lifeTime / TimerMan.DeltaTimeMS)
2174+
PrjDat.rng = PrjDat.vel * GetPPM() * TimerMan.DeltaTimeSecs * (lifeTime / TimerMan.DeltaTimeMS)
21752175
end
21762176

21772177
-- Artificially decrease reported range to make sure AI
@@ -2931,7 +2931,7 @@ function HumanBehaviors.GetAngleToHit(PrjDat, Dist)
29312931
return Dist.AbsRadAngle
29322932
else -- compensate for gravity
29332933
local rootSq, muzVelSq
2934-
local D = Dist / FrameMan.PPM -- convert from pixels to meters
2934+
local D = Dist / GetPPM() -- convert from pixels to meters
29352935
if PrjDat.drg < 1 then -- compensate for air resistance
29362936
local rng = D.Magnitude
29372937
local timeToTarget = math.floor((rng / math.max(PrjDat.vel*PrjDat.drg^math.floor(rng/(PrjDat.vel+1)+0.5), PrjDat.thr)) / TimerMan.DeltaTimeSecs) -- estimate time of flight in frames

Base.rte/AI/NativeHumanAI.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ function NativeHumanAI:Create(Owner)
5656
Owner.Jetpack.Throttle = 0.15 -- increase jetpack strength slightly to compensate for AI ineptitude
5757
end
5858

59-
Members.jetImpulseFactor = Owner.Jetpack:EstimateImpulse(false) * FrameMan.PPM / TimerMan.DeltaTimeSecs
60-
Members.jetBurstFactor = (Owner.Jetpack:EstimateImpulse(true) * FrameMan.PPM / TimerMan.DeltaTimeSecs - Members.jetImpulseFactor) * math.pow(TimerMan.DeltaTimeSecs, 2) * 0.5
59+
Members.jetImpulseFactor = Owner.Jetpack:EstimateImpulse(false) * GetPPM() / TimerMan.DeltaTimeSecs
60+
Members.jetBurstFactor = (Owner.Jetpack:EstimateImpulse(true) * GetPPM() / TimerMan.DeltaTimeSecs - Members.jetImpulseFactor) * math.pow(TimerMan.DeltaTimeSecs, 2) * 0.5
6161
Members.minBurstTime = math.min(Owner.Jetpack.BurstSpacing*2, Owner.JetTimeTotal*0.99) -- in milliseconds
6262
end
6363

Base.rte/Constants.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rte.StartingFundsScale = 1.0;
2121
rte.PassengerMax = 3; -- Deprecated. Use 'Craft.MaxPassengers' instead
2222
rte.DiggersRate = 0.4
2323
rte.MetabaseArea = "MetabaseServiceArea"
24-
rte.PxTravelledPerFrame = FrameMan.PPM * TimerMan.DeltaTimeSecs;
24+
rte.PxTravelledPerFrame = GetPPM() * TimerMan.DeltaTimeSecs;
2525

2626
-- Materials
2727
rte.airID = 0;

Base.rte/Devices/Shared/Scripts/TrajectoryGuide.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Update(self)
2626
local guideParPos = self.MuzzlePos;
2727
local guideParVel = Vector(self.projectileVel,0):RadRotate(actor:GetAimAngle(true));
2828
for i = 1, self.maxTrajectoryPars do
29-
guideParVel = guideParVel + Vector((SceneMan.GlobalAcc.X/FrameMan.PPM),(SceneMan.GlobalAcc.Y/FrameMan.PPM));
29+
guideParVel = guideParVel + Vector((SceneMan.GlobalAcc.X/GetPPM()),(SceneMan.GlobalAcc.Y/GetPPM()));
3030
guideParPos = guideParPos + guideParVel;
3131
-- No need to wrap the seam manually, primitives can handle out-of-scene coordinates correctly
3232
--if SceneMan.SceneWrapsX == true then

Base.rte/Devices/Tools/Disarmer/Disarmer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Create(self)
77
self.blink = false;
88
self.fireOn = false;
99

10-
self.disarmRange = FrameMan.PPM * 5;
10+
self.disarmRange = GetPPM() * 5;
1111
self.targetTable = {};
1212
end
1313

Base.rte/Scripts/Global/EnableFriendlyFire.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function FriendlyFireScript:UpdateScript()
88
if self.updateTimer:IsPastSimTimeLimit() then
99
for part in MovableMan.Particles do
1010
if part.HitsMOs and part.Team ~= -1 then
11-
if (part.Age * FrameMan.PPM * part.Vel.Magnitude) / 1000 > self.safeDist then
11+
if (part.Age * GetPPM() * part.Vel.Magnitude) / 1000 > self.safeDist then
1212
part.Team = -1;
1313
part.IgnoresTeamHits = false;
1414
end

Techion.rte/Devices/Weapons/NanoRifle/NanoShot.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
function Create(self)
22
--Collide with objects and deploy the destroy effect.
33
self.CheckCollision = function(Vel)
4-
local Trace = Vel * TimerMan.DeltaTimeSecs * FrameMan.PPM
4+
local Trace = Vel * TimerMan.DeltaTimeSecs * GetPPM()
55
local moid = SceneMan:CastMORay(self.Pos, Trace, 0, self.Team, 0, true, 1)
66
if moid > 0 and moid < rte.NoMOID then
77
local hitPos = Vector()
88
SceneMan:CastFindMORay(self.Pos, Trace, moid, hitPos, 0, true, 1)
99
self.deleteNextFrame = true
10-
self.Vel = (SceneMan:ShortestDistance(self.Pos, hitPos, true) / TimerMan.DeltaTimeSecs) / FrameMan.PPM
10+
self.Vel = (SceneMan:ShortestDistance(self.Pos, hitPos, true) / TimerMan.DeltaTimeSecs) / GetPPM()
1111

1212
local target = MovableMan:GetMOFromID(moid)
1313
if target then

0 commit comments

Comments
 (0)