Skip to content

Commit 8d6a515

Browse files
committed
drop difficulty scaling
1 parent 7baa222 commit 8d6a515

5 files changed

Lines changed: 67 additions & 1 deletion

File tree

Data/DifficultyScaler.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace DropCostsEnhanced.Data
2+
{
3+
public class DifficultyScaler
4+
{
5+
public int minDiff = 0;
6+
public int maxDiff = 0;
7+
public float modifier = 1.0f;
8+
}
9+
}

Data/Settings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public class Settings
1919
public float roundToNearist = 10000f;
2020
public string heatSunkStat = "CACOverrallHeatSinked";
2121

22+
public bool useDifficultyCostScaling = false;
23+
public float defaultDifficultyCostModifier = 1.0f;
24+
public List<DifficultyScaler> difficultyCostModifiers = new List<DifficultyScaler>();
25+
2226
public List<FactionCapital> capitals = new List<FactionCapital>();
2327

2428
[JsonConverter(typeof(StringEnumConverter))]

DropCostsEnhanced.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
</ItemGroup>
7070
<ItemGroup>
7171
<Compile Include="Data\AmmoCost.cs" />
72+
<Compile Include="Data\DifficultyScaler.cs" />
7273
<Compile Include="Data\DropCostFactor.cs" />
7374
<Compile Include="Data\EDifficultyType.cs" />
7475
<Compile Include="Data\FactionCapital.cs" />

Features/DropCostManager.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace DropCostsEnhanced
1010
public class DropCostManager: BaseCostManager
1111
{
1212
private static DropCostManager _instance;
13+
14+
private Dictionary<int, float> costScaler = new Dictionary<int, float>();
1315

1416
public int LanceTonnage
1517
{
@@ -69,6 +71,13 @@ private float CalculateMechValue(MechDef mech)
6971
LanceTonnage = 0;
7072
uuid = "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0";
7173
ObjectiveText = "DROP COSTS DEDUCTED";
74+
foreach (DifficultyScaler scaler in DCECore.settings.difficultyCostModifiers)
75+
{
76+
for (int i = scaler.minDiff; i <= scaler.maxDiff; i++)
77+
{
78+
costScaler[i] = scaler.modifier;
79+
}
80+
}
7281
}
7382

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

108117
LanceTonnage += (int) mech.Chassis.Tonnage;
109118
}
119+
120+
if (DCECore.settings.useDifficultyCostScaling)
121+
{
122+
int dropDiff = RawCost / DCECore.settings.valuePerHalfSkull;
123+
float diffModifier = DCECore.settings.defaultDifficultyCostModifier;
124+
if (costScaler.ContainsKey(dropDiff))
125+
{
126+
diffModifier = costScaler[dropDiff];
127+
}
128+
129+
Cost = (int) (Cost * diffModifier);
130+
DCECore.modLog.Info?.Write($"Drop Difficulty of: {dropDiff}, has modifier of: {diffModifier}, Changing Drop Cost to: {Cost}");
131+
132+
}
110133

111134

112135
}

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ This was inspired by the original drop cost mod: `DropCostPerMech` and `GlobalDi
3131
"diffMode" : "NotActive",
3232
"valuePerHalfSkull" : 16500000,
3333
"defaultMechsToCount" : 8,
34-
"maxDifficulty" : 25
34+
"maxDifficulty" : 25,
35+
"useDifficultyCostScaling" : false,
36+
"defaultDifficultyCostModifier" : 1.0,
37+
"difficultyCostModifiers" : []
3538
}
3639
```
3740

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

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

61+
`useDifficultyCostScaling` : when enabled drop costs can be scaled based on drop difficulty (mech value based)
62+
63+
`defaultDifficultyCostModifier` : when drop difficulty scaling is enabled this is the default modifier for the drop difficulty if one is not defined
64+
65+
`difficultyCostModifiers` : a list of cost scaling modifier objects
66+
5867
`diffMode` : Controls what mode contract/system difficulty operates on. Options:
5968

6069
- NotActive: The default mode, Global difficulty patches are not applied at all
@@ -94,6 +103,26 @@ example json:
94103
}
95104
```
96105

106+
### Drop Cost Difficulty Scaling
107+
108+
Drop costs can be scaled based on the lance's drop difficulty rating, each modifier specifies a range of difficulty values
109+
(inclusive) where that modifier will be applied.
110+
111+
example json:
112+
```json
113+
{
114+
"minDiff": 0,
115+
"maxDiff" : 0,
116+
"modifier" : 1.0
117+
}
118+
```
119+
120+
`minDiff` : the bottom of the difficulty range where this modifier kicks in
121+
122+
`maxDiff` : the top of the range where this modifier is active
123+
124+
`modifier` : the modifier to apply, less than 1 is a discount, greater than 1 is extra cost
125+
97126

98127
## Ammo Costs
99128

0 commit comments

Comments
 (0)