Skip to content

Commit

Permalink
- Add max cap, remove unnecessary modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
IceRaptor committed Sep 13, 2020
1 parent 9df466c commit 57150a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
20 changes: 12 additions & 8 deletions SizeMatters/SizeMatters/Helper/StraightTonnageCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,17 @@ public static int Modifier(AbstractActor attacker, ICombatant target)
// a 20 vs t 100 => 20 - 100 = -80
// a 100 vs t 20 => 100 - 20 = 80
// a 50 vs t 50 => 0

float rawMod = tonnageFraction * Mod.Config.TonnageMulti;
if (rawMod < 0)
if (tonnageFraction < 0)
{
// Lighter unit attacking a heavier unit
modifier = (int) Math.Ceiling(rawMod);
Mod.Log.Debug?.Write($"RawMod: {rawMod} => ceiling = {modifier}");
modifier = (int) Math.Ceiling(tonnageFraction);
Mod.Log.Debug?.Write($"RawMod: {tonnageFraction} => ceiling = {modifier}");
}
else if (rawMod > 0)
else if (tonnageFraction > 0)
{
// Heavier unit attacking a lighter unit
modifier = (int) Math.Floor(rawMod);
Mod.Log.Debug?.Write($"RawMod: {rawMod} => floor = {modifier}");
modifier = (int) Math.Floor(tonnageFraction);
Mod.Log.Debug?.Write($"RawMod: {tonnageFraction} => floor = {modifier}");
}
else
{
Expand All @@ -53,6 +51,12 @@ public static int Modifier(AbstractActor attacker, ICombatant target)
Mod.Log.Warn?.Write(e, "Failed to calculate tonnage delta modifier!");
}

if (Math.Abs(modifier) > Mod.Config.ModifierCap)
{
if (modifier > 0) modifier = Mod.Config.ModifierCap;
else if (modifier < 0) modifier = Mod.Config.ModifierCap * -1;
}

return modifier;
}

Expand Down
7 changes: 6 additions & 1 deletion SizeMatters/SizeMatters/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ public class ModConfig
public bool Trace = false;

public float TonnageDivisor = 5.0f;
public float TonnageMulti = 0.5f;
public int ModifierCap = 5;

public VirtualTonnage VirtualTonnage = new VirtualTonnage();

public void LogConfig()
{
Mod.Log.Info?.Write("=== MOD CONFIG BEGIN ===");
Mod.Log.Info?.Write($" DEBUG: {this.Debug} Trace: {this.Trace}");
Mod.Log.Info?.Write($"");
Mod.Log.Info?.Write($" TonnageDivisor: {this.TonnageDivisor} ModifierCap: {this.ModifierCap}");
Mod.Log.Info?.Write($" Virtual Tonnage - Turrets => light: {this.VirtualTonnage.LightTurret} medium: {this.VirtualTonnage.MediumTurret} heavy: {this.VirtualTonnage.HeavyTurret}");
Mod.Log.Info?.Write($" Virtual Tonnage - Building: {this.VirtualTonnage.Building}");

Mod.Log.Info?.Write("=== MOD CONFIG END ===");
}

Expand Down
4 changes: 2 additions & 2 deletions SizeMatters/SizeMatters/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]

0 comments on commit 57150a7

Please sign in to comment.