From 8d4ebacb0970947a1c15a479c20ff76a3183290d Mon Sep 17 00:00:00 2001 From: data-bomb Date: Sat, 23 Nov 2024 07:31:58 -0800 Subject: [PATCH] Adds Worm Bounty Scaling - Scales the amount of the bounty reward for killing a Great Worm based on the current team technology tier - The bounty is multiplied by a scaling factor between 1 and 3. 1 representing tech tier 0 and 3 representing the maximum tech tier. - The default preferences will allow a bounty of 2000 in the early game up to a bounty of 6000 in the late game --- Si_WormBounty/Si_WormBounty.cs | 37 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/Si_WormBounty/Si_WormBounty.cs b/Si_WormBounty/Si_WormBounty.cs index a2745eb..142786b 100644 --- a/Si_WormBounty/Si_WormBounty.cs +++ b/Si_WormBounty/Si_WormBounty.cs @@ -37,7 +37,7 @@ You should have received a copy of the GNU General Public License using Si_WormBounty; -[assembly: MelonInfo(typeof(WormBounty), "Worm Bounty", "1.0.0", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(WormBounty), "Worm Bounty", "1.1.0", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -50,14 +50,16 @@ public class WormBounty : MelonMod static MelonPreferences_Entry _Pref_GreatWorms_SpawnChance = null!; static MelonPreferences_Entry _Pref_GreatWorms_Bounty_BaseAmount = null!; static MelonPreferences_Entry _Pref_GreatWorms_Bounty_RandomBonusMax = null!; + static MelonPreferences_Entry _Pref_GreatWorms_Bounty_TechScaling = null!; public override void OnInitializeMelon() { _modCategory ??= MelonPreferences.CreateCategory("Silica"); _Pref_GreatWorms_MaxNumber ??= _modCategory.CreateEntry("GreatWorms_MaxNumber", 2); - _Pref_GreatWorms_Bounty_BaseAmount ??= _modCategory.CreateEntry("GreatWorms_Bounty_BaseAmount", 500); + _Pref_GreatWorms_Bounty_BaseAmount ??= _modCategory.CreateEntry("GreatWorms_Bounty_BaseAmount", 1250); _Pref_GreatWorms_Bounty_RandomBonusMax ??= _modCategory.CreateEntry("GreatWorms_Bounty_Bonus_RandomMax", 750); + _Pref_GreatWorms_Bounty_TechScaling ??= _modCategory.CreateEntry("GreatWorms_Bounty_TechScaling", true); _Pref_GreatWorms_SpawnChance ??= _modCategory.CreateEntry("GreatWorms_SpawnChance", 0.25f); } @@ -195,7 +197,7 @@ public static void Prefix(AmbientLife __instance, Unit __0, GameObject __1) } // determine bounty amount - int bountyAmount = FindBounty(); + int bountyAmount = FindBounty(attackerPlayer.Team); // award bounty AwardBounty(attackerPlayer, bountyAmount); @@ -207,23 +209,38 @@ public static void Prefix(AmbientLife __instance, Unit __0, GameObject __1) } } - private static int FindBounty() + private static int FindBounty(Team team) { // explosion kills earn a bit less - int baseAmount = _Pref_GreatWorms_Bounty_BaseAmount.Value; + int baseBounty = _Pref_GreatWorms_Bounty_BaseAmount.Value; // give a little more, perhaps - int varyingAmount = 0; + int varyingBounty = 0; if (_Pref_GreatWorms_Bounty_RandomBonusMax.Value > 0) { System.Random randomIndex = new System.Random(); - varyingAmount = randomIndex.Next(0, _Pref_GreatWorms_Bounty_RandomBonusMax.Value); + varyingBounty = randomIndex.Next(0, _Pref_GreatWorms_Bounty_RandomBonusMax.Value); + } + + int bountyTotal = baseBounty + varyingBounty; - // round down to nearest ten - varyingAmount = (int)Math.Round(varyingAmount / 10.0) * 10; + // scale up for later tech tiers, perhaps + if (_Pref_GreatWorms_Bounty_TechScaling.Value) + { + bountyTotal = (int)Math.Round(bountyTotal * FindTechScalingFactor(team)); } - return baseAmount + varyingAmount; + // round down to nearest ten + bountyTotal = (int)Math.Round(bountyTotal / 10.0) * 10; + + return bountyTotal; + } + + // map the technology tier to a multiplier between 1 and 3 + private static float FindTechScalingFactor(Team team) + { + float techTierPercentage = (float)team.CurrentTechnologyTier / (float)team.MaximumTechnologyTier; + return 1f + techTierPercentage * (2f); } private static void AwardBounty(Player player, int bounty)