Skip to content

Commit

Permalink
- Add blacklist-by-component tags (thanks to Haree78)
Browse files Browse the repository at this point in the history
- Compensation offering now skips any blacklisted components (thanks to Haree78)
  • Loading branch information
IceRaptor committed May 4, 2020
1 parent 30f5f77 commit 3493533
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
3 changes: 3 additions & 0 deletions LootMagnet/LootMagnet/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ModConfig {
public float[] RollupMRBValue = new float[] { 40000f, 60000f, 90000f, 130000f, 180000f, 240000f };

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

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

Expand Down Expand Up @@ -146,6 +147,8 @@ public void LogConfig() {
Mod.Log.Info($" MRB Rollup Values: {rollupMRBVal}");
string rollupBlacklistS = string.Join(", ", RollupBlacklist.ToArray<string>());
Mod.Log.Info($" Rollup Blacklists: {rollupBlacklistS}");
string rollupBlacklistTagsS = string.Join(", ", RollupBlacklistTags.ToArray<string>());
Mod.Log.Info($" Rollup Blacklist Tags: {rollupBlacklistTagsS}");

Mod.Log.Info($"FACTION REPUTATION VALUES");
foreach (RepCfg factionCfg in Reputation) {
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("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
[assembly: AssemblyVersion("5.1.0.0")]
[assembly: AssemblyFileVersion("5.1.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
41 changes: 32 additions & 9 deletions LootMagnet/LootMagnet/Utils/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,32 @@ private static void RollupSalvageDef(SalvageDef salvageDef, float threshold, Lis

// Checks to determine if a mech part is blacklisted
public static bool IsBlacklisted(SalvageDef salvageDef) {
bool isBlacklisted = false;

// If the blacklist config contains the componentDef
if (Mod.Config.RollupBlacklist.Contains(salvageDef?.MechComponentDef?.Description?.Id)) {
isBlacklisted = true;
if (Mod.Config.RollupBlacklist.Contains(salvageDef?.MechComponentDef?.Description?.Id))
{
Mod.Log.Debug($" Component blacklisted by id: {salvageDef?.MechComponentDef?.Description?.Id}");
return true;
}

// If the component is a LootComponent and is blacklisted
if (salvageDef.MechComponentDef.Is<LootMagnetComp>(out LootMagnetComp lootComponent) && lootComponent.Blacklisted) {
isBlacklisted = true;
if (salvageDef.MechComponentDef.Is<LootMagnetComp>(out LootMagnetComp lootComponent) && lootComponent.Blacklisted)
{
Mod.Log.Debug($" Component blacklisted by CC:LootMagnetComp.");
return true;
}

return isBlacklisted;
foreach (string componentTag in salvageDef?.MechComponentDef?.ComponentTags)
{
// If the blacklist config contains the componentDef
if (Mod.Config.RollupBlacklistTags.Contains(componentTag))
{
Mod.Log.Debug($" Component blacklisted by component tag: {componentTag}");
return true;
}
}

return false;
}

public static void CalculateHoldback(List<SalvageDef> potentialSalvage) {
Expand Down Expand Up @@ -201,11 +214,21 @@ public static void CalculateCompensation(List<SalvageDef> potentialSalvage) {
List<SalvageDef> allComponents = potentialSalvage.Where(sd => sd.Type == SalvageDef.SalvageType.COMPONENT).ToList();
foreach (SalvageDef compSDef in allComponents) {
Mod.Log.Info($" Component:{compSDef.Description.Id}::{compSDef.Description.Name}");
if (compSDef.Description.Cost > adjValueCap) {
bool isBlacklisted = IsBlacklisted(compSDef);
if (isBlacklisted)
{
Mod.Log.Info($" Blacklisted: skipping.");
}
else if (compSDef.Description.Cost > adjValueCap)
{
Mod.Log.Info($" cost:{compSDef.Description.Cost} greater than cap, skipping.");
} else if (compSDef.Description.Cost > compensation) {
}
else if (compSDef.Description.Cost > compensation)
{
Mod.Log.Info($" remaining compensation:{compensation} less than cost:{compSDef.Description.Cost}, skipping.");
} else {
}
else
{
int available = (int)Math.Floor(compensation / compSDef.Description.Cost);
Mod.Log.Info($" - remaining compensation:{compensation} / cost: {compSDef.Description.Cost} = available:{available}");

Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ In the BattleTech lore salvage was a hotly negotiated topic for mercenaries. Mos

To simulate that negotiation process, this mod modifies your salvage choices based upon your MSRB rating and your faction allegiance. The vanilla experience becomes the default for low MSRB and faction contracts. As your MSRB or faction allegiance increases, your employer will be more willing to negotiate bundles of equipment of equivalent value. At the highest levels, you'll find all similar equipment bundled together as a single salvage pick.

:warning: This mod requires [Custom Components](https://github.com/denadan/customcomponents/). Most mod packs include this mod. If yours does not, or you are installing this mod independently, you need to download the most recent [Mech Engineer](https://github.com/battletechmodders/mechengineer) and copy CustomComponents.dll into the Mods/LootMagnet directory. After doing so, remove the following line from the `Mods/LootMagnet/mod.json`:

` "DependsOn" : [ "CustomComponents" ],`

### Attributions

Thanks to gnivler, who contributed several key quality of life improvements. Your help is appreciated!

Thanks for haree78 who contributed blacklist-by-tags for components.

## Salvage Rollup

If a faction trusts you and wants to continue working with you, they will negotiate more favorable terms. One of the most common 'little favors' is to allow salvage to be driven by equivalent cash amounts, instead of a strict item by item accounting. We refer to this as **Salvage Rollup**.
Expand Down Expand Up @@ -56,7 +62,11 @@ Mech parts may also be rolled up, if your faction rating is good enough. The **R

### 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*. If you are using the [CustomComponents](https://github.com/battletechmodders/customcomponents/) mod, you can blacklist items by including the following in the item JSON:
Some items are too powerful or rare for employers to allow being bundled, or to be included as compensation in exchange for a holdback. Mod authors can blacklist items in one of three ways:

* By component *description.id* in `RollupBlacklist`
* By component tag in `RollupBlacklistTags`
* As a [Custom Component](https://github.com/denadan/customcomponents/) on the component definition:

```json
"Custom" : {
Expand Down
3 changes: 2 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "LootMagnet",
"Enabled": true,
"Version": "5.0.0",
"Version": "5.1.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 @@ -12,6 +12,7 @@
"Debug" : true,
"RollupMRBValue" : [ 40000, 60000, 90000, 130000, 180000, 240000 ],
"RollupBlacklist": [ ],
"RollupBlacklistTags" : [ ],
"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 3493533

Please sign in to comment.