Decompiled source of Real Voodoo Witch Malukah v1.1.1

BepInEx/plugins/com.shazixnar.RealVoodooWitchTraits.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obeliskial_Content;
using Obeliskial_Essentials;
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("com.shazixnar.RealVoodooWitchTraits")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Real Voodoo Witch Traits, made by Shazixnar")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("Real Voodoo Witch Malukah")]
[assembly: AssemblyTitle("com.shazixnar.RealVoodooWitchTraits")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 TraitMod
{
	[HarmonyPatch]
	internal class Traits
	{
		public static string[] myTraitList = new string[2] { "malukahjinx", "malukahhealingbrew" };

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "DamageBonus")]
		public static void DamageBonusPostfix(ref Character __instance, ref float[] __result)
		{
			if (AtOManager.Instance.TeamHaveTrait("malukahhealingbrew") && __instance.HpCurrent > 120 && __instance.IsHero)
			{
				int num = __instance.HpCurrent - 120;
				if (num >= 18)
				{
					__result[0] += (float)num / 18f;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "HealReceivedBonus")]
		public static void HealReceivedPostfix(ref Character __instance, ref float[] __result)
		{
			if (AtOManager.Instance.TeamHaveTrait("malukahhealingbrew") && __instance.HpCurrent > 120 && __instance.IsHero)
			{
				int num = __instance.HpCurrent - 120;
				if (num >= 18)
				{
					__result[0] += (float)num / 18f;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CardData), "SetDescriptionNew")]
		public static void SetDescriptionNewPostfix(ref CardData __instance)
		{
			if ((Object)(object)__instance.Item != (Object)null && __instance.Item.AuracurseCustomString == "itemCustomTextExplodeChargesMonsters")
			{
				if (__instance.Item.AuracurseCustomModValue1 - 25 >= 0)
				{
					__instance.DescriptionNormalized = Regex.Replace(__instance.DescriptionNormalized, "monsters explode at [0-9]*", "monsters explosion charges <color=#263ABC><size=+.1>+" + (__instance.Item.AuracurseCustomModValue1 - 25) + "</color></size> stacks");
				}
				else if (__instance.Item.AuracurseCustomModValue1 - 25 < 0)
				{
					__instance.DescriptionNormalized = Regex.Replace(__instance.DescriptionNormalized, "monsters explode at [0-9]*", "monsters explosion charges <color=#263ABC><size=+.1>-" + (25 - __instance.Item.AuracurseCustomModValue1) + "</color></size> stacks");
				}
			}
		}

		public static void myDoTrait(string _trait, ref Trait __instance)
		{
			//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_00ce: Unknown result type (might be due to invalid IL or missing references)
			EventActivation value = Traverse.Create((object)__instance).Field("theEvent").GetValue<EventActivation>();
			Character value2 = Traverse.Create((object)__instance).Field("character").GetValue<Character>();
			Character value3 = Traverse.Create((object)__instance).Field("target").GetValue<Character>();
			int value4 = Traverse.Create((object)__instance).Field("auxInt").GetValue<int>();
			string value5 = Traverse.Create((object)__instance).Field("auxString").GetValue<string>();
			CardData value6 = Traverse.Create((object)__instance).Field("castedCard").GetValue<CardData>();
			Traverse.Create((object)__instance).Field("character").SetValue((object)value2);
			Traverse.Create((object)__instance).Field("target").SetValue((object)value3);
			Traverse.Create((object)__instance).Field("theEvent").SetValue((object)value);
			Traverse.Create((object)__instance).Field("auxInt").SetValue((object)value4);
			Traverse.Create((object)__instance).Field("auxString").SetValue((object)value5);
			Traverse.Create((object)__instance).Field("castedCard").SetValue((object)value6);
			TraitData traitData = Globals.Instance.GetTraitData(_trait);
			List<CardData> list = new List<CardData>();
			List<string> heroHand = MatchManager.Instance.GetHeroHand(value2.HeroIndex);
			Hero[] teamHero = MatchManager.Instance.GetTeamHero();
			NPC[] teamNPC = MatchManager.Instance.GetTeamNPC();
			if (_trait == "malukahjinx")
			{
				if (value3 != null && value3.Alive)
				{
					value3.SetAuraTrait(value2, "dark", 2);
					value3.SetAuraTrait(value2, "poison", 2);
					((CharacterItem)value2.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_Jinx", ""), (CombatScrollEffectType)7);
				}
			}
			else
			{
				if (!(_trait == "malukahhealingbrew") || !((Object)(object)MatchManager.Instance != (Object)null) || !((Object)(object)value6 != (Object)null))
				{
					return;
				}
				traitData = Globals.Instance.GetTraitData("malukahhealingbrew");
				if ((MatchManager.Instance.activatedTraits != null && MatchManager.Instance.activatedTraits.ContainsKey("malukahhealingbrew") && MatchManager.Instance.activatedTraits["malukahhealingbrew"] > traitData.TimesPerTurn - 1) || MatchManager.Instance.energyJustWastedByHero <= 0 || (!value6.GetCardTypes().Contains((CardType)12) && !value6.GetCardTypes().Contains((CardType)9)) || !((Object)(object)value2.HeroData != (Object)null))
				{
					return;
				}
				if (!MatchManager.Instance.activatedTraits.ContainsKey("malukahhealingbrew"))
				{
					MatchManager.Instance.activatedTraits.Add("malukahhealingbrew", 1);
				}
				else
				{
					MatchManager.Instance.activatedTraits["malukahhealingbrew"]++;
				}
				MatchManager.Instance.SetTraitInfoText();
				value2.ModifyEnergy(1, true);
				if ((Object)(object)value2.HeroItem != (Object)null)
				{
					((CharacterItem)value2.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_Healing Brew", "") + TextChargesLeft(MatchManager.Instance.activatedTraits["malukahhealingbrew"], traitData.TimesPerTurn), (CombatScrollEffectType)7);
					EffectsManager.Instance.PlayEffectAC("energy", true, ((CharacterItem)value2.HeroItem).CharImageT, false, 0f);
				}
				int num = ((Character)teamHero[0]).HpCurrent;
				Hero val = teamHero[0];
				for (int i = 0; i < teamHero.Length; i++)
				{
					if (teamHero[i] != null && (Object)(object)((Character)teamHero[i]).HeroData != (Object)null && ((Character)teamHero[i]).Alive)
					{
						int hpCurrent = ((Character)teamHero[i]).HpCurrent;
						if (num > hpCurrent)
						{
							num = hpCurrent;
							val = teamHero[i];
						}
					}
				}
				((Character)val).SetAuraTrait(value2, "regeneration", 2);
				((Character)val).SetAuraTrait(value2, "vitality", 1);
				if ((Object)(object)((Character)val).HeroItem != (Object)null)
				{
					EffectsManager.Instance.PlayEffectAC("regeneration", true, ((CharacterItem)((Character)val).HeroItem).CharImageT, false, 0f);
					EffectsManager.Instance.PlayEffectAC("vitality", true, ((CharacterItem)((Character)val).HeroItem).CharImageT, false, 0f);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Trait), "DoTrait")]
		public static bool DoTrait(EventActivation _theEvent, string _trait, Character _character, Character _target, int _auxInt, string _auxString, CardData _castedCard, ref Trait __instance)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MatchManager.Instance == (Object)null)
			{
				return false;
			}
			Traverse.Create((object)__instance).Field("character").SetValue((object)_character);
			Traverse.Create((object)__instance).Field("target").SetValue((object)_target);
			Traverse.Create((object)__instance).Field("theEvent").SetValue((object)_theEvent);
			Traverse.Create((object)__instance).Field("auxInt").SetValue((object)_auxInt);
			Traverse.Create((object)__instance).Field("auxString").SetValue((object)_auxString);
			Traverse.Create((object)__instance).Field("castedCard").SetValue((object)_castedCard);
			if (Content.medsCustomTraitsSource.Contains(_trait) && myTraitList.Contains(_trait))
			{
				myDoTrait(_trait, ref __instance);
				return false;
			}
			return true;
		}

		public static string TextChargesLeft(int currentCharges, int chargesTotal)
		{
			int num = currentCharges;
			int num2 = chargesTotal;
			return "<br><color=#FFF>" + num + "/" + num2 + "</color>";
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(AtOManager), "GlobalAuraCurseModificationByTraitsAndItems")]
		public static void GlobalAuraCurseModificationByTraitsAndItemsPostfix(ref AtOManager __instance, ref AuraCurseData __result, string _type, string _acId, Character _characterCaster, Character _characterTarget)
		{
			bool flag = false;
			bool flag2 = false;
			if (_characterCaster != null && _characterCaster.IsHero)
			{
				flag = _characterCaster.IsHero;
			}
			if (_characterTarget != null && _characterTarget.IsHero)
			{
				flag2 = true;
			}
			if (_acId == "dark")
			{
				int num = 25;
				if (_type == "set")
				{
					float num2 = 2f;
					if (!flag2)
					{
						if (__instance.TeamHaveItem("thedarkone", 0, true))
						{
							num += Globals.Instance.GetItemData("thedarkone").AuracurseCustomModValue1 - 25;
						}
						if (__instance.TeamHaveItem("blackdeck", 0, true))
						{
							num += Globals.Instance.GetItemData("blackdeck").AuracurseCustomModValue1 - 25;
						}
						if (__instance.TeamHaveItem("cupofdeath", 0, true))
						{
							num += Globals.Instance.GetItemData("cupofdeath").AuracurseCustomModValue1 - 25;
						}
						if (__instance.TeamHaveTrait("malukahshadowform"))
						{
							num += 5;
							num2 += 0.5f;
						}
						if (__instance.TeamHavePerk("mainperkdark2c"))
						{
							num2 += 0.7f;
						}
						__result.ExplodeAtStacks = num;
						__result.DamageWhenConsumedPerCharge = num2;
					}
				}
				else
				{
					if (!(_type == "consume"))
					{
						return;
					}
					float num3 = 2f;
					if (!flag)
					{
						if (__instance.TeamHaveTrait("malukahshadowform"))
						{
							num3 += 0.5f;
						}
						if (__instance.TeamHavePerk("mainperkdark2c"))
						{
							num3 += 0.7f;
						}
						__result.DamageWhenConsumedPerCharge = num3;
					}
				}
			}
			else if (_acId == "sharp" && _type == "set" && flag2)
			{
				if (__instance.TeamHavePerk("mainperkSharp1d"))
				{
					__result.AuraDamageType3 = (DamageType)9;
					__result.AuraDamageIncreasedPerStack3 = 1f;
				}
				if (__instance.TeamHaveTrait("shrilltone"))
				{
					__result.AuraDamageType4 = (DamageType)7;
					__result.AuraDamageIncreasedPerStack4 = 1f;
				}
			}
			else if (_acId == "regeneration" && _type == "set" && flag2)
			{
				if (__instance.TeamHavePerk("mainperkregeneration1c"))
				{
					__result.ResistModified = (DamageType)10;
					__result.ResistModifiedPercentagePerStack = 0.5f;
					__result.CharacterStatModified = (CharacterStat)1;
					__result.CharacterStatModifiedValuePerStack = 1;
				}
				if (__instance.TeamHaveTrait("malukahjinx"))
				{
					__result.AuraDamageType = (DamageType)9;
					__result.AuraDamageIncreasedPerStack = 0.5f;
				}
			}
			else if (_acId == "vitality" && _type == "set" && flag2 && _characterTarget != null && __instance.TeamHavePerk("mainperkvitality1a"))
			{
				__result.CharacterStatModifiedValuePerStack = 8;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "SetEvent")]
		public static void SetEventPrefix(ref Character __instance, ref EventActivation theEvent, Character target = null)
		{
		}
	}
}
namespace RealVoodooWitchMalukah
{
	[BepInPlugin("com.shazixnar.RealVoodooWitchTraits", "Real Voodoo Witch Malukah", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("AcrossTheObelisk.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal const int ModDate = 20241001;

		private readonly Harmony harmony = new Harmony("com.shazixnar.RealVoodooWitchTraits");

		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"com.shazixnar.RealVoodooWitchTraits 1.1.1 has loaded!");
			Essentials.RegisterMod("Real Voodoo Witch Malukah", "Shazixnar", "Make Malukah gain more curse or support.", "1.1.1", 20241001, "https://across-the-obelisk.thunderstore.io/package/Shazixnar/Real_Voodoo_Witch_Malukah/", (string[])null, "Real Voodoo Witch Malukah", 100, new string[5] { "content", "hero", "trait", "card", "perk" }, "", true);
			Essentials.medsTexts["custommainperksharp1d"] = "Sharp on heroes also increases the Shadow damage by 1 per charge.";
			Essentials.medsTexts["custommainperkregeneration1c"] = "Regeneration on heroes also increases all resistance by 0.5% per charge and increases Max HP by 1 per charge.";
			Essentials.medsTexts["custommainperkvitality1a"] = "Vitality on heroes instead increases Max HP by 8 per charge.";
			Essentials.medsTexts["custommainperkdark2c"] = "Dark explosion on enemies deals 0.7 more damage per charge.";
			harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.shazixnar.RealVoodooWitchTraits";

		public const string PLUGIN_NAME = "Real Voodoo Witch Malukah";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}