Decompiled source of OwlsGrimoire v1.0.0

BepInEx/plugins/OwlsGrimoire/OwlsGrimoire.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BlackMagicAPI.Enums;
using BlackMagicAPI.Managers;
using BlackMagicAPI.Modules.Spells;
using OwlsGrimoire.Spells;
using Steamworks;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BG3Spells")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BG3Spells")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ef521a3-d3a7-4513-9853-d37ec2ad19d1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace OwlsGrimoire
{
	[BepInPlugin("com.owls8.owlsgrimoire", "owlsgrimoire", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class OwlsGrimoirePlugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> VampiricTouchCfg;

		private ConfigEntry<bool> ChainLightningCfg;

		private void Awake()
		{
			VampiricTouchCfg = ((BaseUnityPlugin)this).Config.Bind<bool>("Spells", "VampiricTouch", true, "Vampiric Touch Spell");
			if (VampiricTouchCfg.Value)
			{
				LoadVampiricTouchAssets();
				BlackMagicManager.RegisterSpell((BaseUnityPlugin)(object)this, typeof(VampiricTouchData), typeof(VampiricTouchLogic));
			}
			ChainLightningCfg = ((BaseUnityPlugin)this).Config.Bind<bool>("Spells", "ChainLightning", true, "Chain Lightning Spell");
			if (ChainLightningCfg.Value)
			{
				LoadChainLightningAssets();
				BlackMagicManager.RegisterSpell((BaseUnityPlugin)(object)this, typeof(ChainLightningData), typeof(ChainLightningLogic));
			}
		}

		public void LoadVampiricTouchAssets()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string text = Path.Combine(directoryName, "Assets", "vampire");
				if (File.Exists(text))
				{
					VampiricTouchData.vampiricTouchBundle = AssetBundle.LoadFromFile(text);
					if ((Object)(object)VampiricTouchData.vampiricTouchBundle != (Object)null)
					{
						VampiricTouchData.vampireSound = VampiricTouchData.vampiricTouchBundle.LoadAsset<AudioClip>("vampireSFX");
						if ((Object)(object)VampiricTouchData.vampireSound == (Object)null)
						{
							Debug.LogWarning((object)"[VampiricTouch] Could not find 'vampireSFX' audio clip in AssetBundle");
						}
						VampiricTouchData.vampireVFX = VampiricTouchData.vampiricTouchBundle.LoadAsset<GameObject>("VampireVFX");
						if ((Object)(object)VampiricTouchData.vampireVFX == (Object)null)
						{
							Debug.LogWarning((object)"[VampiricTouch] Could not find 'Vampire' prefab in AssetBundle");
						}
					}
					else
					{
						Debug.LogError((object)"[VampiricTouch] Failed to load AssetBundle");
					}
				}
				else
				{
					Debug.LogError((object)("[VampiricTouch] AssetBundle file does not exist at path: " + text));
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[VampiricTouch] Error loading AssetBundle: " + ex.Message));
			}
		}

		public void LoadChainLightningAssets()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string text = Path.Combine(directoryName, "Assets", "chainlightning");
				if (File.Exists(text))
				{
					ChainLightningData.chainLightningBundle = AssetBundle.LoadFromFile(text);
					if ((Object)(object)ChainLightningData.chainLightningBundle != (Object)null)
					{
						ChainLightningData.chainLightningSound = ChainLightningData.chainLightningBundle.LoadAsset<AudioClip>("lightningSFX");
						if ((Object)(object)ChainLightningData.chainLightningSound == (Object)null)
						{
							Debug.LogWarning((object)"[ChainLightning] Could not find audio clip in AssetBundle");
						}
						ChainLightningData.chainLightningVFX = ChainLightningData.chainLightningBundle.LoadAsset<GameObject>("LightningLine");
						if ((Object)(object)ChainLightningData.chainLightningVFX == (Object)null)
						{
							Debug.LogWarning((object)"[ChainLightning] Could not find VFX prefab in AssetBundle");
						}
						ChainLightningData.chainLightningHitFX = ChainLightningData.chainLightningBundle.LoadAsset<GameObject>("LightningHit");
						if ((Object)(object)ChainLightningData.chainLightningHitFX == (Object)null)
						{
							Debug.LogWarning((object)"[ChainLightning] Could not find HitVFX prefab in AssetBundle");
						}
					}
					else
					{
						Debug.LogError((object)"[ChainLightning] Failed to load AssetBundle");
					}
				}
				else
				{
					Debug.LogError((object)("[ChainLightning] AssetBundle file does not exist at path: " + text));
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChainLightning] Error loading AssetBundle: " + ex.Message));
			}
		}
	}
}
namespace OwlsGrimoire.Spells
{
	internal class ChainLightningData : SpellData
	{
		public static AssetBundle chainLightningBundle;

		public static AudioClip chainLightningSound;

		public static GameObject chainLightningVFX;

		public static GameObject chainLightningHitFX;

		public override SpellType SpellType => (SpellType)0;

		public override string Name => "Chain Lightning";

		public override float Cooldown => 3f;

		public override Color GlowColor => Color.blue;

		public override bool DebugForceSpawn => true;
	}
	internal class ChainLightningLogic : SpellLogic
	{
		[CompilerGenerated]
		private sealed class <ChainLightningEffect>d__2 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject victim;

			public int castingLevel;

			private PlayerMovement <victimMovement>5__1;

			private GameObject[] <allPlayers>5__2;

			private GameObject[] <>s__3;

			private int <>s__4;

			private GameObject <targetPlayer>5__5;

			private PlayerMovement <targetPlayerMovement>5__6;

			private float <distanceToTarget>5__7;

			private Exception <e>5__8;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ChainLightningEffect>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<victimMovement>5__1 = null;
				<allPlayers>5__2 = null;
				<>s__3 = null;
				<targetPlayer>5__5 = null;
				<targetPlayerMovement>5__6 = null;
				<e>5__8 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0266: Unknown result type (might be due to invalid IL or missing references)
				//IL_0270: Expected O, but got Unknown
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<victimMovement>5__1 = victim.GetComponent<PlayerMovement>();
					<allPlayers>5__2 = GameObject.FindGameObjectsWithTag("Player");
					<victimMovement>5__1.NonRpcDamagePlayer(35f + (float)(castingLevel * 7 / 2), (GameObject)null, "chainlightning");
					PlayChainLightningSFX(victim.transform.position);
					<>s__3 = <allPlayers>5__2;
					for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
					{
						<targetPlayer>5__5 = <>s__3[<>s__4];
						Debug.LogWarning((object)"iterating target players");
						if ((Object)(object)<targetPlayer>5__5 != (Object)null)
						{
							Debug.LogWarning((object)"target player not null");
							<targetPlayerMovement>5__6 = <targetPlayer>5__5.GetComponent<PlayerMovement>();
							<distanceToTarget>5__7 = Vector3.Distance(victim.transform.position, <targetPlayer>5__5.transform.position);
							if (<distanceToTarget>5__7 < 15f && (Object)(object)<targetPlayerMovement>5__6 != (Object)null)
							{
								if (!affectedPlayers[<targetPlayerMovement>5__6])
								{
									Debug.LogWarning((object)"player is close enough to a valid target");
									if (<targetPlayerMovement>5__6.playerTeam == <victimMovement>5__1.playerTeam)
									{
										affectedPlayers[<targetPlayerMovement>5__6] = true;
										try
										{
											PlayChainLightningVFX(victim, <targetPlayer>5__5);
										}
										catch (Exception ex)
										{
											<e>5__8 = ex;
											Debug.LogError((object)("[ChainLightning] Error playing VFX: " + <e>5__8.Message));
										}
										((MonoBehaviour)<targetPlayerMovement>5__6).StartCoroutine(ChainLightningEffect(<targetPlayer>5__5, castingLevel));
									}
								}
								else
								{
									Debug.LogWarning((object)"player is already being hit");
								}
							}
							else
							{
								Debug.LogWarning((object)"Target is too far or doesn't exist");
							}
							<targetPlayerMovement>5__6 = null;
						}
						Debug.LogWarning((object)"Finished an iteration");
						<targetPlayer>5__5 = null;
					}
					<>s__3 = null;
					Debug.LogWarning((object)"Waiting time");
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Debug.LogWarning((object)"Setting to unaffected");
					affectedPlayers[<victimMovement>5__1] = false;
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static Dictionary<PlayerMovement, bool> affectedPlayers = new Dictionary<PlayerMovement, bool>();

		public override void CastSpell(GameObject playerObj, PageController page, Vector3 spawnPos, Vector3 viewDirectionVector, int castingLevel)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			PlayerMovement component = playerObj.GetComponent<PlayerMovement>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			GameObject[] array = GameObject.FindGameObjectsWithTag("Player");
			Vector3 position = playerObj.transform.position;
			Vector3 forward = playerObj.transform.forward;
			string personaName = SteamFriends.GetPersonaName();
			PlayerMovement val = null;
			PlayerMovement[] array2 = Object.FindObjectsByType<PlayerMovement>((FindObjectsSortMode)0);
			PlayerMovement[] array3 = array2;
			foreach (PlayerMovement val2 in array3)
			{
				if (val2.playername == personaName)
				{
					val = val2;
					break;
				}
			}
			PlayerMovement[] array4 = array2;
			foreach (PlayerMovement key in array4)
			{
				affectedPlayers[key] = false;
			}
			GameObject val3 = null;
			float num = float.MaxValue;
			PlayerMovement val4 = null;
			GameObject[] array5 = array;
			RaycastHit val10 = default(RaycastHit);
			foreach (GameObject val5 in array5)
			{
				if ((Object)(object)val5 == (Object)(object)playerObj)
				{
					continue;
				}
				Vector3 val6 = val5.transform.position - position;
				Vector3 normalized = ((Vector3)(ref val6)).normalized;
				float num2 = Vector3.Distance(position, val5.transform.position);
				if (!(num2 <= 30f))
				{
					continue;
				}
				float num3 = Vector3.Angle(forward, normalized);
				if (!(num3 <= 45f))
				{
					continue;
				}
				PlayerMovement component2 = val5.GetComponent<PlayerMovement>();
				if ((Object)(object)component2 != (Object)null && component.playerTeam == component2.playerTeam)
				{
					continue;
				}
				Vector3 val7 = position + Vector3.up * 1.5f;
				Vector3 val8 = val5.transform.position + Vector3.up * 1.5f;
				val6 = val8 - val7;
				Vector3 normalized2 = ((Vector3)(ref val6)).normalized;
				float num4 = Vector3.Distance(val7, val8);
				int num5 = ~(1 << LayerMask.NameToLayer("Player"));
				float[] array6 = new float[3] { -5f, 0f, 5f };
				bool flag = false;
				for (int l = 0; l < array6.Length; l++)
				{
					Vector3 val9 = Quaternion.Euler(0f, array6[l], 0f) * normalized2;
					if (!Physics.Raycast(val7, val9, ref val10, num4, num5))
					{
						flag = true;
						break;
					}
				}
				if (flag && (Object)(object)component2 != (Object)null && (!((Object)(object)val != (Object)null) || !((Object)(object)component2 == (Object)(object)val) || !affectedPlayers.ContainsKey(component2) || !affectedPlayers[component2]))
				{
					float num6 = Vector3.Angle(forward, normalized);
					float num7 = num6 * 2f + num2;
					if (num7 < num)
					{
						val3 = val5;
						num = num7;
						val4 = component2;
					}
				}
			}
			if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
			{
				affectedPlayers[val4] = true;
				((MonoBehaviour)val4).StartCoroutine(ChainLightningEffect(val3, castingLevel));
				PlayChainLightningVFX(playerObj, val3);
			}
		}

		[IteratorStateMachine(typeof(<ChainLightningEffect>d__2))]
		public static IEnumerator ChainLightningEffect(GameObject victim, int castingLevel)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ChainLightningEffect>d__2(0)
			{
				victim = victim,
				castingLevel = castingLevel
			};
		}

		private static void PlayChainLightningVFX(GameObject start, GameObject end)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			GameObject chainLightningVFX = ChainLightningData.chainLightningVFX;
			GameObject val = Object.Instantiate<GameObject>(chainLightningVFX, start.transform.position, Quaternion.identity);
			val.SetActive(true);
			LineRenderer component = val.GetComponent<LineRenderer>();
			((Renderer)component).enabled = true;
			component.positionCount = 2;
			component.startWidth = 1f;
			component.endWidth = 1f;
			component.useWorldSpace = true;
			component.SetPosition(0, start.transform.position + Vector3.up * 2f);
			component.SetPosition(1, end.transform.position + Vector3.up * 2f);
			Debug.LogWarning((object)"SPAWNED VFX from VICTIM TO VICTIM");
			GameObject val2 = Object.Instantiate<GameObject>(ChainLightningData.chainLightningHitFX, start.transform.position + Vector3.up * 2f, Quaternion.identity);
			val2.SetActive(true);
			Debug.LogWarning((object)"SPawned HIT FX");
			float num = 0f;
			float num2;
			for (num2 = 0.6f; num < num2; num += Time.deltaTime)
			{
				component.SetPosition(0, start.transform.position + Vector3.up * 2f);
				component.SetPosition(1, end.transform.position + Vector3.up * 2f);
			}
			Object.Destroy((Object)(object)val, num2);
			Object.Destroy((Object)(object)val2, 2.4f);
		}

		private static void PlayChainLightningSFX(Vector3 position)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)ChainLightningData.chainLightningSound != (Object)null)
				{
					GameObject val = new GameObject("ChainLightningAudio");
					val.transform.position = position;
					AudioSource val2 = val.AddComponent<AudioSource>();
					val2.clip = ChainLightningData.chainLightningSound;
					val2.volume = 0.8f;
					val2.spatialBlend = 1f;
					val2.rolloffMode = (AudioRolloffMode)1;
					val2.minDistance = 5f;
					val2.maxDistance = 50f;
					val2.Play();
					float num = ChainLightningData.chainLightningSound.length + 0.1f;
					Object.Destroy((Object)(object)val, num);
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ChainLightning] Error playing sound: " + ex.Message));
			}
		}
	}
	internal class VampiricTouchData : SpellData
	{
		public static AssetBundle vampiricTouchBundle;

		public static AudioClip vampireSound;

		public static GameObject vampireVFX;

		public override SpellType SpellType => (SpellType)0;

		public override string Name => "Touch";

		public override float Cooldown => 12f;

		public override Color GlowColor => Color.green;
	}
	internal class VampiricTouchLogic : SpellLogic
	{
		public override void CastSpell(GameObject playerObj, PageController page, Vector3 spawnPos, Vector3 viewDirectionVector, int castingLevel)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			PlayerMovement component = playerObj.GetComponent<PlayerMovement>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			GameObject[] array = GameObject.FindGameObjectsWithTag("Player");
			Vector3 position = playerObj.transform.position;
			Vector3 forward = playerObj.transform.forward;
			string personaName = SteamFriends.GetPersonaName();
			PlayerMovement val = null;
			PlayerMovement[] array2 = Object.FindObjectsByType<PlayerMovement>((FindObjectsSortMode)0);
			PlayerMovement[] array3 = array2;
			foreach (PlayerMovement val2 in array3)
			{
				if (val2.playername == personaName)
				{
					val = val2;
					break;
				}
			}
			GameObject val3 = null;
			float num = float.MaxValue;
			PlayerMovement val4 = null;
			GameObject[] array4 = array;
			foreach (GameObject val5 in array4)
			{
				if ((Object)(object)val5 == (Object)(object)playerObj)
				{
					continue;
				}
				Vector3 val6 = val5.transform.position - position;
				Vector3 normalized = ((Vector3)(ref val6)).normalized;
				float num2 = Vector3.Distance(position, val5.transform.position);
				if (!(num2 <= 3f))
				{
					continue;
				}
				float num3 = Vector3.Angle(forward, normalized);
				if (!(num3 <= 45f))
				{
					continue;
				}
				PlayerMovement component2 = val5.GetComponent<PlayerMovement>();
				if ((Object)(object)component2 != (Object)null && component.playerTeam == component2.playerTeam)
				{
					continue;
				}
				Vector3 val7 = position + Vector3.up * 1.5f;
				Vector3 val8 = val5.transform.position + Vector3.up * 1.5f;
				val6 = val8 - val7;
				Vector3 normalized2 = ((Vector3)(ref val6)).normalized;
				if ((Object)(object)component2 != (Object)null)
				{
					if (!((Object)(object)val != (Object)null) || (Object)(object)component2 == (Object)(object)val)
					{
					}
					float num4 = Vector3.Angle(forward, normalized);
					float num5 = num4 * 2f + num2;
					if (num5 < num)
					{
						val3 = val5;
						num = num5;
						val4 = component2;
					}
				}
			}
			if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
			{
				val4.NonRpcDamagePlayer(15f + (float)(castingLevel * 5), (GameObject)null, "vampirictouch");
				playerObj.GetComponent<PlayerMovement>().nonnetworkedheal(25f + (float)(castingLevel * 5));
				PlayVampiricTouchVFX(val4);
				PlayVampiricTouchSFX(val3.transform.position);
			}
		}

		private static void PlayVampiricTouchVFX(PlayerMovement victim)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)VampiricTouchData.vampireVFX == (Object)null)
			{
				Debug.LogWarning((object)"Vampire VFX prefab is null.");
				return;
			}
			Vector3 val = ((Component)victim).transform.position + Vector3.up * 1.5f;
			GameObject val2 = Object.Instantiate<GameObject>(VampiricTouchData.vampireVFX, val, Quaternion.identity);
			val2.SetActive(true);
			val2.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
			Object.Destroy((Object)(object)val2, 2f);
		}

		private static void PlayVampiricTouchSFX(Vector3 position)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)VampiricTouchData.vampireSound != (Object)null)
				{
					GameObject val = new GameObject("VampiricTouchAudio");
					val.transform.position = position;
					AudioSource val2 = val.AddComponent<AudioSource>();
					val2.clip = VampiricTouchData.vampireSound;
					val2.volume = 0.8f;
					val2.spatialBlend = 1f;
					val2.rolloffMode = (AudioRolloffMode)1;
					val2.minDistance = 5f;
					val2.maxDistance = 50f;
					val2.Play();
					float num = VampiricTouchData.vampireSound.length + 0.1f;
					Object.Destroy((Object)(object)val, num);
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[VampiricTouch] Error playing sound: " + ex.Message));
			}
		}
	}
}