More cheap train

This commit is contained in:
2024-12-31 16:05:33 +01:00
parent cd104d142e
commit a71a25226f
2 changed files with 44 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ namespace CykaRaider {
public static ConfigEntry<int> lootTimeAdder;
public static ConfigEntry<float> maxStackMultiplier;
public static ConfigEntry<bool> autoLoot;
public static ConfigEntry<float> upgradePriceMultiplier;
public static ConfigEntry<bool> debugMode;
@@ -22,6 +23,7 @@ namespace CykaRaider {
lootTimeAdder = Config.Bind("General", "Loot Time Adder", 0, new ConfigDescription("Loot Time Adder"));
maxStackMultiplier = Config.Bind("General", "Max Stack Multiplier", 1f, new ConfigDescription("Max Stack Multiplier"));
autoLoot = Config.Bind("General", "Auto Loot", false, new ConfigDescription("Auto Loot"));
upgradePriceMultiplier = Config.Bind("General", "Upgrade Price Multiplier", 1f, new ConfigDescription("Upgrade Price Multiplier"));
Logger.LogInfo("Cyka mod loaded");
HarmonyFileLog.Enabled = true;

View File

@@ -1,4 +1,6 @@
using System;
using System;
using System.Collections.Generic;
using System.Reflection.Emit;
using HarmonyLib;
using UnityEngine.UI;
@@ -52,6 +54,44 @@ namespace CykaRaider
Console.WriteLine("CykaRaider: autoLoot: Bag closed");
}
}
[HarmonyPatch(typeof(NPCControl), "UpgradeSkill")]
public static class upgradePriceMultiplier {
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
if (Main.debugMode.Value)
Console.WriteLine("CykaRaider: upgradePriceMultiplier: Transpiler");
var codes = new List<CodeInstruction>(instructions);
for (int i = 0; i < codes.Count; i++) {
if (codes[i].opcode == OpCodes.Ldc_I4 && ((int)codes[i].operand == 125000 || (int)codes[i].operand == -125000)) {
if (Main.debugMode.Value)
Console.WriteLine("CykaRaider: upgradePriceMultiplier: Old price {0}", codes[i].operand);
codes[i].operand = (int)((float)codes[i].operand * Main.upgradePriceMultiplier.Value);
if (Main.debugMode.Value)
Console.WriteLine("CykaRaider: upgradePriceMultiplier: New price {0}", codes[i].operand);
}
}
return codes;
}
}
[HarmonyPatch(typeof(NPCControl), "RefreshSkill")]
public static class refreshSkillPriceMultiplier {
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
if (Main.debugMode.Value)
Console.WriteLine("CykaRaider: refreshSkillPriceMultiplier: Transpiler");
var codes = new List<CodeInstruction>(instructions);
for (int i = 0; i < codes.Count; i++) {
if (codes[i].opcode == OpCodes.Ldc_I4 && ((int)codes[i].operand == 125000 || (int)codes[i].operand == -125000)) {
if (Main.debugMode.Value)
Console.WriteLine("CykaRaider: refreshSkillPriceMultiplier: Old price {0}", codes[i].operand);
codes[i].operand = (int)((float)codes[i].operand * Main.upgradePriceMultiplier.Value);
if (Main.debugMode.Value)
Console.WriteLine("CykaRaider: refreshSkillPriceMultiplier: New price {0}", codes[i].operand);
}
}
return codes;
}
}
// [HarmonyPrefix]
// [HarmonyPatch(typeof(XRL.World.Parts.Experience), "HandleEvent")]
// static void xpMultiplier(ref AwardedXPEvent E) {