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 AyukisTale v0.1.2
DundrFix.dll
Decompiled 8 hours agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("DundrFix")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DundrFix")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9CB67B34-B7FF-4522-9D7A-DA0BF58E8465")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace DundrFix; [BepInPlugin("com.example.dundrskillreload", "Dundr Skill Reload", "1.0.0")] public sealed class DundrSkillReloadPlugin : BaseUnityPlugin { public const string PluginGuid = "com.example.dundrskillreload"; public const string PluginName = "Dundr Skill Reload"; public const string PluginVersion = "1.0.0"; internal static ConfigEntry<float> BaseReloadSeconds; internal static ConfigEntry<float> MaxReductionPercent; internal static ConfigEntry<float> BaseEitrCost; internal static ConfigEntry<float> MaxEitrReductionPercent; private static ConfigEntry<KeyCode> _reloadKey; private static ConfigEntry<KeyCode> _autoReloadKey; internal static bool ReloadRequested; internal static bool AutoReload = true; internal static ItemData loadedItem; private Harmony _harmony; public static ManualLogSource logger = Logger.CreateLogSource("Dundr Skill Reload"); private ConfigEntry<bool> AffectMagic; private ConfigEntry<bool> AffectBows; private ConfigEntry<bool> AffectCrossbows; private ConfigEntry<float> StaminaCost; private ConfigEntry<float> KickRange; private void Awake() { //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown AffectMagic = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "MagicWeapons", true, "Enable kick secondary on magic weapons."); AffectBows = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Bows", true, "Enable kick secondary on bows."); AffectCrossbows = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Crossbows", true, "Enable kick secondary on crossbows."); StaminaCost = ((BaseUnityPlugin)this).Config.Bind<float>("Kick", "StaminaCost", 8f, "Stamina cost of the kick."); KickRange = ((BaseUnityPlugin)this).Config.Bind<float>("Kick", "Range", 1.5f, "Intended melee attack range."); _reloadKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ReloadKey", (KeyCode)101, "Key to manually reload a crossbow."); _autoReloadKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "AutoReloadKey", (KeyCode)113, "Key to enable auto reload of a crossbow."); BaseReloadSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Dundr", "BaseReloadSeconds", 2.5f, "Dundr reload duration at Elemental Magic level 0, in seconds."); MaxReductionPercent = ((BaseUnityPlugin)this).Config.Bind<float>("Dundr", "MaxReloadReductionPercent", 50f, "Reload-time reduction at Elemental Magic level 100."); BaseEitrCost = ((BaseUnityPlugin)this).Config.Bind<float>("Dundr", "BaseEitrCost", 25f, "Dundr Eitr cost at Elemental Magic level 0."); MaxEitrReductionPercent = ((BaseUnityPlugin)this).Config.Bind<float>("Dundr", "MaxEitrReductionPercent", 50f, "Eitr-cost reduction at Elemental Magic level 100."); _harmony = new Harmony("com.example.dundrskillreload"); _harmony.PatchAll(); logger.LogInfo((object)"Dundr Skill Reload loaded. Dundr reload and Eitr cost scale with Elemental Magic."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 if (ZInput.GetKeyDown(_autoReloadKey.Value, true)) { AutoReload = !AutoReload; ((Character)Player.m_localPlayer).Message((MessageType)2, $"Auto reload : {AutoReload}", 0, (Sprite)null, false); } if (!ZInput.GetKeyDown(_reloadKey.Value, true)) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || InventoryGui.IsVisible()) { return; } ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (!DundrScaling.IsDundr(currentWeapon)) { SharedData shared = currentWeapon.m_shared; if (shared == null || (int)shared.m_skillType != 14) { return; } } if (currentWeapon.m_shared.m_attack != null && currentWeapon.m_shared.m_attack.m_requiresReload && !((Humanoid)localPlayer).IsWeaponLoaded()) { ReloadRequested = true; } } internal static void ConfigureWeapons(ObjectDB db) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Invalid comparison between Unknown and I4 //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Invalid comparison between Unknown and I4 //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Invalid comparison between Unknown and I4 //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Invalid comparison between Unknown and I4 //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Invalid comparison between Unknown and I4 if ((Object)(object)db == (Object)null || db.m_items == null) { return; } Attack val = null; foreach (GameObject item in db.m_items) { if ((Object)(object)item == (Object)null) { continue; } ItemDrop component = item.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null || component.m_itemData.m_shared == null) { continue; } SharedData shared = component.m_itemData.m_shared; if ((int)shared.m_itemType == 14) { logger.LogWarning((object)"FOund it"); } if ((int)shared.m_skillType == 2) { logger.LogWarning((object)"FOund one"); if (shared.m_secondaryAttack != null) { val = shared.m_secondaryAttack; break; } } } if (val == null) { logger.LogWarning((object)"Expected unarmed kick attack not found."); return; } Attack secondaryAttack = val.Clone(); foreach (GameObject item2 in db.m_items) { if ((Object)(object)item2 == (Object)null) { continue; } ItemDrop component2 = item2.GetComponent<ItemDrop>(); if (!((Object)(object)component2 == (Object)null) && component2.m_itemData != null && component2.m_itemData.m_shared != null) { SharedData shared2 = component2.m_itemData.m_shared; bool flag = (int)shared2.m_itemType == 4 || (int)shared2.m_skillType == 8; bool flag2 = (int)shared2.m_skillType == 14; bool flag3 = (int)shared2.m_skillType == 9 || (int)shared2.m_skillType == 10; if (shared2.m_secondaryAttack == null && shared2.m_attack != null) { shared2.m_secondaryAttack = secondaryAttack; } } } } } internal static class DundrScaling { internal static bool IsDundr(ItemData item) { if (item == null) { return false; } string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : string.Empty); return text == "StaffLightning"; } internal static float SkillFraction() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return 0f; } float skillLevel = ((Character)localPlayer).GetSkillLevel((SkillType)9); return Mathf.Clamp01(skillLevel / 100f); } internal static float Reduction(float configuredPercent) { return Mathf.Clamp(configuredPercent, 0f, 100f) / 100f * SkillFraction(); } } [HarmonyPatch(typeof(Aoe), "OnHit")] internal static class AoeOnHitPatch { private static readonly FieldInfo m_gaveSkill = AccessTools.Field(typeof(Aoe), "m_gaveSkill"); private static readonly FieldInfo m_owner = AccessTools.Field(typeof(Aoe), "m_owner"); private static readonly FieldInfo m_itemData = AccessTools.Field(typeof(Aoe), "m_itemData"); private static void Postfix(Aoe __instance, Collider collider, Vector3 hitPoint, ref bool __result) { //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_001e: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Invalid comparison between Unknown and I4 if (!__result) { return; } SkillType val = __instance.m_skill; if ((int)val == 999 || (int)val == 0) { ItemData val2 = (ItemData)m_itemData.GetValue(__instance); if (val2?.m_shared != null) { val = val2.m_shared.m_skillType; } } GameObject val3 = Projectile.FindHitObject(collider); if ((Object)(object)val3 == (Object)null) { return; } IDestructible component = val3.GetComponent<IDestructible>(); Character val4 = (Character)m_owner.GetValue(__instance); if (component is Character) { if ((bool)m_gaveSkill.GetValue(__instance) && Object.op_Implicit((Object)(object)val4) && (int)val != 0 && (int)val != 999 && __instance.m_canRaiseSkill) { val4.RaiseSkill(val, 0.5f); } val4.AddAdrenaline(3f); } } } internal static class ExcludeLifeSkillDeathLowering { private static readonly List<SkillType> LifeSkills = new List<SkillType> { (SkillType)105, (SkillType)104, (SkillType)106, (SkillType)107, (SkillType)110 }; internal static void LowerBattleSkill(Skills skills, float factor) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<SkillType, Skill> item in (Dictionary<SkillType, Skill>)AccessTools.Field(typeof(Skills), "m_skillData").GetValue(skills)) { if (!LifeSkills.Contains(item.Key)) { float num = item.Value.m_level * factor; Skill value = item.Value; value.m_level -= num; item.Value.m_accumulator = 0f; } } ((Character)Player.m_localPlayer).Message((MessageType)1, "$msg_skills_lowered", 0, (Sprite)null, false); } } [HarmonyPatch(typeof(Skills), "OnDeath")] internal static class SkillsOnDeathPatch { private static bool Prefix(Skills __instance) { ExcludeLifeSkillDeathLowering.LowerBattleSkill(__instance, __instance.m_DeathLowerFactor * Game.m_skillReductionRate); return false; } } [HarmonyPatch(typeof(SE_Shield), "IsDone")] internal static class BloodMagicLevelingPatch { private static readonly FieldInfo m_damaged = AccessTools.Field(typeof(SE_Shield), "m_damage"); private static readonly FieldInfo m_totalAbsorbDamage = AccessTools.Field(typeof(SE_Shield), "m_totalAbsorbDamage"); private static readonly FieldInfo m_tameable = AccessTools.Field(typeof(Character), "m_tameable"); private static readonly FieldInfo m_tameableMonsterAI = AccessTools.Field(typeof(Character), "m_tameableMonsterAI"); private static void Postfix(SE_Shield __instance) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_0111: Unknown result type (might be due to invalid IL or missing references) Character character = ((StatusEffect)__instance).m_character; if (!character.IsTamed()) { return; } Tameable val = (Tameable)m_tameable.GetValue(character); MonsterAI val2 = (MonsterAI)m_tameableMonsterAI.GetValue(character); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)character).GetComponent<Tameable>(); val2 = ((Component)character).GetComponent<MonsterAI>(); } if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !((float)m_damaged.GetValue(__instance) > (float)m_totalAbsorbDamage.GetValue(__instance)) || (int)__instance.m_levelUpSkillOnBreak == 0) { return; } GameObject followTarget = val2.GetFollowTarget(); if ((Object)(object)followTarget == (Object)null || !Object.op_Implicit((Object)(object)followTarget)) { return; } Character component = followTarget.GetComponent<Character>(); if (!((Object)(object)component == (Object)null)) { Skills skills = component.GetSkills(); if ((Object)(object)skills != (Object)null) { skills.RaiseSkill(__instance.m_levelUpSkillOnBreak, __instance.m_levelUpSkillFactor); } } } } [HarmonyPatch(typeof(ItemData), "GetWeaponLoadingTime")] internal static class DundrReloadDurationPatch { private static void Postfix(ItemData __instance, ref float __result) { if (DundrScaling.IsDundr(__instance)) { float num = DundrScaling.Reduction(DundrSkillReloadPlugin.MaxReductionPercent.Value); __result = Mathf.Max(0.05f, DundrSkillReloadPlugin.BaseReloadSeconds.Value * (1f - num)); } } } [HarmonyPatch(typeof(Humanoid), "HideHandItems")] internal static class DundrHideHandItemsPatch { private static bool Prefix(Humanoid __instance, bool onlyRightHand = false, bool animation = true) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)__instance != (Object)(object)localPlayer) { return true; } if (((Humanoid)localPlayer).GetCurrentWeapon() != null && ((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_attack.m_requiresReload && ((Humanoid)localPlayer).IsWeaponLoaded()) { DundrSkillReloadPlugin.loadedItem = ((Humanoid)localPlayer).GetCurrentWeapon(); } return true; } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] internal static class DundrEquipItemPatch { private static readonly FieldInfo LoadedWeaponField = AccessTools.Field(typeof(Player), "m_weaponLoaded"); private static bool Prefix(Humanoid __instance, ItemData item, bool triggerEquipEffects = true) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)__instance != (Object)(object)localPlayer) { return true; } if (DundrSkillReloadPlugin.loadedItem != null && item == DundrSkillReloadPlugin.loadedItem) { LoadedWeaponField?.SetValue(localPlayer, item); } DundrSkillReloadPlugin.loadedItem = null; return true; } } [HarmonyPatch(typeof(Player), "UpdateWeaponLoading")] internal static class DundrReloadEitrPatch { private static float _originalDrain; private static bool _changed; private static bool Prefix(Player __instance, ItemData weapon) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 _changed = false; bool flag = DundrScaling.IsDundr(weapon) && weapon.m_shared?.m_attack != null; if (!flag && ((int)weapon.m_shared.m_skillType != 14 || !weapon.m_shared.m_attack.m_requiresReload)) { return true; } if (flag) { _originalDrain = weapon.m_shared.m_attack.m_reloadEitrDrain; float num = DundrScaling.Reduction(DundrSkillReloadPlugin.MaxEitrReductionPercent.Value); weapon.m_shared.m_attack.m_reloadEitrDrain = DundrSkillReloadPlugin.BaseEitrCost.Value * (1f - num); _changed = true; } if (!DundrSkillReloadPlugin.ReloadRequested && !DundrSkillReloadPlugin.AutoReload) { return false; } DundrSkillReloadPlugin.ReloadRequested = false; return true; } private static void Postfix(ItemData weapon) { if (_changed && weapon != null) { weapon.m_shared.m_attack.m_reloadEitrDrain = _originalDrain; } _changed = false; } }