using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterBlight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterBlight")]
[assembly: AssemblyTitle("BetterBlight")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 BetterBlight
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.tetrapink.BetterBlight", "BetterBlight", "1.0.3")]
public class BetterBlight : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<Instruction, bool> <>9__44_1;
public static Func<Instruction, bool> <>9__44_2;
public static Func<Instruction, bool> <>9__44_3;
public static Func<Instruction, bool> <>9__44_4;
public static Func<Instruction, bool> <>9__44_5;
public static Func<Instruction, bool> <>9__44_6;
public static Func<Instruction, bool> <>9__44_7;
public static Func<Instruction, bool> <>9__44_8;
public static Func<Instruction, bool> <>9__44_9;
public static Manipulator <>9__44_0;
internal void <Awake>b__44_0(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[9]
{
(Instruction x) => ILPatternMatchingExt.MatchNewobj(x, "RoR2.DotController/DotDef"),
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.333f),
(Instruction x) => ILPatternMatchingExt.MatchStfld(x, "RoR2.DotController/DotDef", "interval"),
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.2f),
(Instruction x) => ILPatternMatchingExt.MatchStfld(x, "RoR2.DotController/DotDef", "damageCoefficient"),
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 4)
}))
{
val.Index += 2;
val.Next.Operand = 1f / BlightTicksPerSecond.Value;
val.Index += 3;
val.Next.Operand = BlightDamagePerTick.Value / 100f;
}
else
{
Log.Error(((MemberReference)il.Method).Name + " DotController ilhook failed");
}
}
internal bool <Awake>b__44_1(Instruction x)
{
return ILPatternMatchingExt.MatchNewobj(x, "RoR2.DotController/DotDef");
}
internal bool <Awake>b__44_2(Instruction x)
{
return ILPatternMatchingExt.MatchDup(x);
}
internal bool <Awake>b__44_3(Instruction x)
{
return ILPatternMatchingExt.MatchLdcR4(x, 0.333f);
}
internal bool <Awake>b__44_4(Instruction x)
{
return ILPatternMatchingExt.MatchStfld(x, "RoR2.DotController/DotDef", "interval");
}
internal bool <Awake>b__44_5(Instruction x)
{
return ILPatternMatchingExt.MatchDup(x);
}
internal bool <Awake>b__44_6(Instruction x)
{
return ILPatternMatchingExt.MatchLdcR4(x, 0.2f);
}
internal bool <Awake>b__44_7(Instruction x)
{
return ILPatternMatchingExt.MatchStfld(x, "RoR2.DotController/DotDef", "damageCoefficient");
}
internal bool <Awake>b__44_8(Instruction x)
{
return ILPatternMatchingExt.MatchDup(x);
}
internal bool <Awake>b__44_9(Instruction x)
{
return ILPatternMatchingExt.MatchLdcI4(x, 4);
}
}
public const string PluginGUID = "com.tetrapink.BetterBlight";
public const string PluginAuthor = "tetrapink";
public const string PluginName = "BetterBlight";
public const string PluginVersion = "1.0.3";
public static ConfigEntry<float> SpeedReduction { get; set; }
public static ConfigEntry<float> DmgReduction { get; set; }
public static ConfigEntry<int> ArmorReduction { get; set; }
public static ConfigEntry<bool> UseSoftScaling { get; set; }
public static ConfigEntry<float> DmgScalingParam { get; set; }
public static ConfigEntry<float> SpeedScalingParam { get; set; }
public static ConfigEntry<float> BlightDuration { get; set; }
public static ConfigEntry<float> BlightDamagePerTick { get; set; }
public static ConfigEntry<float> BlightTicksPerSecond { get; set; }
public static ConfigEntry<bool> ResetDurationOnStack { get; set; }
public void Awake()
{
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Expected O, but got Unknown
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Expected O, but got Unknown
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Expected O, but got Unknown
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Expected O, but got Unknown
SpeedReduction = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Speed Reduction Percent", 10f, "Reduces an enemy's Speed stat by this percent for every stack of Blight they have.");
DmgReduction = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Damage Reduction Percent", 5f, "Reduces an enemy's Damage stat by this percent for every stack of Blight they have.");
ArmorReduction = ((BaseUnityPlugin)this).Config.Bind<int>("Stats", "Armor Reduction", 10, "Reduces an enemy's Armor by this value for every stack of Blight they have.");
UseSoftScaling = ((BaseUnityPlugin)this).Config.Bind<bool>("Stats", "Use Diminishing Returns", true, "Gives diminishing returns to Blight's Speed and Damage reduction. Enabled by default.");
DmgScalingParam = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Damage - Diminishing Returns", 0.75f, "Raises the number of Blight stacks to this power when calculating damage reduction. Only used when 'Use Diminishing Returns' is enabled.");
SpeedScalingParam = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Speed - Diminishing Returns", 0.75f, "Raises the number of Blight stacks to this power when calculating speed reduction. Only used when 'Use Diminishing Returns' is enabled.");
BlightDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Blight Duration", 6f, "How long the Blight stack lasts.");
BlightDamagePerTick = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Blight Damage Per Tick", 16f, "How much damage each tick of Blight deals, as a percent of Acrid's base damage.");
BlightTicksPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Blight Ticks Per Second", 3f, "How many times Blight ticks each second.");
ResetDurationOnStack = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Reset Duration On Stack", true, "Resets Blight duration upon stack. Enabled by default.");
Log.Init(((BaseUnityPlugin)this).Logger);
LanguageAPI.Add("CROCO_PASSIVE_ALT_DESCRIPTION", $"Attacks that apply <style=cIsHealing>Poison</style> apply stacking <style=cIsDamage>Blight</style> instead, dealing <style=cIsDamage>{Mathf.Round(BlightDamagePerTick.Value * BlightTicksPerSecond.Value)}% damage per second</style>. Enemies afflicted with <style=cIsDamage>Blight</style> have their armor reduced by <style=cIsUtility>{ArmorReduction.Value}</style>, speed reduced by <style=cIsUtility>{SpeedReduction.Value}%</style>, and damage reduced by <style=cIsDamage>{DmgReduction.Value}%</style>.");
if (ResetDurationOnStack.Value)
{
DotController.AddDot_GameObject_float_DotIndex_float_Nullable1_Nullable1_Nullable1 += new hook_AddDot_GameObject_float_DotIndex_float_Nullable1_Nullable1_Nullable1(RefreshBlightDurationOnStack);
DotController.AddDot_GameObject_float_HurtBox_DotIndex_float_Nullable1_Nullable1_Nullable1 += new hook_AddDot_GameObject_float_HurtBox_DotIndex_float_Nullable1_Nullable1_Nullable1(DotController_AddDot_GameObject_float_HurtBox_DotIndex_float_Nullable1_Nullable1_Nullable1);
}
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(BlightDebuffStatModifier);
object obj = <>c.<>9__44_0;
if (obj == null)
{
Manipulator val = delegate(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
ILCursor val2 = new ILCursor(il);
if (val2.TryGotoNext(new Func<Instruction, bool>[9]
{
(Instruction x) => ILPatternMatchingExt.MatchNewobj(x, "RoR2.DotController/DotDef"),
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.333f),
(Instruction x) => ILPatternMatchingExt.MatchStfld(x, "RoR2.DotController/DotDef", "interval"),
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.2f),
(Instruction x) => ILPatternMatchingExt.MatchStfld(x, "RoR2.DotController/DotDef", "damageCoefficient"),
(Instruction x) => ILPatternMatchingExt.MatchDup(x),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 4)
}))
{
val2.Index += 2;
val2.Next.Operand = 1f / BlightTicksPerSecond.Value;
val2.Index += 3;
val2.Next.Operand = BlightDamagePerTick.Value / 100f;
}
else
{
Log.Error(((MemberReference)il.Method).Name + " DotController ilhook failed");
}
};
<>c.<>9__44_0 = val;
obj = (object)val;
}
DotController.InitDotCatalog += (Manipulator)obj;
}
private void DotController_AddDot_GameObject_float_HurtBox_DotIndex_float_Nullable1_Nullable1_Nullable1(orig_AddDot_GameObject_float_HurtBox_DotIndex_float_Nullable1_Nullable1_Nullable1 orig, DotController self, GameObject attackerObject, float duration, HurtBox hitHurtBox, DotIndex dotIndex, float damageMultiplier, uint? maxStacksFromAttacker, float? totalDamage, DotIndex? preUpgradeDotIndex)
{
//IL_0008: 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_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, attackerObject, duration, hitHurtBox, dotIndex, damageMultiplier, maxStacksFromAttacker, totalDamage, preUpgradeDotIndex);
Log.Message(dotIndex);
if ((int)dotIndex != 5)
{
return;
}
foreach (DotStack dotStack in self.dotStackList)
{
if (dotStack.dotIndex == dotIndex)
{
dotStack.timer = BlightDuration.Value;
}
}
}
private void BlightDebuffStatModifier(CharacterBody victim, StatHookEventArgs stats)
{
int buffCount = victim.GetBuffCount(Buffs.Blight);
if (buffCount > 0)
{
stats.armorAdd -= (float)(buffCount * ArmorReduction.Value);
stats.damageTotalMult *= Mathf.Pow(1f - DmgReduction.Value / 100f, Mathf.Pow((float)buffCount, UseSoftScaling.Value ? DmgScalingParam.Value : 1f));
stats.moveSpeedTotalMult *= Mathf.Pow(1f - SpeedReduction.Value / 100f, Mathf.Pow((float)buffCount, UseSoftScaling.Value ? SpeedScalingParam.Value : 1f));
}
}
private void RefreshBlightDurationOnStack(orig_AddDot_GameObject_float_DotIndex_float_Nullable1_Nullable1_Nullable1 orig, DotController self, GameObject attackerObject, float duration, DotIndex dotIndex, float damageMultiplier, uint? maxStacksFromAttacker, float? totalDamage, DotIndex? preUpgradeDotIndex)
{
//IL_0006: 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_0026: Invalid comparison between Unknown and I4
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, attackerObject, duration, dotIndex, damageMultiplier, maxStacksFromAttacker, totalDamage, preUpgradeDotIndex);
Log.Message(dotIndex);
if ((int)dotIndex != 5)
{
return;
}
foreach (DotStack dotStack in self.dotStackList)
{
if (dotStack.dotIndex == dotIndex)
{
dotStack.timer = BlightDuration.Value;
}
}
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}