Skip to content

Commit

Permalink
- Added rollup blacklist
Browse files Browse the repository at this point in the history
- Fixed issue with bundled items not eligible for random pickup.
  • Loading branch information
IceRaptor committed May 19, 2019
1 parent f463135 commit 10286de
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 37 deletions.
36 changes: 13 additions & 23 deletions LootMagnet/LootMagnet/Patches/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,6 @@ public static void Prefix(Contract __instance, MissionResult result, bool isGood
}
}

//[HarmonyPatch(typeof(Contract), "GetPotentialSalvage")]
//public static class Contract_GetPotentialSalvage {

// // At this point, salvage has been collapsed and grouped. For each of those that have count > 1, change their name, add them to the Dict, and set count to 1.
// public static void Postfix(Contract __instance, List<SalvageDef> __result) {
// if (__result != null) {

// // Sort by price, since other functions depend on it
// __result.Sort(new Helper.SalvageDefByCostDescendingComparer());

// // Roll up any remaining salvage
// List<SalvageDef> rolledUpSalvage = Helper.RollupSalvage(__result);

// // Update the result that will be returned
// __result.Clear();
// __result.AddRange(rolledUpSalvage);
// }
// }
//}

[HarmonyPatch(typeof(ListElementController_SalvageMechPart_NotListView), "RefreshInfoOnWidget")]
[HarmonyPatch(new Type[] { typeof(InventoryItemElement_NotListView) })]
public static class ListElementController_SalvageMechPart_RefreshInfoOnWidget {
Expand All @@ -86,14 +66,24 @@ public static void Postfix(ListElementController_SalvageMechPart_NotListView __i
public static class Contract_AddToFinalSalvage {

public static void Prefix(Contract __instance, ref SalvageDef def) {
if (def != null) {
if (def.RewardID != null && def.RewardID.Contains("_qty")) {
Mod.Log.Debug($"C:ATFS - entered.");
if (def?.RewardID != null) {
if (def.RewardID.Contains("_qty")) {
Mod.Log.Debug($" Salvage ({def.Description.Name}) has rewardID:({def.RewardID}) with multiple quantities");
int qtyIdx = def.RewardID.IndexOf("_qty");
string countS = def.RewardID.Substring(qtyIdx + 4);
Mod.Log.Debug($"Salvage {def.Description.Name} with rewardID:{def.RewardID} will be given count: {countS}");
Mod.Log.Debug($" Salvage ({def.Description.Name}) with rewardID:({def.RewardID}) will be given count: {countS}");
int count = int.Parse(countS);
def.Count = count;
} else {
Mod.Log.Debug($" Salvage ({def.Description.Name}) has rewardID:({def.RewardID})");
List<string> compPartIds = State.CompensationParts.Select(sd => sd.RewardID).ToList();
if (compPartIds.Contains(def.RewardID)) {
Mod.Log.Debug($" Found item in compensation that was randomly assigned.");
}
}
} else {
Mod.Log.Debug($" RewardId was null for def:({def?.Description?.Name})");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions LootMagnet/LootMagnet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("2.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]
[assembly: AssemblyVersion("2.5.0.0")]
[assembly: AssemblyFileVersion("2.5.0.0")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
15 changes: 13 additions & 2 deletions LootMagnet/LootMagnet/Utils/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ public static List<SalvageDef> RollupSalvage(List<SalvageDef> rawSalvage) {

private static void RollupSalvageDef(SalvageDef salvageDef, float threshold, List<SalvageDef> salvage) {
int rollupCount = (int)Math.Ceiling(threshold / salvageDef.Description.Cost);
Mod.Log.Debug($"threshold:{threshold.ToString("0")} / cost:{salvageDef?.Description?.Cost} = result:{rollupCount}");
Mod.Log.Debug($" threshold:{threshold.ToString("0")} / cost:{salvageDef?.Description?.Cost} = result:{rollupCount}");

if (rollupCount > 1) {
if (Mod.Config.RollupBlacklist.Contains(salvageDef.MechComponentDef.Description.Id)) {
Mod.Log.Info($" BLACKLISTED: {salvageDef.MechComponentDef.Description.Id} cannot be rolled up. Skipping. ");
salvage.Add(salvageDef);
} else if (rollupCount > 1) {
int buckets = (int)Math.Floor(salvageDef.Count / (double)rollupCount);
int remainder = salvageDef.Count % rollupCount;
Mod.Log.Debug($"count:{salvageDef.Count} / limit:{rollupCount} = buckets:{buckets}, remainder:{remainder}");
Expand Down Expand Up @@ -316,6 +319,14 @@ public static void CalculateAndAddAvailableSalvage(AAR_SalvageScreen salvageScre
Mod.Log.Debug("CAAAS - updated salvageController count");

salvageSelection.ApplySalvageSorting();

// Update the contract potential salvage
Contract contract = salvageScreenT.Field("contract").GetValue<Contract>();
Traverse finalPotentialSalvageT = Traverse.Create(contract).Field("finalPotentialSalvage");
List<SalvageDef> finalPotentialSalvage = finalPotentialSalvageT.GetValue<List<SalvageDef>>();

finalPotentialSalvage.Clear();
finalPotentialSalvage.AddRange(potentialSalvage);
}
}
}
18 changes: 9 additions & 9 deletions LootMagnet/LootMagnet/Utils/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class ModConfig {
// The values used to define the base amounts for rollup
public float[] RollupMRBValue = new float[] { 40000f, 60000f, 90000f, 130000f, 180000f, 240000f };

public List<string> RollupBlacklist = new List<string>();

public List<RepCfg> Reputation = new List<RepCfg>() {};

public HoldbackCfg Holdback = new HoldbackCfg();
Expand All @@ -82,22 +84,20 @@ public void LogConfig() {

string rollupMRBVal = string.Join(", ", RollupMRBValue.Select(v => v.ToString("0.00")).ToArray());
Mod.Log.Info($" MRB Rollup Values: {rollupMRBVal}");
string rollupBlacklistS = string.Join(", ", RollupBlacklist.ToArray<string>());
Mod.Log.Info($" Rollup Blacklists: {rollupBlacklistS}");

Mod.Log.Info($"FACTION REPUTATION VALUES");
foreach (RepCfg factionCfg in Reputation) {
Mod.Log.Info($" Reputation:{factionCfg.Reputation} ComponentRollup:{factionCfg.RollupMultiComponent} MechRollup:{factionCfg.RollupMultiMech} HoldbackTrigger:{factionCfg.HoldbackTrigger}%");
}

Mod.Log.Info($"HOLDBACK VALUES");
//Mod.Logger.Log($" Holdback Picks: {Holdback.PickRange[0]} to {Holdback.PickRange[1]}");

//Mod.Logger.Log($" Reputation ACCEPT:x{Holdback.RepMultiAccept} REFUSE:x{Holdback.RepMultiRefuse} DISPUTE_MRB:x{Holdback.RepMultiDisputeMRB}");
//Mod.Logger.Log($" Reputation DISPUTE_SUCCESS:x{Holdback.RepMultiDisputeSuccess} DISPUTE_FAIL:x{Holdback.RepMultiDisputeFail} DISPUTE_CRIT_FAIL:x{Holdback.RepMultiDisputeCriticalFail}");

//Mod.Logger.Log($" Dispute Chance BASE:{Holdback.DisputeSuccessBase}% CRIT_CHANCE:{Holdback.DisputeCritChance}% " +
// $"MRB_FACTOR:{Holdback.DisputeMRBSuccessFactor}% RANDOM:{Holdback.DisputeSuccessRandomBound}%");

//Mod.Logger.Log($" MRB_Fees:x{Holdback.DisputeMRBFeeFactor} FAIL_PAYOUT:x{Holdback.DisputeFailPayoutFactor} CRIT_FAIL_PAYOUT:X{Holdback.DisputeCritFailPayoutFactor}");
Mod.Log.Info($" Holdback Picks: {Holdback.MechParts[0]} to {Holdback.MechParts[1]}");
Mod.Log.Info($" Rep Range: {Holdback.ReputationRange[0]} to {Holdback.ReputationRange[1]}");
Mod.Log.Info($" Dispute Picks: {Holdback.DisputePicks[0]} to {Holdback.DisputePicks[1]}");
Mod.Log.Info($" Dispute SuccessBase:{Holdback.DisputeSuccessBase} MRBSuccessFactor:{Holdback.DisputeMRBSuccessFactor} " +
$"SuccessRandomBound:{Holdback.DisputeSuccessRandomBound} MRBFeeFactor:{Holdback.DisputeMRBFeeFactor}");

Mod.Log.Info("=== MOD CONFIG END ===");
}
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Mech parts may also be rolled up, if your faction rating is good enough. The **R
| 4 | 0 | 0 | 1,800,000 | 2,700,000 | 16,200,000 |
| 5 | 0 | 0 | 2,400,000 | 3,600,000 | 21,600,000 |

### Blacklist

Some items are too powerful or rare for employers to offer multiples. To mark any items as being ineligible for rollup, add them to the **RollupBlacklist** array in *mod.json*.



## Salvage Holdback

Mercenaries are contract workers. Even friendly employers hesitate when they notice LosTech or rare Battlemechs being carted off the field by a temporary 'friend'. Hidden clauses and fine print are the weapons Inner Sphere lawyers use to **hold back** items they desperately desire. In lore, this was very common when salvage included Star League or Clan technology.
Expand Down
18 changes: 17 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "LootMagnet",
"Enabled": true,
"Version": "2.4.0",
"Version": "2.5.0",
"Description": "Groups salvage of a similar type into a single pick. Provides lore-based employer shenanigans.",
"Author": "IceRaptor",
"Website": "https://github.com/IceRaptor/LootMagnet",
Expand All @@ -11,6 +11,22 @@
"Settings": {
"Debug" : false,
"RollupMRBValue" : [ 40000, 60000, 90000, 130000, 180000, 240000 ],
"RollupBlacklist": [
"Lootable_arm_mortis", "Lootable_Actuator_CoolingJacket",
"Lootable_AmmunitionBox_Hydra_LRM", "lootable_kit_shs", "lootable_engineslots_std_center", "lootable_kit_dhs_royal",
"StatusEffect-Initiative_Gain-B2000", "emod_lootable_armor_clstandard", "lootable_armorslots_Primitive", "lootable_ChameleonLightPolarizationShield",
"lootable_Cockpit_CLAN_Standard", "lootable_Cockpit_Generic_Standard", "lootable_Cockpit_Primitive", "lootable_Cockpit_SLDF_Standard",
"lootable_Cockpit_SolarisCage", "lootable_FCS_Generic_Clan", "lootable_FCS_Generic_SLDF", lootable_FCS_Generic_Standard",
"lootable_FCS_Primitive_Standard", "lootable_FCS_Society", "lootable_Gyro_Coventry_Brawler", "lootable_Gyro_Coventry_Dreadnought",
"lootable_Gyro_Ultralight_Stabilized", "lootable_Sensors_Clan", "lootable_Sensors_Generic_Standard", "lootable_Sensors_Primitive_Standard",
"lootable_Sensors_SLDF", "lootable_Sensors_Society", "Lootable_structureslots_EndoTSM",
"Lootable_Carebear_VibroClaws", "Lootable_Actuator_Prototype_Hatchet", "Lootable_Actuator_Prototype_Hatchet_Axman",
"Lootable_Actuator_Prototype_Hatchet_Berserker", "Lootable_Actuator_Prototype_Hatchet_pirate", "Lootable_Actuator_Prototype_Sword_5K",
"Lootable_Actuator_Prototype_Sword_BLK9", "Lootable_Actuator_Prototype_Sword_NDA", "Lootable_Actuator_Prototype_V4_Hatchet",
"Lootable_Actuator_Prototype_VibroShank", "Lootable_Actuator_Prototype_VibroSword", "Lootable_Actuator_Prototype_VibroSword_AES_S",
"Lootable_Actuator_Prototype_VibroSword_Muramasa", "Lootable_Actuator_Prototype_VibroSword_S",
"emod_armorslots_clanferrolamellor"
],
"Reputation" : [
{ "Reputation" : "LOATHED", "RollupMultiComponent" : 0, "RollupMultiMech" : 0, "HoldbackTrigger" : 72, "HoldbackValueCapMulti" : 0.2 },
{ "Reputation" : "HATED", "RollupMultiComponent" : 0, "RollupMultiMech" : 0, "HoldbackTrigger" : 48, "HoldbackValueCapMulti" : 0.3 },
Expand Down

0 comments on commit 10286de

Please sign in to comment.