Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SkillsToPayBills v1.0.3
Cjayride.SkillsToPayBills.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.SkillsToPayBills")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3+f78c83b30eddda90716bfb03bfa5e01bf8166f0b")] [assembly: AssemblyProduct("Cjayride.SkillsToPayBills")] [assembly: AssemblyTitle("Cjayride.SkillsToPayBills")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Cjayride.SkillsToPayBills { public class ConfigurationManagerAttributes { public bool? IsAdminOnly; } internal static class ConstitutionLayer { [HarmonyPatch(typeof(Player), "GetBaseFoodHP")] private static class BaseFoodHpPatch { private static void Postfix(Player __instance, ref float __result) { __result += ExtraHealth(__instance); } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] private static class TotalFoodValuePatch { private static void Postfix(Player __instance, ref float hp, ref float stamina) { EnsureExtras(__instance); hp += extraHealth; stamina += extraStamina; } } [HarmonyPatch(typeof(Player), "UpdateFood")] private static class UpdateFoodPatch { private static void Prefix(Player __instance) { if (foodUpdate >= 1500 || __instance.m_foods.Count == 0 || ++foodUpdate % 50 != 0) { return; } foreach (Food food in __instance.m_foods) { ItemData item = food.m_item; skillRaise += (item.m_shared.m_food * SkillsConfig.ConFoodHealthGain.Value + item.m_shared.m_foodStamina * SkillsConfig.ConFoodStaminaGain.Value) / item.m_shared.m_foodBurnTime; } } } [HarmonyPatch(typeof(Player), "UseStamina")] private static class UseStaminaPatch { private static void Prefix(Player __instance, float v) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (foodUpdate < 1500 || v <= 0f || skillRaise <= 0f) { return; } Skill skill = ((Character)__instance).GetSkills().GetSkill(Plugin.ConstitutionSkill); float num = skill.m_level * SkillsConfig.ConActivityToSkill.Value; stamUsage += v; if (!(stamUsage < num)) { if (skill.m_level < 100f && skillRaise > 0f) { ((Character)__instance).RaiseSkill(Plugin.ConstitutionSkill, (float)Math.Round(skillRaise, 2)); } foodUpdate = 0; stamUsage = 0f; skillRaise = 0f; } } } private static float stamUsage; private static float skillRaise; private static int foodUpdate; private static float extraHealth; private static float extraStamina; private static Player extrasPlayer; private static float extrasLevel = -1f; internal static void Refresh(Player player) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { float num = ((Character)player).GetSkills().GetSkill(Plugin.ConstitutionSkill)?.m_level ?? 0f; extrasPlayer = player; extrasLevel = num; extraHealth = SkillsConfig.ConBaseHealth.Value + num * SkillsConfig.ConHealthPerPoint.Value; extraStamina = SkillsConfig.ConBaseStamina.Value + num * SkillsConfig.ConStaminaPerPoint.Value; } } internal static float ExtraHealth(Player player) { EnsureExtras(player); return extraHealth; } internal static float ExtraStamina(Player player) { EnsureExtras(player); return extraStamina; } private static void EnsureExtras(Player player) { if (!((Object)(object)player == (Object)(object)extrasPlayer) || !(extrasLevel >= 0f)) { Refresh(player); } } } internal static class BlacksmithingLayer { [HarmonyPatch(typeof(CraftingStation), "GetLevel")] private static class StationLevel { private static void Postfix(CraftingStation __instance, ref int __result) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null)) { int level = Mathf.RoundToInt(SkillRegistry.Level(Player.m_localPlayer, Plugin.BlacksmithingSkill)); __result += StationBonus(((Object)__instance).name, level); } } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] private static class CraftXp { private static void Prefix(InventoryGui __instance) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.m_craftRecipe == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } ItemData itemData = __instance.m_craftRecipe.m_item.m_itemData; if (IsGear(itemData.m_shared)) { int num = Mathf.RoundToInt(SkillRegistry.Level(Player.m_localPlayer, Plugin.BlacksmithingSkill)); if (itemData.m_customData == null) { itemData.m_customData = new Dictionary<string, string>(); } itemData.m_customData["stp_bs"] = num.ToString(); Game.instance.m_playerProfile.m_playerStats[0].m_itemCraftStats.TryGetValue(itemData.m_shared.m_name, out var value); float num2 = 15f * ((SkillsConfig.XpReduceThreshold.Value > 0) ? Mathf.Max(1f - value / (float)SkillsConfig.XpReduceThreshold.Value * SkillsConfig.XpReduceFactor.Value, 0f) : 1f); if (value <= 0f) { num2 += (float)SkillsConfig.FirstCraftBonus.Value; } ((Character)Player.m_localPlayer).RaiseSkill(Plugin.BlacksmithingSkill, num2); } } } [HarmonyPatch(typeof(ItemData), "GetMaxDurability", new Type[] { typeof(int) })] private static class Durability { private static void Postfix(ItemData __instance, ref float __result) { if (__instance.m_customData != null && __instance.m_customData.TryGetValue("stp_bs", out var value) && int.TryParse(value, out var result)) { __result *= SkillsConfig.BaseDurability.Value * (1f + (float)result / 100f * (SkillsConfig.DurabilityFactor.Value - 1f)); } } } [HarmonyPatch(typeof(InventoryGui), "HaveRepairableItems")] private static class InventoryRepair { private static void Postfix(ref bool __result) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!__result && !((Object)(object)Player.m_localPlayer == (Object)null) && SkillsConfig.RepairLevel.Value > 0 && SkillRegistry.Level(Player.m_localPlayer, Plugin.BlacksmithingSkill) >= (float)SkillsConfig.RepairLevel.Value) { List<ItemData> list = new List<ItemData>(); ((Humanoid)Player.m_localPlayer).GetInventory().GetWornItems(list); __result = list.Count > 0; } } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] private static class ExtraUpgrade { private static void Prefix() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)InventoryGui.instance == (Object)null) && !((Object)(object)((RecipeDataPair)(ref InventoryGui.instance.m_selectedRecipe)).Recipe == (Object)null)) { SharedData shared = ((RecipeDataPair)(ref InventoryGui.instance.m_selectedRecipe)).Recipe.m_item.m_itemData.m_shared; if (SkillsConfig.ExtraUpgradeLevel.Value > 0 && IsGear(shared) && !(SkillRegistry.Level(Player.m_localPlayer, Plugin.BlacksmithingSkill) < (float)SkillsConfig.ExtraUpgradeLevel.Value) && BumpedQuality.Add(shared)) { shared.m_maxQuality++; } } } } private const string Key = "stp_bs"; private static readonly HashSet<SharedData> BumpedQuality = new HashSet<SharedData>(); private static bool IsGear(SharedData item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 if ((int)item.m_itemType != 4 && (int)item.m_itemType != 7 && (int)item.m_itemType != 12 && (int)item.m_itemType != 6 && (int)item.m_itemType != 11 && (int)item.m_itemType != 5 && (int)item.m_itemType != 17 && (int)item.m_itemType != 14 && (int)item.m_itemType != 22) { if ((int)item.m_itemType == 3) { return !item.m_attack.m_consumeItem; } return false; } return true; } private static int StationBonus(string name, int level) { if (name.IndexOf("forge", StringComparison.OrdinalIgnoreCase) >= 0 && name.IndexOf("black", StringComparison.OrdinalIgnoreCase) < 0) { if (SkillsConfig.Forge2.Value > 0 && level >= SkillsConfig.Forge2.Value) { return 2; } if (SkillsConfig.Forge1.Value > 0 && level >= SkillsConfig.Forge1.Value) { return 1; } } else if (name.IndexOf("blackforge", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("black_forge", StringComparison.OrdinalIgnoreCase) >= 0) { if (SkillsConfig.BlackForge2.Value > 0 && level >= SkillsConfig.BlackForge2.Value) { return 2; } if (SkillsConfig.BlackForge1.Value > 0 && level >= SkillsConfig.BlackForge1.Value) { return 1; } } else if (name.IndexOf("galdr", StringComparison.OrdinalIgnoreCase) >= 0) { if (SkillsConfig.Galdr2.Value > 0 && level >= SkillsConfig.Galdr2.Value) { return 2; } if (SkillsConfig.Galdr1.Value > 0 && level >= SkillsConfig.Galdr1.Value) { return 1; } } else if (name.IndexOf("piece_workbench", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Workbench", StringComparison.OrdinalIgnoreCase) >= 0) { if (SkillsConfig.Wb2.Value > 0 && level >= SkillsConfig.Wb2.Value) { return 2; } if (SkillsConfig.Wb1.Value > 0 && level >= SkillsConfig.Wb1.Value) { return 1; } } return 0; } } internal static class CookingLayer { [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] private static class CookXp { private static void Prefix(InventoryGui __instance) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.m_craftRecipe == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { SharedData shared = __instance.m_craftRecipe.m_item.m_itemData.m_shared; if (!(shared.m_food <= 0f) || !(shared.m_foodStamina <= 0f) || !(shared.m_foodEitr <= 0f)) { ((Character)Player.m_localPlayer).RaiseSkill(Plugin.CookingSkill, 1f); } } } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] private static class FasterCook { private static void Postfix(InventoryGui __instance) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || __instance.m_craftTimer < 0f) { return; } Recipe recipe = ((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe; if (!((Object)(object)recipe == (Object)null)) { SharedData shared = recipe.m_item.m_itemData.m_shared; if (!(shared.m_food <= 0f) || !(shared.m_foodStamina <= 0f)) { float num = SkillRegistry.Factor(Player.m_localPlayer, Plugin.CookingSkill); __instance.m_craftTimer += Time.deltaTime * num * (float)SkillsConfig.CookTimeReduce.Value / 100f; } } } } [HarmonyPatch(typeof(Player), "EatFood")] private static class HappyEat { private static void Postfix(Player __instance, ItemData item, bool __result) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (__result && item != null && !(item.m_shared.m_food <= 0f) && SkillsConfig.HappyLevel.Value > 0) { float num = SkillRegistry.Factor(__instance, Plugin.CookingSkill); if (!(num * 100f < (float)SkillsConfig.HappyLevel.Value) && Random.value < num) { ((Character)__instance).GetSEMan().AddStatusEffect(Happy(), true, 0, 0f, (short)(-1)); } } } } private static StatusEffect happy; internal static StatusEffect Happy() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)happy != (Object)null) { return happy; } happy = (StatusEffect)(object)ScriptableObject.CreateInstance<SE_Stats>(); ((Object)happy).name = "SkillsToPayBills Happy"; happy.m_name = "Happy"; happy.m_ttl = (float)SkillsConfig.HappyMinutes.Value * 60f; ((SE_Stats)happy).m_speedModifier = SkillsConfig.HappySpeed.Value - 1f; return happy; } } internal static class SailingLayer { [HarmonyPatch(typeof(Player), "Update")] private static class XpAndNudge { private static float acc; private static void Postfix(Player __instance) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } Ship standingOnShip = ((Character)__instance).GetStandingOnShip(); if ((Object)(object)standingOnShip == (Object)null) { return; } if (standingOnShip.GetSpeed() > 0.5f) { acc += Time.deltaTime; if (acc >= 1f) { acc = 0f; ((Character)__instance).RaiseSkill(Plugin.SailingSkill, 1f); } } float num = SkillRegistry.Factor(__instance, Plugin.SailingSkill); if (num > 0f) { Minimap.instance.Explore(((Component)__instance).transform.position, 100f * (1f + num * (SkillsConfig.ExploreRadius.Value - 1f))); } if (!SkillsConfig.AllowNudge.Value) { return; } KeyboardShortcut value = SkillsConfig.NudgeKey.Value; if (!((KeyboardShortcut)(ref value)).IsPressed() || !standingOnShip.m_nview.IsOwner()) { return; } Rigidbody component = ((Component)standingOnShip).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { Vector3 linearVelocity = component.linearVelocity; if (((Vector3)(ref linearVelocity)).magnitude < 0.2f) { component.AddForce(((Component)__instance).transform.forward * SkillsConfig.NudgeForce.Value, (ForceMode)1); } } } } [HarmonyPatch(typeof(Ship), "GetSailForce")] private static class Speed { private static void Postfix(ref Vector3 __result) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { float num = SkillRegistry.Factor(localPlayer, Plugin.SailingSkill); __result *= 1f + num * (SkillsConfig.ShipSpeed.Value - 1f); } } } [HarmonyPatch(typeof(Ship), "Awake")] private static class Health { private static void Postfix(Ship __instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) WearNTear component = ((Component)__instance).GetComponent<WearNTear>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { float num = SkillRegistry.Factor(Player.m_localPlayer, Plugin.SailingSkill); component.m_health *= 1f + num * (SkillsConfig.ShipHealth.Value - 1f); } } } } internal static class ForagingLayer { [HarmonyPatch(typeof(Player), "Update")] private static class Sync { private static void Postfix(Player __instance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { ((Character)__instance).m_nview.GetZDO().Set("Foraging Skill Factor", SkillRegistry.Factor(__instance, Plugin.ForagingSkill)); } } } [HarmonyPatch(typeof(Pickable), "RPC_Pick")] private static class Pick { private static void Prefix(Pickable __instance, long sender, ref int __state) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) __state = -1; if (!__instance.m_nview.IsOwner() || __instance.m_picked || !IsForaging(__instance)) { return; } Player val = Player.s_players.Find((Player p) => ((ZDOID)(ref ((Character)p).m_nview.GetZDO().m_uid)).UserID == sender); if (!((Object)(object)val == (Object)null)) { ((Character)val).RaiseSkill(Plugin.ForagingSkill, 1f); float num = ((Character)val).m_nview.GetZDO().GetFloat("Foraging Skill Factor", 0f); if (Random.Range(0f, 1f) < num) { __state = __instance.m_amount; int num2 = Mathf.FloorToInt(SkillsConfig.ForagingYield.Value); __instance.m_amount *= num2 + ((Random.Range(0f, 1f) < SkillsConfig.ForagingYield.Value - (float)num2) ? 1 : 0); } } } private static void Postfix(Pickable __instance, long sender, int __state) { if (__state >= 0 && IsForaging(__instance)) { Player val = Player.s_players.Find((Player p) => ((ZDOID)(ref ((Character)p).m_nview.GetZDO().m_uid)).UserID == sender); if (!((Object)(object)val == (Object)null)) { long num = __instance.m_nview.GetZDO().GetLong("picked_time", 0L); float num2 = ((Character)val).m_nview.GetZDO().GetFloat("Foraging Skill Factor", 0f); ZDO zDO = __instance.m_nview.GetZDO(); DateTime minValue = DateTime.MinValue; zDO.Set("picked_time", Math.Max(minValue.Ticks, num - (long)((double)(__instance.m_respawnTimeMinutes * 600000000f) * (1.0 - 1.0 / (double)SkillsConfig.ForagingRespawnSpeed.Value) * (double)num2))); } } } private static void Finalizer(Pickable __instance, int __state) { if (__state >= 0) { __instance.m_amount = __state; } } } [HarmonyPatch(typeof(Pickable), "GetHoverText")] private static class Hover { private static void Postfix(Pickable __instance, ref string __result) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_nview.IsValid() && __instance.m_picked && !(__instance.m_respawnTimeMinutes <= 0f) && SkillsConfig.ForagingRespawnDisplay.Value > 0 && !(SkillRegistry.Factor(Player.m_localPlayer, Plugin.ForagingSkill) < (float)SkillsConfig.ForagingRespawnDisplay.Value / 100f)) { DateTime dateTime = new DateTime(__instance.m_nview.GetZDO().GetLong("picked_time", 0L)); TimeSpan timeSpan = TimeSpan.FromMinutes(__instance.m_respawnTimeMinutes) - (ZNet.instance.GetTime() - dateTime); __result = __result + "\nRespawn in: " + (timeSpan - new TimeSpan(timeSpan.Ticks % 10000000)).ToString("c"); } } } internal static bool IsForaging(Pickable pickable) { if ((Object)(object)pickable == (Object)null || (Object)(object)pickable.m_itemPrefab == (Object)null) { return false; } string value = SkillsConfig.ForagingScope.Value; if (string.Equals(value, "Everything", StringComparison.OrdinalIgnoreCase)) { return true; } if (string.Equals(value, "NoCrops", StringComparison.OrdinalIgnoreCase)) { int num = LayerMask.NameToLayer("piece_nonsolid"); int num2 = LayerMask.NameToLayer("item"); int layer = ((Component)pickable).gameObject.layer; if (layer != num) { if (layer == num2) { return pickable.m_amount <= 1; } return true; } return false; } if (pickable.m_respawnTimeMinutes > 0f && ((Object)pickable.m_itemPrefab).name != "Wood") { return ((Object)pickable.m_itemPrefab).name != "DragonEgg"; } return false; } } internal static class FarmingLayer { [HarmonyPatch(typeof(Skills), "Awake")] private static class FarmingXpStep { private static void Postfix(Skills __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 foreach (SkillDef skill in __instance.m_skills) { if ((int)skill.m_skill == 106) { skill.m_increseStep = SkillsConfig.FarmingGain.Value; } } } } [HarmonyPatch(typeof(Player), "PlacePiece")] private static class PlaceFlag { private static void Prefix() { Planting = true; } private static void Finalizer() { Planting = false; } } [HarmonyPatch(typeof(Plant), "Awake")] private static class SaveSkill { private static void Postfix(Plant __instance) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (Planting && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.GetZDO() != null) { __instance.m_nview.GetZDO().Set("Farming Skill Level", ((Character)Player.m_localPlayer).GetSkillFactor((SkillType)106) + 1E-14f); ((Character)Player.m_localPlayer).RaiseSkill((SkillType)106, 1f); } if (SkillsConfig.IgnoreBiomeLevel.Value > 0 && (Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.GetZDO() != null && __instance.m_nview.GetZDO().GetFloat("Farming Skill Level", 0f) >= (float)SkillsConfig.IgnoreBiomeLevel.Value / 100f) { __instance.m_biome = (Biome)(-1); } } } [HarmonyPatch(typeof(Plant), "GetGrowTime")] private static class GrowFaster { private static void Postfix(Plant __instance, ref float __result) { if (!((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.GetZDO() != null) { __result /= 1f + __instance.m_nview.GetZDO().GetFloat("Farming Skill Level", 0f) * (SkillsConfig.GrowSpeed.Value - 1f); } } } [HarmonyPatch(typeof(Plant), "Grow")] private static class GrowYield { private static void Prefix(Plant __instance) { GrowSkill = (((Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.GetZDO() != null) ? __instance.m_nview.GetZDO().GetFloat("Farming Skill Level", 0f) : 0f); } private static void Finalizer() { GrowSkill = 0f; } } [HarmonyPatch(typeof(Pickable), "Awake")] private static class CropYield { private static void Postfix(Pickable __instance) { if ((Object)(object)__instance.m_nview == (Object)null || __instance.m_nview.GetZDO() == null) { return; } ZDO zDO = __instance.m_nview.GetZDO(); int num = zDO.GetInt("Farming Yield Multiplier", 1); if (GrowSkill > 0f) { if (Random.Range(0f, 1f) < GrowSkill) { int num2 = Mathf.FloorToInt(SkillsConfig.CropYield.Value); num = num2 + ((Random.Range(0f, 1f) < SkillsConfig.CropYield.Value - (float)num2) ? 1 : 0); } zDO.Set("Farming Yield Multiplier", num); } __instance.m_amount *= Math.Max(1, num); } } [HarmonyPatch(typeof(Plant), "GetHoverText")] private static class Progress { private static void Postfix(Plant __instance, ref string __result) { if (SkillsConfig.ShowProgressLevel.Value > 0 && !((Object)(object)Player.m_localPlayer == (Object)null) && !(((Character)Player.m_localPlayer).GetSkillFactor((SkillType)106) < (float)SkillsConfig.ShowProgressLevel.Value / 100f)) { float num = (float)(__instance.TimeSincePlanted() / (double)__instance.GetGrowTime() * 100.0); __result = __result + "\n" + Math.Min(100.0, Math.Round(num)) + "% grown"; } } } [HarmonyPatch(typeof(Player), "UseStamina")] private static class PlantStamina { private static void Prefix(Player __instance, ref float v) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 if (!(v <= 0f) && SkillsConfig.StaminaReducePerLevel.Value > 0 && ((Humanoid)__instance).GetRightItem() != null && (int)((Humanoid)__instance).GetRightItem().m_shared.m_skillType == 106) { float num = SkillRegistry.Level(__instance, (SkillType)106) * (float)SkillsConfig.StaminaReducePerLevel.Value / 100f; v *= Math.Max(0f, 1f - num); } } } internal static bool Planting; internal static float GrowSkill; } internal static class RanchingLayer { [HarmonyPatch(typeof(Player), "Update")] private static class Sync { private static void Postfix(Player __instance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { ((Character)__instance).m_nview.GetZDO().Set("Ranching Skill", SkillRegistry.Factor(__instance, Plugin.RanchingSkill)); } } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] private static class TameDrops { private static void Postfix(CharacterDrop __instance, List<KeyValuePair<GameObject, int>> __result) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!__instance.m_character.IsTamed()) { return; } Player closestPlayer = Player.GetClosestPlayer(((Component)__instance).transform.position, 50f); if (!((Object)(object)closestPlayer == (Object)null)) { float num = ((Character)closestPlayer).m_nview.GetZDO().GetFloat("Ranching Skill", 0f) * (SkillsConfig.RanchDrop.Value - 1f); int num2 = ((Random.Range(0f, 1f) < num % 1f) ? 1 : 0) + (int)num; for (int i = 0; i < __result.Count; i++) { __result[i] = new KeyValuePair<GameObject, int>(__result[i].Key, __result[i].Value * (1 + num2)); } ((Character)closestPlayer).RaiseSkill(Plugin.RanchingSkill, 50f); } } } [HarmonyPatch(typeof(Tameable), "DecreaseRemainingTime")] private static class TameFaster { private static void Prefix(Tameable __instance, ref float time) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Player closestPlayer = Player.GetClosestPlayer(((Component)__instance).transform.position, 10f); if (!((Object)(object)closestPlayer == (Object)null)) { time *= 1f + ((Character)closestPlayer).m_nview.GetZDO().GetFloat("Ranching Skill", 0f) * (SkillsConfig.RanchTame.Value - 1f); if (Random.Range(0, 10) == 0) { ((Character)closestPlayer).RaiseSkill(Plugin.RanchingSkill, 7f); } } } } [HarmonyPatch(typeof(MonsterAI), "UpdateAI")] private static class TameFlag { private static void Prefix(MonsterAI __instance) { Tameable val = (((Object)(object)((BaseAI)__instance).m_character != (Object)null) ? ((Component)((BaseAI)__instance).m_character).GetComponent<Tameable>() : null); GettingTamed = (Object)(object)val != (Object)null && val.GetTameness() > 0; } private static void Finalizer() { GettingTamed = false; } } [HarmonyPatch(typeof(Player), "GetStealthFactor")] private static class Calm { private static bool Prefix(Player __instance, ref float __result) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (GettingTamed && SkillsConfig.RanchCalmLevel.Value > 0 && SkillRegistry.Factor(__instance, Plugin.RanchingSkill) >= (float)SkillsConfig.RanchCalmLevel.Value / 100f) { __result = 0f; return false; } return true; } } [HarmonyPatch(typeof(Tameable), "GetStatusString")] private static class Info { private static void Postfix(Tameable __instance, ref string __result) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!__instance.m_character.IsTamed() || (Object)(object)Player.m_localPlayer == (Object)null) { return; } float num = SkillRegistry.Factor(Player.m_localPlayer, Plugin.RanchingSkill); Procreation component = ((Component)__instance).GetComponent<Procreation>(); if ((Object)(object)component != (Object)null && SkillsConfig.RanchPregLevel.Value > 0 && num >= (float)SkillsConfig.RanchPregLevel.Value / 100f) { if (component.IsPregnant()) { __result += ", Pregnant"; } else { int num2 = Mathf.RoundToInt((float)__instance.m_nview.GetZDO().GetInt("lovePoints", 0) / (float)component.m_requiredLovePoints * 100f); __result = __result + ", Pre-Pregnancy: " + num2 + "%"; } } if (!__instance.IsHungry() && SkillsConfig.RanchFoodLevel.Value > 0 && num >= (float)SkillsConfig.RanchFoodLevel.Value / 100f) { TimeSpan timeSpan = new DateTime(__instance.m_nview.GetZDO().GetLong("TameLastFeeding", 0L)).AddSeconds(__instance.m_fedDuration) - ZNet.instance.GetTime(); __result = __result + ", Hungry in: " + timeSpan.ToString("hh\\:mm\\:ss"); } } } [HarmonyPatch(typeof(Procreation), "Procreate")] private static class Offspring { private static int cached = -1; private static void Prefix(Procreation __instance) { if (SkillsConfig.RanchLevelUpLevel.Value <= 0) { return; } float num = 0f; foreach (Player s_player in Player.s_players) { num = Math.Max(num, ((Character)s_player).m_nview.GetZDO().GetFloat("Ranching Skill", 0f)); } if (num >= (float)SkillsConfig.RanchLevelUpLevel.Value / 100f && Random.value <= (float)SkillsConfig.RanchLevelUpChance.Value / 100f) { cached = __instance.m_minOffspringLevel; int num2 = (((Object)(object)__instance.m_character != (Object)null) ? __instance.m_character.GetLevel() : Math.Max(1, __instance.m_minOffspringLevel)); __instance.m_minOffspringLevel = num2 + 1; } } private static void Finalizer(Procreation __instance) { if (cached >= 0) { __instance.m_minOffspringLevel = cached; cached = -1; } } } internal static bool GettingTamed; } [BepInPlugin("cjayride.skillstopaybills", "SkillsToPayBills", "1.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("cjayride.vigor")] [BepInIncompatibility("org.bepinex.plugins.tenacity")] [BepInIncompatibility("org.bepinex.plugins.packhorse")] [BepInIncompatibility("org.bepinex.plugins.blacksmithing")] [BepInIncompatibility("org.bepinex.plugins.mining")] [BepInIncompatibility("org.bepinex.plugins.lumberjacking")] [BepInIncompatibility("org.bepinex.plugins.foraging")] [BepInIncompatibility("org.bepinex.plugins.farming")] [BepInIncompatibility("org.bepinex.plugins.ranching")] [BepInIncompatibility("org.bepinex.plugins.cooking")] [BepInIncompatibility("org.bepinex.plugins.sailing")] [BepInIncompatibility("VitalityRewrite")] [BepInIncompatibility("papajin68.constitution")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "cjayride.skillstopaybills"; public const string PluginName = "SkillsToPayBills"; public const string PluginVersion = "1.0.3"; internal static Plugin Instance; internal static Harmony Harmony; internal static SkillType VitalitySkill; internal static SkillType ConstitutionSkill; internal static SkillType TenacitySkill; internal static SkillType PackHorseSkill; internal static SkillType BlacksmithingSkill; internal static SkillType MiningSkill; internal static SkillType LumberjackingSkill; internal static SkillType ForagingSkill; internal static SkillType RanchingSkill; internal static SkillType CookingSkill; internal static SkillType SailingSkill; internal static bool Logging { get { if (SkillsConfig.LoggingEnabled != null) { return SkillsConfig.LoggingEnabled.Value; } return false; } } private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected I4, but got Unknown //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Expected I4, but got Unknown //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Expected I4, but got Unknown Instance = this; SkillsConfig.Bind(((BaseUnityPlugin)this).Config); VitalitySkill = AddNamedSkill("cjayride.vigor.vitality", "Vitality", "Travel and hard labor raise your base body. Stacks with Constitution.", 1f); ConstitutionSkill = AddNamedSkill("cjayride.vigor.constitution", "Constitution", "Honest meals and spent stamina harden the body. Stacks with Vitality.", 1f); TenacitySkill = AddNamedSkill("Tenacity", "Tenacity", "Reduces damage taken slightly.", SkillsConfig.TenacityGain.Value); PackHorseSkill = AddNamedSkill("PackHorse", "Pack Horse", "Increases the maximum carry weight.", SkillsConfig.PackHorseGain.Value); BlacksmithingSkill = AddNamedSkill("Blacksmithing", "Blacksmithing", "Increases the durability of crafted armor and weapons.", SkillsConfig.BlacksmithingGain.Value); MiningSkill = AddNamedSkill("Mining", "Mining", "Increases mining damage and ore yield.", SkillsConfig.MiningGain.Value); LumberjackingSkill = AddNamedSkill("Lumberjacking", "Lumberjacking", "Increases chop damage and tree yield.", SkillsConfig.LumberjackingGain.Value); ForagingSkill = AddNamedSkill("Foraging", "Foraging", "Increases forage yield and respawn speed.", SkillsConfig.ForagingGain.Value); RanchingSkill = AddNamedSkill("Ranching", "Ranching", "Tames faster and increases tame drops.", SkillsConfig.RanchingGain.Value); CookingSkill = AddNamedSkill("Cooking", "Cooking", "Cooks faster and can cook happy meals.", SkillsConfig.CookingGain.Value); SailingSkill = AddNamedSkill("Sailing", "Sailing", "Improves ship speed, health, and exploration.", SkillsConfig.SailingGain.Value); SkillIcons.Map(VitalitySkill, (SkillType)102); SkillIcons.Map(ConstitutionSkill, (SkillType)105); SkillIcons.LoadTenacityIcon(TenacitySkill); SkillIcons.Map(PackHorseSkill, (SkillType)102); SkillIcons.Map(BlacksmithingSkill, (SkillType)107); SkillIcons.Map(MiningSkill, (SkillType)12); SkillIcons.Map(LumberjackingSkill, (SkillType)13); SkillIcons.Map(ForagingSkill, (SkillType)106); SkillIcons.Map(RanchingSkill, (SkillType)110); SkillIcons.Map(CookingSkill, (SkillType)105); SkillIcons.Map(SailingSkill, (SkillType)103); SkillRegistry.DeathLoss[VitalitySkill] = SkillsConfig.BodySkillDeathLoss.Value; SkillRegistry.DeathLoss[ConstitutionSkill] = SkillsConfig.BodySkillDeathLoss.Value; SkillRegistry.DeathLoss[TenacitySkill] = SkillsConfig.TenacityLoss.Value; SkillRegistry.DeathLoss[PackHorseSkill] = SkillsConfig.PackHorseLoss.Value; SkillRegistry.DeathLoss[BlacksmithingSkill] = SkillsConfig.BlacksmithingLoss.Value; SkillRegistry.DeathLoss[MiningSkill] = SkillsConfig.MiningLoss.Value; SkillRegistry.DeathLoss[LumberjackingSkill] = SkillsConfig.LumberjackingLoss.Value; SkillRegistry.DeathLoss[ForagingSkill] = SkillsConfig.ForagingLoss.Value; SkillRegistry.DeathLoss[RanchingSkill] = SkillsConfig.RanchingLoss.Value; SkillRegistry.DeathLoss[CookingSkill] = SkillsConfig.CookingLoss.Value; SkillRegistry.DeathLoss[SailingSkill] = SkillsConfig.SailingLoss.Value; SkillRegistry.DeathLoss[(SkillType)106] = SkillsConfig.FarmingLoss.Value; Harmony = new Harmony("cjayride.skillstopaybills"); Harmony.PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Tenacity={2} Constitution={3} Vitality={4}", "SkillsToPayBills", "1.0.3", (int)TenacitySkill, (int)ConstitutionSkill, (int)VitalitySkill)); } private static SkillType AddNamedSkill(string identifier, string name, string description, float increaseStep) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) SkillType val = SkillManager.Instance.AddSkill(new SkillConfig { Identifier = identifier, Name = name, Description = description, IncreaseStep = increaseStep }); SkillRegistry.Track(val); return val; } internal static void Log(string message) { if (Logging) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } internal static void LogWarning(string message) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)message); } } } internal static class SkillIcons { [HarmonyPatch(typeof(Skills), "Awake")] private static class SkillsAwakePatch { private static void Postfix(List<SkillDef> ___m_skills) { Apply(___m_skills); } } private const string TenacityIconResource = "Cjayride.SkillsToPayBills.Assets.tenacity-icon.png"; private static readonly Dictionary<SkillType, SkillType> FromVanilla = new Dictionary<SkillType, SkillType>(); private static readonly Dictionary<SkillType, Sprite> Embedded = new Dictionary<SkillType, Sprite>(); private static Sprite _tenacitySprite; internal static void Map(SkillType custom, SkillType vanilla) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) FromVanilla[custom] = vanilla; } internal static void LoadTenacityIcon(SkillType tenacity) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_tenacitySprite == (Object)null) { _tenacitySprite = LoadSpriteFromEmbedded("Cjayride.SkillsToPayBills.Assets.tenacity-icon.png"); } if ((Object)(object)_tenacitySprite != (Object)null) { Embedded[tenacity] = _tenacitySprite; } } internal static void Apply(List<SkillDef> skills) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if (skills == null || skills.Count == 0) { return; } Dictionary<SkillType, Sprite> dictionary = new Dictionary<SkillType, Sprite>(); for (int i = 0; i < skills.Count; i++) { SkillDef val = skills[i]; if (val != null && (Object)(object)val.m_icon != (Object)null) { dictionary[val.m_skill] = val.m_icon; } } foreach (KeyValuePair<SkillType, SkillType> item in FromVanilla) { if (!dictionary.TryGetValue(item.Value, out var value)) { continue; } for (int j = 0; j < skills.Count; j++) { SkillDef val2 = skills[j]; if (val2 != null && val2.m_skill == item.Key) { val2.m_icon = value; } } } foreach (KeyValuePair<SkillType, Sprite> item2 in Embedded) { for (int k = 0; k < skills.Count; k++) { SkillDef val3 = skills[k]; if (val3 != null && val3.m_skill == item2.Key && (Object)(object)item2.Value != (Object)null) { val3.m_icon = item2.Value; } } } } private static Sprite LoadSpriteFromEmbedded(string resourceName) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { Plugin.LogWarning("Skill icon not found in assembly: " + resourceName); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!TryDecodePng(val, array)) { Object.Destroy((Object)(object)val); return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } private static bool TryDecodePng(Texture2D texture, byte[] data) { Type type = AccessTools.TypeByName("UnityEngine.ImageConversion"); if (type == null) { return false; } MethodInfo methodInfo = AccessTools.Method(type, "LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }, (Type[])null); if (methodInfo == null) { return false; } object obj = methodInfo.Invoke(null, new object[2] { texture, data }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } } internal static class SkillIds { public const string Vitality = "cjayride.vigor.vitality"; public const string Constitution = "cjayride.vigor.constitution"; public const string Tenacity = "Tenacity"; public const string PackHorse = "PackHorse"; public const string Blacksmithing = "Blacksmithing"; public const string Mining = "Mining"; public const string Lumberjacking = "Lumberjacking"; public const string Foraging = "Foraging"; public const string Ranching = "Ranching"; public const string Cooking = "Cooking"; public const string Sailing = "Sailing"; } internal static class TenacityLayer { [HarmonyPatch(typeof(Character), "RPC_Damage")] private static class ReduceDamage { private static void Prefix(Character __instance, HitData hit) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!((Object)(object)val == (Object)null)) { float num = SkillRegistry.Factor(val, Plugin.TenacitySkill) * SkillsConfig.TenacityEffect.Value; ((Character)val).RaiseSkill(Plugin.TenacitySkill, (float)Math.Sqrt(Math.Max(0f, hit.GetTotalDamage()))); hit.ApplyModifier(1f - num * 0.2f); } } } } internal static class PackHorseLayer { [HarmonyPatch(typeof(Character), "UpdateWalking")] private static class Gain { private static void Postfix(Character __instance, float dt) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && ((Vector3)(ref ((Character)val).m_currentVel)).magnitude > 0.1f && val.GetMaxCarryWeight() * 0.9f <= ((Humanoid)val).m_inventory.m_totalWeight) { gain += dt; if (gain > 1f) { gain = 0f; ((Character)val).RaiseSkill(Plugin.PackHorseSkill, 1f); } } } } [HarmonyPatch(typeof(Player), "GetMaxCarryWeight")] private static class Carry { private static void Postfix(Player __instance, ref float __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) __result *= 1f + SkillRegistry.Factor(__instance, Plugin.PackHorseSkill) * SkillsConfig.PackHorseEffect.Value; } } private static float gain; } internal static class MiningLayer { [HarmonyPatch(typeof(Player), "Update")] private static class Hotkey { private static void Postfix(Player __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { ((Character)__instance).m_nview.GetZDO().Set("Mining Skill Factor", SkillRegistry.Factor(__instance, Plugin.MiningSkill)); KeyboardShortcut value = SkillsConfig.MiningExplodeHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Explosive = !Explosive; ((Character)__instance).Message((MessageType)1, "Explosive Mining: " + Explosive, 0, (Sprite)null, false); } } } } [HarmonyPatch(typeof(SEMan), "ModifyAttack")] private static class Dmg { private static void Prefix(SEMan __instance, ref HitData hitData) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (!((Object)(object)val == (Object)null)) { hitData.m_damage.m_pickaxe *= 1f + SkillRegistry.Factor(val, Plugin.MiningSkill) * (SkillsConfig.MiningDamage.Value - 1f); } } } [HarmonyPatch(typeof(MineRock5), "RPC_Damage")] private static class Rock5 { private static bool Prefix(MineRock5 __instance, HitData hit) { return Handle(hit, __instance.m_minToolTier, __instance.m_nview, delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown for (int i = 0; i < __instance.m_hitAreas.Count; i++) { if (__instance.m_hitAreas[i].m_health > 0f) { MineRock5 obj = __instance; int num = i; HitData val = new HitData { m_damage = { m_damage = __instance.m_health } }; Bounds bounds = __instance.m_hitAreas[i].m_collider.bounds; val.m_point = ((Bounds)(ref bounds)).center; val.m_toolTier = 100; val.m_attacker = hit.m_attacker; obj.DamageArea(num, val); } } }); } private static void Finalizer() { IsMining = false; } } [HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { typeof(int) })] private static class Yield { [HarmonyPriority(100)] private static void Postfix(ref List<GameObject> __result) { if (!IsMining) { return; } List<GameObject> list = new List<GameObject>(); float num = 1f + MiningFactor * (SkillsConfig.MiningYield.Value - 1f); foreach (GameObject item in __result) { for (int num2 = Mathf.FloorToInt(num + Random.Range(0f, 1f)); num2 > 0; num2--) { list.Add(item); } } __result = list; } } internal static bool Explosive = true; internal static bool IsMining; internal static float MiningFactor; internal static bool Handle(HitData hit, int minTier, ZNetView netView, Action explode) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if ((Object)(object)val == (Object)null) { return true; } IsMining = true; MiningFactor = ((((Character)val).m_nview.GetZDO() != null) ? ((Character)val).m_nview.GetZDO().GetFloat("Mining Skill Factor", 0f) : SkillRegistry.Factor(val, Plugin.MiningSkill)); if (hit.m_toolTier >= minTier && hit.m_damage.m_pickaxe > 0f && (Object)(object)netView != (Object)null && netView.IsValid() && netView.IsOwner()) { ((Character)val).RaiseSkill(Plugin.MiningSkill, 1f); float num = (float)SkillsConfig.MiningExplodeLevel.Value / 100f; if (Explosive && SkillsConfig.MiningExplodeLevel.Value > 0 && MiningFactor >= num) { float num2 = (MiningFactor - (float)(SkillsConfig.MiningExplodeLevel.Value - 10) / 100f) / (1f - (float)(SkillsConfig.MiningExplodeLevel.Value - 10) / 100f) * SkillsConfig.MiningExplodeChance.Value / 100f; if (Random.Range(0f, 1f) <= num2) { explode(); return false; } } } return true; } } internal static class LumberjackingLayer { [HarmonyPatch(typeof(Player), "Update")] private static class Sync { private static void Postfix(Player __instance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { ((Character)__instance).m_nview.GetZDO().Set("Lumberjacking Skill Factor", SkillRegistry.Factor(__instance, Plugin.LumberjackingSkill)); } } } [HarmonyPatch(typeof(SEMan), "ModifyAttack")] private static class ChopDmg { private static void Prefix(SEMan __instance, ref HitData hitData) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (!((Object)(object)val == (Object)null)) { hitData.m_damage.m_chop *= 1f + SkillRegistry.Factor(val, Plugin.LumberjackingSkill) * (SkillsConfig.TreeDamage.Value - 1f); } } } [HarmonyPatch(typeof(TreeLog), "RPC_Damage")] private static class LogFlag { private static void Prefix(HitData hit) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); IsChop = (Object)(object)val != (Object)null && hit.m_damage.m_chop > 0f; Factor = (((Object)(object)val != (Object)null) ? SkillRegistry.Factor(val, Plugin.LumberjackingSkill) : 0f); if (IsChop) { ((Character)val).RaiseSkill(Plugin.LumberjackingSkill, 1f); } } private static void Finalizer() { IsChop = false; } } [HarmonyPatch(typeof(TreeBase), "RPC_Damage")] private static class TreeFlag { private static void Prefix(HitData hit) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); IsChop = (Object)(object)val != (Object)null && hit.m_damage.m_chop > 0f; Factor = (((Object)(object)val != (Object)null) ? SkillRegistry.Factor(val, Plugin.LumberjackingSkill) : 0f); if (IsChop) { ((Character)val).RaiseSkill(Plugin.LumberjackingSkill, 1f); } } private static void Finalizer() { IsChop = false; } } [HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { typeof(int) })] private static class Yield { [HarmonyPriority(100)] private static void Postfix(ref List<GameObject> __result) { if (!IsChop) { return; } List<GameObject> list = new List<GameObject>(); float num = 1f + Factor * (SkillsConfig.TreeYield.Value - 1f); foreach (GameObject item in __result) { for (int num2 = Mathf.FloorToInt(num + Random.Range(0f, 1f)); num2 > 0; num2--) { list.Add(item); } } __result = list; } } [HarmonyPatch(typeof(ImpactEffect), "OnCollisionEnter")] private static class TreeHit { private static void Prefix(ImpactEffect __instance) { HitByTree = (Object)(object)((Component)__instance).GetComponent<TreeLog>() != (Object)null; } private static void Finalizer() { HitByTree = false; } } [HarmonyPatch(typeof(Character), "Damage")] private static class FallDmg { private static void Prefix(Character __instance, HitData hit) { if (HitByTree) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!((Object)(object)val == (Object)null)) { float num = ((Character)val).m_nview.GetZDO().GetFloat("Lumberjacking Skill Factor", 0f); hit.ApplyModifier(1f - num * (1f - SkillsConfig.TreeFallDmg.Value)); } } } } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] private static class ForestWalk { private static void Postfix(Player __instance, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 Biome val = Heightmap.FindBiome(((Component)__instance).transform.position); if ((int)val == 8 || (int)val == 1) { float num = SkillRegistry.Factor(__instance, Plugin.LumberjackingSkill); __result *= 1f + num * (SkillsConfig.ForestSpeed.Value - 1f); } } } internal static bool IsChop; internal static float Factor; internal static bool HitByTree; } internal static class SkillRegistry { [HarmonyPatch(typeof(Skills), "GetSkillDef")] private static class GetSkillDefPatch { private static void Postfix(SkillType type, List<SkillDef> ___m_skills, ref SkillDef __result) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) SkillDef value; if (__result != null) { SkillIcons.Apply(___m_skills); } else if (Defs.TryGetValue(type, out value) && value != null) { if (!___m_skills.Contains(value)) { ___m_skills.Add(value); } SkillIcons.Apply(___m_skills); __result = value; } } } [HarmonyPatch(typeof(Skills), "IsSkillValid")] private static class IsSkillValidPatch { private static void Postfix(SkillType type, ref bool __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!__result && Defs.ContainsKey(type)) { __result = true; } } } [HarmonyPatch(typeof(Skills), "OnDeath")] private static class OnDeathPatch { private static void Prefix(Skills __instance, ref Dictionary<SkillType, Skill> __state) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) __state = new Dictionary<SkillType, Skill>(); foreach (KeyValuePair<SkillType, int> item in DeathLoss) { Drain(__instance, item.Key, __state); } } private static void Drain(Skills skills, SkillType type, Dictionary<SkillType, Skill> state) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (skills.m_skillData.TryGetValue(type, out var value)) { int num = 5; if (DeathLoss.TryGetValue(type, out var value2)) { num = value2; } if (num > 0) { value.m_level = Mathf.Floor(Mathf.Max(0f, value.m_level * (1f - (float)num / 100f))); value.m_accumulator = 0f; } state[type] = value; skills.m_skillData.Remove(type); } } private static void Finalizer(Skills __instance, Dictionary<SkillType, Skill> __state) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (__state == null) { return; } foreach (KeyValuePair<SkillType, Skill> item in __state) { __instance.m_skillData[item.Key] = item.Value; } } } internal static readonly Dictionary<SkillType, SkillDef> Defs = new Dictionary<SkillType, SkillDef>(); internal static readonly Dictionary<SkillType, int> DeathLoss = new Dictionary<SkillType, int>(); internal static int StableHash(string str) { int num = 5381; int num2 = num; for (int i = 0; i < str.Length && str[i] != 0; i += 2) { num = ((num << 5) + num) ^ str[i]; if (i == str.Length - 1 || str[i + 1] == '\0') { break; } num2 = ((num2 << 5) + num2) ^ str[i + 1]; } return num + num2 * 1566083941; } internal static void Track(SkillType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!Defs.ContainsKey(type)) { Defs[type] = null; } } internal static SkillType RegisterNamedSkill(string englishName, string description, float increaseStep) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) SkillType val = (SkillType)Math.Abs(StableHash(englishName)); Defs[val] = new SkillDef { m_skill = val, m_description = description, m_increseStep = increaseStep, m_icon = null }; return val; } internal static void SetGain(SkillType type, float step) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Defs.TryGetValue(type, out var value)) { value.m_increseStep = step; } } internal static float Factor(Player player, SkillType type) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { return ((Character)player).GetSkillFactor(type); } return 0f; } internal static float Level(Player player, SkillType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Factor(player, type) * 100f; } } internal static class SkillsConfig { internal static ConfigEntry<bool> LoggingEnabled; internal static ConfigEntry<float> ConBaseHealth; internal static ConfigEntry<float> ConBaseStamina; internal static ConfigEntry<float> ConFoodHealthGain; internal static ConfigEntry<float> ConFoodStaminaGain; internal static ConfigEntry<float> ConHealthPerPoint; internal static ConfigEntry<float> ConStaminaPerPoint; internal static ConfigEntry<float> ConActivityToSkill; internal static ConfigEntry<float> VitMaxHealth; internal static ConfigEntry<float> VitHealthRegen; internal static ConfigEntry<float> VitMaxStamina; internal static ConfigEntry<float> VitMaxEitr; internal static ConfigEntry<float> VitStaminaRegen; internal static ConfigEntry<float> VitEitrRegen; internal static ConfigEntry<float> VitStaminaDelay; internal static ConfigEntry<float> VitJumpCost; internal static ConfigEntry<float> VitSwimCost; internal static ConfigEntry<bool> BlockStaminaRegenInWater; internal static ConfigEntry<float> VitWalkSpeed; internal static ConfigEntry<float> VitRunSpeed; internal static ConfigEntry<float> VitSwimSpeed; internal static ConfigEntry<float> VitCarry; internal static ConfigEntry<float> VitJumpHeight; internal static ConfigEntry<float> VitFallDamage; internal static ConfigEntry<bool> VitDoubleJumpFallReset; internal static ConfigEntry<float> VitWoodcutting; internal static ConfigEntry<float> VitMining; internal static ConfigEntry<float> VitSkillGain; internal static ConfigEntry<float> VitWorkDamageGain; internal static ConfigEntry<int> BodySkillDeathLoss; internal static ConfigEntry<float> TenacityGain; internal static ConfigEntry<float> TenacityEffect; internal static ConfigEntry<int> TenacityLoss; internal static ConfigEntry<float> PackHorseGain; internal static ConfigEntry<float> PackHorseEffect; internal static ConfigEntry<int> PackHorseLoss; internal static ConfigEntry<int> Wb1; internal static ConfigEntry<int> Wb2; internal static ConfigEntry<int> Forge1; internal static ConfigEntry<int> Forge2; internal static ConfigEntry<int> BlackForge1; internal static ConfigEntry<int> BlackForge2; internal static ConfigEntry<int> Galdr1; internal static ConfigEntry<int> Galdr2; internal static ConfigEntry<int> RepairLevel; internal static ConfigEntry<int> ExtraUpgradeLevel; internal static ConfigEntry<float> BaseDurability; internal static ConfigEntry<float> DurabilityFactor; internal static ConfigEntry<int> FirstCraftBonus; internal static ConfigEntry<int> XpReduceThreshold; internal static ConfigEntry<float> XpReduceFactor; internal static ConfigEntry<float> BlacksmithingGain; internal static ConfigEntry<int> BlacksmithingLoss; internal static ConfigEntry<float> MiningDamage; internal static ConfigEntry<float> MiningYield; internal static ConfigEntry<int> MiningExplodeLevel; internal static ConfigEntry<float> MiningExplodeChance; internal static ConfigEntry<KeyboardShortcut> MiningExplodeHotkey; internal static ConfigEntry<float> MiningGain; internal static ConfigEntry<int> MiningLoss; internal static ConfigEntry<float> TreeYield; internal static ConfigEntry<float> TreeDamage; internal static ConfigEntry<float> TreeFallDmg; internal static ConfigEntry<float> ForestSpeed; internal static ConfigEntry<float> LumberjackingGain; internal static ConfigEntry<int> LumberjackingLoss; internal static ConfigEntry<string> ForagingScope; internal static ConfigEntry<float> ForagingYield; internal static ConfigEntry<int> ForagingRespawnDisplay; internal static ConfigEntry<float> ForagingRespawnSpeed; internal static ConfigEntry<float> ForagingGain; internal static ConfigEntry<int> ForagingLoss; internal static ConfigEntry<float> GrowSpeed; internal static ConfigEntry<float> CropYield; internal static ConfigEntry<int> ShowProgressLevel; internal static ConfigEntry<int> IgnoreBiomeLevel; internal static ConfigEntry<int> StaminaReducePerLevel; internal static ConfigEntry<float> FarmingGain; internal static ConfigEntry<int> FarmingLoss; internal static ConfigEntry<float> RanchDrop; internal static ConfigEntry<float> RanchTame; internal static ConfigEntry<int> RanchFoodLevel; internal static ConfigEntry<int> RanchCalmLevel; internal static ConfigEntry<int> RanchPregLevel; internal static ConfigEntry<int> RanchLevelUpLevel; internal static ConfigEntry<int> RanchLevelUpChance; internal static ConfigEntry<float> RanchingGain; internal static ConfigEntry<int> RanchingLoss; internal static ConfigEntry<int> CookTimeReduce; internal static ConfigEntry<int> HappyLevel; internal static ConfigEntry<int> HappyMinutes; internal static ConfigEntry<float> HappySpeed; internal static ConfigEntry<float> CookingGain; internal static ConfigEntry<int> CookingLoss; internal static ConfigEntry<float> ShipSpeed; internal static ConfigEntry<float> ExploreRadius; internal static ConfigEntry<float> ShipHealth; internal static ConfigEntry<bool> AllowNudge; internal static ConfigEntry<float> NudgeForce; internal static ConfigEntry<KeyboardShortcut> NudgeKey; internal static ConfigEntry<float> SailingGain; internal static ConfigEntry<int> SailingLoss; private static ConfigDescription Admin(string desc) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { IsAdminOnly = true } }); } private static ConfigDescription AdminRange(string desc, AcceptableValueBase range) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return new ConfigDescription(desc, range, new object[1] { new ConfigurationManagerAttributes { IsAdminOnly = true } }); } internal static void Bind(ConfigFile config) { //IL_0841: Unknown result type (might be due to invalid IL or missing references) //IL_0e75: Unknown result type (might be due to invalid IL or missing references) LoggingEnabled = config.Bind<bool>("Logging", "Logging Enabled", false, "Enable extra log lines."); ConBaseHealth = config.Bind<float>("Constitution", "BaseHealthAdjust", 10f, Admin("Health added to the base pool.")); ConBaseStamina = config.Bind<float>("Constitution", "BaseStaminaAdjust", 10f, Admin("Stamina added to the base pool.")); ConFoodHealthGain = config.Bind<float>("Constitution", "ConstitutionGainHealthModifier", 0.2f, Admin("Food-health constitution XP.")); ConFoodStaminaGain = config.Bind<float>("Constitution", "ConstitutionGainStaminaModifier", 0.2f, Admin("Food-stamina constitution XP.")); ConHealthPerPoint = config.Bind<float>("Constitution", "HealthPerConstitution", 0.5f, Admin("Health per constitution level.")); ConStaminaPerPoint = config.Bind<float>("Constitution", "StaminaPerConstitution", 0.5f, Admin("Stamina per constitution level.")); ConActivityToSkill = config.Bind<float>("Constitution", "ActivityToSkillModifer", 1f, Admin("Stamina spent before food XP applies.")); VitMaxHealth = config.Bind<float>("Vitality", "MaxIncrease", 125f, Admin("Extra max health at vitality 100.")); VitHealthRegen = config.Bind<float>("Vitality", "RegenerationIncrease", 100f, Admin("Health regen increase % at vitality 100.")); VitMaxStamina = config.Bind<float>("Vitality", "MaxStaminaIncrease", 150f, Admin("Extra max stamina at vitality 100.")); VitMaxEitr = config.Bind<float>("Vitality", "MaxEitrIncrease", 40f, Admin("Extra max eitr at vitality 100.")); VitStaminaRegen = config.Bind<float>("Vitality", "StaminaRegenerationIncrease", 24f, Admin("Stamina regen increase % at vitality 100.")); VitEitrRegen = config.Bind<float>("Vitality", "EitrRegenerationIncrease", 72f, Admin("Eitr regen increase % at vitality 100.")); VitStaminaDelay = config.Bind<float>("Vitality", "RegenerationDelayReduction", 50f, Admin("Stamina regen delay reduction % at vitality 100.")); VitJumpCost = config.Bind<float>("Vitality", "JumpCostReduction", 50f, Admin("Jump stamina cost reduction % at vitality 100.")); VitSwimCost = config.Bind<float>("Vitality", "SwimCostReduction", 75f, Admin("Swim stamina cost reduction % at vitality 100.")); BlockStaminaRegenInWater = config.Bind<bool>("Vitality", "BlockStaminaRegenInWater", true, Admin("Force stamina regen to 0 while swimming not on ground.")); VitWalkSpeed = config.Bind<float>("Vitality", "WalkingBase", 12.5f, Admin("Walk speed increase at vitality 100.")); VitRunSpeed = config.Bind<float>("Vitality", "RunBase", 12.5f, Admin("Run speed increase at vitality 100.")); VitSwimSpeed = config.Bind<float>("Vitality", "SwimBase", 100f, Admin("Swim speed increase % at vitality 100.")); VitCarry = config.Bind<float>("Vitality", "Carryweight", 400f, Admin("Extra carry weight at vitality 100.")); VitJumpHeight = config.Bind<float>("Vitality", "JumpHeight", 10f, Admin("Jump height increase % at vitality 100.")); VitFallDamage = config.Bind<float>("Vitality", "FallDamageReduction", 10f, Admin("Fall damage reduction % at vitality 100.")); VitDoubleJumpFallReset = config.Bind<bool>("Vitality", "DoubleJumpFallDamageReset", true, Admin("Reset fall height on jump.")); VitWoodcutting = config.Bind<float>("Vitality", "WoodcuttingIncrease", 25f, Admin("Chop damage increase % at vitality 100.")); VitMining = config.Bind<float>("Vitality", "MiningIncrease", 25f, Admin("Pickaxe damage increase % at vitality 100.")); VitSkillGain = config.Bind<float>("Vitality", "GeneralMultiplier", 1f, Admin("Vitality XP multiplier.")); VitWorkDamageGain = config.Bind<float>("Vitality", "WorkDamageMultiplier", 1f, Admin("Extra vitality XP from tool damage.")); BodySkillDeathLoss = config.Bind<int>("Death", "Vitality and Constitution death loss", 5, AdminRange("Percent of Vitality and Constitution lost on death (floored).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); TenacityGain = config.Bind<float>("Tenacity", "Skill gain factor", 1f, AdminRange("XP rate.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); TenacityEffect = config.Bind<float>("Tenacity", "Skill effect factor", 0.1f, AdminRange("Power vs default 20% DR at 100.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); TenacityLoss = config.Bind<int>("Tenacity", "Skill loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); PackHorseGain = config.Bind<float>("PackHorse", "Skill gain factor", 1f, AdminRange("XP rate.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); PackHorseEffect = config.Bind<float>("PackHorse", "Skill effect factor", 0.2f, AdminRange("Carry multiplier power (1 + factor at 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); PackHorseLoss = config.Bind<int>("PackHorse", "Skill loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); Wb1 = config.Bind<int>("Blacksmithing", "Skill Level for first Workbench Upgrade", 10, Admin("0 disables.")); Wb2 = config.Bind<int>("Blacksmithing", "Skill Level for second Workbench Upgrade", 20, Admin("0 disables.")); Forge1 = config.Bind<int>("Blacksmithing", "Skill Level for first Forge Upgrade", 30, Admin("0 disables.")); Forge2 = config.Bind<int>("Blacksmithing", "Skill Level for second Forge Upgrade", 40, Admin("0 disables.")); BlackForge1 = config.Bind<int>("Blacksmithing", "Skill Level for first Black Forge Upgrade", 50, Admin("0 disables.")); BlackForge2 = config.Bind<int>("Blacksmithing", "Skill Level for second Black Forge Upgrade", 60, Admin("0 disables.")); Galdr1 = config.Bind<int>("Blacksmithing", "Skill Level for first Galdr Table Upgrade", 50, Admin("0 disables.")); Galdr2 = config.Bind<int>("Blacksmithing", "Skill Level for second Galdr Table Upgrade", 60, Admin("0 disables.")); RepairLevel = config.Bind<int>("Blacksmithing", "Skill Level for Inventory Repair", 70, Admin("0 disables.")); ExtraUpgradeLevel = config.Bind<int>("Blacksmithing", "Skill Level for Extra Upgrade Level", 80, Admin("0 disables.")); BaseDurability = config.Bind<float>("Blacksmithing", "Base Durability Factor", 1f, Admin("Durability at skill 0.")); DurabilityFactor = config.Bind<float>("Blacksmithing", "Durability Factor", 2f, Admin("Durability at skill 100.")); FirstCraftBonus = config.Bind<int>("Blacksmithing", "First Craft Bonus", 75, Admin("Bonus XP first craft of an item.")); XpReduceThreshold = config.Bind<int>("Blacksmithing", "Experience Reduction Threshold", 5, Admin("Crafts before XP drops. 0 off.")); XpReduceFactor = config.Bind<float>("Blacksmithing", "Experience Reduction Factor", 0.5f, Admin("Additive XP cut per threshold.")); BlacksmithingGain = config.Bind<float>("Blacksmithing", "Skill Experience Gain Factor", 0.2f, AdminRange("XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); BlacksmithingLoss = config.Bind<int>("Blacksmithing", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); MiningDamage = config.Bind<float>("Mining", "Mining Damage Factor", 3f, Admin("Pickaxe damage at 100.")); MiningYield = config.Bind<float>("Mining", "Mining Yield Factor", 2f, Admin("Ore yield at 100.")); MiningExplodeLevel = config.Bind<int>("Mining", "Mining Explosion Level Requirement", 50, Admin("0 disables.")); MiningExplodeChance = config.Bind<float>("Mining", "Mining Explosion Chance", 1f, Admin("Chance at 100.")); MiningExplodeHotkey = config.Bind<KeyboardShortcut>("Mining", "Toggle Explosive Mining Hotkey", new KeyboardShortcut((KeyCode)116, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Stand still to toggle."); MiningGain = config.Bind<float>("Mining", "Skill Experience Gain Factor", 0.2f, AdminRange("XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); MiningLoss = config.Bind<int>("Mining", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); TreeYield = config.Bind<float>("Lumberjacking", "Tree item yield modifier at level 100", 2f, Admin("Yield at 100.")); TreeDamage = config.Bind<float>("Lumberjacking", "Damage to trees modifier at level 100", 3f, Admin("Chop at 100.")); TreeFallDmg = config.Bind<float>("Lumberjacking", "Tree fall damage modifier at level 100", 0.3f, Admin("Falling-tree damage taken at 100.")); ForestSpeed = config.Bind<float>("Lumberjacking", "Movement speed modifier in forests at level 100", 1.1f, Admin("Forest move at 100.")); LumberjackingGain = config.Bind<float>("Lumberjacking", "Skill Experience Gain Factor", 0.2f, AdminRange("XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); LumberjackingLoss = config.Bind<int>("Lumberjacking", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); ForagingScope = config.Bind<string>("Foraging", "Foraging Scope", "Foraging", Admin("Foraging, NoCrops, or Everything.")); ForagingYield = config.Bind<float>("Foraging", "Foraging Yield Factor", 2f, Admin("Yield at 100.")); ForagingRespawnDisplay = config.Bind<int>("Foraging", "Minimum Level Respawn Display", 30, Admin("0 disables.")); ForagingRespawnSpeed = config.Bind<float>("Foraging", "Multiplier for Respawn Speed", 2f, Admin("Respawn speed at 100.")); ForagingGain = config.Bind<float>("Foraging", "Skill Experience Gain Factor", 0.2f, AdminRange("XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); ForagingLoss = config.Bind<int>("Foraging", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); GrowSpeed = config.Bind<float>("Farming", "Grow Speed Factor", 3f, Admin("Grow speed at farming 100.")); CropYield = config.Bind<float>("Farming", "Crop Yield Factor", 2f, Admin("Yield at 100.")); ShowProgressLevel = config.Bind<int>("Farming", "Show Progress Level", 30, Admin("0 disables.")); IgnoreBiomeLevel = config.Bind<int>("Farming", "Ignore Biome Level", 50, Admin("0 disables.")); StaminaReducePerLevel = config.Bind<int>("Farming", "Stamina Reduction per Level", 1, Admin("% stamina cut per farming level.")); FarmingGain = config.Bind<float>("Farming", "Skill Experience Gain Factor", 0.2f, AdminRange("Vanilla farming XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); FarmingLoss = config.Bind<int>("Farming", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); RanchDrop = config.Bind<float>("Ranching", "Item Drop Factor", 2f, Admin("Tame drop at 100.")); RanchTame = config.Bind<float>("Ranching", "Taming Factor", 2f, Admin("Tame speed at 100.")); RanchFoodLevel = config.Bind<int>("Ranching", "Food Level Requirement", 10, Admin("0 disables.")); RanchCalmLevel = config.Bind<int>("Ranching", "Calming Level Requirement", 20, Admin("0 disables.")); RanchPregLevel = config.Bind<int>("Ranching", "Pregnancy Level Requirement", 40, Admin("0 disables.")); RanchLevelUpLevel = config.Bind<int>("Ranching", "Level Up Level Requirement", 50, Admin("0 disables.")); RanchLevelUpChance = config.Bind<int>("Ranching", "Level Up Chance", 5, Admin("Offspring +1 star chance.")); RanchingGain = config.Bind<float>("Ranching", "Skill Experience Gain Factor", 0.2f, AdminRange("XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); RanchingLoss = config.Bind<int>("Ranching", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); CookTimeReduce = config.Bind<int>("Cooking", "Crafting Time Reduction", 30, Admin("% craft time cut at 100.")); HappyLevel = config.Bind<int>("Cooking", "Happy Required Level", 75, Admin("0 disables.")); HappyMinutes = config.Bind<int>("Cooking", "Happy Buff Duration", 3, Admin("Minutes.")); HappySpeed = config.Bind<float>("Cooking", "Happy Buff Strength", 1.05f, Admin("Move speed with Happy.")); CookingGain = config.Bind<float>("Cooking", "Skill Experience Gain Factor", 0.2f, AdminRange("XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); CookingLoss = config.Bind<int>("Cooking", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); ShipSpeed = config.Bind<float>("Sailing", "Ship Speed Factor", 1.5f, Admin("Speed at 100 for all ships.")); ExploreRadius = config.Bind<float>("Sailing", "Exploration Radius Factor", 5f, Admin("Explore radius at 100.")); ShipHealth = config.Bind<float>("Sailing", "Ship Health Factor", 2f, Admin("Ship HP at 100.")); AllowNudge = config.Bind<bool>("Sailing", "Allow Ship Nudge", true, Admin("Unstick ships.")); NudgeForce = config.Bind<float>("Sailing", "Ship Nudge Force", 10f, Admin("Nudge impulse.")); NudgeKey = config.Bind<KeyboardShortcut>("Sailing", "Ship Nudge Modifier Key", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), "Hold to nudge."); SailingGain = config.Bind<float>("Sailing", "Skill Experience Gain Factor", 0.2f, AdminRange("XP step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f))); SailingLoss = config.Bind<int>("Sailing", "Skill Experience Loss", 5, AdminRange("Death loss %.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100))); } } internal static class VitalityLayer { [HarmonyPatch(typeof(Player), "UpdateFood")] private static class HealthRegenPatch { private static void Prefix(ref float ___m_foodRegenTimer) { if (___m_foodRegenTimer == 0f) { float num = skillFactor * SkillsConfig.VitHealthRegen.Value / 100f + 1f; if (num > 0f) { ___m_foodRegenTimer = 10f - 10f / num; } } } } [HarmonyPatch(typeof(Player), "SetMaxHealth")] private static class MaxHealthPatch { private static void Prefix(ref float health) { health += healthBonus; } } [HarmonyPatch(typeof(Player), "SetMaxStamina")] private static class MaxStaminaPatch { private static void Prefix(ref float stamina) { stamina += staminaBonus; } } [HarmonyPatch(typeof(Player), "SetMaxEitr")] private static class MaxEitrPatch { private static void Prefix(ref float eitr) { if (eitr > 0f) { eitr += eitrBonus; } } } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] private static class WalkSpeedPatch { private static void Postfix(ref float __result) { __result += walkBonus; } } [HarmonyPatch(typeof(Player), "GetRunSpeedFactor")] private static class RunSpeedPatch { private static void Postfix(ref float __result) { __result += runBonus; } } [HarmonyPatch(typeof(Character), "UpdateGroundContact")] private static class FallDamagePatch { private static void Prefix(Character __instance, ref float ___m_maxAirAltitude, bool ___m_groundContact) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (___m_groundContact && __instance is Player) { float num = ___m_maxAirAltitude - ((Component)__instance).transform.position.y; if (num > 4f) { ___m_maxAirAltitude -= num * fallReduce; } } } } [HarmonyPatch(typeof(Player), "OnJump")] private static class JumpPatch { private static void Prefix(Player __instance) { float num = ((Character)__instance).m_jumpStaminaUsage - ((Character)__instance).m_jumpStaminaUsage * ((Character)__instance).GetEquipmentJumpStaminaModifier(); if (((Character)__instance).HaveStamina(num * Game.m_moveStaminaRate)) { Gain(__instance, 0.14f); } } private static void Postfix(Player __instance, ref float ___m_maxAirAltitude) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (SkillsConfig.VitDoubleJumpFallReset.Value) { ___m_maxAirAltitude = ((Component)__instance).transform.position.y; } } } [HarmonyPatch(typeof(SEMan), "ModifyStaminaRegen")] [HarmonyPriority(0)] private static class SwimStaminaRegenPatch { private static void Postfix(SEMan __instance, ref float staminaMultiplier) { if (SkillsConfig.BlockStaminaRegenInWater != null && SkillsConfig.BlockStaminaRegenInWater.Value) { Character character = __instance.m_character; if (!((Object)(object)character == (Object)null) && character.IsPlayer() && character.IsSwimming() && !character.IsOnGround()) { staminaMultiplier = 0f; } } } } [HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })] private static class UpdateStatsPatch { private static void Prefix(Player __instance, float dt, out float __state) { __state = __instance.GetStamina(); if (((Character)__instance).IsFlying()) { return; } if (((Character)__instance).IsRunning() && ((Character)__instance).IsOnGround()) { runSwimSkill += 0.1f * dt; } if (((Character)__instance).InWater() && !((Character)__instance).IsOnGround()) { float staminaPercentage = ((Character)__instance).GetStaminaPercentage(); if (!Mathf.Approximately(lastSwimStamina, staminaPercentage)) { runSwimSkill += 0.25f * dt; } lastSwimStamina = staminaPercentage; } if (runSwimSkill >= 1f) { Gain(__instance, runSwimSkill); runSwimSkill = 0f; } } [HarmonyPriority(0)] private static void Postfix(Player __instance, float __state) { if (SkillsConfig.BlockStaminaRegenInWater != null && SkillsConfig.BlockStaminaRegenInWater.Value && ((Character)__instance).IsSwimming() && !((Character)__instance).IsOnGround() && __instance.GetStamina() > __state) { __instance.m_stamina = __state; } } } [HarmonyPatch(typeof(Player), "Load")] private static class LoadPatch { private static void Postfix(Player __instance) { captured = false; Apply(__instance); } } [HarmonyPatch(typeof(Player), "OnSkillLevelup")] private static class LevelUpPatch { private static void Postfix(Player __instance, SkillType skill) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (skill == Plugin.VitalitySkill || skill == Plugin.ConstitutionSkill) { Apply(__instance); } } } [HarmonyPatch(typeof(MineRock5), "DamageArea")] private static class MineRockPatch { private static void Prefix(MineRock5 __instance, HitData hit) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !(((Character)localPlayer).GetZDOID() != hit.m_attacker) && (int)hit.m_skill == 12) { hit.m_damage.m_pickaxe *= miningMul; Gain(localPlayer, 0.04f + hit.m_damage.m_pickaxe * 0.00075f * SkillsConfig.VitWorkDamageGain.Value); if (Plugin.Logging) { Plugin.Log($"MineRock5 {((Object)__instance).name} dmg={hit.m_damage.m_pickaxe}"); } } } } [HarmonyPatch(typeof(Destructible), "Damage")] private static class DestructiblePatch { private static void Prefix(Destructible __instance, HitData hit) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !(((Character)localPlayer).GetZDOID() != hit.m_attacker)) { if ((int)hit.m_skill == 12 && ((Object)__instance).name.IndexOf("rock", StringComparison.OrdinalIgnoreCase) >= 0) { hit.m_damage.m_pickaxe *= miningMul; Gain(localPlayer, 0.1f + hit.m_damage.m_pickaxe * 0.001f * SkillsConfig.VitWorkDamageGain.Value); } else if ((int)hit.m_skill == 13) { hit.m_damage.m_chop *= woodMul; Gain(localPlayer, 0.1f + hit.m_damage.m_chop * 0.001f * SkillsConfig.VitWorkDamageGain.Value); } } } } [HarmonyPatch(typeof(TreeBase), "Damage")] private static class TreePatch { private static void Prefix(TreeBase __instance, HitData hit) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !(((Character)localPlayer).GetZDOID() != hit.m_attacker) && (int)hit.m_skill == 13 && hit.m_toolTier >= __instance.m_minToolTier) { hit.m_damage.m_chop *= woodMul; Gain(localPlayer, 0.1f + hit.m_damage.m_chop * 0.001f * SkillsConfig.VitWorkDamageGain.Value); } } } [HarmonyPatch(typeof(TreeLog), "Damage")] private static class TreeLogPatch { private static void Prefix(TreeLog __instance, HitData hit) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !(((Character)localPlayer).GetZDOID() != hit.m_attacker) && (int)hit.m_skill == 13 && hit.m_toolTier >= __instance.m_minToolTier) { hit.m_damage.m_chop *= woodMul; Gain(localPlayer, 0.1f + hit.m_damage.m_chop * 0.001f * SkillsConfig.VitWorkDamageGain.Value); } } } private static float skillFactor; private static float walkBonus; private static float runBonus; private static float healthBonus; private static float staminaBonus; private static float eitrBonus; private static float miningMul; private static float woodMul; private static float fallReduce; private static float runSwimSkill; private static float lastSwimStamina; private static float baseJumpForce; private static float baseMaxCarry; private static float baseJumpStamina; private static float baseStaminaDelay; private static float baseStaminaRegen; private static float baseEitrRegen; private static float baseSwimDrainMin; private static float baseSwimDrainMax; private static float baseSwimSpeed; private static float baseSwimTurn; private static bool captured; private static bool eitrFieldResolved; private static FieldInfo eitrRegenField; internal static void ApplyAllPlayers() { foreach (Player allPlayer in Player.GetAllPlayers()) { Apply(allPlayer); } } internal static void Apply(Player player) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { if (!captured) { Capture(player); } skillFactor = ((Character)player).GetSkillFactor(Plugin.VitalitySkill); walkBonus = skillFactor * SkillsConfig.VitWalkSpeed.Value / 100f; runBonus = skillFactor * SkillsConfig.VitRunSpeed.Value / 100f; healthBonus = skillFactor * SkillsConfig.VitMaxHealth.Value; staminaBonus = skillFactor * SkillsConfig.VitMaxStamina.Value; eitrBonus = skillFactor * SkillsConfig.VitMaxEitr.Value; miningMul = 1f + skillFactor * SkillsConfig.VitMining.Value / 100f; woodMul = 1f + skillFactor * SkillsConfig.VitWoodcutting.Value / 100f; fallReduce = skillFactor * SkillsConfig.VitFallDamage.Value / 100f; ConstitutionLayer.Refresh(player); if (Plugin.Logging) { Plugin.Log($"Vitality skillFactor={skillFactor}"); } ((Character)player).m_jumpForce = baseJumpForce * (1f + skillFactor * SkillsConfig.VitJumpHeight.Value / 100f); player.m_staminaRegen = baseStaminaRegen * (1f + skillFactor * SkillsConfig.VitStaminaRegen.Value / 100f); SetEitrRegen(player, baseEitrRegen * (1f + skillFactor * SkillsConfig.VitEitrRegen.Value / 100f)); player.m_swimStaminaDrainMinSkill = baseSwimDrainMin * (1f - skillFactor * SkillsConfig.VitSwimCost.Value / 100f); player.m_swimStaminaDrainMaxSkill = baseSwimDrainMax * (1f - skillFactor * SkillsConfig.VitSwimCost.Value / 100f); player.m_maxCarryWeight = baseMaxCarry + skillFactor * SkillsConfig.VitCarry.Value; ((Character)player).m_jumpStaminaUsage = baseJumpStamina * (1f - skillFactor * SkillsConfig.VitJumpCost.Value / 100f); player.m_staminaRegenDelay = baseStaminaDelay * (1f - skillFactor * SkillsConfig.VitStaminaDelay.Value / 100f); ((Character)player).m_swimSpeed = baseSwimSpeed * (1f + skillFactor * SkillsConfig.VitSwimSpeed.Value / 100f); ((Character)player).m_swimTurnSpeed = baseSwimTurn * (1f + skillFactor * SkillsConfig.VitSwimSpeed.Value / 100f); } } private static void Capture(Player player) { baseJumpForce = ((Character)player).m_jumpForce; baseStaminaRegen = player.m_staminaRegen; baseEitrRegen = GetEitrRegen(player); baseSwimDrainMin = player.m_swimStaminaDrainMinSkill; baseSwimDrainMax = player.m_swimStaminaDrainMaxSkill; baseMaxCarry = player.m_maxCarryWeight; baseJumpStamina = ((Character)player).m_jumpStaminaUsage; baseStaminaDelay = player.m_staminaRegenDelay; baseSwimSpeed = ((Character)player).m_swimSpeed; baseSwimTurn = ((Character)player).m_swimTurnSpeed; captured = true; } private static float GetEitrRegen(Player player) { ResolveEitrField(); if (!(eitrRegenField != null)) { return 0f; } return (float)eitrRegenField.GetValue(player); } private static void SetEitrRegen(Player player, float value) { ResolveEitrField(); eitrRegenField?.SetValue(player, value); } private static void ResolveEitrField() { if (!eitrFieldResolved) { eitrRegenField = AccessTools.Field(typeof(Player), "m_eiterRegen") ?? AccessTools.Field(typeof(Player), "m_eitrRegen"); eitrFieldResolved = true; } } private static void Gain(Player player, float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Character)player).RaiseSkill(Plugin.VitalitySkill, value * SkillsConfig.VitSkillGain.Value); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }