using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Agents; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CellMenu; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Microsoft.CodeAnalysis; using Player; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ChickenHealthAndMeleeTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ChickenHealthAndMeleeTweaks")] [assembly: AssemblyTitle("ChickenHealthAndMeleeTweaks")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ChickenMods.HealthAndMeleeTweaks { [BepInPlugin("com.chicken.healthandmeleetweaks", "Health and Melee Tweaks", "1.0.0")] public class Plugin : BasePlugin { public const string PluginGUID = "com.chicken.healthandmeleetweaks"; public const string PluginVersion = "1.0.0"; public static ConfigEntry MeleeDamageMultiplier = null; public static ConfigEntry MaxHealthMultiplier = null; public static ConfigEntry HealthRegenCap = null; public static ConfigEntry HealthRegenRate = null; public static ManualLogSource Log = null; private static readonly Dictionary _baseHealthByBlock = new Dictionary(); public override void Load() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown Log = ((BasePlugin)this).Log; ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(93, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Chicken] Health and Melee Tweaks v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" — datablock health tuning, native regen, melee intercept."); } log.LogInfo(val); MeleeDamageMultiplier = ((BasePlugin)this).Config.Bind("Melee", "DamageMultiplier", 2f, new ConfigDescription("Multiplier for all player melee attacks.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1000f), Array.Empty())); MaxHealthMultiplier = ((BasePlugin)this).Config.Bind("Health", "MaxHealthMultiplier", 1f, new ConfigDescription("Multiplier for player max health (2.0 = 200% health).", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 100f), Array.Empty())); HealthRegenCap = ((BasePlugin)this).Config.Bind("Health", "RegenCapPercentage", 0.2f, new ConfigDescription("Max health fraction you can regenerate up to (0.2 = 20%, 1.0 = 100%).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); HealthRegenRate = ((BasePlugin)this).Config.Bind("Health", "RegenPerSecond", 1f, new ConfigDescription("How fast health regenerates while below the cap (health units/sec).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1000f), Array.Empty())); Harmony val2 = new Harmony("com.chicken.healthandmeleetweaks"); val2.PatchAll(typeof(Plugin)); TryHookHealthDataBlock(val2); foreach (MethodBase patchedMethod in val2.GetPatchedMethods()) { ManualLogSource log2 = Log; val = new BepInExInfoLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Chicken] Confirmed patched: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(patchedMethod.DeclaringType?.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(patchedMethod.Name); } log2.LogInfo(val); } Log.LogInfo((object)"[Chicken] Roost secured. Health and Melee Tweaks loaded successfully!"); } private static void TryHookHealthDataBlock(Harmony harmony) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown string[] array = new string[3] { "Setup", "OnEnable", "PostSetup" }; bool flag = default(bool); foreach (string text in array) { try { MethodInfo methodInfo = AccessTools.Method(typeof(CM_PageRundown_New), text, (Type[])null, (Type[])null); if (methodInfo == null) { continue; } harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ApplyHealthDataBlockSettings", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Chicken] Health datablock hook attached to CM_PageRundown_New."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); } log.LogInfo(val); return; } catch (Exception ex) { ManualLogSource log2 = Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Chicken] Could not hook CM_PageRundown_New."); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log2.LogWarning(val2); } } Log.LogError((object)"[Chicken] Failed to attach the health datablock hook. Health tuning will NOT apply. Check the CM_PageRundown_New method name for your game build."); } public static void ApplyHealthDataBlockSettings() { //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown bool flag = default(bool); try { float value = MaxHealthMultiplier.Value; Il2CppArrayBase allBlocks = GameDataBlockBase.GetAllBlocks(); if (allBlocks == null) { return; } for (int i = 0; i < allBlocks.Count; i++) { PlayerDataBlock val = allBlocks[i]; if (val != null) { uint persistentID = ((GameDataBlockBase)(object)val).persistentID; if (!_baseHealthByBlock.TryGetValue(persistentID, out var value2)) { value2 = val.health; _baseHealthByBlock[persistentID] = value2; } val.health = value2 * value; val.healthRegenRelMax = HealthRegenCap.Value; val.healthRegenPerSecond = HealthRegenRate.Value; } } ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(87, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Chicken] Applied health settings to "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(allBlocks.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" PlayerDataBlock(s): "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("maxHP x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", regen cap "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(HealthRegenCap.Value, "P0"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", rate "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(HealthRegenRate.Value); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("/s."); } log.LogInfo(val2); } catch (Exception ex) { ManualLogSource log2 = Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Chicken] ApplyHealthDataBlockSettings failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } log2.LogError(val3); } } [HarmonyPatch(typeof(Dam_EnemyDamageBase), "ReceiveMeleeDamage")] [HarmonyPrefix] public static void Patch_EnemyMeleeDamage(ref pFullDamageData data) { Agent val = default(Agent); if (((pAgent)(ref data.source)).TryGet(ref val) && (Object)(object)((Il2CppObjectBase)val).TryCast() != (Object)null) { float num = (float)(int)data.damage.internalValue * MeleeDamageMultiplier.Value; data.damage.internalValue = (ushort)Mathf.Clamp(num, 0f, 65535f); } } } }