Skip to content

Commit 233f906

Browse files
committed
v4.1 FINAL fix thrusterPower bug, add fullThrustMin
Fixes bug in thrust force, allows semi-fullThrust mode (clamp below which fullThrust doesn't engage).
1 parent c688b7b commit 233f906

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

0 Bytes
Binary file not shown.

ModuleRCSFX/Readme_MRCSFX.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ which, when set to true, means that RCS will fire forwards with the throttle.
1919

2020

2121
** RCS Thrust Control **
22-
fullThrust defaults to false. Set it to true and RCS will always fire at full thrust (or 10% thrust in precision mode), rather than the less-than-full-thrust, dependent-on-angle they do stock.
22+
fullThrust defaults to false. Set it to true and if the thrust ratio is > fullThrustMin (default: 0.2) RCS will fire at full thrust (or 10% thrust in precision mode), rather than the less-than-full-thrust, dependent-on-angle they do stock.
2323

2424
useLever defaults to false. When it's false, fine controls will make RCS fire at 10% (default) power only. When it's set to true, stock behavior returns (i.e. fine controls means lever arm compensation).
2525

@@ -39,6 +39,10 @@ LICENSE remains the ialdabaoth license (CC-BY-SA + tweaks).
3939
SOURCE is https://github.com/NathanKell/ModuleRCSFX
4040

4141
CHANGELOG
42+
v4.1
43+
* Fix bug with fuel consumption and thrust (thrusterPower wasn't being applied right)
44+
* When in fullThrust mode, don't switch to full thrust unless thrust ratio already starts out at fullThrustMin (configurable).
45+
4246
v4.0
4347
* Update to KSP 1.0.
4448
* Speed improvements. (Death to foreach! Don't recalculate values!)

Source/ModuleRCSFX.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ public class ModuleRCSFX : ModuleRCS
1111
[KSPField]
1212
public bool fullThrust = false; // always use full thrust
1313

14+
/// <summary>
15+
/// If fullThrust = true, if thrust ratio is < this, do not apply full thrust (leave thrust unchanged)
16+
/// </summary>
17+
[KSPField]
18+
public float fullThrustMin = 0.2f; // if thrust amount from dots < this, don't do full thrust
19+
1420
[KSPField]
1521
public bool useEffects = false;
1622

@@ -250,7 +256,7 @@ public override void OnStart(StartState state)
250256

251257
if (thrust > 0f)
252258
{
253-
if (fullThrust)
259+
if (fullThrust && thrust >= fullThrustMin)
254260
thrust = 1f;
255261

256262
if (precision)
@@ -276,7 +282,8 @@ public override void OnStart(StartState state)
276282

277283
if (success)
278284
{
279-
curThrust += thrust;
285+
thrustForce *= thrusterPower;
286+
curThrust += thrustForce;
280287
thrustForces.Add(thrustForce);
281288
if (!isJustForShow)
282289
{
@@ -333,12 +340,12 @@ private void UpdatePropellantStatus()
333340

334341
new public float CalculateThrust(float totalForce, out bool success)
335342
{
336-
double massFlow = flowMult * fuelFlow * (double)totalForce * TimeWarp.fixedDeltaTime;
343+
double massFlow = flowMult * fuelFlow * (double)totalForce;
337344

338345
double propAvailable = 1.0d;
339346

340347
if (!CheatOptions.InfiniteRCS)
341-
propAvailable = RequestPropellant(massFlow);
348+
propAvailable = RequestPropellant(massFlow * thrusterPower * TimeWarp.fixedDeltaTime);
342349

343350
totalForce = (float)(massFlow * exhaustVel * propAvailable);
344351

Source/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("0.4.*")]
36-
[assembly: AssemblyFileVersion("0.4.0.0")]
36+
[assembly: AssemblyFileVersion("0.4.1.0")]

0 commit comments

Comments
 (0)