Skip to content

Commit

Permalink
The real AME nerf (space-wizards#29587)
Browse files Browse the repository at this point in the history
* The real AME nerf

* oh the real change

* Update AmeNodeGroup.cs
  • Loading branch information
EmoGarbage404 authored and themias committed Aug 9, 2024
1 parent 44f8728 commit c8bddb6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
27 changes: 9 additions & 18 deletions Content.Server/Ame/AmeNodeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,11 @@ public float InjectFuel(int fuel, out bool overloading)
// The AME is being overloaded.
// Note about these maths: I would assume the general idea here is to make larger engines less safe to overload.
// In other words, yes, those are supposed to be CoreCount, not safeFuelLimit.
var instability = 0;
var overloadVsSizeResult = fuel - CoreCount;

// fuel > safeFuelLimit: Slow damage. Can safely run at this level for burst periods if the engine is small and someone is keeping an eye on it.
if (_random.Prob(0.5f))
instability = 1;
// overloadVsSizeResult > 5:
if (overloadVsSizeResult > 5)
instability = 3;
// overloadVsSizeResult > 10: This will explode in at most 20 injections.
if (overloadVsSizeResult > 10)
instability = 5;

// Apply calculated instability
if (instability == 0)
return powerOutput;
var instability = overloadVsSizeResult / CoreCount;
var fuzz = _random.Next(-1, 2); // -1 to 1
instability += fuzz; // fuzz the values a tiny bit.

overloading = true;
var integrityCheck = 100;
Expand Down Expand Up @@ -179,10 +168,12 @@ public float InjectFuel(int fuel, out bool overloading)
/// </summary>
public float CalculatePower(int fuel, int cores)
{
// Fuel is squared so more fuel vastly increases power and efficiency
// We divide by the number of cores so a larger AME is less efficient at the same fuel settings
// this results in all AMEs having the same efficiency at the same fuel-per-core setting
return 20000f * fuel * fuel / cores;
// Balanced around a single core AME with injection level 2 producing 120KW.
// Overclocking yields diminishing returns until it evens out at around 360KW.

// The adjustment for cores make it so that a 1 core AME at 2 injections is better than a 2 core AME at 2 injections.
// However, for the relative amounts for each (1 core at 2 and 2 core at 4), more cores has more output.
return 200000f * MathF.Log10(fuel * fuel) * MathF.Pow(0.75f, cores - 1);
}

public int GetTotalStability()
Expand Down
20 changes: 15 additions & 5 deletions Content.Server/Ame/EntitySystems/AmeControllerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ public void SetInjectionAmount(EntityUid uid, int value, EntityUid? user = null,
At the time of editing, players regularly "overclock" the AME and those cases require no admin attention.
// Admin alert
var safeLimit = 0;
var safeLimit = int.MaxValue;
if (TryGetAMENodeGroup(uid, out var group))
safeLimit = group.CoreCount * 2;
safeLimit = group.CoreCount * 4;
if (oldValue <= safeLimit && value > safeLimit)
{
Expand All @@ -291,10 +291,20 @@ public void SetInjectionAmount(EntityUid uid, int value, EntityUid? user = null,
*/
}

public void AdjustInjectionAmount(EntityUid uid, int delta, int min = 0, int max = int.MaxValue, EntityUid? user = null, AmeControllerComponent? controller = null)
public void AdjustInjectionAmount(EntityUid uid, int delta, EntityUid? user = null, AmeControllerComponent? controller = null)
{
if (Resolve(uid, ref controller))
SetInjectionAmount(uid, MathHelper.Clamp(controller.InjectionAmount + delta, min, max), user, controller);
if (!Resolve(uid, ref controller))
return;

var max = GetMaxInjectionAmount((uid, controller));
SetInjectionAmount(uid, MathHelper.Clamp(controller.InjectionAmount + delta, 0, max), user, controller);
}

public int GetMaxInjectionAmount(Entity<AmeControllerComponent> ent)
{
if (!TryGetAMENodeGroup(ent, out var group))
return 0;
return group.CoreCount * 8;
}

private void UpdateDisplay(EntityUid uid, int stability, AmeControllerComponent? controller = null, AppearanceComponent? appearance = null)
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Ame/Components/AmeFuelContainerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public sealed partial class AmeFuelContainerComponent : Component
/// The amount of fuel in the container.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public int FuelAmount = 1000;
public int FuelAmount = 500;

/// <summary>
/// The maximum fuel capacity of the container.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public int FuelCapacity = 1000;
public int FuelCapacity = 500;
}

0 comments on commit c8bddb6

Please sign in to comment.