Skip to content

Commit

Permalink
drop difficulty scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
wmtorode committed Dec 5, 2020
1 parent 7baa222 commit 8d6a515
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Data/DifficultyScaler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace DropCostsEnhanced.Data
{
public class DifficultyScaler
{
public int minDiff = 0;
public int maxDiff = 0;
public float modifier = 1.0f;
}
}
4 changes: 4 additions & 0 deletions Data/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class Settings
public float roundToNearist = 10000f;
public string heatSunkStat = "CACOverrallHeatSinked";

public bool useDifficultyCostScaling = false;
public float defaultDifficultyCostModifier = 1.0f;
public List<DifficultyScaler> difficultyCostModifiers = new List<DifficultyScaler>();

public List<FactionCapital> capitals = new List<FactionCapital>();

[JsonConverter(typeof(StringEnumConverter))]
Expand Down
1 change: 1 addition & 0 deletions DropCostsEnhanced.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Data\AmmoCost.cs" />
<Compile Include="Data\DifficultyScaler.cs" />
<Compile Include="Data\DropCostFactor.cs" />
<Compile Include="Data\EDifficultyType.cs" />
<Compile Include="Data\FactionCapital.cs" />
Expand Down
23 changes: 23 additions & 0 deletions Features/DropCostManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace DropCostsEnhanced
public class DropCostManager: BaseCostManager
{
private static DropCostManager _instance;

private Dictionary<int, float> costScaler = new Dictionary<int, float>();

public int LanceTonnage
{
Expand Down Expand Up @@ -69,6 +71,13 @@ private float CalculateMechValue(MechDef mech)
LanceTonnage = 0;
uuid = "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0";
ObjectiveText = "DROP COSTS DEDUCTED";
foreach (DifficultyScaler scaler in DCECore.settings.difficultyCostModifiers)
{
for (int i = scaler.minDiff; i <= scaler.maxDiff; i++)
{
costScaler[i] = scaler.modifier;
}
}
}

new public int CalculateFinalCosts(List<AbstractActor> actors)
Expand Down Expand Up @@ -107,6 +116,20 @@ public void CalculateLanceCost(List<MechDef> mechDefs)

LanceTonnage += (int) mech.Chassis.Tonnage;
}

if (DCECore.settings.useDifficultyCostScaling)
{
int dropDiff = RawCost / DCECore.settings.valuePerHalfSkull;
float diffModifier = DCECore.settings.defaultDifficultyCostModifier;
if (costScaler.ContainsKey(dropDiff))
{
diffModifier = costScaler[dropDiff];
}

Cost = (int) (Cost * diffModifier);
DCECore.modLog.Info?.Write($"Drop Difficulty of: {dropDiff}, has modifier of: {diffModifier}, Changing Drop Cost to: {Cost}");

}


}
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ This was inspired by the original drop cost mod: `DropCostPerMech` and `GlobalDi
"diffMode" : "NotActive",
"valuePerHalfSkull" : 16500000,
"defaultMechsToCount" : 8,
"maxDifficulty" : 25
"maxDifficulty" : 25,
"useDifficultyCostScaling" : false,
"defaultDifficultyCostModifier" : 1.0,
"difficultyCostModifiers" : []
}
```

Expand All @@ -55,6 +58,12 @@ This was inspired by the original drop cost mod: `DropCostPerMech` and `GlobalDi

`heatSunkStat` : the name of the stat used by CAC to track heat sunk

`useDifficultyCostScaling` : when enabled drop costs can be scaled based on drop difficulty (mech value based)

`defaultDifficultyCostModifier` : when drop difficulty scaling is enabled this is the default modifier for the drop difficulty if one is not defined

`difficultyCostModifiers` : a list of cost scaling modifier objects

`diffMode` : Controls what mode contract/system difficulty operates on. Options:

- NotActive: The default mode, Global difficulty patches are not applied at all
Expand Down Expand Up @@ -94,6 +103,26 @@ example json:
}
```

### Drop Cost Difficulty Scaling

Drop costs can be scaled based on the lance's drop difficulty rating, each modifier specifies a range of difficulty values
(inclusive) where that modifier will be applied.

example json:
```json
{
"minDiff": 0,
"maxDiff" : 0,
"modifier" : 1.0
}
```

`minDiff` : the bottom of the difficulty range where this modifier kicks in

`maxDiff` : the top of the range where this modifier is active

`modifier` : the modifier to apply, less than 1 is a discount, greater than 1 is extra cost


## Ammo Costs

Expand Down

0 comments on commit 8d6a515

Please sign in to comment.