Decompiled source of Too Many Perks v1.6.2

BepInEx/plugins/com.binbin.PerkManager.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
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.binbin.PerkManager")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.6.2.0")]
[assembly: AssemblyInformationalVersion("1.6.2+dfd84327d7a2be2af52611e0f413b1c9e7a65ba5")]
[assembly: AssemblyProduct("Custom Perks")]
[assembly: AssemblyTitle("com.binbin.PerkManager")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.2.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 PerkManager
{
	public class CustomFunctions
	{
		public enum AppliesTo
		{
			None,
			Global,
			Monsters,
			Heroes,
			ThisHero
		}

		public enum CharacterHas
		{
			Perk,
			Item,
			Trait
		}

		public static void TraitHeal(ref Character _character, ref Character _target, int healAmount, string traitName)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			int num = healAmount;
			if (_target.GetHpLeftForMax() < healAmount)
			{
				num = _target.GetHpLeftForMax();
			}
			if (num > 0)
			{
				_target.ModifyHp(num, true, true);
				CastResolutionForCombatText val = new CastResolutionForCombatText();
				val.heal = num;
				if (_target.HeroItem != null)
				{
					((CharacterItem)_target.HeroItem).ScrollCombatTextDamageNew(val);
					EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)_target.HeroItem).CharImageT, false, 0f, false);
				}
				else
				{
					((CharacterItem)_target.NPCItem).ScrollCombatTextDamageNew(val);
					EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)_target.NPCItem).CharImageT, false, 0f, false);
				}
				_target.SetEvent((EventActivation)15, (Character)null, 0, "", (Character)null);
				_character.SetEvent((EventActivation)14, _target, 0, "", (Character)null);
				((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
			}
		}

		public static void TraitHealHero(ref Character _character, ref Hero _target, int healAmount, string traitName)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			if (_target == null || !((Character)_target).IsHero || !((Character)_target).Alive)
			{
				return;
			}
			int num = healAmount;
			if (((Character)_target).GetHpLeftForMax() < healAmount)
			{
				num = ((Character)_target).GetHpLeftForMax();
			}
			if (num > 0)
			{
				((Character)_target).ModifyHp(num, true, true);
				CastResolutionForCombatText val = new CastResolutionForCombatText();
				val.heal = num;
				if (((Character)_target).HeroItem != null)
				{
					((CharacterItem)((Character)_target).HeroItem).ScrollCombatTextDamageNew(val);
					EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)((Character)_target).HeroItem).CharImageT, false, 0f, false);
				}
				else
				{
					((CharacterItem)((Character)_target).NPCItem).ScrollCombatTextDamageNew(val);
					EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)((Character)_target).NPCItem).CharImageT, false, 0f, false);
				}
				((Character)_target).SetEvent((EventActivation)15, (Character)null, 0, "", (Character)null);
				_character.SetEvent((EventActivation)14, (Character)(object)_target, 0, "", (Character)null);
				((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
			}
		}

		public static void WhenYouPlayXRefund1Energy(CardType cardType, ref Character _character, string traitName, string traitID)
		{
		}

		public static void ApplyAuraCurseTo(string auraCurse, int amount, bool allHeroFlag, bool allNpcFlag, bool randomHeroFlag, bool randomNpcFlag, ref Character _character, ref Hero[] teamHeroes, ref NPC[] teamNpc, string traitName, string soundEffect)
		{
			if (allNpcFlag)
			{
				for (int i = 0; i < teamNpc.Length; i++)
				{
					if (teamNpc[i] != null && ((Character)teamNpc[i]).Alive)
					{
						((Character)teamNpc[i]).SetAuraTrait(_character, auraCurse, amount);
						if (((Character)teamNpc[i]).NPCItem != null)
						{
							((CharacterItem)((Character)teamNpc[i]).NPCItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
							EffectsManager.Instance.PlayEffectAC(soundEffect, true, ((CharacterItem)((Character)teamNpc[i]).NPCItem).CharImageT, false, 0f, false);
						}
					}
				}
			}
			if (!allHeroFlag)
			{
				return;
			}
			for (int j = 0; j < teamHeroes.Length; j++)
			{
				if (teamHeroes[j] != null && ((Character)teamHeroes[j]).Alive)
				{
					((Character)teamHeroes[j]).SetAuraTrait(_character, auraCurse, amount);
					if (((Character)teamHeroes[j]).NPCItem != null)
					{
						((CharacterItem)((Character)teamHeroes[j]).HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
						EffectsManager.Instance.PlayEffectAC(soundEffect, true, ((CharacterItem)((Character)teamHeroes[j]).NPCItem).CharImageT, false, 0f, false);
					}
				}
			}
		}

		public static void WhenYouGainXGainY(string gainedAuraCurse, string desiredAuraCurse, string appliedAuraCurse, int n_charges_incoming, int n_bonus_charges, float multiplier, ref Character _character, string traitName)
		{
			if ((Object)(object)MatchManager.Instance != (Object)null && gainedAuraCurse != null && (Object)(object)_character.HeroData != (Object)null && gainedAuraCurse == desiredAuraCurse)
			{
				int num = Mathf.RoundToInt((float)(n_charges_incoming + n_bonus_charges) * multiplier);
				_character.SetAuraTrait(_character, appliedAuraCurse, num);
				((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
			}
		}

		public static void WhenYouPlayXGainY(CardType desiredCardType, string desiredAuraCurse, int n_charges, CardData castedCard, ref Character _character, string traitName)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MatchManager.Instance != (Object)null && (Object)(object)castedCard != (Object)null && (Object)(object)_character.HeroData != (Object)null && castedCard.GetCardTypes().Contains(desiredCardType))
			{
				_character.SetAuraTrait(_character, desiredAuraCurse, n_charges);
				((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
			}
		}

		public static void ReduceCostByStacks(CardType cardType, string auraCurseName, int n_charges, ref Character _character, ref List<string> heroHand, ref List<CardData> cardDataList, string traitName, bool applyToAllCards)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_character.HeroData != (Object)null))
			{
				return;
			}
			int num = Mathf.FloorToInt((float)(_character.EffectCharges(auraCurseName) / n_charges));
			if (num <= 0)
			{
				return;
			}
			for (int i = 0; i < heroHand.Count; i++)
			{
				CardData cardData = MatchManager.Instance.GetCardData(heroHand[i], true);
				if (cardData.GetCardFinalCost() > 0 && (cardData.GetCardTypes().Contains(cardType) || applyToAllCards))
				{
					cardDataList.Add(cardData);
				}
			}
			for (int j = 0; j < cardDataList.Count; j++)
			{
				CardData obj = cardDataList[j];
				obj.EnergyReductionTemporal += num;
				MatchManager.Instance.UpdateHandCards();
				CardItem cardFromTableByIndex = MatchManager.Instance.GetCardFromTableByIndex(cardDataList[j].InternalId);
				cardFromTableByIndex.PlayDissolveParticle();
				cardFromTableByIndex.ShowEnergyModification(-num);
				((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
				MatchManager.Instance.CreateLogCardModification(cardDataList[j].InternalId, MatchManager.Instance.GetHero(_character.HeroIndex));
			}
		}

		public static void AddImmunityToHero(string immunity, ref Hero _character)
		{
			if (!((Character)_character).AuracurseImmune.Contains(immunity))
			{
				((Character)_character).AuracurseImmune.Add(immunity);
			}
		}

		public static void IncreaseChargesByStacks(string auraCurseToModify, float stacks_per_bonus, string auraCurseDependent, ref Character _character, string traitName)
		{
			int auraCharges = _character.GetAuraCharges(auraCurseDependent);
			int num = Mathf.FloorToInt((float)auraCharges / stacks_per_bonus);
			_character.ModifyAuraCurseQuantity(auraCurseToModify, num);
		}

		public static AuraCurseData GetAuraCurseData(string ac)
		{
			return Globals.Instance.GetAuraCurseData(ac);
		}

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

		public static void Duality(ref Character _character, ref CardData _castedCard, CardClass class1, CardClass class2, string traitName)
		{
			//IL_0089: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			if (MatchManager.Instance == null || _castedCard == null)
			{
				return;
			}
			TraitData traitData = Globals.Instance.GetTraitData(traitName);
			if (MatchManager.Instance.activatedTraits != null && MatchManager.Instance.activatedTraits.ContainsKey(traitName) && MatchManager.Instance.activatedTraits[traitName] > traitData.TimesPerTurn - 1)
			{
				return;
			}
			for (int i = 0; i < 2; i++)
			{
				CardClass val;
				CardClass val2;
				if (i == 0)
				{
					val = class1;
					val2 = class2;
				}
				else
				{
					val = class2;
					val2 = class1;
				}
				if (_castedCard.CardClass != val)
				{
					continue;
				}
				if (MatchManager.Instance.CountHeroHand(-1) == 0 || _character.HeroData == null)
				{
					break;
				}
				List<CardData> list = new List<CardData>();
				List<string> heroHand = MatchManager.Instance.GetHeroHand(_character.HeroIndex);
				int num = 0;
				for (int j = 0; j < heroHand.Count; j++)
				{
					CardData cardData = MatchManager.Instance.GetCardData(heroHand[j], true);
					if (cardData != null && cardData.CardClass == val2 && _character.GetCardFinalCost(cardData) > num)
					{
						num = _character.GetCardFinalCost(cardData);
					}
				}
				if (num <= 0)
				{
					break;
				}
				for (int k = 0; k < heroHand.Count; k++)
				{
					CardData cardData2 = MatchManager.Instance.GetCardData(heroHand[k], true);
					if (cardData2 != null && cardData2.CardClass == val2 && _character.GetCardFinalCost(cardData2) >= num)
					{
						list.Add(cardData2);
					}
				}
				if (list.Count <= 0)
				{
					break;
				}
				CardData val3 = ((list.Count != 1) ? list[MatchManager.Instance.GetRandomIntRange(0, list.Count, "trait", "")] : list[0]);
				if (val3 != null)
				{
					if (!MatchManager.Instance.activatedTraits.ContainsKey(traitName))
					{
						MatchManager.Instance.activatedTraits.Add(traitName, 1);
					}
					else
					{
						Dictionary<string, int> activatedTraits = MatchManager.Instance.activatedTraits;
						int value = activatedTraits[traitName] + 1;
						activatedTraits[traitName] = value;
					}
					MatchManager.Instance.SetTraitInfoText();
					int num2 = 1;
					val3.EnergyReductionTemporal += num2;
					MatchManager.Instance.GetCardFromTableByIndex(val3.InternalId).ShowEnergyModification(-num2);
					MatchManager.Instance.UpdateHandCards();
					((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, "") + TextChargesLeft(MatchManager.Instance.activatedTraits[traitName], traitData.TimesPerTurn), (CombatScrollEffectType)7);
					MatchManager.Instance.CreateLogCardModification(val3.InternalId, MatchManager.Instance.GetHero(_character.HeroIndex));
				}
				break;
			}
		}

		public static void PermanentyReduceXWhenYouPlayY(ref Character _character, ref CardData _castedCard, CardType reduceThis, CardType whenYouPlayThis, int amountToReduce, string traitName)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Invalid comparison between Unknown and I4
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if (MatchManager.Instance == null || _castedCard == null)
			{
				return;
			}
			TraitData traitData = Globals.Instance.GetTraitData(traitName);
			if ((MatchManager.Instance.activatedTraits != null && MatchManager.Instance.activatedTraits.ContainsKey(traitName) && MatchManager.Instance.activatedTraits[traitName] > traitData.TimesPerTurn - 1) || !_castedCard.GetCardTypes().Contains(whenYouPlayThis) || MatchManager.Instance.CountHeroHand(-1) == 0 || _character.HeroData == null)
			{
				return;
			}
			List<CardData> list = new List<CardData>();
			List<string> heroHand = MatchManager.Instance.GetHeroHand(_character.HeroIndex);
			if ((int)reduceThis == 0)
			{
				for (int i = 0; i < heroHand.Count; i++)
				{
					CardData cardData = MatchManager.Instance.GetCardData(heroHand[i], true);
					if (cardData != null)
					{
						list.Add(cardData);
					}
				}
			}
			else
			{
				for (int j = 0; j < heroHand.Count; j++)
				{
					CardData cardData2 = MatchManager.Instance.GetCardData(heroHand[j], true);
					if (cardData2 != null && cardData2.GetCardTypes().Contains(reduceThis))
					{
						list.Add(cardData2);
					}
				}
			}
			if (!MatchManager.Instance.activatedTraits.ContainsKey(traitName))
			{
				MatchManager.Instance.activatedTraits.Add(traitName, 1);
			}
			else
			{
				Dictionary<string, int> activatedTraits = MatchManager.Instance.activatedTraits;
				int value = activatedTraits[traitName] + 1;
				activatedTraits[traitName] = value;
			}
			CardData val = list[MatchManager.Instance.GetRandomIntRange(0, list.Count, "trait", "")];
			val.EnergyReductionPermanent += amountToReduce;
			MatchManager.Instance.GetCardFromTableByIndex(val.InternalId).ShowEnergyModification(-amountToReduce);
			MatchManager.Instance.UpdateHandCards();
			((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, "") + TextChargesLeft(MatchManager.Instance.activatedTraits[traitName], traitData.TimesPerTurn), (CombatScrollEffectType)7);
			MatchManager.Instance.CreateLogCardModification(val.InternalId, MatchManager.Instance.GetHero(_character.HeroIndex));
		}

		public static int CountAllStacks(string auraCurse, Hero[] teamHero, NPC[] teamNpc)
		{
			int num = 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)
				{
					num += ((Character)teamHero[i]).GetAuraCharges(auraCurse);
				}
			}
			for (int j = 0; j < teamNpc.Length; j++)
			{
				if (teamNpc[j] != null && ((Character)teamNpc[j]).Alive)
				{
					num += ((Character)teamNpc[j]).GetAuraCharges(auraCurse);
				}
			}
			return num;
		}

		public static void DealIndirectDamageToAllMonsters(DamageType damageType, int amount)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			NPC[] teamNPC = MatchManager.Instance.GetTeamNPC();
			foreach (NPC val in teamNPC)
			{
				if (val != null && ((Character)val).Alive && !((Character)val).IsHero)
				{
					((Character)val).IndirectDamage(damageType, amount, (AudioClip)null, "", "", "");
				}
			}
		}

		public static Character GetRandomCharacter(Character[] array)
		{
			if (array == null)
			{
				Plugin.LogDebug(Plugin.debugBase + "Null Array");
			}
			List<Character> list = new List<Character>();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i] == null)
				{
					Plugin.LogDebug(Plugin.debugBase + "Null index");
					continue;
				}
				Character val = array[i];
				if (val.Alive && val != null)
				{
					list.Add(val);
				}
			}
			if (list.Count == 0)
			{
				return null;
			}
			int randomIntRange = MatchManager.Instance.GetRandomIntRange(0, list.Count, "default", "");
			if (randomIntRange < list.Count)
			{
				return list[randomIntRange];
			}
			if (list[randomIntRange] == null)
			{
				return null;
			}
			return list[0];
		}

		public static bool IsLivingHero(Character _character)
		{
			return _character != null && _character.Alive && _character.IsHero;
		}

		public static bool IsLivingNPC(Character _character)
		{
			return _character != null && _character.Alive && !_character.IsHero;
		}

		public static bool CharacterHasPerkForSet(string perkName, bool flag, AtOManager __instance, Character _characterTarget)
		{
			return flag && _characterTarget != null && __instance.CharacterHavePerk(_characterTarget.SubclassName, Plugin.perkBase + perkName);
		}

		public static bool CharacterHasPerkForConsume(string perkName, bool flag, AtOManager __instance, Character _characterCaster)
		{
			return flag && _characterCaster != null && __instance.CharacterHavePerk(_characterCaster.SubclassName, Plugin.perkBase + perkName);
		}

		public static bool TeamHasPerkForSet(string perkName, bool flag, AtOManager __instance, Character _characterTarget)
		{
			return _characterTarget != null && __instance.TeamHavePerk(Plugin.perkBase + perkName) && flag;
		}

		public static bool TeamHasPerk(string perkName)
		{
			return AtOManager.Instance.TeamHavePerk(Plugin.perkBase + perkName);
		}

		public static bool TeamHasPerkForConsume(string perkName, bool flag, AtOManager __instance, Character _characterCaster)
		{
			return _characterCaster != null && __instance.TeamHavePerk(Plugin.perkBase + perkName) && flag;
		}

		public static bool CharacterObjectHavePerk(Character _character, string _perk_id)
		{
			if (_character == null)
			{
				return false;
			}
			return AtOManager.Instance.CharacterHavePerk(_character.SubclassName, Plugin.perkBase + _perk_id) || AtOManager.Instance.CharacterHavePerk(_character.SubclassName, _perk_id);
		}

		public static void CastTargetCard(string cardToCast)
		{
			CardData cardData = Globals.Instance.GetCardData(cardToCast, true);
			((MonoBehaviour)MatchManager.Instance).StartCoroutine(MatchManager.Instance.CastCard((CardItem)null, true, cardData, 0, -1, true));
		}

		public static bool IfCharacterHas(Character characterOfInterest, CharacterHas characterHas, string id, AppliesTo appliesTo = AppliesTo.Global, string _type = "", string onlyThisType = "")
		{
			if (appliesTo == AppliesTo.None || characterOfInterest == null || (Object)(object)AtOManager.Instance == (Object)null)
			{
				return false;
			}
			if (_type != "" && onlyThisType != _type)
			{
				return false;
			}
			bool flag = (characterOfInterest.IsHero && appliesTo == AppliesTo.Heroes) || (!characterOfInterest.IsHero && appliesTo == AppliesTo.Monsters) || appliesTo == AppliesTo.Global || (appliesTo == AppliesTo.ThisHero && characterOfInterest.IsHero);
			bool flag2 = false;
			if (appliesTo == AppliesTo.ThisHero)
			{
				switch (characterHas)
				{
				case CharacterHas.Item:
					flag2 = AtOManager.Instance.CharacterHaveItem(characterOfInterest.SubclassName, Plugin.perkBase + id) || AtOManager.Instance.CharacterHaveItem(characterOfInterest.SubclassName, id);
					break;
				case CharacterHas.Perk:
					flag2 = AtOManager.Instance.CharacterHavePerk(characterOfInterest.SubclassName, Plugin.perkBase + id) || AtOManager.Instance.CharacterHavePerk(characterOfInterest.SubclassName, id);
					break;
				case CharacterHas.Trait:
					flag2 = AtOManager.Instance.CharacterHaveTrait(characterOfInterest.SubclassName, Plugin.perkBase + id) || AtOManager.Instance.CharacterHaveTrait(characterOfInterest.SubclassName, id);
					break;
				}
			}
			else
			{
				switch (characterHas)
				{
				case CharacterHas.Item:
					flag2 = AtOManager.Instance.TeamHaveItem(Plugin.perkBase + id, -1, false) || AtOManager.Instance.TeamHaveItem(id, -1, false);
					break;
				case CharacterHas.Perk:
					flag2 = AtOManager.Instance.TeamHavePerk(Plugin.perkBase + id) || AtOManager.Instance.TeamHavePerk(id);
					break;
				case CharacterHas.Trait:
					flag2 = AtOManager.Instance.TeamHaveTrait(Plugin.perkBase + id) || AtOManager.Instance.TeamHaveTrait(id);
					break;
				}
			}
			return flag2 && flag;
		}
	}
	[HarmonyPatch]
	public class PerkBackgroundExtension
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(PerkNodeAmplify), "SetForNodes")]
		public static bool SetForNodesPrefix(PerkNodeAmplify __instance, int _numNodes)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			PolygonCollider2D component = ((Component)__instance).GetComponent<PolygonCollider2D>();
			float num = -0.7f * (float)(_numNodes - 1);
			switch (_numNodes)
			{
			case 2:
				((Component)__instance.bg2).gameObject.SetActive(true);
				((Component)__instance.bg3).gameObject.SetActive(false);
				((Component)__instance.bg4).gameObject.SetActive(false);
				__instance.amplifyNodes.localPosition = new Vector3(num, __instance.amplifyNodes.localPosition.y, __instance.amplifyNodes.localPosition.z);
				component.points = ((Component)__instance.bg2).GetComponent<PolygonCollider2D>().points;
				break;
			case 3:
				((Component)__instance.bg2).gameObject.SetActive(false);
				((Component)__instance.bg3).gameObject.SetActive(true);
				((Component)__instance.bg4).gameObject.SetActive(false);
				__instance.amplifyNodes.localPosition = new Vector3(num, __instance.amplifyNodes.localPosition.y, __instance.amplifyNodes.localPosition.z);
				component.points = ((Component)__instance.bg3).GetComponent<PolygonCollider2D>().points;
				break;
			default:
			{
				((Component)__instance.bg2).gameObject.SetActive(false);
				((Component)__instance.bg3).gameObject.SetActive(false);
				((Component)__instance.bg4).gameObject.SetActive(true);
				__instance.amplifyNodes.localPosition = new Vector3(num, __instance.amplifyNodes.localPosition.y, __instance.amplifyNodes.localPosition.z);
				float num2 = (float)_numNodes / 4f;
				((Component)__instance.bg4).transform.localScale = new Vector3(num2, 1f, 1f);
				PolygonCollider2D component2 = ((Component)__instance.bg4).GetComponent<PolygonCollider2D>();
				Vector2[] points = component2.points;
				for (int i = 0; i < points.Length; i++)
				{
					points[i] = new Vector2(points[i].x * num2, points[i].y);
				}
				component.points = points;
				break;
			}
			}
			return false;
		}
	}
	[HarmonyPatch]
	public class PerkPatches
	{
		public static int[] paralyzeCounters = new int[4];

		public static bool blockShieldFlag = false;

		public static int blockCount = 0;

		public static int shieldCount = 0;

		public static bool mark1dFlag = true;

		public static bool poison2gFlag = true;

		public static bool bleed2gFlag = true;

		public static bool thorns1eFlag = true;

		public static bool shackle1fFlag = false;

		public static bool insulate1dFlag = false;

		public static bool isDamagePreviewActive = false;

		public static bool isCalculateDamageActive = false;

		public static int infiniteProctection = 0;

		public static int infiniteProctectionPowerful = 0;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(AtOManager), "BeginAdventure")]
		public static void BeginAdventurePostfix(ref AtOManager __instance)
		{
			Hero[] value = Traverse.Create((object)__instance).Field("teamAtO").GetValue<Hero[]>();
			foreach (Hero hero in value)
			{
				HandleExpPerks(hero);
			}
		}

		public static void HandleExpPerks(Hero _hero)
		{
			int num = 0;
			int num2 = 10;
			int num3 = 40;
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_hero, "exp0"))
			{
				num += num2;
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_hero, "exp1"))
			{
				num += num2;
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_hero, "exp2"))
			{
				num += num2;
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_hero, "exp3"))
			{
				num += num3;
			}
			((Character)_hero).GrantExperience(num);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(AtOManager), "HeroLevelUp")]
		public static void HeroLevelUpPrefix(ref AtOManager __instance, int heroIndex, string traitId)
		{
			Hero[] value = Traverse.Create((object)__instance).Field("teamAtO").GetValue<Hero[]>();
			Hero val = value[heroIndex];
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)val, "health6b"))
			{
				int num = 12;
				((Character)value[heroIndex]).ModifyMaxHP(num);
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)val, "health6c"))
			{
				int num2 = -14;
				((Character)value[heroIndex]).ModifyMaxHP(num2);
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)val, "shards5b"))
			{
				int num3 = 125;
				AtOManager.Instance.GivePlayer(1, num3, "", "", true, false);
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)val, "currency6b"))
			{
				int num4 = 125;
				AtOManager.Instance.GivePlayer(0, num4, "", "", true, false);
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)val, "resistance5b"))
			{
				Plugin.LogDebug("Attempting to add resistances");
				int num5 = 4;
				string text = Plugin.perkBase + "resistance5b";
				PerkData perkData = Globals.Instance.GetPerkData(text);
				perkData.ResistModified = (DamageType)10;
				perkData.ResistModifiedValue += num5;
				Dictionary<string, PerkData> value2 = Traverse.Create((object)Globals.Instance).Field("_PerksSource").GetValue<Dictionary<string, PerkData>>();
				if (value2.ContainsKey(text))
				{
					Plugin.LogDebug("Setting perk dictionary");
					value2[text] = perkData;
				}
				Traverse.Create((object)Globals.Instance).Field("_PerksSource").SetValue((object)value2);
			}
			if (CustomFunctions.CharacterObjectHavePerk((Character)(object)val, "resistance5c"))
			{
				Plugin.LogDebug("Attempting to add resistances");
				int num6 = -4;
				string text2 = Plugin.perkBase + "resistance5b";
				PerkData perkData2 = Globals.Instance.GetPerkData(text2);
				perkData2.ResistModified = (DamageType)10;
				perkData2.ResistModifiedValue += num6;
				Dictionary<string, PerkData> value3 = Traverse.Create((object)Globals.Instance).Field("_PerksSource").GetValue<Dictionary<string, PerkData>>();
				if (value3.ContainsKey(text2))
				{
					Plugin.LogDebug("Setting perk dictionary");
					value3[text2] = perkData2;
				}
				Traverse.Create((object)Globals.Instance).Field("_PerksSource").SetValue((object)value3);
			}
			HandleExpPerks(val);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(MatchManager), "GenerateHeroes")]
		public static void GenerateHeroesPostfix(ref MatchManager __instance)
		{
			Hero[] teamHero = MatchManager.Instance.GetTeamHero();
			for (int i = 0; i < teamHero.Length; i++)
			{
				if (teamHero[i] != null)
				{
					Hero _character = teamHero[i];
					if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_character, "weak1d"))
					{
						CustomFunctions.AddImmunityToHero("weak", ref _character);
					}
					if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_character, "disarm1a"))
					{
						CustomFunctions.AddImmunityToHero("disarm", ref _character);
					}
					if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_character, "silence1a"))
					{
						CustomFunctions.AddImmunityToHero("silence", ref _character);
					}
					if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_character, "shackle1b"))
					{
						CustomFunctions.AddImmunityToHero("shackle", ref _character);
					}
					if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_character, "stanza0e"))
					{
						CustomFunctions.AddImmunityToHero("stanzai", ref _character);
						CustomFunctions.AddImmunityToHero("stanzaiii", ref _character);
					}
					if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_character, "energize1e"))
					{
						CustomFunctions.AddImmunityToHero("fatigue", ref _character);
					}
					if (CustomFunctions.CharacterObjectHavePerk((Character)(object)_character, "vulnerable0d"))
					{
						CustomFunctions.AddImmunityToHero("vulnerable", ref _character);
						CustomFunctions.AddImmunityToHero("reinforce", ref _character);
						CustomFunctions.AddImmunityToHero("insulate", ref _character);
						CustomFunctions.AddImmunityToHero("courage", ref _character);
					}
				}
			}
			Traverse.Create((object)MatchManager.Instance).Field("teamHero").SetValue((object)teamHero);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Globals), "GetCostReroll")]
		public static void GetRerollCostPostfix(ref int __result)
		{
			if (CustomFunctions.TeamHasPerk("currency6d"))
			{
				__result = Mathf.RoundToInt(0.75f * (float)__result);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Globals), "GetDivinationCost")]
		public static void GetDivinationCost(ref Globals __instance, ref int __result)
		{
			if (CustomFunctions.TeamHasPerk("currency6e"))
			{
				__result = Mathf.RoundToInt(0.85f * (float)__result);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GetTraitHealReceivedPercentBonus")]
		public static void GetTraitHealReceivedPercentBonusPostfix(ref Character __instance, ref float __result)
		{
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "heal5c") && __instance.IsHero && __instance.Alive && __instance != null)
			{
				__result += 35f;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "SetEvent")]
		public static void SetEventPrefix(ref Character __instance, EventActivation theEvent, ref int auxInt, Character target = null, string auxString = "")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0040: 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_004e: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Invalid comparison between Unknown and I4
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Invalid comparison between Unknown and I4
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Invalid comparison between Unknown and I4
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Invalid comparison between Unknown and I4
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Invalid comparison between Unknown and I4
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Invalid comparison between Unknown and I4
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Invalid comparison between Unknown and I4
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Invalid comparison between Unknown and I4
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Invalid comparison between Unknown and I4
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Invalid comparison between Unknown and I4
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Invalid comparison between Unknown and I4
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Invalid comparison between Unknown and I4
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Invalid comparison between Unknown and I4
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Invalid comparison between Unknown and I4
			//IL_0730: Unknown result type (might be due to invalid IL or missing references)
			//IL_0732: Invalid comparison between Unknown and I4
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_077e: Invalid comparison between Unknown and I4
			//IL_0811: Unknown result type (might be due to invalid IL or missing references)
			//IL_0814: Invalid comparison between Unknown and I4
			//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08aa: Invalid comparison between Unknown and I4
			//IL_0912: Unknown result type (might be due to invalid IL or missing references)
			//IL_0915: Invalid comparison between Unknown and I4
			//IL_0970: Unknown result type (might be due to invalid IL or missing references)
			//IL_0973: Invalid comparison between Unknown and I4
			//IL_0a3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3d: Invalid comparison between Unknown and I4
			//IL_0abe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac0: Invalid comparison between Unknown and I4
			//IL_0b27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2a: Invalid comparison between Unknown and I4
			if ((int)theEvent == 18 || (int)theEvent == 26 || __instance == null || (int)theEvent == 0)
			{
				return;
			}
			Hero[] teamHeroes = MatchManager.Instance.GetTeamHero();
			NPC[] teamNpc = MatchManager.Instance.GetTeamNPC();
			string name = Enum.GetName(typeof(EventActivation), theEvent);
			if ((int)theEvent == 1)
			{
				infiniteProctection = 0;
				paralyzeCounters = new int[4];
				mark1dFlag = true;
			}
			if ((int)theEvent == 23 && CustomFunctions.IsLivingNPC(__instance) && CustomFunctions.TeamHasPerk("mark1d") && __instance.HasEffect("mark") && auxString == "mark" && __instance.GetAuraCharges("mark") >= 10 && mark1dFlag)
			{
				__instance.SetAura(__instance, CustomFunctions.GetAuraCurseData("taunt"), 2, false, (CardClass)11, false, true);
				mark1dFlag = false;
			}
			if ((int)theEvent == 23 && CustomFunctions.IsLivingNPC(target) && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "spark2g") && auxString == "spark")
			{
				target.SetAura((Character)null, CustomFunctions.GetAuraCurseData("crack"), 2, false, (CardClass)11, true, true);
			}
			if ((int)theEvent == 23 && auxString == "powerful" && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.TeamHasPerk("powerful1d") && __instance.HasEffect("powerful"))
			{
				AuraCurseData auraCurseData = CustomFunctions.GetAuraCurseData("powerful");
				if ((__instance.GetAuraCharges("powerful") == auraCurseData.MaxCharges || __instance.GetAuraCharges("powerful") == auraCurseData.MaxCharges + 7) && infiniteProctectionPowerful < 10)
				{
					__instance.SetAuraTrait(__instance, "vitality", 1);
					infiniteProctectionPowerful++;
				}
			}
			if ((int)theEvent == 23 && auxString == "shackle" && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "shackle1e") && __instance.HasEffect("shackle"))
			{
				int auraCharges = __instance.GetAuraCharges("shackle");
				__instance.ModifyAuraCurseQuantity("dark", auraCharges);
			}
			if ((int)theEvent == 23 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.IsLivingNPC(target) && CustomFunctions.CharacterObjectHavePerk(__instance, "poison2h") && auxString == "poison")
			{
				int auraCharges2 = target.GetAuraCharges("poison");
				float num = (target.HasEffect("rust") ? 0.3f : 0.2f);
				int num2 = Mathf.RoundToInt((float)auraCharges2 * num);
				target.IndirectDamage((DamageType)7, num2, (AudioClip)null, "", "", "");
			}
			if ((int)theEvent == 23 && CustomFunctions.IsLivingHero(target) && target.HasEffect("courage") && CustomFunctions.CharacterObjectHavePerk(target, "courage1d") && auxString == "shield")
			{
				int auraCharges3 = target.GetAuraCharges("courage");
				shieldCount++;
				if (shieldCount % 2 == 1 && shieldCount < 100)
				{
					target.SetAura(__instance, CustomFunctions.GetAuraCurseData("shield"), auraCharges3, false, (CardClass)11, false, true);
				}
			}
			if ((int)theEvent == 23 && CustomFunctions.IsLivingHero(target) && target.HasEffect("reinforce") && CustomFunctions.CharacterObjectHavePerk(target, "reinforce1d") && auxString == "block")
			{
				int auraCharges4 = __instance.GetAuraCharges("reinforce");
				blockCount++;
				if (blockCount % 2 == 1 && blockCount < 100)
				{
					target.SetAura(__instance, CustomFunctions.GetAuraCurseData("block"), auraCharges4, false, (CardClass)11, false, true);
				}
			}
			if ((int)theEvent == 23 && CustomFunctions.IsLivingNPC(target) && CustomFunctions.TeamHasPerk("sight1e") && auxString == "sight" && target.HasEffect("sight") && target.GetAuraCharges("sight") >= 100)
			{
				target.HealCursesName((List<string>)null, "sight");
				target.DispelAuras(3);
			}
			if ((int)theEvent == 23 && __instance != null && CustomFunctions.IsLivingNPC(target) && CustomFunctions.TeamHasPerk("paralyze1c") && auxString == "spark")
			{
				int auraCharges5 = target.GetAuraCharges("spark");
				if (auraCharges5 >= 100 && paralyzeCounters[target.NPCIndex] <= 0)
				{
					AuraCurseData auraCurseData2 = CustomFunctions.GetAuraCurseData("paralyze");
					paralyzeCounters[target.NPCIndex]++;
					target.SetAura(__instance, auraCurseData2, 1, false, (CardClass)11, true, true);
				}
			}
			if ((int)theEvent == 23 && auxString == "block" && CustomFunctions.IsLivingHero(target) && CustomFunctions.CharacterObjectHavePerk(target, "block5d"))
			{
				int num3 = 1;
				DamageType val = (DamageType)2;
				int num4 = target.DamageWithCharacterBonus(num3, val, (CardClass)11, 0, -1000);
				Character[] array = (Character[])(object)teamNpc;
				Character randomCharacter = CustomFunctions.GetRandomCharacter(array);
				if (randomCharacter.Alive && randomCharacter != null && target.Alive && target != null)
				{
					randomCharacter.IndirectDamage(val, num4, (AudioClip)null, "", "", "");
					target.IndirectDamage(val, num4, (AudioClip)null, "", "", "");
				}
			}
			if ((int)theEvent == 23 && auxString == "rust" && CustomFunctions.IsLivingNPC(__instance) && CustomFunctions.CharacterObjectHavePerk(target, "rust0h"))
			{
				__instance.DispelAuras(1);
			}
			if ((int)theEvent == 23 && auxString == "decay" && CustomFunctions.IsLivingNPC(__instance) && CustomFunctions.IsLivingHero(target) && CustomFunctions.CharacterObjectHavePerk(target, "decay1g"))
			{
				target.SetAura(__instance, CustomFunctions.GetAuraCurseData("rust"), 1, false, (CardClass)11, true, true);
				target.SetAura(target, CustomFunctions.GetAuraCurseData("rust"), 1, false, (CardClass)11, true, true);
			}
			if ((int)theEvent == 1 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "block5c"))
			{
				bool allHeroFlag = true;
				bool allNpcFlag = false;
				CustomFunctions.ApplyAuraCurseTo("block", 2, allHeroFlag, allNpcFlag, randomHeroFlag: false, randomNpcFlag: false, ref __instance, ref teamHeroes, ref teamNpc, "", "");
			}
			if ((int)theEvent == 1 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "shield5c"))
			{
				bool allHeroFlag2 = true;
				bool allNpcFlag2 = false;
				CustomFunctions.ApplyAuraCurseTo("shield", 4, allHeroFlag2, allNpcFlag2, randomHeroFlag: false, randomNpcFlag: false, ref __instance, ref teamHeroes, ref teamNpc, "", "");
			}
			if ((int)theEvent == 1 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "fortify1f"))
			{
				bool allHeroFlag3 = true;
				bool allNpcFlag3 = false;
				CustomFunctions.ApplyAuraCurseTo("fortify", 2, allHeroFlag3, allNpcFlag3, randomHeroFlag: false, randomNpcFlag: false, ref __instance, ref teamHeroes, ref teamNpc, "", "");
			}
			if ((int)theEvent == 1 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "rust0g"))
			{
				bool allHeroFlag4 = true;
				bool allNpcFlag4 = false;
				CustomFunctions.ApplyAuraCurseTo("rust", 2, allHeroFlag4, allNpcFlag4, randomHeroFlag: false, randomNpcFlag: false, ref __instance, ref teamHeroes, ref teamNpc, "", "");
			}
			if ((int)theEvent == 35 && !target.IsHero && target != null && CustomFunctions.TeamHasPerk("poison2g") && target.HasEffect("poison") && poison2gFlag)
			{
				poison2gFlag = false;
				int auraCharges6 = target.GetAuraCharges("poison");
				int num5 = Mathf.RoundToInt((float)auraCharges6 * 0.5f);
				Character[] array = (Character[])(object)teamNpc;
				Character randomCharacter2 = CustomFunctions.GetRandomCharacter(array);
				if (CustomFunctions.IsLivingNPC(randomCharacter2))
				{
					randomCharacter2.SetAura(__instance, CustomFunctions.GetAuraCurseData("poison"), num5, false, (CardClass)11, false, true);
				}
			}
			if ((int)theEvent == 35 && !target.IsHero && target != null && CustomFunctions.TeamHasPerk("thorns1e") && target.HasEffect("thorns") && thorns1eFlag)
			{
				thorns1eFlag = false;
				int auraCharges7 = target.GetAuraCharges("thorns");
				int num6 = Mathf.RoundToInt((float)auraCharges7 * 1f);
				Character[] array = (Character[])(object)teamHeroes;
				Character randomCharacter3 = CustomFunctions.GetRandomCharacter(array);
				if (CustomFunctions.IsLivingHero(randomCharacter3))
				{
					randomCharacter3.SetAura(__instance, CustomFunctions.GetAuraCurseData("thorns"), num6, false, (CardClass)11, false, true);
				}
			}
			if ((int)theEvent == 35 && !target.IsHero && target != null && CustomFunctions.TeamHasPerk("bleed2g") && target.HasEffect("bleed") && bleed2gFlag)
			{
				bleed2gFlag = false;
				int auraCharges8 = target.GetAuraCharges("bleed");
				int amount = Mathf.RoundToInt((float)auraCharges8 * 0.25f);
				CustomFunctions.DealIndirectDamageToAllMonsters((DamageType)0, amount);
			}
			if ((int)theEvent == 9 && CustomFunctions.IsLivingNPC(__instance) && CustomFunctions.IsLivingHero(target) && CustomFunctions.CharacterObjectHavePerk(target, "bleed2e"))
			{
				int auraCharges9 = __instance.GetAuraCharges("bleed");
				int num7 = Mathf.RoundToInt((float)auraCharges9 * 0.25f);
				target.IndirectHeal(num7, (AudioClip)null, "", "");
			}
			if ((int)theEvent == 9 && CustomFunctions.IsLivingNPC(__instance) && CustomFunctions.IsLivingHero(target) && CustomFunctions.CharacterObjectHavePerk(target, "spark2f"))
			{
				int auraCharges10 = __instance.GetAuraCharges("spark");
				int num8 = Mathf.RoundToInt((float)auraCharges10 * 0.2f);
				int nPCIndex = __instance.NPCIndex;
				List<NPC> nPCSides = MatchManager.Instance.GetNPCSides(nPCIndex);
				for (int i = 0; i < nPCSides.Count; i++)
				{
					if (((Character)nPCSides[i]).Alive && nPCSides[i] != null)
					{
						((Character)nPCSides[i]).IndirectDamage((DamageType)6, num8, (AudioClip)null, "", "", "");
					}
				}
			}
			if ((int)theEvent == 7 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "spellsword1d"))
			{
				CardData value = Traverse.Create((object)__instance).Field("cardCasted").GetValue<CardData>();
				if ((Object)(object)value != (Object)null && MatchManager.Instance.energyJustWastedByHero >= 4 && (value.HasCardType((CardType)19) || value.HasCardType((CardType)20)))
				{
					__instance.SetAuraTrait(__instance, "spellsword", 1);
				}
			}
			if ((int)theEvent == 7 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "energy2e"))
			{
				CardData value2 = Traverse.Create((object)__instance).Field("cardCasted").GetValue<CardData>();
				if ((Object)(object)value2 != (Object)null && MatchManager.Instance.energyJustWastedByHero >= 4)
				{
					__instance.ModifyEnergy(1, false);
				}
			}
			if ((int)theEvent == 20 && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.CharacterObjectHavePerk(__instance, "taunt1g") && __instance.HasEffect("taunt"))
			{
				__instance.ConsumeEffectCharges("taunt", 1);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GetEnergyTurn")]
		public static void GetEnergyTurnPostfix(Character __instance, ref int __result)
		{
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "energy2e") && __instance.IsHero && __instance.Alive && __instance != null)
			{
				__result--;
				if (__result < 0)
				{
					__result = 0;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "DamageReflected")]
		public static bool DamageReflectedPrefix(ref Character __instance, Hero theCasterHero, NPC theCasterNPC, int damageAmount = 0, int blockedAmount = 0)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.IsHero && theCasterHero != null)
			{
				return true;
			}
			List<Aura> auraList = __instance.AuraList;
			for (int i = 0; i < auraList.Count; i++)
			{
				if (auraList[i] == null)
				{
					continue;
				}
				AuraCurseData aCData = auraList[i].ACData;
				if (!((Object)(object)aCData != (Object)null) || aCData.DamageReflectedMultiplier <= 0 || __instance.GetAuraCharges(aCData.Id) < aCData.ChargesPreReqForDamageReflection)
				{
					continue;
				}
				RefectedDamageModifierType damageReflectedModifierType = aCData.DamageReflectedModifierType;
				RefectedDamageModifierType val = damageReflectedModifierType;
				if ((int)val == 0 && aCData.Id == "thorns" && theCasterNPC != null && CustomFunctions.IfCharacterHas(__instance, CustomFunctions.CharacterHas.Perk, "zeal0j", CustomFunctions.AppliesTo.Heroes) && __instance.HasEffect("zeal"))
				{
					((Character)theCasterNPC).SetAura(__instance, Globals.Instance.GetAuraCurseData("burn"), Functions.FuncRoundToInt((float)auraList[i].AuraCharges * 0.5f), false, (CardClass)11, true, true);
					if (aCData.DamageReflectedConsumeCharges > 0)
					{
						__instance.ConsumeEffectCharges(aCData.Id, aCData.DamageReflectedConsumeCharges);
					}
					return false;
				}
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "EndRound")]
		public static void EndRoundPostfix(ref Character __instance)
		{
			Plugin.LogDebug("EndRoundPostfix");
			if (__instance != null)
			{
				int auraCharges = __instance.GetAuraCharges("spark");
				if ((Object)(object)AtOManager.Instance != (Object)null && AtOManager.Instance.TeamHavePerk("mainperkspark2c"))
				{
					__instance.SetAuraTrait((Character)null, "slow", Mathf.FloorToInt(1f / 14f * (float)auraCharges));
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "DamageWithCharacterBonus")]
		public static void DamageWithCharacterBonusPostfix(ref Character __instance, ref int __result, int value, DamageType DT, CardClass CC, int energyCost = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Invalid comparison between Unknown and I4
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Invalid comparison between Unknown and I4
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Invalid comparison between Unknown and I4
			if ((int)CC == 11 || !CustomFunctions.IsLivingHero(__instance) || value == 0 || __result == 0 || (int)DT == 0 || (Object)(object)AtOManager.Instance == (Object)null || (Object)(object)MatchManager.Instance == (Object)null || !CustomFunctions.CharacterObjectHavePerk(__instance, "energy2d"))
			{
				return;
			}
			float num = 4f;
			num += (float)__instance.GetAuraCharges("bless") * 0.25f;
			if ((int)DT == 1 || (int)DT == 3 || ((int)DT == 9 && AtOManager.Instance.CharacterHavePerk(__instance.SubclassName, "mainperkSharp1d")) || ((int)DT == 7 && AtOManager.Instance.TeamHaveTrait("shrilltone")))
			{
				num += (float)__instance.GetAuraCharges("sharp") * 0.2f;
			}
			if (((int)DT == 4 || (int)DT == 2) && AtOManager.Instance.CharacterHavePerk(__instance.SubclassName, "mainperkfortify1a"))
			{
				num += (float)__instance.GetAuraCharges("fortify") * 0.2f;
			}
			Dictionary<int, float> dictionary = new Dictionary<int, float>
			{
				{ 0, 0.4f },
				{ 1, 0.7f },
				{ 2, 1f },
				{ 3, 1.4f },
				{ 4, 1.8f },
				{ 5, 2.2f },
				{ 6, 2.7f },
				{ 7, 3.2f },
				{ 8, 3.9f },
				{ 9, 4.8f },
				{ 10, 6f }
			};
			int num2 = __result;
			if (dictionary.ContainsKey(energyCost))
			{
				int val = Mathf.RoundToInt(((float)__result - num * MathF.Sqrt(energyCost)) * dictionary[energyCost] + num);
				if (energyCost < 2)
				{
					__result = Math.Min(val, Mathf.RoundToInt((float)num2 * dictionary[energyCost]));
				}
				else
				{
					__result = Math.Max(val, num2);
				}
				if (__result < 0)
				{
					__result = 0;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "SetAura")]
		public static void SetAuraPrefix(ref Character __instance, Character theCaster, AuraCurseData _acData, ref int charges, bool fromTrait = false, CardClass CC = 11, bool useCharacterMods = true, bool canBePreventable = true)
		{
			if (CustomFunctions.TeamHasPerk("weak1b") && __instance != null && __instance.Alive && CustomFunctions.IsLivingNPC(theCaster) && theCaster.HasEffect("weak"))
			{
				charges = Functions.FuncRoundToInt(0.8f * (float)charges);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "BeginTurn")]
		public static void BeginTurnPrefix(ref Character __instance)
		{
			poison2gFlag = true;
			bleed2gFlag = true;
			thorns1eFlag = true;
			infiniteProctection = 0;
			infiniteProctectionPowerful = 0;
			if (!__instance.Alive || __instance == null || (Object)(object)MatchManager.Instance == (Object)null)
			{
				return;
			}
			Hero[] teamHero = MatchManager.Instance.GetTeamHero();
			NPC[] teamNPC = MatchManager.Instance.GetTeamNPC();
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "rust0f"))
			{
				int num = 2;
				__instance.SetAuraTrait(__instance, "rust", num);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "shackle1d"))
			{
				int auraCharges = __instance.GetAuraCharges("shackle");
				int num2 = 2;
				__instance.SetAuraTrait(__instance, "fortify", auraCharges * num2);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "mitigate1a"))
			{
				int num3 = 2;
				__instance.SetAuraTrait(__instance, "mitigate", num3);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "mitigate1c"))
			{
				int num4 = 7 * __instance.GetAuraCharges("mitigate");
				__instance.SetAuraTrait(__instance, "block", num4);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "health6c"))
			{
				Plugin.LogDebug("Health6c current: " + __instance.HpCurrent + " Max: " + __instance.GetMaxHP());
				if (__instance.GetMaxHP() <= __instance.HpCurrent || __instance.GetHpLeftForMax() <= 0)
				{
					int num5 = 2;
					__instance.SetAuraTrait(__instance, "vitality", num5);
				}
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "chill2f"))
			{
				int num6 = 3;
				__instance.SetAuraTrait(__instance, "chill", num6);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "sight1d"))
			{
				int num7 = 0;
				NPC[] array = teamNPC;
				foreach (NPC val in array)
				{
					if (CustomFunctions.IsLivingNPC((Character)(object)val) && ((Character)val).GetAuraCharges("sight") >= 100)
					{
						num7++;
					}
				}
				__instance.SetAuraTrait(__instance, "evasion", num7);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "energize1a") && MatchManager.Instance.GetCurrentRound() == 1)
			{
				__instance.SetAuraTrait(__instance, "energize", 1);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "spellsword1c"))
			{
				Hero[] array2 = teamHero;
				foreach (Hero val2 in array2)
				{
					if (CustomFunctions.IsLivingHero((Character)(object)val2) && (!(((Character)val2).SubclassName == "queen") || ((Character)val2).GetAuraCharges("spellsword") != 4))
					{
						((Character)val2).SetAuraTrait(__instance, "spellsword", 1);
					}
				}
				NPC[] array3 = teamNPC;
				foreach (NPC val3 in array3)
				{
					if (CustomFunctions.IsLivingNPC((Character)(object)val3))
					{
						((Character)val3).SetAuraTrait(__instance, "spellsword", 1);
					}
				}
			}
			if (CustomFunctions.TeamHasPerk("sanctify2e") && __instance.IsHero && __instance.HasEffect("sanctify"))
			{
				int auraCharges2 = __instance.GetAuraCharges("sanctify");
				int num8 = Mathf.FloorToInt((float)auraCharges2 * 0.05f);
				AuraCurseData auraCurseData = CustomFunctions.GetAuraCurseData("zeal");
				__instance.SetAura(__instance, auraCurseData, num8, false, (CardClass)11, false, true);
			}
			if (CustomFunctions.TeamHasPerk("insane2f") && __instance.HasEffect("insane"))
			{
				int num9 = Mathf.FloorToInt((float)(__instance.GetAuraCharges("insane") / 30));
				__instance.SetAuraTrait(__instance, "scourge", num9);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "stealh1d") && __instance.IsHero && !__instance.HasEffect("stealth"))
			{
				__instance.SetAura(__instance, CustomFunctions.GetAuraCurseData("stealth"), 1, false, (CardClass)11, false, true);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "stanza0d") && __instance.IsHero && MatchManager.Instance.GetCurrentRound() == 1)
			{
				__instance.SetAura(__instance, CustomFunctions.GetAuraCurseData("stanzai"), 1, false, (CardClass)11, false, true);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "stanza0e") && __instance.IsHero && MatchManager.Instance.GetCurrentRound() == 1)
			{
				__instance.SetAura(__instance, CustomFunctions.GetAuraCurseData("stanzaii"), 1, false, (CardClass)11, false, true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GetTraitDamagePercentModifiers")]
		public static void GetTraitDamagePercentModifiersPostfix(ref Character __instance, ref float __result)
		{
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "currency6c"))
			{
				int playerGold = AtOManager.Instance.GetPlayerGold();
				int num = Mathf.FloorToInt((float)(10 * playerGold / 2000));
				__result += num;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(MatchManager), "EndTurn")]
		public static void MatchManagerEndTurnPrefix(MatchManager __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			Character characterActive = __instance.GetCharacterActive();
			if (!CustomFunctions.IsLivingHero(characterActive))
			{
				return;
			}
			if (CustomFunctions.CharacterObjectHavePerk(characterActive, "inspire0d") && __instance.CountHeroHand(-1) >= 4)
			{
				characterActive.SetAuraTrait(characterActive, "inspire", 1);
			}
			if (CustomFunctions.CharacterObjectHavePerk(characterActive, "health6d") && characterActive.GetHpLeftForMax() <= 0)
			{
				characterActive.SetAuraTrait(characterActive, "vitality", 2);
			}
			if (!CustomFunctions.TeamHasPerk("fury1d") || !characterActive.HasEffect("fury"))
			{
				return;
			}
			float num = 0.7f;
			if ((Object)(object)characterActive.HeroItem != (Object)null)
			{
				List<Hero> heroSides = MatchManager.Instance.GetHeroSides(characterActive.Position);
				for (int i = 0; i < heroSides.Count; i++)
				{
					((Character)heroSides[i]).SetAura((Character)null, Globals.Instance.GetAuraCurseData("fury"), Functions.FuncRoundToInt((float)characterActive.GetAuraCharges("fury") * num), false, (CardClass)11, true, true);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(MatchManager), "SetDamagePreview")]
		public static void SetDamagePreviewPrefix()
		{
			isDamagePreviewActive = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(MatchManager), "SetDamagePreview")]
		public static void SetDamagePreviewPostfix()
		{
			isDamagePreviewActive = false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterItem), "CalculateDamagePrePostForThisCharacter")]
		public static void CalculateDamagePrePostForThisCharacterPrefix()
		{
			isCalculateDamageActive = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharacterItem), "CalculateDamagePrePostForThisCharacter")]
		public static void CalculateDamagePrePostForThisCharacterPostfix()
		{
			isCalculateDamageActive = false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "IndirectDamage")]
		public static void IndirectDamagePostfix(ref Character __instance, DamageType damageType, ref int damage, AudioClip sound = null, string effect = "", string sourceCharacterName = "", string sourceCharacterId = "")
		{
			Plugin.LogDebug("IndirectDamagePostfix");
			if (!((Object)(object)MatchManager.Instance == (Object)null))
			{
				Character characterById = MatchManager.Instance.GetCharacterById(sourceCharacterId);
				if (CustomFunctions.TeamHasPerk("thorns1f") && CustomFunctions.IsLivingHero(characterById) && characterById.HasEffect("bless") && effect == "thorns")
				{
					int auraCharges = characterById.GetAuraCharges("rust");
					float num = 1f + 0.05f * (float)auraCharges;
					damage = Mathf.RoundToInt((float)damage * num);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "HealReceivedFinal")]
		public static void HealReceivedFinalPostfix(Character __instance, int __result, int heal, bool isIndirect = false)
		{
			if (infiniteProctection <= 100 && !isDamagePreviewActive && !isCalculateDamageActive && !((Object)(object)MatchManager.Instance == (Object)null) && CustomFunctions.IsLivingHero(__instance) && MatchManager.Instance.GetHeroHeroActive() != null)
			{
				infiniteProctection++;
				Hero heroHeroActive = MatchManager.Instance.GetHeroHeroActive();
				if (__result >= 0 && __instance.GetHpLeftForMax() <= 0 && CustomFunctions.CharacterObjectHavePerk((Character)(object)heroHeroActive, "heal5b") && CustomFunctions.IsLivingHero(__instance) && CustomFunctions.IsLivingHero((Character)(object)heroHeroActive) && heal > 0 && !isIndirect)
				{
					__instance.SetAura(__instance, CustomFunctions.GetAuraCurseData("powerful"), 2, false, (CardClass)11, false, true);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "EndTurn")]
		public static void CharacterEndTurnPrefix(Character __instance)
		{
			if (!__instance.Alive || __instance == null || (Object)(object)MatchManager.Instance == (Object)null)
			{
				return;
			}
			Hero[] teamHero = MatchManager.Instance.GetTeamHero();
			if (CustomFunctions.CharacterHasPerkForConsume("zeal0h", __instance.IsHero, AtOManager.Instance, __instance))
			{
				Plugin.LogDebug("zeal0h");
				int auraCharges = __instance.GetAuraCharges("zeal");
				AuraCurseData auraCurseData = CustomFunctions.GetAuraCurseData("zeal");
				int num = ((!auraCurseData.ConsumeAll) ? auraCurseData.AuraConsumed : auraCharges);
				int num2 = 4 * num;
				int amount = __instance.DamageWithCharacterBonus(num2, (DamageType)8, (CardClass)11, 0, -1000);
				CustomFunctions.DealIndirectDamageToAllMonsters((DamageType)8, amount);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "paralyze1b"))
			{
				AuraCurseData auraCurseData2 = CustomFunctions.GetAuraCurseData("paralyze");
				Hero[] array = teamHero;
				foreach (Hero val in array)
				{
					if (((Character)val).Alive && val != null)
					{
						((Character)val).HealAuraCurse(auraCurseData2);
					}
				}
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "energize1d") && __instance.EnergyCurrent >= 4)
			{
				__instance.SetAuraTrait(__instance, "energize", 1);
			}
			if (CustomFunctions.CharacterObjectHavePerk(__instance, "fortify1d"))
			{
				int auraCharges2 = __instance.GetAuraCharges("fortify");
				int num3 = Mathf.RoundToInt((float)auraCharges2 * 0.5f);
				__instance.SetAuraTrait(__instance, "reinforce", num3);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GainEnergyTurn")]
		public static void GainEnergyTurn(ref Character __instance)
		{
			if (MatchManager.Instance.GetCurrentRound() > 3 && CustomFunctions.IfCharacterHas(__instance, CustomFunctions.CharacterHas.Perk, "energy2f", CustomFunctions.AppliesTo.ThisHero))
			{
				Plugin.LogDebug("Updated Energy2f perk");
				__instance.ModifyEnergy(1, true);
			}
			if (MatchManager.Instance.GetCurrentRound() == 4 && AtOManager.Instance.CharacterHavePerk(__instance.SubclassName, "mainperkenergy2c"))
			{
				Plugin.LogDebug("Updated Energy2c perk");
				__instance.ModifyEnergy(1, true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(AtOManager), "GlobalAuraCurseModificationByTraitsAndItems")]
		public static void GlobalAuraCurseModificationByTraitsAndItemsPostfix(ref AtOManager __instance, ref AuraCurseData __result, string _type, string _acId, Character _characterCaster, Character _characterTarget)
		{
			//IL_0b08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0e: Invalid comparison between Unknown and I4
			//IL_0b24: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2a: Invalid comparison between Unknown and I4
			//IL_0b40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b46: Invalid comparison between Unknown and I4
			//IL_0b5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b62: Invalid comparison between Unknown and I4
			Character val = ((_type == "set") ? _characterTarget : _characterCaster);
			Character val2 = ((_type == "set") ? _characterCaster : _characterTarget);
			if (val == null)
			{
				return;
			}
			bool flag = false;
			if (val != null)
			{
				flag = val.HasEffect("rust");
			}
			switch (_acId)
			{
			case "evasion":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "evasion0b", CustomFunctions.AppliesTo.Heroes))
				{
					__result.ConsumeAll = true;
					__result.GainCharges = true;
					__result.ConsumedAtTurnBegin = true;
				}
				break;
			case "mark":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mark1e", CustomFunctions.AppliesTo.Monsters))
				{
					__result.IncreasedDamageReceivedType = (DamageType)3;
					__result.IncreasedDirectDamageReceivedPerStack = 1.5f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mark1g"))
				{
					AuraCurseData obj9 = __result;
					obj9.IncreasedDirectDamageReceivedPerStack *= 0.5f;
					__result.CharacterStatModified = (CharacterStat)2;
					__result.CharacterStatModifiedValuePerStack = -1f;
				}
				break;
			case "disarm":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "disarm1b", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.Removable = false;
					__result.ResistModified = (DamageType)10;
					__result.ResistModifiedValue = 10f;
				}
				break;
			case "silence":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "silence1b", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.Removable = false;
					__result.AuraDamageType = (DamageType)10;
					__result.AuraDamageIncreasedTotal = 7;
				}
				break;
			case "stealth":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "stealth1d", CustomFunctions.AppliesTo.Heroes))
				{
					__result.AuraDamageIncreasedPercentPerStack = 0f;
				}
				break;
			case "fast":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "fast0b", CustomFunctions.AppliesTo.Heroes))
				{
					__result.GainCharges = true;
					__result.ConsumeAll = true;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "fast0c", CustomFunctions.AppliesTo.Heroes))
				{
					__result.ConsumedAtTurn = true;
					__result.ConsumedAtTurnBegin = false;
				}
				break;
			case "slow":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "slow0b", CustomFunctions.AppliesTo.Monsters))
				{
					__result.GainCharges = true;
					__result.MaxCharges = 10;
					__result.MaxMadnessCharges = 10;
					__result.CharacterStatModifiedValuePerStack = -1f;
					__result.ChargesAuxNeedForOne1 = ((!flag) ? 1 : 2);
					__result.CharacterStatChargesMultiplierNeededForOne = ((!flag) ? 1 : 2);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "slow0c", CustomFunctions.AppliesTo.Monsters))
				{
					__result.GainCharges = true;
					__result.MaxCharges = 10;
					__result.MaxMadnessCharges = 10;
					__result.CharacterStatModifiedValuePerStack = -1f;
					__result.ChargesAuxNeedForOne1 = ((!flag) ? 1 : 2);
					__result.CharacterStatChargesMultiplierNeededForOne = ((!flag) ? 1 : 2);
				}
				break;
			case "fortify":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "fortify1e", CustomFunctions.AppliesTo.Heroes))
				{
					__result.GainCharges = true;
					AuraCurseData obj21 = __result;
					int maxCharges = (__result.MaxMadnessCharges = 5);
					obj21.MaxCharges = maxCharges;
					__result = AtOManager.Instance.GlobalAuraCurseModifyDamage(__result, (DamageType)10, 0, -1, 0);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "fortify1f", CustomFunctions.AppliesTo.Heroes))
				{
					AuraCurseData obj22 = __result;
					int maxCharges = (__result.MaxMadnessCharges = 2);
					obj22.MaxCharges = maxCharges;
				}
				break;
			case "fury":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "fury1d", CustomFunctions.AppliesTo.Heroes))
				{
					__result.ConsumeAll = true;
				}
				break;
			case "sharp":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperksharp1d", CustomFunctions.AppliesTo.Heroes))
				{
					__result = AtOManager.Instance.GlobalAuraCurseModifyDamage(__result, (DamageType)9, 0, 1, 0);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "zeal0e", CustomFunctions.AppliesTo.ThisHero) && val.HasEffect("zeal"))
				{
					__result = AtOManager.Instance.GlobalAuraCurseModifyDamage(__result, (DamageType)8, 0, 1, 0);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "sharp1g", CustomFunctions.AppliesTo.ThisHero))
				{
					float num13 = (AtOManager.Instance.TeamHaveTrait("shrilltone") ? 1.5f : 1f);
					if (flag)
					{
						num13 *= 0.5f;
					}
					if (AtOManager.Instance.TeamHaveTrait("shrilltone"))
					{
						if ((int)__result.AuraDamageType == 7)
						{
							__result.AuraDamageIncreasedPerStack = num13;
						}
						if ((int)__result.AuraDamageType2 == 7)
						{
							__result.AuraDamageIncreasedPerStack2 = num13;
						}
						if ((int)__result.AuraDamageType3 == 7)
						{
							__result.AuraDamageIncreasedPerStack3 = num13;
						}
						if ((int)__result.AuraDamageType4 == 7)
						{
							__result.AuraDamageIncreasedPerStack4 = num13;
						}
					}
					else
					{
						__result.AuraDamageType4 = (DamageType)7;
						__result.AuraDamageIncreasedPerStack4 = num13;
					}
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "sharp1e", CustomFunctions.AppliesTo.Heroes))
				{
					__result = AtOManager.Instance.GlobalAuraCurseModifyDamage(__result, (DamageType)9, 0, 1, 0);
					__result.MaxCharges = 25;
					__result.MaxMadnessCharges = 25;
					__result.AuraDamageIncreasedPerStack = (flag ? 0.75f : 1.5f);
					__result.AuraDamageIncreasedPerStack2 = (flag ? 0.75f : 1.5f);
					__result.AuraDamageIncreasedPerStack3 = (flag ? 0.75f : 1.5f);
					__result.AuraDamageIncreasedPerStack4 = (flag ? 0.75f : 1.5f);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "insane2e", CustomFunctions.AppliesTo.ThisHero))
				{
					__result = AtOManager.Instance.GlobalAuraCurseModifyDamage(__result, (DamageType)9, 0, 1, 0);
					int auraCharges8 = val.GetAuraCharges("insane");
					AuraCurseData obj23 = __result;
					obj23.AuraDamageIncreasedPerStack *= 1f + 0.01f * (float)auraCharges8;
					AuraCurseData obj24 = __result;
					obj24.AuraDamageIncreasedPerStack2 *= 1f + 0.01f * (float)auraCharges8;
					AuraCurseData obj25 = __result;
					obj25.AuraDamageIncreasedPerStack3 *= 1f + 0.01f * (float)auraCharges8;
					AuraCurseData obj26 = __result;
					obj26.AuraDamageIncreasedPerStack4 *= 1f + 0.01f * (float)auraCharges8;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "sharp1f", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.AuraDamageIncreasedPerStack = 0f;
					__result.AuraDamageIncreasedPerStack2 = 0f;
					__result.AuraDamageIncreasedPerStack3 = 0f;
					__result.AuraDamageIncreasedPerStack4 = 0f;
					__result = AtOManager.Instance.GlobalAuraCurseModifyDamage(__result, (DamageType)9, 0, 1, 0);
				}
				break;
			case "crack":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "insane2d", CustomFunctions.AppliesTo.Monsters))
				{
					int auraCharges2 = val.GetAuraCharges("insane");
					AuraCurseData obj11 = __result;
					obj11.IncreasedDirectDamageReceivedPerStack += (float)(flag ? Mathf.FloorToInt(0.03f * (float)auraCharges2) : Mathf.FloorToInt(0.02f * (float)auraCharges2));
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "crack2d", CustomFunctions.AppliesTo.Monsters))
				{
					__result.CharacterStatModified = (CharacterStat)2;
					__result.CharacterStatModifiedValue = -1;
					__result.CharacterStatChargesMultiplierNeededForOne = (flag ? 10 : 5);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "crack2e", CustomFunctions.AppliesTo.Monsters))
				{
					float num2 = (flag ? (-0.45f) : (-0.3f));
					__result = __instance.GlobalAuraCurseModifyResist(__result, (DamageType)6, 0, num2);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "crack2f", CustomFunctions.AppliesTo.Monsters))
				{
					__result.IncreasedDamageReceivedType2 = (DamageType)4;
					__result.IncreasedDirectDamageReceivedPerStack2 = (flag ? 1.125f : 0.75f);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "crack2g"))
				{
					__result.IncreasedDamageReceivedType2 = (DamageType)7;
					__result.IncreasedDirectDamageReceivedPerStack2 = (flag ? 1.125f : 0.75f);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "crack2h"))
				{
					float num3 = (flag ? (-0.45f) : (-0.3f));
					__result = __instance.GlobalAuraCurseModifyResist(__result, (DamageType)1, 0, num3);
					__result = __instance.GlobalAuraCurseModifyResist(__result, (DamageType)3, 0, num3);
				}
				break;
			case "shackle":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "shackle1f", CustomFunctions.AppliesTo.Monsters))
				{
					shackle1fFlag = !shackle1fFlag;
					if (!shackle1fFlag)
					{
						break;
					}
					int num5 = val.GetSpeed()[1];
					__result.IncreasedDamageReceivedType = (DamageType)10;
					float num6 = 1f;
					__result.IncreasedDirectDamageReceivedPerStack = Mathf.RoundToInt((float)num5 * num6);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "shackle1c"))
				{
					__result.Preventable = false;
				}
				break;
			case "mitigate":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mitigate1a", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.MaxCharges = 5;
					__result.MaxMadnessCharges = 5;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mitigate1b", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.ConsumedAtTurnBegin = false;
					__result.MaxCharges = 12;
					__result.MaxMadnessCharges = 12;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mitigate1d", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.ConsumeAll = true;
					__result.IncreasedDirectDamageReceivedPerStack = -2f;
					__result.ChargesMultiplierDescription = 2;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mitigate1e"))
				{
					__result.AuraDamageType = (DamageType)10;
					__result.AuraDamageIncreasedPercentPerStack = 10f;
				}
				break;
			case "poison":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkpoison2c", CustomFunctions.AppliesTo.Monsters))
				{
					__result.ConsumedAtTurnBegin = true;
					__result.ConsumedAtTurn = false;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "poison2d"))
				{
					__result.MaxMadnessCharges = (flag ? 450 : 300);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "poison2e"))
				{
					__result.ResistModified3 = (DamageType)1;
					__result.ResistModifiedPercentagePerStack3 = (flag ? (-0.3f) : (-0.2f));
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "poison2f", CustomFunctions.AppliesTo.Monsters))
				{
					__result.DamageTypeWhenConsumed = (DamageType)9;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "decay1e"))
				{
					int auraCharges7 = val.GetAuraCharges("decay");
					float num10 = 1f + 0.2f * (float)auraCharges7;
					AuraCurseData obj20 = __result;
					obj20.DamageWhenConsumedPerCharge *= num10;
				}
				break;
			case "bleed":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkbleed2b", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.MaxCharges = 50;
					__result.MaxMadnessCharges = 50;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkbleed2c", CustomFunctions.AppliesTo.Monsters))
				{
					__result.Removable = false;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "bleed2d"))
				{
					__result.MaxMadnessCharges = 300;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "bleed2f", CustomFunctions.AppliesTo.Monsters))
				{
					__result.ResistModified3 = (DamageType)3;
					__result.ResistModifiedPercentagePerStack3 = -0.25f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "decay1f"))
				{
					int auraCharges = val.GetAuraCharges("decay");
					float num = 1f + 0.2f * (float)auraCharges;
					AuraCurseData obj10 = __result;
					obj10.DamageWhenConsumedPerCharge *= num;
				}
				break;
			case "thorns":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "thorns1d", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.Removable = false;
				}
				break;
			case "reinforce":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkreinforce1b", CustomFunctions.AppliesTo.Heroes))
				{
					__result.ResistModifiedValue = 40f;
					__result.ResistModifiedValue2 = 40f;
					__result.ResistModifiedValue3 = 40f;
				}
				break;
			case "block":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "block5b", CustomFunctions.AppliesTo.Heroes))
				{
					__result.MaxMadnessCharges = 600;
				}
				break;
			case "vulnerable":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "crack2i", CustomFunctions.AppliesTo.Monsters))
				{
					int num9 = Mathf.FloorToInt(0.04f * (float)val.GetAuraCharges("crack"));
					AuraCurseData obj18 = __result;
					obj18.MaxCharges += num9;
					AuraCurseData obj19 = __result;
					obj19.MaxMadnessCharges += num9;
				}
				break;
			case "taunt":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "taunt1e", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.GainCharges = true;
					__result.AuraDamageType = (DamageType)10;
					__result.AuraDamageIncreasedPerStack = 1f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "taunt1g", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.ConsumedAtTurn = false;
				}
				break;
			case "rust":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "rust0f", CustomFunctions.AppliesTo.ThisHero))
				{
					AuraCurseData auraCurseData2 = CustomFunctions.GetAuraCurseData("None");
					__result.PreventedAuraCurse = auraCurseData2;
					__result.PreventedAuraCurseStackPerStack = 0;
					__result.RemoveAuraCurse = auraCurseData2;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "rust0e", CustomFunctions.AppliesTo.ThisHero))
				{
					AuraCurseData auraCurseData3 = CustomFunctions.GetAuraCurseData("None");
					__result.PreventedAuraCurse = auraCurseData3;
					__result.PreventedAuraCurseStackPerStack = 0;
					__result.RemoveAuraCurse = auraCurseData3;
					__result = __instance.GlobalAuraCurseModifyResist(__result, (DamageType)1, 0, -5f);
					__result = __instance.GlobalAuraCurseModifyResist(__result, (DamageType)3, 0, -5f);
					__result = __instance.GlobalAuraCurseModifyResist(__result, (DamageType)2, 0, -5f);
				}
				break;
			case "powerful":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "taunt1f", CustomFunctions.AppliesTo.Heroes))
				{
					int auraCharges3 = val.GetAuraCharges("taunt");
					AuraCurseData obj12 = __result;
					obj12.MaxCharges += auraCharges3;
					AuraCurseData obj13 = __result;
					obj13.MaxMadnessCharges += auraCharges3;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "powerful1e", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.AuraDamageIncreasedPercentPerStack = 2f;
					AuraCurseData obj14 = __result;
					int maxCharges = (__result.MaxMadnessCharges = -1);
					obj14.MaxCharges = maxCharges;
				}
				break;
			case "inspire":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "inspire0e", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.AuraDamageType = (DamageType)8;
					__result.AuraDamageType2 = (DamageType)7;
					__result.AuraDamageIncreasedPerStack = 0.5f;
					__result.AuraDamageIncreasedPerStack2 = 0.5f;
				}
				break;
			case "insulate":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkinsulate1b", CustomFunctions.AppliesTo.Heroes))
				{
					__result.ResistModifiedValue = 40f;
					__result.ResistModifiedValue2 = 40f;
					__result.ResistModifiedValue3 = 40f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "insulate1e", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.AuraDamageType = (DamageType)4;
					__result.AuraDamageType2 = (DamageType)5;
					__result.AuraDamageType3 = (DamageType)6;
					__result.AuraDamageIncreasedPercentPerStack = 5f;
					__result.AuraDamageIncreasedPercentPerStack2 = 5f;
					__result.AuraDamageIncreasedPercentPerStack3 = 5f;
					__result.ResistModifiedValue = 15f;
					__result.ResistModifiedValue2 = 15f;
					__result.ResistModifiedValue3 = 15f;
					__result.GainCharges = true;
					__result.MaxCharges = 8;
					__result.MaxMadnessCharges = 8;
				}
				break;
			case "spellsword":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "spellsword1a", CustomFunctions.AppliesTo.Heroes))
				{
					AuraCurseData obj = __result;
					obj.MaxCharges += 2;
					if (__result.MaxMadnessCharges != -1)
					{
						AuraCurseData obj2 = __result;
						obj2.MaxMadnessCharges += 2;
					}
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "spellsword1b", CustomFunctions.AppliesTo.Heroes))
				{
					__result.AuraDamageType = (DamageType)0;
					__result.AuraDamageIncreasedPerStack = 0f;
					__result.IncreasedDirectDamageReceivedPerStack = -2f;
					__result.ChargesMultiplierDescription = 2;
				}
				break;
			case "energize":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "energize1b", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.MaxCharges = 1;
					__result.MaxMadnessCharges = 1;
					__result.CharacterStatModifiedValuePerStack = 2f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "energize1c", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.AuraDamageType = (DamageType)10;
					__result.AuraDamageIncreasedPerStack = 1f;
				}
				break;
			case "burn":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkburn2d", CustomFunctions.AppliesTo.Monsters))
				{
					__result.DoubleDamageIfCursesLessThan = 4;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "scourge0h", CustomFunctions.AppliesTo.Heroes))
				{
					int auraCharges6 = val.GetAuraCharges("scourge");
					float num8 = 0.15f * (float)auraCharges6 + 1f;
					AuraCurseData obj17 = __result;
					obj17.DamageWhenConsumedPerCharge *= num8;
				}
				break;
			case "chill":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "chill2e"))
				{
					__result.ResistModified = (DamageType)5;
					__result.ResistModified2 = (DamageType)7;
					__result.ResistModifiedPercentagePerStack = -0.5f;
					__result.ResistModifiedPercentagePerStack2 = -0.5f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "chill2f", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.CharacterStatChargesMultiplierNeededForOne = 10;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "chill2g", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.CharacterStatChargesMultiplierNeededForOne = 3;
					__result.ResistModified = (DamageType)0;
					__result.ResistModifiedPercentagePerStack = 0f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "insulate1d", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.CharacterStatModified = (CharacterStat)0;
					__result.CharacterStatAbsoluteValuePerStack = 0;
				}
				break;
			case "wet":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "zeal0g") && val.HasEffect("zeal"))
				{
					__result.ResistModified3 = (DamageType)10;
					__result = __instance.GlobalAuraCurseModifyResist(__result, (DamageType)10, 0, 0.5f);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "wet1d"))
				{
					AuraCurseData auraCurseData = CustomFunctions.GetAuraCurseData("None");
					__result.PreventedAuraCurse = auraCurseData;
					__result.PreventedAuraCurseStackPerStack = 0;
					__result.RemoveAuraCurse = auraCurseData;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "rust0bd", CustomFunctions.AppliesTo.Monsters))
				{
					AuraCurseData obj4 = __result;
					obj4.IncreasedDirectDamageReceivedPerStack *= 2.25f;
					AuraCurseData obj5 = __result;
					obj5.IncreasedDirectDamageReceivedPerStack2 *= 2.25f;
					AuraCurseData obj6 = __result;
					obj6.ResistModifiedPercentagePerStack *= 2.25f;
					AuraCurseData obj7 = __result;
					obj7.ResistModifiedPercentagePerStack2 *= 2.25f;
					AuraCurseData obj8 = __result;
					obj8.ResistModifiedPercentagePerStack3 *= 2.25f;
				}
				break;
			case "spark":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "spark2d", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.AuraDamageType = (DamageType)6;
					__result.AuraDamageIncreasedPerStack = 1f;
					__result.ChargesAuxNeedForOne1 = 5f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "spark2e", CustomFunctions.AppliesTo.Monsters))
				{
					__result.DamageTypeWhenConsumed = (DamageType)4;
					__result.ResistModified = (DamageType)6;
					__result.ResistModified2 = (DamageType)4;
					__result.ResistModifiedPercentagePerStack = -0.5f;
					__result.ResistModifiedPercentagePerStack2 = -0.5f;
				}
				break;
			case "shield":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "shield5b"))
				{
					__result.MaxMadnessCharges = 300;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "shield5d", CustomFunctions.AppliesTo.Heroes))
				{
					__result.AuraDamageType = (DamageType)8;
					__result.AuraDamageIncreasedPerStack = 0.2f;
				}
				break;
			case "regeneration":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "regeneration1d", CustomFunctions.AppliesTo.Heroes))
				{
					__result.PreventedAuraCurse = CustomFunctions.GetAuraCurseData("vulnerable");
					__result.PreventedAuraCurseStackPerStack = 1;
				}
				break;
			case "dark":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkdark2b", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.Removable = false;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "dark2e"))
				{
					__result.DamageTypeWhenConsumed = (DamageType)4;
					__result.ResistModified2 = (DamageType)4;
					__result.ResistModifiedPercentagePerStack2 = -0.5f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "sanctify2d"))
				{
					int auraCharges4 = val.GetAuraCharges("sanctify");
					AuraCurseData obj15 = __result;
					obj15.ExplodeAtStacks += Mathf.FloorToInt(0.2f * (float)auraCharges4);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "burn2e"))
				{
					int auraCharges5 = val.GetAuraCharges("burn");
					float num7 = 1f + 0.05f * (float)auraCharges5;
					AuraCurseData obj16 = __result;
					obj16.DamageWhenConsumedPerCharge *= num7;
				}
				break;
			case "decay":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "decay1d"))
				{
					__result.RemoveAuraCurse = CustomFunctions.GetAuraCurseData("insulate");
				}
				break;
			case "courage":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "mainperkcourage1b", CustomFunctions.AppliesTo.Heroes))
				{
					__result.ResistModifiedValue = 40f;
					__result.ResistModifiedValue2 = 40f;
					__result.ResistModifiedValue3 = 40f;
				}
				break;
			case "zeal":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "zeal0d", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.AuraDamageType = (DamageType)10;
					__result.AuraDamageIncreasedPercent = Mathf.RoundToInt(1.5f * (float)val.GetAuraCharges("bleed"));
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "zeal0i", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.GainCharges = true;
					__result.ResistModified = (DamageType)0;
					__result.ResistModifiedPercentagePerStack = 0f;
					__result.GainAuraCurseConsumption = CustomFunctions.GetAuraCurseData("burn");
					__result.GainAuraCurseConsumptionPerCharge = 5;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "zeal0f", CustomFunctions.AppliesTo.Heroes))
				{
					__result.CharacterStatModified = (CharacterStat)2;
					__result.CharacterStatModifiedValuePerStack = 2f;
				}
				break;
			case "scourge":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "scourge0e"))
				{
					__result.ConsumeAll = false;
					__result.AuraConsumed = ((!CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Trait, "moontouchedtrait4a")) ? 3 : 0);
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "scourge0f", CustomFunctions.AppliesTo.Monsters))
				{
					__result.GainCharges = true;
					__result.ResistModified2 = (DamageType)10;
					__result.ResistModifiedPercentagePerStack2 = 3f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "scourge0g"))
				{
					__result.ConsumedDamageChargesBasedOnACCharges = CustomFunctions.GetAuraCurseData("sight");
					__result.DamageWhenConsumedPerCharge = 2f;
				}
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "scourge0j") && val.GetCurseList().Count <= 2)
				{
					AuraCurseData obj3 = __result;
					obj3.DamageWhenConsumedPerCharge *= 4f;
				}
				break;
			case "weak":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "weak1c", CustomFunctions.AppliesTo.Monsters))
				{
					__result.Preventable = false;
					__result.AuraDamageIncreasedPercent = -20;
					__result.HealDonePercent = -20;
				}
				break;
			case "vitality":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "vitality1d", CustomFunctions.AppliesTo.ThisHero))
				{
					__result.RemoveAuraCurse = CustomFunctions.GetAuraCurseData("poison");
				}
				break;
			case "bless":
				if (CustomFunctions.IfCharacterHas(val, CustomFunctions.CharacterHas.Perk, "bless1d", CustomFunctions.AppliesTo.Heroes))
				{
					__result.AuraDamageType = (DamageType)1;
					__result.AuraDamageType2 = (DamageType)4;
					__result.AuraDamageType3 = (DamageType)8;
					__result.AuraDamageIncreasedPercentPerStack = 3f;
					__result.AuraDamageIncreasedPercentPerStack2 = 3f;
					__result.AuraDamageIncreasedPercentPerStack3 = 3f;
					__result.AuraDamageIncreasedPerStack = 0f;
				}
				break;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GetTraitAuraCurseModifiers")]
		public static void GetTraitAuraCurseModifiersPostfix(ref Character __instance, ref Dictionary<string, int> __result)
		{
			string text = Plugin.perkBase + "sharp1f";
			if (CustomFunctions.IsLivingHero(__instance) && AtOManager.Instance.CharacterHavePerk(__instance.SubclassName, text))
			{
				Plugin.LogDebug("Executing Perk " + text);
				int num = __instance.EffectCharges("sharp");
				int num2 = Mathf.FloorToInt((float)num * 0.125f);
				if (num2 != 0)
				{
					__result["bleed"] = num2;
				}
			}
		}
	}
	[HarmonyPatch]
	public class PerkRewrites
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Functions), "GetCardByRarity")]
		public static bool GetCardByRarityPrefix(ref string __result, int rarity, CardData _cardData, bool isChallenge = false)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Invalid comparison between Unknown and I4
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Invalid comparison between Unknown and I4
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Invalid comparison between Unknown and I4
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Invalid comparison between Unknown and I4
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Invalid comparison between Unknown and I4
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			int num = 78;
			int num2 = 88;
			int num3 = 98;
			int num4 = 0;
			if (!GameManager.Instance.IsObeliskChallenge())
			{
				num4 = AtOManager.Instance.GetMadnessDifficulty();
				if (num4 > 0)
				{
					num = 75;
					num2 = 85;
					num3 = 95;
				}
			}
			else
			{
				num4 = AtOManager.Instance.GetObeliskMadness();
			}
			if (AtOManager.Instance.TeamHavePerk(Plugin.perkBase + "shards5c"))
			{
				int num5 = 2;
				num -= num5;
				num2 -= num5;
				num3 -= num5;
			}
			if (num4 > 0)
			{
				num -= num4;
				num2 -= Functions.FuncRoundToInt((float)num4 * 0.5f);
			}
			if (rarity < num)
			{
				__result = (((int)_cardData.CardUpgraded == 0 || !(_cardData.UpgradedFrom != "")) ? _cardData.Id.ToLower() : _cardData.UpgradedFrom.ToLower());
				return false;
			}
			if (rarity >= num && rarity < num2)
			{
				if ((int)_cardData.CardUpgraded == 1)
				{
					__result = _cardData.Id.ToLower();
					return false;
				}
				if ((int)_cardData.CardUpgraded == 0)
				{
					__result = _cardData.UpgradesTo1.ToLower();
					return false;
				}
				if ((int)_cardData.CardUpgraded == 2)
				{
					__result = (_cardData.UpgradedFrom + "A").ToLower();
					return false;
				}
			}
			else
			{
				if (rarity >= num2 && rarity < num3)
				{
					if ((int)_cardData.CardUpgraded == 2)
					{
						__result = _cardData.Id.ToLower();
						return false;
					}
					__result = (((int)_cardData.CardUpgraded == 0) ? _cardData.UpgradesTo2.ToLower() : (_cardData.UpgradedFrom + "B").ToLower());
					return false;
				}
				if ((int)_cardData.CardUpgraded == 0)
				{
					__result = (((Object)(object)_cardData.UpgradesToRare != (Object)null) ? _cardData.UpgradesToRare.Id.ToLower() : _cardData.Id.ToLower());
					return false;
				}
				CardData cardData = Globals.Instance.GetCardData(_cardData.UpgradedFrom, false);
				if ((Object)(object)cardData != (Object)null && (Object)(object)cardData.UpgradesToRare != (Object)null)
				{
					__result = cardData.UpgradesToRare.Id.ToLower();
					return false;
				}
			}
			__result = _cardData.Id.ToLower();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "BonusResists")]
		public static bool BonusResistsPrefix(ref Character __instance, ref int __result, DamageType damageType, string acId = "", bool countChargesConsumedPre = false, bool countChargesConsumedPost = false)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0007: 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)
			//IL_0033: Expected I4, but got Unknown
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			switch (damageType - 1)
			{
			case 0:
				if (__instance.IsImmune((DamageType)1))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistSlashing").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("reinforcedmonsters"))
				{
					num += 10;
				}
				break;
			case 1:
				if (__instance.IsImmune((DamageType)2))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistBlunt").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("reinforcedmonsters"))
				{
					num += 10;
				}
				break;
			case 2:
				if (__instance.IsImmune((DamageType)3))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistPiercing").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("reinforcedmonsters"))
				{
					num += 10;
				}
				break;
			case 3:
				if (__instance.IsImmune((DamageType)4))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistFire").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("elementalmonsters"))
				{
					num += 10;
				}
				break;
			case 4:
				if (__instance.IsImmune((DamageType)5))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistCold").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("elementalmonsters"))
				{
					num += 10;
				}
				break;
			case 5:
				if (__instance.IsImmune((DamageType)6))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistLightning").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("elementalmonsters"))
				{
					num += 10;
				}
				break;
			case 6:
				if (__instance.IsImmune((DamageType)7))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistMind").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("spiritualmonsters"))
				{
					num += 10;
				}
				break;
			case 7:
				if (__instance.IsImmune((DamageType)8))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistHoly").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("spiritualmonsters"))
				{
					num += 10;
				}
				break;
			case 8:
				if (__instance.IsImmune((DamageType)9))
				{
					num = 1000;
					break;
				}
				num += Traverse.Create((object)__instance).Field("resistShadow").GetValue<int>();
				if (!__instance.IsHero && AtOManager.Instance.IsChallengeTraitActive("spiritualmonsters"))
				{
					num += 10;
				}
				break;
			}
			if (num < 1000)
			{
				if (!__instance.IsHero)
				{
					if (MadnessManager.Instance.IsMadnessTraitActive("resistantmonsters") || AtOManager.Instance.IsChallengeTraitActive("resistantmonsters"))
					{
						num += 10;
					}
					if (AtOManager.Instance.IsChallengeTraitAct