using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("JefesValheim")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("JefesValheim")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e216b55d-0d34-4f2d-9443-dd77c6b0396b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace NeckzillaBossMod { [BepInPlugin("com.yournick.valheim.neckzilla", "Neckzilla Boss", "1.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MainPlugin : BaseUnityPlugin { public class NoFleeRefresher : MonoBehaviour { private BaseAI _ai; private float _t; private void Start() { _ai = ((Component)this).GetComponent(); Apply(); } private void Update() { _t += Time.deltaTime; if (_t >= 3f) { _t = 0f; Apply(); } } private void Apply() { if (Object.op_Implicit((Object)(object)_ai)) { TrySetField(_ai, "m_afraidOfFire", value: false); TrySetField(_ai, "m_avoidFire", value: false); TrySetField(_ai, "m_fleeIfHurt", value: false); TrySetField(_ai, "m_backoffOnLowHP", value: false); TrySetField(_ai, "m_avoidPlayer", value: false); TrySetField(_ai, "m_avoidWater", value: false); TrySetField(_ai, "m_afraidOfFireRange", 0f); TrySetField(_ai, "m_avoidFireDistance", 0f); TrySetField(_ai, "m_avoidPlayerDistance", 0f); TrySetField(_ai, "m_avoidWaterDistance", 0f); ForceNoFleeFlags(_ai); } } } [HarmonyPatch(typeof(Character), "Stagger")] public static class Patch_Neckzilla_NoStagger_NoArg { private static bool Prefix(Character __instance) { try { if (Object.op_Implicit((Object)(object)__instance) && __instance.m_name == "Neckzilla") { TrySetField(__instance, "m_staggerDamage", 0f); TrySetField(__instance, "m_staggerTimer", 0f); return false; } } catch { } return true; } } [HarmonyPatch(typeof(Character), "Stagger", new Type[] { typeof(Vector3) })] public static class Patch_Neckzilla_NoStagger_WithDir { private static bool Prefix(Character __instance, Vector3 __0) { try { if (Object.op_Implicit((Object)(object)__instance) && __instance.m_name == "Neckzilla") { TrySetField(__instance, "m_staggerDamage", 0f); TrySetField(__instance, "m_staggerTimer", 0f); return false; } } catch { } return true; } } [HarmonyPatch(typeof(Character), "Damage")] public static class Patch_Neckzilla_InvulnerableDuringPhase2 { private static bool Prefix(Character __instance, HitData hit) { try { if (Object.op_Implicit((Object)(object)__instance) && __instance.m_name == "Neckzilla") { if (((DamageTypes)(ref hit.m_damage)).GetTotalDamage() >= 9999f) { return true; } NeckzillaPhase2 component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && component.IsActive) { return false; } if ((Object)(object)component != (Object)null && component.IsFinalWindup) { return false; } if ((Object)(object)hit.GetAttacker() == (Object)null) { return false; } } } catch { } return true; } } public class KeepFireImmunity : MonoBehaviour { private Character _self; private SEMan _seman; private float _t; private void Start() { _self = ((Component)this).GetComponent(); _seman = ((Component)this).GetComponent(); MakeFireImmune(_self); } private void Update() { _t += Time.deltaTime; if (!(_t >= 2f)) { return; } _t = 0f; MakeFireImmune(_self); try { if (_seman == null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (!(typeof(SEMan).GetField("m_statusEffects", bindingAttr)?.GetValue(_seman) is IList list) || list.Count == 0) { return; } List list2 = new List(); foreach (object item in list) { if (item != null) { string text = item.GetType().Name.ToLowerInvariant(); FieldInfo field = item.GetType().GetField("m_name", bindingAttr); string text2 = ((field != null) ? (field.GetValue(item) as string) : null)?.ToLowerInvariant() ?? ""; if (text.Contains("burn") || text2.Contains("burn")) { list2.Add(item); } } } if (list2.Count <= 0) { return; } MethodInfo method = typeof(SEMan).GetMethod("RemoveStatusEffect", bindingAttr, null, new Type[1] { typeof(int) }, null); foreach (object item2 in list2) { FieldInfo field2 = item2.GetType().GetField("m_nameHash", bindingAttr); if (method != null && field2 != null) { int num = (int)field2.GetValue(item2); method.Invoke(_seman, new object[1] { num }); } else { item2.GetType().GetMethod("Stop", bindingAttr)?.Invoke(item2, new object[1] { _seman }); } } } catch { } } } [HarmonyPatch(typeof(Character), "Damage")] public static class Patch_Neckzilla_BiteDamage { private static void Prefix(Character __instance, ref HitData hit) { if (hit == null) { return; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null || attacker.m_name != "Neckzilla") { return; } float pierce = hit.m_damage.m_pierce; float slash = hit.m_damage.m_slash; float num = pierce + slash; if (!(num <= 0.0001f)) { if (BITE_BASE > 0f) { float num2 = BITE_BASE / num; hit.m_damage.m_pierce = pierce * num2; hit.m_damage.m_slash = slash * num2; } else if (BITE_MULT != 1f) { hit.m_damage.m_pierce *= BITE_MULT; hit.m_damage.m_slash *= BITE_MULT; } } } } [HarmonyPatch(typeof(Character), "Damage")] public static class Patch_Neckzilla_LavaFireDamage { private static void Prefix(Character __instance, ref HitData hit) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (!(__instance is Player) || hit == null || hit.m_damage.m_fire <= 0f) { return; } float lAVA_FIRE_MULT = LAVA_FIRE_MULT; if (Mathf.Approximately(lAVA_FIRE_MULT, 1f)) { return; } bool flag = false; List list = new List(); try { Character.GetCharactersInRange(((Component)__instance).transform.position, 60f, list); } catch { } for (int i = 0; i < list.Count; i++) { Character val = list[i]; if (!((Object)(object)val == (Object)null) && !(val.m_name != "Neckzilla")) { NeckzillaLavaField component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && component.IsActive) { flag = true; break; } } } if (flag) { hit.m_damage.m_fire *= lAVA_FIRE_MULT; } } } [HarmonyPatch(typeof(Character), "SetLevel")] public static class Patch_Neckzilla_NoStars { private static bool Prefix(Character __instance, int level) { if (level > 1 && __instance.m_name == "Neckzilla") { return false; } return true; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__93_36; public static Action <>9__95_0; public static Action <>9__95_1; internal void b__93_36(ConsoleEventArgs _) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) GameObject prefab = PrefabManager.Instance.GetPrefab("Boss_Neckzilla"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"Prefab no disponible aún."); return; } Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer)) { Vector3 val = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 5f; Quaternion val2 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); Object.Instantiate(prefab, val, val2); } } internal void b__95_0(AudioClip c) { RoarClip = c; } internal void b__95_1(AudioClip c) { MusicClip = c; } } public const string ModGuid = "com.yournick.valheim.neckzilla"; public const string ModName = "Neckzilla Boss"; public const string ModVersion = "1.1.2"; internal static MainPlugin Instance; internal static ManualLogSource Log; private Harmony _harmony; private const string BossPrefabName = "Boss_Neckzilla"; private ConfigEntry _cfgScale; private ConfigEntry _cfgHealth; private ConfigEntry _stompCooldown; private ConfigEntry _stompRange; private ConfigEntry _stompDamage; private ConfigEntry _stompPush; private ConfigEntry _stompFxSteps; private ConfigEntry _stompTelegraphSeconds; private ConfigEntry _stompTelegraphFx; private ConfigEntry _bombCooldown; private ConfigEntry _bombMinRange; private ConfigEntry _bombMaxRange; private ConfigEntry _bombSpeed; private ConfigEntry _bombImpactFire; private ConfigEntry _bombImpactBlunt; private ConfigEntry _bombAoeRadius; private ConfigEntry _phase2ThresholdPct; private ConfigEntry _phase2Duration; private ConfigEntry _phase2AuraRadius; private ConfigEntry _phase2AuraTick; private ConfigEntry _phase2AuraDamage; private ConfigEntry _phase2PlayerStaggerEvery; private ConfigEntry _phase2BossLightningAt; private ConfigEntry _phase2LeviathanDur; private ConfigEntry _phase2BoltPrefab; private ConfigEntry _thunderStrikePrefab; private ConfigEntry _thunderCooldown; private ConfigEntry _thunderDelay; private ConfigEntry _thunderDamage; private ConfigEntry _thunderRadius; private ConfigEntry _lavaPrefabName; private ConfigEntry _lavaMinRadius; private ConfigEntry _lavaMaxRadius; private ConfigEntry _lavaInterval; private ConfigEntry _lavaBurst; private ConfigEntry _lavaFireDamageMultiplier; private ConfigEntry _biteBaseDamage; private ConfigEntry _biteDamageMultiplier; internal static string LAVA_PREFAB; internal static float LAVA_RMIN; internal static float LAVA_RMAX; internal static float LAVA_INTERVAL; internal static int LAVA_BURST; internal static float ST_COOLDOWN; internal static float ST_RANGE; internal static float ST_DAMAGE; internal static float ST_PUSH; internal static int ST_FXSTEPS; internal static string ST_FXNAME = "fx_Abomination_attack2"; internal static float P2_THRESHOLD_PCT; internal static float P2_DURATION; internal static float P2_AURA_RADIUS; internal static float P2_AURA_TICK; internal static float P2_AURA_DAMAGE; internal static float P2_STAGGER_EVERY; internal static float THU_COOLDOWN; internal static float THU_DELAY; internal static float THU_DAMAGE; internal static float THU_RADIUS; internal static string THU_STRIKE_PREFAB = "lightningAOE"; internal static float P2_BOSS_LIGHTNING_AT = 17f; internal static float P2_LEVIATHAN_DUR = 27f; internal static string P2_BOLT_PREFAB = "lightningAOE"; internal static float BMB_CD; internal static float BMB_MIN; internal static float BMB_MAX; internal static float BMB_SPEED; internal static float BMB_FIRE; internal static float BMB_BLUNT; internal static float BMB_AOE; internal const string BMB_PROJ_NAME = "DvergerStaffFire_clusterbomb_projectile"; internal static float ST_TELEGRAPH; internal static string ST_TELE_FX; internal static float BITE_BASE; internal static float BITE_MULT; internal static float LAVA_FIRE_MULT; private ConfigEntry _cfgDrop1; private ConfigEntry _cfgDrop2; private ConfigEntry _cfgDrop3; private ConfigEntry _cfgDrop4; private ConfigEntry _cfgDrop5; private ConfigEntry _cfgRoarFile; private ConfigEntry _cfgMusicFile; internal static AudioClip RoarClip; internal static AudioClip MusicClip; private static AudioSource _bossMusic; private static AudioMixerGroup _sfxMixerGroup; internal static bool BossMusicActive; private static readonly List _mutedVanillaSources = new List(); private static Material _charredMatCache; private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Expected O, but got Unknown //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Expected O, but got Unknown //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Expected O, but got Unknown //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Expected O, but got Unknown //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Expected O, but got Unknown //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Expected O, but got Unknown //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Expected O, but got Unknown //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Expected O, but got Unknown //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Expected O, but got Unknown //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Expected O, but got Unknown //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Expected O, but got Unknown //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Expected O, but got Unknown //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Expected O, but got Unknown //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Expected O, but got Unknown //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Expected O, but got Unknown //IL_07a0: Unknown result type (might be due to invalid IL or missing references) //IL_07aa: Expected O, but got Unknown //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Expected O, but got Unknown //IL_0866: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Expected O, but got Unknown //IL_08a4: Unknown result type (might be due to invalid IL or missing references) //IL_08ae: Expected O, but got Unknown //IL_0d6e: Unknown result type (might be due to invalid IL or missing references) //IL_0d5a: Unknown result type (might be due to invalid IL or missing references) //IL_0d5f: Unknown result type (might be due to invalid IL or missing references) //IL_0d65: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogWarning((object)"=== NECKZILLA 1.1.2 AWAKE === Si ves esto, el DLL nuevo esta cargado."); _harmony = new Harmony("com.yournick.valheim.neckzilla"); _harmony.PatchAll(); ApplyMusicManPatches(); _cfgScale = ((BaseUnityPlugin)this).Config.Bind("Neckzilla", "Scale", 3f, "Multiplicador de tamaño (1 = Neck normal)."); _cfgHealth = ((BaseUnityPlugin)this).Config.Bind("Neckzilla", "Health", 2500f, "Vida base de Neckzilla."); _stompCooldown = ((BaseUnityPlugin)this).Config.Bind("Stomp", "Cooldown", 4f, new ConfigDescription("Segundos entre pisotones.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 60f), Array.Empty())); _stompRange = ((BaseUnityPlugin)this).Config.Bind("Stomp", "Range", 8f, new ConfigDescription("Radio del AOE.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 20f), Array.Empty())); _stompDamage = ((BaseUnityPlugin)this).Config.Bind("Stomp", "Damage", 80f, new ConfigDescription("Daño blunt por pisotón.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5000f), Array.Empty())); _stompPush = ((BaseUnityPlugin)this).Config.Bind("Stomp", "PushForce", 40f, new ConfigDescription("Empuje radial.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 200f), Array.Empty())); _stompFxSteps = ((BaseUnityPlugin)this).Config.Bind("Stomp", "FxSteps", 6, new ConfigDescription("Número de FX del anillo.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 12), Array.Empty())); _bombCooldown = ((BaseUnityPlugin)this).Config.Bind("Bombard", "Cooldown", 6f, new ConfigDescription("Segundos entre bombardeos.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 60f), Array.Empty())); _bombMinRange = ((BaseUnityPlugin)this).Config.Bind("Bombard", "MinRange", 10f, new ConfigDescription("Distancia mínima para disparar.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 60f), Array.Empty())); _bombMaxRange = ((BaseUnityPlugin)this).Config.Bind("Bombard", "MaxRange", 35f, new ConfigDescription("Distancia máxima para disparar.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 120f), Array.Empty())); _bombSpeed = ((BaseUnityPlugin)this).Config.Bind("Bombard", "ProjectileSpeed", 10f, new ConfigDescription("Velocidad del proyectil.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 80f), Array.Empty())); _bombImpactFire = ((BaseUnityPlugin)this).Config.Bind("Bombard", "ImpactFire", 30f, new ConfigDescription("Daño de fuego directo al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 500f), Array.Empty())); _bombImpactBlunt = ((BaseUnityPlugin)this).Config.Bind("Bombard", "ImpactBlunt", 60f, new ConfigDescription("Daño blunt directo al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 500f), Array.Empty())); _bombAoeRadius = ((BaseUnityPlugin)this).Config.Bind("Bombard", "ImpactRadius", 3.5f, new ConfigDescription("Radio del daño directo al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 12f), Array.Empty())); _phase2ThresholdPct = ((BaseUnityPlugin)this).Config.Bind("Phase2", "TriggerAtHealthPct", 0.8f, new ConfigDescription("Umbral de activación (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 0.95f), Array.Empty())); _phase2Duration = ((BaseUnityPlugin)this).Config.Bind("Phase2", "Duration", 30f, new ConfigDescription("Duración de la fase 2 en segundos.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 120f), Array.Empty())); _phase2AuraRadius = ((BaseUnityPlugin)this).Config.Bind("Phase2", "AuraRadius", 8f, new ConfigDescription("Radio del aura de daño.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 20f), Array.Empty())); _phase2AuraTick = ((BaseUnityPlugin)this).Config.Bind("Phase2", "AuraTickSeconds", 0.5f, new ConfigDescription("Periodo del tick de aura.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 2f), Array.Empty())); _phase2AuraDamage = ((BaseUnityPlugin)this).Config.Bind("Phase2", "AuraDamageFire", 4f, new ConfigDescription("Daño de fuego por tick del aura.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 200f), Array.Empty())); _phase2PlayerStaggerEvery = ((BaseUnityPlugin)this).Config.Bind("Phase2", "StaggerPlayersEvery", 2f, new ConfigDescription("Cada cuantos segundos se aplica stagger a jugadores.", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 10f), Array.Empty())); _phase2BossLightningAt = ((BaseUnityPlugin)this).Config.Bind("Phase2", "Transformacion_RayoSegundo", 17f, new ConfigDescription("Segundo del faseo en que cae el rayo sobre el boss.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 55f), Array.Empty())); _phase2LeviathanDur = ((BaseUnityPlugin)this).Config.Bind("Phase2", "Transformacion_Duracion", 27f, new ConfigDescription("Duracion del FX leviathan. Al terminar se activan los rayos.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 60f), Array.Empty())); _phase2BoltPrefab = ((BaseUnityPlugin)this).Config.Bind("Phase2", "Transformacion_RayoPrefab", "lightningAOE", "Prefab del rayo que cae sobre el boss durante la transformacion (sin danar al boss)."); _thunderStrikePrefab = ((BaseUnityPlugin)this).Config.Bind("Thunder", "RayoPrefab", "lightningAOE", "Prefab del rayo que cae sobre jugadores."); _thunderCooldown = ((BaseUnityPlugin)this).Config.Bind("Thunder", "Cooldown", 2f, new ConfigDescription("Segundos entre llamadas de trueno. Debe ser menor que (Phase2.Duration - Transformacion_Duracion).", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 30f), Array.Empty())); _thunderDelay = ((BaseUnityPlugin)this).Config.Bind("Thunder", "WarningDelay", 1.5f, new ConfigDescription("Segundos de aviso antes de que caiga el rayo.", (AcceptableValueBase)(object)new AcceptableValueRange(0.3f, 4f), Array.Empty())); _thunderDamage = ((BaseUnityPlugin)this).Config.Bind("Thunder", "Damage", 55f, new ConfigDescription("Daño de relámpago por rayo.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 500f), Array.Empty())); _thunderRadius = ((BaseUnityPlugin)this).Config.Bind("Thunder", "ImpactRadius", 3f, new ConfigDescription("Radio de daño al impactar.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 10f), Array.Empty())); _lavaPrefabName = ((BaseUnityPlugin)this).Config.Bind("LavaField", "Prefab", "LavaRock", "Nombre del prefab del geíser/roca de lava (p.ej. 'LavaRock')."); _lavaMinRadius = ((BaseUnityPlugin)this).Config.Bind("LavaField", "MinRadius", 4f, new ConfigDescription("Radio mínimo desde el boss.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 80f), Array.Empty())); _lavaMaxRadius = ((BaseUnityPlugin)this).Config.Bind("LavaField", "MaxRadius", 28f, new ConfigDescription("Radio máximo desde el boss.", (AcceptableValueBase)(object)new AcceptableValueRange(4f, 120f), Array.Empty())); _lavaInterval = ((BaseUnityPlugin)this).Config.Bind("LavaField", "Interval", 2f, new ConfigDescription("Segundos entre spawns.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 10f), Array.Empty())); _lavaBurst = ((BaseUnityPlugin)this).Config.Bind("LavaField", "BurstCount", 6, new ConfigDescription("Cantidad por tick.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 6), Array.Empty())); _stompTelegraphSeconds = ((BaseUnityPlugin)this).Config.Bind("Stomp", "TelegraphSeconds", 1.5f, new ConfigDescription("Segundos de aviso antes del golpe del Stomp.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); _stompTelegraphFx = ((BaseUnityPlugin)this).Config.Bind("Stomp", "TelegraphFx", "fx_Abomination_attack2", "Nombre del FX para marcar el área del Stomp (se repite durante el aviso)."); _biteBaseDamage = ((BaseUnityPlugin)this).Config.Bind("Neckzilla", "BiteBaseDamage", -1f, "Daño físico TOTAL del mordisco. >0 fija el total físico; <=0 desactiva y usa BiteDamageMultiplier."); _biteDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind("Neckzilla", "BiteDamageMultiplier", 2.3f, new ConfigDescription("Multiplicador para el daño físico del mordisco (melee).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); _lavaFireDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind("LavaField", "FireDamageMultiplier", 1f, new ConfigDescription("Multiplica el daño de fuego recibido cerca de nuestros LavaRock (0..1).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); _cfgDrop1 = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1", "TrophyNeck, 1, 1, 1.0", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado."); _cfgDrop2 = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2", "Coins, 100, 200, 1.0", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado."); _cfgDrop3 = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop3", "NeckTail, 5, 10, 1.0", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado."); _cfgDrop4 = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop4", "", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado."); _cfgDrop5 = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop5", "", "Formato: NombrePrefab, cantMin, cantMax, probabilidad (0.0-1.0). Vacío = desactivado."); _cfgRoarFile = ((BaseUnityPlugin)this).Config.Bind("Audio", "RoarFile", "neckzilla_roar.ogg", "Nombre del archivo de rugido en la carpeta del plugin (ogg/wav/mp3). Dejar vacío para deshabilitar."); _cfgMusicFile = ((BaseUnityPlugin)this).Config.Bind("Audio", "MusicFile", "neckzilla_music.ogg", "Nombre del archivo de música en la carpeta del plugin (ogg/wav/mp3). Dejar vacío para deshabilitar."); ((MonoBehaviour)this).StartCoroutine(LoadAudioFiles()); _lavaPrefabName.SettingChanged += delegate { UpdateStatics(); }; _lavaMinRadius.SettingChanged += delegate { UpdateStatics(); }; _lavaMaxRadius.SettingChanged += delegate { UpdateStatics(); }; _lavaInterval.SettingChanged += delegate { UpdateStatics(); }; _lavaBurst.SettingChanged += delegate { UpdateStatics(); }; UpdateStatics(); _stompCooldown.SettingChanged += delegate { UpdateStatics(); }; _stompRange.SettingChanged += delegate { UpdateStatics(); }; _stompDamage.SettingChanged += delegate { UpdateStatics(); }; _stompPush.SettingChanged += delegate { UpdateStatics(); }; _stompFxSteps.SettingChanged += delegate { UpdateStatics(); }; _bombCooldown.SettingChanged += delegate { UpdateStatics(); }; _bombMinRange.SettingChanged += delegate { UpdateStatics(); }; _bombMaxRange.SettingChanged += delegate { UpdateStatics(); }; _bombSpeed.SettingChanged += delegate { UpdateStatics(); }; _bombImpactFire.SettingChanged += delegate { UpdateStatics(); }; _bombImpactBlunt.SettingChanged += delegate { UpdateStatics(); }; _bombAoeRadius.SettingChanged += delegate { UpdateStatics(); }; _phase2ThresholdPct.SettingChanged += delegate { UpdateStatics(); }; _phase2Duration.SettingChanged += delegate { UpdateStatics(); }; _phase2AuraRadius.SettingChanged += delegate { UpdateStatics(); }; _phase2AuraTick.SettingChanged += delegate { UpdateStatics(); }; _phase2AuraDamage.SettingChanged += delegate { UpdateStatics(); }; _phase2PlayerStaggerEvery.SettingChanged += delegate { UpdateStatics(); }; _phase2BossLightningAt.SettingChanged += delegate { UpdateStatics(); }; _phase2LeviathanDur.SettingChanged += delegate { UpdateStatics(); }; _phase2BoltPrefab.SettingChanged += delegate { UpdateStatics(); }; _thunderStrikePrefab.SettingChanged += delegate { UpdateStatics(); }; _stompTelegraphSeconds.SettingChanged += delegate { UpdateStatics(); }; _stompTelegraphFx.SettingChanged += delegate { UpdateStatics(); }; _biteBaseDamage.SettingChanged += delegate { UpdateStatics(); }; _biteDamageMultiplier.SettingChanged += delegate { UpdateStatics(); }; _lavaFireDamageMultiplier.SettingChanged += delegate { UpdateStatics(); }; _thunderCooldown.SettingChanged += delegate { UpdateStatics(); }; _thunderDelay.SettingChanged += delegate { UpdateStatics(); }; _thunderDamage.SettingChanged += delegate { UpdateStatics(); }; _thunderRadius.SettingChanged += delegate { UpdateStatics(); }; PrefabManager.OnVanillaPrefabsAvailable += CreateNeckzillaPrefab; object obj = <>c.<>9__93_36; if (obj == null) { ConsoleEvent val = delegate { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) GameObject prefab = PrefabManager.Instance.GetPrefab("Boss_Neckzilla"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"Prefab no disponible aún."); } else { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer)) { Vector3 val2 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 5f; Quaternion val3 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); Object.Instantiate(prefab, val2, val3); } } }; <>c.<>9__93_36 = val; obj = (object)val; } new ConsoleCommand("spawn_neckzilla", "Invoca a Neckzilla frente a ti.", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private void UpdateStatics() { ST_COOLDOWN = _stompCooldown.Value; ST_RANGE = _stompRange.Value; ST_DAMAGE = _stompDamage.Value; ST_PUSH = _stompPush.Value; ST_FXSTEPS = Mathf.Max(1, _stompFxSteps.Value); ST_FXNAME = ((_stompTelegraphFx == null || string.IsNullOrWhiteSpace(_stompTelegraphFx.Value)) ? "fx_Abomination_attack2" : _stompTelegraphFx.Value); P2_THRESHOLD_PCT = Mathf.Clamp01(_phase2ThresholdPct.Value); P2_DURATION = _phase2Duration.Value; P2_AURA_RADIUS = _phase2AuraRadius.Value; P2_AURA_TICK = _phase2AuraTick.Value; P2_AURA_DAMAGE = _phase2AuraDamage.Value; P2_STAGGER_EVERY = _phase2PlayerStaggerEvery.Value; P2_BOSS_LIGHTNING_AT = Mathf.Max(1f, _phase2BossLightningAt.Value); P2_LEVIATHAN_DUR = Mathf.Max(5f, _phase2LeviathanDur.Value); P2_BOLT_PREFAB = (string.IsNullOrWhiteSpace(_phase2BoltPrefab.Value) ? "lightningAOE" : _phase2BoltPrefab.Value.Trim()); THU_STRIKE_PREFAB = (string.IsNullOrWhiteSpace(_thunderStrikePrefab.Value) ? "lightningAOE" : _thunderStrikePrefab.Value.Trim()); BMB_CD = _bombCooldown.Value; BMB_MIN = _bombMinRange.Value; BMB_MAX = _bombMaxRange.Value; BMB_SPEED = _bombSpeed.Value; BMB_FIRE = _bombImpactFire.Value; BMB_BLUNT = _bombImpactBlunt.Value; BMB_AOE = _bombAoeRadius.Value; LAVA_PREFAB = _lavaPrefabName.Value; LAVA_RMIN = _lavaMinRadius.Value; LAVA_RMAX = Mathf.Max(LAVA_RMIN + 1f, _lavaMaxRadius.Value); LAVA_INTERVAL = Mathf.Max(0.05f, _lavaInterval.Value); LAVA_BURST = Mathf.Max(1, _lavaBurst.Value); ST_TELEGRAPH = Mathf.Max(0f, _stompTelegraphSeconds.Value); ST_TELE_FX = _stompTelegraphFx.Value; BITE_BASE = _biteBaseDamage.Value; BITE_MULT = _biteDamageMultiplier.Value; LAVA_FIRE_MULT = Mathf.Max(0f, _lavaFireDamageMultiplier.Value); THU_COOLDOWN = Mathf.Max(1f, _thunderCooldown.Value); THU_DELAY = Mathf.Max(0.1f, _thunderDelay.Value); THU_DAMAGE = Mathf.Max(0f, _thunderDamage.Value); THU_RADIUS = Mathf.Max(0.5f, _thunderRadius.Value); } private IEnumerator LoadAudioFiles() { string pluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (!string.IsNullOrWhiteSpace(_cfgRoarFile.Value)) { string path2 = Path.Combine(pluginDir, _cfgRoarFile.Value.Trim()); yield return LoadClip(path2, delegate(AudioClip c) { RoarClip = c; }, "rugido"); } if (!string.IsNullOrWhiteSpace(_cfgMusicFile.Value)) { string path = Path.Combine(pluginDir, _cfgMusicFile.Value.Trim()); yield return LoadClip(path, delegate(AudioClip c) { MusicClip = c; }, "música"); } } private static IEnumerator LoadClip(string path, Action onLoaded, string label) { if (!File.Exists(path)) { Log.LogWarning((object)("[Audio] Archivo de " + label + " no encontrado: " + path)); yield break; } string ext = Path.GetExtension(path).ToLowerInvariant(); AudioType audioType = (AudioType)14; if (ext == ".wav") { audioType = (AudioType)20; } else if (ext == ".mp3") { audioType = (AudioType)13; } UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), audioType); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { Log.LogError((object)("[Audio] Error cargando " + label + ": " + req.error)); yield break; } AudioClip clip = DownloadHandlerAudioClip.GetContent(req); if ((Object)(object)clip != (Object)null) { ((Object)clip).name = "Neckzilla_" + label; onLoaded(clip); Log.LogInfo((object)$"[Audio] '{label}' cargado: {clip.length:F1}s"); } } finally { ((IDisposable)req)?.Dispose(); } } private static AudioMixerGroup GetSFXMixerGroup() { if ((Object)(object)_sfxMixerGroup != (Object)null) { return _sfxMixerGroup; } string[] array = new string[3] { "sfx_hit", "sfx_swing_axe", "sfx_arrow_hit" }; foreach (string text in array) { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(text) : null); if (!((Object)(object)val == (Object)null)) { AudioSource componentInChildren = val.GetComponentInChildren(true); if ((Object)(object)((componentInChildren != null) ? componentInChildren.outputAudioMixerGroup : null) != (Object)null) { _sfxMixerGroup = componentInChildren.outputAudioMixerGroup; break; } } } return _sfxMixerGroup; } internal static void PlayRoar(Vector3 pos) { //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) if (!((Object)(object)RoarClip == (Object)null)) { GameObject val = new GameObject("NeckzillaRoarSFX"); val.transform.position = pos; AudioSource val2 = val.AddComponent(); val2.clip = RoarClip; val2.spatialBlend = 1f; val2.minDistance = 15f; val2.maxDistance = 200f; val2.rolloffMode = (AudioRolloffMode)0; val2.volume = 1f; val2.outputAudioMixerGroup = GetSFXMixerGroup(); val2.Play(); Object.Destroy((Object)(object)val, RoarClip.length + 0.5f); } } internal static void StartBossMusic() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown if ((Object)(object)MusicClip == (Object)null || (Object)(object)_bossMusic != (Object)null) { return; } _mutedVanillaSources.Clear(); if ((Object)(object)MusicMan.instance != (Object)null) { AudioSource[] componentsInChildren = ((Component)MusicMan.instance).GetComponentsInChildren(true); foreach (AudioSource val in componentsInChildren) { if ((Object)(object)val != (Object)null && val.volume > 0f) { val.volume = 0f; _mutedVanillaSources.Add(val); } } } BossMusicActive = true; GameObject val2 = new GameObject("NeckzillaBossMusic"); Object.DontDestroyOnLoad((Object)(object)val2); AudioSource val3 = val2.AddComponent(); val3.clip = MusicClip; val3.loop = true; val3.spatialBlend = 0f; val3.volume = 0.5f; val3.Play(); _bossMusic = val3; Log.LogInfo((object)"[Audio] Música de boss iniciada, vanilla silenciada."); } internal static void StopBossMusic() { if ((Object)(object)_bossMusic == (Object)null) { return; } Object.Destroy((Object)(object)((Component)_bossMusic).gameObject); _bossMusic = null; BossMusicActive = false; foreach (AudioSource mutedVanillaSource in _mutedVanillaSources) { if ((Object)(object)mutedVanillaSource != (Object)null) { mutedVanillaSource.volume = 1f; } } _mutedVanillaSources.Clear(); Log.LogInfo((object)"[Audio] Música de boss detenida, vanilla restaurada."); } private static bool MusicManBlockPrefix() { return !BossMusicActive; } private void ApplyMusicManPatches() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(MainPlugin).GetMethod("MusicManBlockPrefix", BindingFlags.Static | BindingFlags.NonPublic)); string[] array = new string[4] { "StartMusic", "StartRandomEventMusic", "UpdateMusic", "QueueMusic" }; foreach (string text in array) { try { MethodInfo method = typeof(MusicMan).GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { _harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)("[Audio] Parcheado MusicMan." + text)); } } catch (Exception ex) { Log.LogWarning((object)("[Audio] No se pudo parchar MusicMan." + text + ": " + ex.Message)); } } } private void ApplyLootDrops(GameObject clone) { //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown CharacterDrop val = clone.GetComponent() ?? clone.AddComponent(); val.m_drops.Clear(); ConfigEntry[] array = new ConfigEntry[5] { _cfgDrop1, _cfgDrop2, _cfgDrop3, _cfgDrop4, _cfgDrop5 }; foreach (ConfigEntry val2 in array) { if (val2 == null || string.IsNullOrWhiteSpace(val2.Value)) { continue; } string[] array2 = val2.Value.Split(new char[1] { ',' }); if (array2.Length < 4) { continue; } string text = array2[0].Trim(); if (!string.IsNullOrEmpty(text) && int.TryParse(array2[1].Trim(), out var result) && int.TryParse(array2[2].Trim(), out var result2) && float.TryParse(array2[3].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { PrefabManager instance = PrefabManager.Instance; GameObject val3 = ((instance != null) ? instance.GetPrefab(text) : null); if ((Object)(object)val3 == (Object)null) { Log.LogWarning((object)("[Loot] Prefab '" + text + "' no encontrado.")); continue; } val.m_drops.Add(new Drop { m_prefab = val3, m_amountMin = Mathf.Max(0, result), m_amountMax = Mathf.Max(result, result2), m_chance = Mathf.Clamp01(result3), m_onePerPlayer = false, m_levelMultiplier = false }); Log.LogInfo((object)$"[Loot] Drop: {text} x{result}-{result2} ({result3 * 100f:F0}%)"); } } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= CreateNeckzillaPrefab; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void CreateNeckzillaPrefab() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("Boss_Neckzilla"))) { return; } GameObject prefab = PrefabManager.Instance.GetPrefab("Neck"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"No se encontró el prefab 'Neck'."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("Boss_Neckzilla", prefab); Character component = val.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_name = "Neckzilla"; component.m_boss = true; component.m_health = _cfgHealth.Value; MakeFireImmune(component); val.AddComponent(); TrySetField(component, "m_fleeIfHurt", value: false); TrySetField(component, "m_staggerDamageFactor", 0f); } float num = Mathf.Max(1f, _cfgScale.Value); val.transform.localScale = Vector3.one * num; BaseAI component2 = val.GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { float factor = Mathf.Clamp(num, 1f, 4f); TryScaleFloatField(component2, "m_viewRange", factor); TryScaleFloatField(component2, "m_hearRange", factor); TryScaleFloatField(component2, "m_noiseRange", factor); TryMaxFloatField(component2, "m_interceptTimeMax", 8f); TrySetField(component2, "m_afraidOfFire", value: false); TrySetField(component2, "m_avoidFire", value: false); TrySetField(component2, "m_fleeIfHurt", value: false); TrySetField(component2, "m_backoffOnLowHP", value: false); TrySetField(component2, "m_avoidPlayer", value: false); TrySetField(component2, "m_avoidWater", value: false); TrySetField(component2, "m_afraidOfFireRange", 0f); TrySetField(component2, "m_avoidFireDistance", 0f); TrySetField(component2, "m_avoidPlayerDistance", 0f); TrySetField(component2, "m_avoidWaterDistance", 0f); TryScaleFloatField(component, "m_walkSpeed", 1.5f); TryScaleFloatField(component, "m_runSpeed", 1.5f); TryScaleFloatField(component, "m_acceleration", 1.1f); TryScaleFloatField(component, "m_turnSpeed", 1.15f); ForceNoFleeFlags(component2); val.AddComponent(); } val.AddComponent(); val.AddComponent(); val.AddComponent(); val.AddComponent(); val.AddComponent(); ApplyLootDrops(val); ((Object)val).name = "Boss_Neckzilla"; PrefabManager.Instance.AddPrefab(new CustomPrefab(val, true)); Log.LogInfo((object)"Boss_Neckzilla creado y registrado correctamente."); } internal static bool TrySetField(TObj obj, string fieldName, TValue value) { FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return false; } try { object obj2 = value; if (obj2 != null && field.FieldType != obj2.GetType()) { obj2 = Convert.ChangeType(obj2, field.FieldType); } field.SetValue(obj, obj2); return true; } catch { return false; } } private static void TryScaleFloatField(object obj, string fieldName, float factor) { FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null || field.FieldType != typeof(float)) { return; } try { float num = (float)field.GetValue(obj); field.SetValue(obj, num * factor); } catch { } } private static void TryMaxFloatField(object obj, string fieldName, float minValue) { FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null || field.FieldType != typeof(float)) { return; } try { float num = (float)field.GetValue(obj); if (num < minValue) { field.SetValue(obj, minValue); } } catch { } } internal static void ForceNoFleeFlags(object ai) { if (ai == null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo[] fields = ai.GetType().GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { string text = fieldInfo.Name.ToLowerInvariant(); if (fieldInfo.FieldType == typeof(bool) && (text.Contains("flee") || text.Contains("afraid") || text.Contains("avoid") || text.Contains("backoff"))) { try { fieldInfo.SetValue(ai, false); } catch { } } if (fieldInfo.FieldType == typeof(float) && (text.Contains("range") || text.Contains("distance")) && (text.Contains("fire") || text.Contains("flee") || text.Contains("avoid") || text.Contains("afraid"))) { try { fieldInfo.SetValue(ai, 0f); } catch { } } } } private static Color ParseHtmlColor(string html, Color fallback) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); if (!string.IsNullOrWhiteSpace(html) && ColorUtility.TryParseHtmlString(html.Trim(), ref result)) { return result; } return fallback; } internal static void ApplyLiliesEmission(GameObject target) { //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Expected O, but got Unknown //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_0851: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Expected O, but got Unknown //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Expected O, but got Unknown //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Expected O, but got Unknown //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Expected O, but got Unknown //IL_087a: Unknown result type (might be due to invalid IL or missing references) //IL_0765: Unknown result type (might be due to invalid IL or missing references) //IL_089a: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_charredMatCache == (Object)null) { string[] array = new string[2] { "Charred_Melee_Dyrnwyn", "CharredMeleeDyrnwyn" }; foreach (string text in array) { GameObject val = null; if (PrefabManager.Instance != null) { val = PrefabManager.Instance.GetPrefab(text); } if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(text); } if ((Object)(object)val == (Object)null) { continue; } Renderer[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (string.Equals(((Object)((Component)val2).gameObject).name, "Body", StringComparison.OrdinalIgnoreCase) && val2.sharedMaterials.Length != 0 && (Object)(object)val2.sharedMaterials[0] != (Object)null) { _charredMatCache = val2.sharedMaterials[0]; break; } } if ((Object)(object)_charredMatCache != (Object)null) { break; } if ((Object)(object)_charredMatCache == (Object)null) { Renderer componentInChildren = val.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.sharedMaterials.Length != 0 && (Object)(object)componentInChildren.sharedMaterials[0] != (Object)null) { _charredMatCache = componentInChildren.sharedMaterials[0]; Log.LogWarning((object)("[Phase2] Charred: 'Body' no encontrado, usando primer renderer: " + ((Object)((Component)componentInChildren).gameObject).name)); } } if ((Object)(object)_charredMatCache != (Object)null) { break; } } } Material charredMatCache = _charredMatCache; if ((Object)(object)target.transform.Find("NeckzillaLiliesLight") == (Object)null) { GameObject val3 = new GameObject("NeckzillaLiliesLight"); val3.transform.SetParent(target.transform, false); val3.transform.localPosition = new Vector3(0f, 0.6f, -0.3f); Light val4 = val3.AddComponent(); val4.type = (LightType)2; val4.color = new Color(0.15f, 0.6f, 1f); val4.intensity = 3f; val4.range = 2.5f; val4.shadows = (LightShadows)0; } SkinnedMeshRenderer componentInChildren2 = target.GetComponentInChildren(true); if ((Object)(object)componentInChildren2 != (Object)null && componentInChildren2.bones != null) { List list = new List(); Transform[] bones = componentInChildren2.bones; foreach (Transform val5 in bones) { if (!((Object)(object)val5 == (Object)null)) { string name = ((Object)val5).name; if (name.IndexOf("eye", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("ojo", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(val5); } } } if (list.Count == 0) { Transform val6 = null; Transform[] bones2 = componentInChildren2.bones; foreach (Transform val7 in bones2) { if (!((Object)(object)val7 == (Object)null) && string.Equals(((Object)val7).name, "Head", StringComparison.OrdinalIgnoreCase)) { val6 = val7; break; } } if ((Object)(object)val6 == (Object)null) { Transform[] bones3 = componentInChildren2.bones; foreach (Transform val8 in bones3) { if (!((Object)(object)val8 == (Object)null)) { string name2 = ((Object)val8).name; if (name2.IndexOf("head", StringComparison.OrdinalIgnoreCase) >= 0 || name2.IndexOf("cabeza", StringComparison.OrdinalIgnoreCase) >= 0) { val6 = val8; break; } } } } if ((Object)(object)val6 != (Object)null) { Vector3[] array2 = (Vector3[])(object)new Vector3[4] { new Vector3(-0.12f, 0.04f, 0.18f), new Vector3(0.12f, 0.04f, 0.18f), new Vector3(-0.12f, -0.04f, 0.14f), new Vector3(0.12f, -0.04f, 0.14f) }; for (int n = 0; n < array2.Length; n++) { string text2 = "NeckzillaEyeLight_" + n; if (!((Object)(object)val6.Find(text2) != (Object)null)) { GameObject val9 = new GameObject(text2); val9.transform.SetParent(val6, false); val9.transform.localPosition = array2[n]; Light val10 = val9.AddComponent(); val10.type = (LightType)2; val10.color = new Color(0f, 0.85f, 1f); val10.intensity = 6f; val10.range = 0.8f; val10.shadows = (LightShadows)0; } } } } else { for (int num = 0; num < list.Count; num++) { string text3 = "NeckzillaEyeLight_" + num; if (!((Object)(object)list[num].Find(text3) != (Object)null)) { GameObject val11 = new GameObject(text3); val11.transform.SetParent(list[num], false); val11.transform.localPosition = Vector3.zero; Light val12 = val11.AddComponent(); val12.type = (LightType)2; val12.color = new Color(0f, 0.85f, 1f); val12.intensity = 6f; val12.range = 0.8f; val12.shadows = (LightShadows)0; } } } } Color val13 = default(Color); ((Color)(ref val13))..ctor(0f, 0.7f, 3.5f, 1f); Renderer[] componentsInChildren2 = target.GetComponentsInChildren(true); Color val15 = default(Color); foreach (Renderer val14 in componentsInChildren2) { if ((Object)(object)val14 == (Object)null) { continue; } string name3 = ((Object)((Component)val14).gameObject).name; if (string.Equals(name3, "Body", StringComparison.OrdinalIgnoreCase) && (Object)(object)charredMatCache != (Object)null) { val14.SetPropertyBlock((MaterialPropertyBlock)null); Material[] sharedMaterials = val14.sharedMaterials; Material[] array3 = (Material[])(object)new Material[sharedMaterials.Length]; ((Color)(ref val15))..ctor(0f, 0.85f, 3.5f, 1f); for (int num3 = 0; num3 < sharedMaterials.Length; num3++) { if ((Object)(object)sharedMaterials[num3] != (Object)null && ((Object)sharedMaterials[num3]).name.IndexOf("eye", StringComparison.OrdinalIgnoreCase) >= 0) { Material val16 = new Material(sharedMaterials[num3]); if (val16.HasProperty("_Color")) { val16.SetColor("_Color", val15); } if (val16.HasProperty("_BaseColor")) { val16.SetColor("_BaseColor", val15); } val16.EnableKeyword("_EMISSION"); if (val16.HasProperty("_EmissionColor")) { val16.SetColor("_EmissionColor", val15); } array3[num3] = val16; } else { array3[num3] = new Material(charredMatCache); } } val14.materials = array3; } else { if (!string.Equals(name3, "Lillies", StringComparison.OrdinalIgnoreCase)) { continue; } val14.SetPropertyBlock((MaterialPropertyBlock)null); Material[] array4 = (Material[])(object)new Material[val14.sharedMaterials.Length]; for (int num4 = 0; num4 < array4.Length; num4++) { Material val17 = val14.sharedMaterials[num4]; Material val18 = (((Object)(object)val17 != (Object)null) ? new Material(val17) : new Material(Shader.Find("Standard"))); if (val18.HasProperty("_Color")) { val18.SetColor("_Color", val13); } if (val18.HasProperty("_BaseColor")) { val18.SetColor("_BaseColor", val13); } array4[num4] = val18; } val14.materials = array4; } } } internal static void ApplySerpentMaterials(GameObject target, GameObject _source) { ApplyLiliesEmission(target); } private static void ApplyTintToPrefabMaterials(GameObject root, Color tint, float emission) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { continue; } Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (!Object.op_Implicit((Object)(object)val2)) { array[j] = null; continue; } Material val3 = new Material(val2); TrySetColorProps(val3, tint, emission); array[j] = val3; } val.sharedMaterials = array; } } private static void TrySetColorProps(Material m, Color tint, float emission) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_009a: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (m.HasProperty("_Color")) { m.SetColor("_Color", tint); } if (m.HasProperty("_BaseColor")) { m.SetColor("_BaseColor", tint); } if (m.HasProperty("_TintColor")) { m.SetColor("_TintColor", tint); } if (m.HasProperty("_MainColor")) { m.SetColor("_MainColor", tint); } if (emission > 0f && m.HasProperty("_EmissionColor")) { m.EnableKeyword("_EMISSION"); Color val = new Color(tint.r, tint.g, tint.b, 1f) * Mathf.Clamp(emission, 0f, 2f); m.SetColor("_EmissionColor", val); } else if (m.IsKeywordEnabled("_EMISSION") && emission <= 0f) { m.DisableKeyword("_EMISSION"); } } internal static void SafeStagger(Character target, Vector3 fromPos) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) if (!Object.op_Implicit((Object)(object)target)) { return; } try { MethodInfo method = ((object)target).GetType().GetMethod("Stagger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Vector3) }, null); if (method != null) { Vector3 val = ((Component)target).transform.position - fromPos; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.forward; } method.Invoke(target, new object[1] { ((Vector3)(ref val)).normalized }); return; } } catch { } try { MethodInfo method2 = ((object)target).GetType().GetMethod("Stagger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method2 != null) { method2.Invoke(target, null); } } catch { } } internal static void MakeFireImmune(Character ch) { //IL_003f: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ch)) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = typeof(Character).GetField("m_damageModifiers", bindingAttr); if (field == null) { return; } try { DamageModifiers val = (DamageModifiers)field.GetValue(ch); val.m_fire = (DamageModifier)3; field.SetValue(ch, val); } catch { } } } public class NeckzillaStomp : MonoBehaviour { private Character _self; private ZNetView _nview; [SerializeField] private float _cd; [SerializeField] private float _range; [SerializeField] private float _damage; [SerializeField] private float _push; [SerializeField] private int _fxSteps = 6; [SerializeField] private string _fxName = "fx_Abomination_attack2"; private GameObject _fxPrefab; private float _cooldownUntil; private float _telegraphUntil; private bool _telegraphing; private bool _didDamage; private GameObject _circleGO; private LineRenderer _circleLR; private static readonly List _scratch = new List(); private static readonly int SOLID_MASK = LayerMask.GetMask(new string[5] { "Default", "piece", "terrain", "static_solid", "Default_small" }); private void Awake() { if (_cd <= 0f) { _cd = Mathf.Max(1f, MainPlugin.ST_COOLDOWN); } if (_range <= 0f) { _range = Mathf.Max(2f, MainPlugin.ST_RANGE); } if (_damage <= 0f) { _damage = Mathf.Max(1f, MainPlugin.ST_DAMAGE); } if (_push <= 0f) { _push = Mathf.Max(0f, MainPlugin.ST_PUSH); } if (_fxSteps <= 0) { _fxSteps = Mathf.Max(1, MainPlugin.ST_FXSTEPS); } if (string.IsNullOrWhiteSpace(_fxName)) { _fxName = MainPlugin.ST_FXNAME; } } private void Start() { _self = ((Component)this).GetComponent(); _nview = ((Component)this).GetComponent(); PrefabManager instance = PrefabManager.Instance; if (instance != null) { _fxPrefab = instance.GetPrefab(_fxName); } if ((Object)(object)_fxPrefab == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { _fxPrefab = ZNetScene.instance.GetPrefab(_fxName); } _cooldownUntil = Time.time + Random.Range(0f, _cd * 0.5f); EnsureCircle(); } private void Update() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_self)) { return; } NeckzillaPhase2 component = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)component) && (component.IsActive || component.IsFinalPhase)) { StopTelegraph(); _cooldownUntil = Time.time + 1f; } else if (_telegraphing) { if (!IsDedicatedServer()) { UpdateCross(((Component)this).transform.position, _range); } if (!(Time.time >= _telegraphUntil)) { return; } if (!_didDamage) { if (!IsDedicatedServer()) { SpawnImpactFX(((Component)this).transform.position, _range); } if (IsOwnerOrServer()) { ApplyAoEDamage(); } _didDamage = true; } StopTelegraph(); _cooldownUntil = Time.time + _cd; } else { if (Time.time < _cooldownUntil) { return; } Player val = FindTargetPlayer(_range + 0.5f, requireLoS: true); if (!Object.op_Implicit((Object)(object)val)) { _cooldownUntil = Time.time + Mathf.Min(1f, _cd * 0.25f); return; } float num = Mathf.Max(0f, MainPlugin.ST_TELEGRAPH); if (num > 0f) { _telegraphing = true; _didDamage = false; _telegraphUntil = Time.time + num; EnsureCircle(); if (Object.op_Implicit((Object)(object)_circleGO)) { _circleGO.SetActive(true); UpdateCross(((Component)this).transform.position, _range); } } else { if (!IsDedicatedServer()) { SpawnImpactFX(((Component)this).transform.position, _range); } if (IsOwnerOrServer()) { ApplyAoEDamage(); } _cooldownUntil = Time.time + _cd; } } } private bool IsInCross(Vector3 playerPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 val = playerPos - ((Component)this).transform.position; val.y = 0f; Vector3 forward = ((Component)this).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); Vector3 right = ((Component)this).transform.right; right.y = 0f; ((Vector3)(ref right)).Normalize(); float num = Vector3.Dot(val, forward); float num2 = Vector3.Dot(val, right); float num3 = _range * 0.25f; bool flag = Mathf.Abs(num2) <= num3 && Mathf.Abs(num) <= _range; bool flag2 = Mathf.Abs(num) <= num3 && Mathf.Abs(num2) <= _range; return flag || flag2; } private void ApplyAoEDamage() { //IL_0034: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown _scratch.Clear(); try { Character.GetCharactersInRange(((Component)this).transform.position, _range, _scratch); } catch { Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, _range, -1, (QueryTriggerInteraction)2); for (int i = 0; i < array.Length; i++) { Character componentInParent = ((Component)array[i]).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && !_scratch.Contains(componentInParent)) { _scratch.Add(componentInParent); } } } int num = 0; for (int j = 0; j < _scratch.Count; j++) { Character obj2 = _scratch[j]; Player val = (Player)(object)((obj2 is Player) ? obj2 : null); if (Object.op_Implicit((Object)(object)val) && !((Character)val).IsDead() && IsInCross(((Component)val).transform.position)) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; val2.y = 0f; float num2 = Mathf.Max(0.05f, ((Vector3)(ref val2)).magnitude); HitData val3 = new HitData { m_point = ((Character)val).GetCenterPoint(), m_dir = val2 / num2 }; val3.m_damage.m_blunt = _damage; val3.m_pushForce = _push; val3.m_blockable = true; try { val3.SetAttacker(_self); } catch { } ((Character)val).Damage(val3); num++; } } } private void SpawnImpactFX(Vector3 center, float length) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00e0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fxPrefab == (Object)null) { return; } SpawnLocalFX(_fxPrefab, SnapToGround(center)); Vector3 forward = ((Component)this).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); Vector3 right = ((Component)this).transform.right; right.y = 0f; ((Vector3)(ref right)).Normalize(); int num = Mathf.Max(1, _fxSteps / 4); Vector3[] array = (Vector3[])(object)new Vector3[4] { forward, -forward, right, -right }; foreach (Vector3 val in array) { for (int j = 1; j <= num; j++) { float num2 = (float)j / (float)num * length; SpawnLocalFX(_fxPrefab, SnapToGround(center + val * num2)); } } } private static void SpawnLocalFX(GameObject prefab, Vector3 pos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown GameObject val = Object.Instantiate(prefab, pos, Quaternion.identity); if ((Object)(object)val == (Object)null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Component val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null) { continue; } FieldInfo field = ((object)val2).GetType().GetField("m_damage", bindingAttr); if (field != null) { try { field.SetValue(val2, (object?)new HitData()); } catch { } } } ZNetView component = val.GetComponent(); if ((Object)(object)component != (Object)null) { NeckzillaThunder.MakeLocalOnlyStatic(component); } } private void UpdateCross(Vector3 center, float length) { //IL_0029: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0088: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0104: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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) if (!((Object)(object)_circleLR == (Object)null)) { float num = length * 0.25f; Quaternion val = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f); Vector3[] array = (Vector3[])(object)new Vector3[12] { new Vector3(0f - num, 0f, length), new Vector3(num, 0f, length), new Vector3(num, 0f, num), new Vector3(length, 0f, num), new Vector3(length, 0f, 0f - num), new Vector3(num, 0f, 0f - num), new Vector3(num, 0f, 0f - length), new Vector3(0f - num, 0f, 0f - length), new Vector3(0f - num, 0f, 0f - num), new Vector3(0f - length, 0f, 0f - num), new Vector3(0f - length, 0f, num), new Vector3(0f - num, 0f, num) }; _circleLR.positionCount = 12; for (int i = 0; i < 12; i++) { Vector3 pos = center + val * array[i]; pos = SnapToGround(pos) + Vector3.up * 0.03f; _circleLR.SetPosition(i, pos); } } } private void StopTelegraph() { _telegraphing = false; if (Object.op_Implicit((Object)(object)_circleGO)) { _circleGO.SetActive(false); } } private void EnsureCircle() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_012e: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_018f: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (!IsDedicatedServer() && !((Object)(object)_circleGO != (Object)null)) { _circleGO = new GameObject("Neckzilla_StompTelegraph"); _circleGO.SetActive(false); _circleLR = _circleGO.AddComponent(); _circleLR.useWorldSpace = true; _circleLR.loop = true; _circleLR.positionCount = 12; _circleLR.widthMultiplier = 0.08f; ((Renderer)_circleLR).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_circleLR).receiveShadows = false; Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } if ((Object)(object)val != (Object)null) { ((Renderer)_circleLR).material = new Material(val); ((Renderer)_circleLR).material.color = Color.white; } _circleLR.widthMultiplier = 0.25f; Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(new Color(1f, 0.95f, 0f), 0f), new GradientColorKey(new Color(1f, 0.1f, 0f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }); _circleLR.colorGradient = val2; } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)_circleGO)) { Object.Destroy((Object)(object)_circleGO); } } private static Vector3 SnapToGround(Vector3 pos) { //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_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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_008b: Unknown result type (might be due to invalid IL or missing references) Ray val = default(Ray); ((Ray)(ref val))..ctor(pos + Vector3.up * 10f, Vector3.down); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2, 30f, LayerMask.GetMask(new string[6] { "Default", "piece", "terrain", "static_solid", "Default_small", "character" }))) { pos.y = ((RaycastHit)(ref val2)).point.y + 0.05f; } return pos; } private bool IsOwnerOrServer() { return (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) || (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner()); } private static bool IsDedicatedServer() { return Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsDedicated(); } private Player FindTargetPlayer(float r, bool requireLoS) { BaseAI component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { Player val = TryGetAITargetPlayer(component); if (IsValidTarget(val, r, requireLoS)) { return val; } } List allPlayers = Player.GetAllPlayers(); for (int i = 0; i < allPlayers.Count; i++) { if (IsValidTarget(allPlayers[i], r, requireLoS)) { return allPlayers[i]; } } return null; } private Player TryGetAITargetPlayer(BaseAI ai) { string[] array = new string[4] { "m_targetCreature", "m_targetEnemy", "m_targetCharacter", "m_target" }; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Type type = ((object)ai).GetType(); for (int i = 0; i < array.Length; i++) { FieldInfo field = type.GetField(array[i], bindingAttr); if (field == null) { continue; } object value = field.GetValue(ai); Player val = (Player)((value is Player) ? value : null); if (val != null) { return val; } Character val2 = (Character)((value is Character) ? value : null); if (val2 != null) { Player val3 = (Player)(object)((val2 is Player) ? val2 : null); if (val3 != null) { return val3; } } } return null; } private bool IsValidTarget(Player p, float r, bool requireLoS) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)p) || ((Character)p).IsDead()) { return false; } if (Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position) > r) { return false; } if (!requireLoS) { return true; } Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f; Vector3 centerPoint = ((Character)p).GetCenterPoint(); return !Physics.Linecast(val, centerPoint, SOLID_MASK); } } public class NeckzillaPhase2 : MonoBehaviour { private Character _self; private BaseAI _ai; private ZNetView _nview; private Rigidbody _rb; private bool _triggeredOnce; private float _thresholdHealth; private float _healthSnapDelay = 2.5f; private bool _healthSnapped; private float _timeLeft; private float _seqTimer; private float _staggerTimer; private GameObject _fxLeviathanPrefab; private GameObject _fxLeviathanInst; private bool _bossLightningFired; private bool _stormTriggered; private bool _roarP2Fired; private bool _stormForced; private bool _moderForced; private GameObject _electricAuraRoot; private GameObject _lightningAuraRoot; private float _himminAflTimer; private float _liliesMatTimer; private Vector3 _lockPos; private RigidbodyConstraints _rbConstraintsBackup; private bool _rbHadConstraintsBackup; private Animator[] _anims; private bool[] _animRootMotionBackup; private float _deathRoarThreshold; private bool _deathRoarTriggered; private bool _deathRoarActive; private bool _finalWindupActive; private bool _beamRoarFired; private bool _finalRainActive; private float _finalWindupTimer; private const float FinalWindupDuration = 8f; private Vector3 _deathRoarLockPos; private string _deathRoarAnim; private Transform _roarSpine; private Transform _roarSpine1; private Transform _roarNeckBone; private Transform _roarHeadBone; private Transform _roarJawBone; private Quaternion _roarSpineInitRot; private Quaternion _roarSpine1InitRot; private Quaternion _roarNeckInitRot; private Quaternion _roarHeadInitRot; private Quaternion _roarJawInitRot; private Vector3 _roarOriginalScale; private Quaternion _deathRoarLockRot; private float _roarBoneLerpT; private float _finalLightningTimer; private const float FinalLightningInterval = 2.5f; private float _finalMeteorTimer; private const float FinalMeteorInterval = 5f; private GameObject _activeBeamGO; private GameObject _beamAudioGO; private GameObject _meteorPrefabCache; private GameObject _beamPrefabCache; private static readonly List _scratch = new List(); public bool IsActive { get; private set; } public bool ThunderUnlocked { get; private set; } public bool IsFinalWindup => _finalWindupActive; public bool IsFinalPhase => _deathRoarActive; private void Start() { MainPlugin.Log.LogWarning((object)("[Phase2] *** Start() *** go=" + ((Object)((Component)this).gameObject).name + " IsServer=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsServer().ToString() : "ZNet=null"))); _self = ((Component)this).GetComponent(); _ai = ((Component)this).GetComponent(); _nview = ((Component)this).GetComponent(); _rb = ((Component)this).GetComponent(); _thresholdHealth = float.MaxValue; _fxLeviathanPrefab = ((PrefabManager.Instance != null) ? PrefabManager.Instance.GetPrefab("fx_leviathan_leave") : null); if ((Object)(object)_fxLeviathanPrefab == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { _fxLeviathanPrefab = ZNetScene.instance.GetPrefab("fx_leviathan_leave"); } ZNetScene instance = ZNetScene.instance; _beamPrefabCache = ((instance != null) ? instance.GetPrefab("vfx_goblinking_beam_OLD") : null); ZNetScene instance2 = ZNetScene.instance; _meteorPrefabCache = ((instance2 != null) ? instance2.GetPrefab("projectile_ashlandmeteor") : null); _anims = ((Component)this).GetComponentsInChildren(true); _animRootMotionBackup = new bool[_anims.Length]; for (int i = 0; i < _anims.Length; i++) { _animRootMotionBackup[i] = (Object)(object)_anims[i] != (Object)null && _anims[i].applyRootMotion; } } private void Update() { //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Invalid comparison between Unknown and I4 //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Invalid comparison between Unknown and I4 //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_self)) { return; } if (IsActive && _bossLightningFired) { _liliesMatTimer -= Time.deltaTime; if (_liliesMatTimer <= 0f) { _liliesMatTimer = 0.5f; MainPlugin.ApplyLiliesEmission(((Component)this).gameObject); } } if (IsActive && _bossLightningFired) { _himminAflTimer -= Time.deltaTime; if (_himminAflTimer <= 0f) { _himminAflTimer = 3f; SpawnHimminAflOnce(); } } if (!_healthSnapped) { _healthSnapDelay -= Time.deltaTime; if (_healthSnapDelay <= 0f) { float healthSafe = GetHealthSafe(_self); MainPlugin.Log.LogWarning((object)("[Phase2] HealthSnap intento: hp=" + healthSafe + " self=" + (((Object)(object)_self != (Object)null) ? ((Object)_self).name : "NULL") + " IsServer=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsServer().ToString() : "ZNet=null"))); if (healthSafe > 1f) { _thresholdHealth = healthSafe * Mathf.Clamp01(MainPlugin.P2_THRESHOLD_PCT); _deathRoarThreshold = healthSafe * 0.3f; _healthSnapped = true; MainPlugin.Log.LogWarning((object)("[Phase2] HealthSnapped OK: threshold=" + _thresholdHealth + " (" + (MainPlugin.P2_THRESHOLD_PCT * 100f).ToString("F0") + "%)")); } else { _healthSnapDelay = 1f; } } return; } if (_healthSnapped && !_deathRoarTriggered && !IsActive && GetHealthSafe(_self) <= _deathRoarThreshold && GetHealthSafe(_self) > 0f) { BeginDeathRoar(); } if (_deathRoarActive) { if (Object.op_Implicit((Object)(object)_rb)) { RBCompat.Set(_rb, Vector3.zero); _rb.angularVelocity = Vector3.zero; if ((int)_rb.constraints != 14) { _rb.constraints = (RigidbodyConstraints)14; } } ((Component)this).transform.position = _deathRoarLockPos; ((Component)this).transform.rotation = _deathRoarLockRot; if (_finalWindupActive) { _finalWindupTimer -= Time.deltaTime; if (!_beamRoarFired && _finalWindupTimer <= 2f) { _beamRoarFired = true; if (!IsDedicatedServer()) { MainPlugin.PlayRoar(((Component)this).transform.position); } } if (_finalWindupTimer <= 0f) { _finalWindupActive = false; _finalRainActive = true; FireBeamAtSky(); StartBeamAudio(); _finalLightningTimer = 0.5f; _finalMeteorTimer = 3f; MainPlugin.Log.LogInfo((object)"[FinalPhase] Lluvia activa."); } } if (_finalRainActive) { _finalLightningTimer -= Time.deltaTime; if (_finalLightningTimer <= 0f) { _finalLightningTimer = 2.5f; SpawnRainLightning(); } _finalMeteorTimer -= Time.deltaTime; if (_finalMeteorTimer <= 0f) { _finalMeteorTimer = 5f; SpawnRainMeteors(); } if (!Object.op_Implicit((Object)(object)_activeBeamGO)) { FireBeamAtSky(); } } } else { if (_triggeredOnce && !IsActive) { return; } if (!IsActive) { if (!_triggeredOnce && GetHealthSafe(_self) <= _thresholdHealth) { BeginPhase2(); } return; } if (Object.op_Implicit((Object)(object)_rb)) { RBCompat.Set(_rb, Vector3.zero); if ((int)_rb.constraints != 126) { _rb.constraints = (RigidbodyConstraints)126; } } ((Component)this).transform.position = _lockPos; _timeLeft -= Time.deltaTime; _seqTimer += Time.deltaTime; if (!_stormTriggered && _seqTimer >= MainPlugin.P2_BOSS_LIGHTNING_AT - 7f) { _stormTriggered = true; TryForceStorm(); MainPlugin.Log.LogInfo((object)"[Phase2] Clima ThunderStorm iniciado."); } if (!_roarP2Fired && _seqTimer >= MainPlugin.P2_BOSS_LIGHTNING_AT - 2f) { _roarP2Fired = true; if (!IsDedicatedServer()) { MainPlugin.PlayRoar(((Component)this).transform.position); } } if (!_bossLightningFired && _seqTimer >= MainPlugin.P2_BOSS_LIGHTNING_AT) { _bossLightningFired = true; SpawnBossLightning(); SpawnElectricAura(); SpawnLightningAura(); _himminAflTimer = 0f; MainPlugin.ApplySerpentMaterials(((Component)this).gameObject, null); MainPlugin.Log.LogInfo((object)"[Phase2] Rayo + aura + textura activados."); } if (!ThunderUnlocked && _seqTimer >= MainPlugin.P2_LEVIATHAN_DUR) { ThunderUnlocked = true; MainPlugin.Log.LogInfo((object)"[Phase2] Rayos sobre jugadores ACTIVOS."); } if (IsOwnerOrServer()) { _staggerTimer -= Time.deltaTime; if (_staggerTimer <= 0f) { _staggerTimer = Mathf.Max(0.1f, MainPlugin.P2_STAGGER_EVERY); StaggerPlayersInRadius(MainPlugin.P2_AURA_RADIUS); Animator[] anims = _anims; foreach (Animator val in anims) { if (Object.op_Implicit((Object)(object)val)) { val.CrossFade("swimming", 0.15f, 0, 0f); } } } } if (_timeLeft <= 0f) { EndPhase2(); } } } private void BeginDeathRoar() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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) _deathRoarTriggered = true; _deathRoarActive = true; TryForceModer(); _finalWindupActive = true; _beamRoarFired = false; _finalRainActive = false; _finalWindupTimer = 8f; _deathRoarLockPos = ((Component)this).transform.position; _deathRoarLockRot = ((Component)this).transform.rotation; _roarOriginalScale = ((Component)this).transform.localScale; _roarBoneLerpT = 0f; if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = false; } if (Object.op_Implicit((Object)(object)_rb)) { RBCompat.Set(_rb, Vector3.zero); _rb.constraints = (RigidbodyConstraints)126; } MainPlugin.TrySetField(_self, "m_moveDir", Vector3.zero); MainPlugin.TrySetField(_self, "m_moveDirection", Vector3.zero); Animator[] anims = _anims; foreach (Animator val in anims) { if (Object.op_Implicit((Object)(object)val)) { val.applyRootMotion = false; } } SkinnedMeshRenderer componentInChildren = ((Component)this).GetComponentInChildren(true); if (((componentInChildren != null) ? componentInChildren.bones : null) != null) { Transform[] bones = componentInChildren.bones; foreach (Transform val2 in bones) { if (!((Object)(object)val2 == (Object)null)) { switch (((Object)val2).name) { case "Spine": _roarSpine = val2; break; case "Spine1": _roarSpine1 = val2; break; case "Neck": _roarNeckBone = val2; break; case "Head": _roarHeadBone = val2; break; case "Jaw": _roarJawBone = val2; break; } } } _roarSpineInitRot = (((Object)(object)_roarSpine != (Object)null) ? _roarSpine.localRotation : Quaternion.identity); _roarSpine1InitRot = (((Object)(object)_roarSpine1 != (Object)null) ? _roarSpine1.localRotation : Quaternion.identity); _roarNeckInitRot = (((Object)(object)_roarNeckBone != (Object)null) ? _roarNeckBone.localRotation : Quaternion.identity); _roarHeadInitRot = (((Object)(object)_roarHeadBone != (Object)null) ? _roarHeadBone.localRotation : Quaternion.identity); _roarJawInitRot = (((Object)(object)_roarJawBone != (Object)null) ? _roarJawBone.localRotation : Quaternion.identity); } Animator[] anims2 = _anims; foreach (Animator val3 in anims2) { if ((Object)(object)val3 == (Object)null) { continue; } RuntimeAnimatorController runtimeAnimatorController = val3.runtimeAnimatorController; if ((Object)(object)runtimeAnimatorController == (Object)null) { continue; } string text = null; AnimationClip[] animationClips = runtimeAnimatorController.animationClips; foreach (AnimationClip val4 in animationClips) { if (string.Equals(((Object)val4).name, "Throw", StringComparison.OrdinalIgnoreCase)) { text = ((Object)val4).name; break; } } if (text == null) { AnimationClip[] animationClips2 = runtimeAnimatorController.animationClips; foreach (AnimationClip val5 in animationClips2) { if (string.Equals(((Object)val5).name, "Jump", StringComparison.OrdinalIgnoreCase)) { text = ((Object)val5).name; break; } } } if (text != null) { if (_deathRoarAnim == null) { _deathRoarAnim = text; } val3.CrossFade(text, 0.15f, 0, 0f); } } ((MonoBehaviour)this).StartCoroutine(FreezeAnimatorsDelayed(0.5f)); } private IEnumerator FreezeAnimatorsDelayed(float delay) { yield return (object)new WaitForSeconds(delay); Animator[] anims = _anims; foreach (Animator anim in anims) { if (Object.op_Implicit((Object)(object)anim)) { anim.speed = 0f; } } } private void StartBeamAudio() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_beamAudioGO)) { return; } ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab("sfx_goblinking_beam") : null); if ((Object)(object)val == (Object)null) { MainPlugin.Log.LogWarning((object)"[FinalPhase] sfx_goblinking_beam no encontrado en ZNetScene."); return; } AudioClip val2 = null; AudioMixerGroup val3 = null; ZSFX[] componentsInChildren = val.GetComponentsInChildren(true); foreach (ZSFX val4 in componentsInChildren) { if (val4.m_audioClips != null && val4.m_audioClips.Length != 0) { val2 = val4.m_audioClips[0]; } AudioSource component = ((Component)val4).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.outputAudioMixerGroup != (Object)null) { val3 = component.outputAudioMixerGroup; } if ((Object)(object)val2 != (Object)null) { break; } } if ((Object)(object)val2 == (Object)null) { MainPlugin.Log.LogWarning((object)"[FinalPhase] No se pudo extraer clip de sfx_goblinking_beam."); return; } _beamAudioGO = new GameObject("NeckzillaBeamAudio"); _beamAudioGO.transform.SetParent(((Component)this).transform, false); _beamAudioGO.transform.localPosition = Vector3.up * 2f; AudioSource val5 = _beamAudioGO.AddComponent(); val5.clip = val2; val5.loop = true; val5.spatialBlend = 1f; val5.minDistance = 5f; val5.maxDistance = 80f; val5.volume = 0.4f; val5.rolloffMode = (AudioRolloffMode)1; if ((Object)(object)val3 != (Object)null) { val5.outputAudioMixerGroup = val3; } val5.Play(); MainPlugin.Log.LogInfo((object)("[FinalPhase] Sonido beam iniciado: clip=" + ((Object)val2).name + " mixer=" + (((val3 != null) ? ((Object)val3).name : null) ?? "none"))); } private void BeginPhase2() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) MainPlugin.Log.LogWarning((object)("[Phase2] *** BeginPhase2() *** IsServer=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsServer().ToString() : "ZNet=null") + " IsDedicated=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsDedicated().ToString() : "ZNet=null"))); IsActive = true; ThunderUnlocked = false; _triggeredOnce = true; _bossLightningFired = false; _stormTriggered = false; _roarP2Fired = false; _timeLeft = Mathf.Max(1f, MainPlugin.P2_DURATION); _seqTimer = 0f; _staggerTimer = 0f; if (!IsDedicatedServer()) { MainPlugin.StartBossMusic(); } if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = false; } _lockPos = ((Component)this).transform.position; if (Object.op_Implicit((Object)(object)_rb)) { _rbConstraintsBackup = _rb.constraints; _rbHadConstraintsBackup = true; RBCompat.Set(_rb, Vector3.zero); _rb.constraints = (RigidbodyConstraints)126; } for (int i = 0; i < _anims.Length; i++) { if (Object.op_Implicit((Object)(object)_anims[i])) { _anims[i].applyRootMotion = false; } } MainPlugin.TrySetField(_self, "m_moveDir", Vector3.zero); MainPlugin.TrySetField(_self, "m_moveDirection", Vector3.zero); SafeDestroyFxLeviathan(); if ((Object)(object)_fxLeviathanPrefab != (Object)null) { _fxLeviathanInst = Object.Instantiate(_fxLeviathanPrefab, ((Component)this).transform.position, Quaternion.identity); } Animator[] anims = _anims; foreach (Animator val in anims) { if (Object.op_Implicit((Object)(object)val)) { val.CrossFade("swimming", 0.3f, 0, 0f); } } ((Component)this).GetComponent()?.Activate(); } private void EndPhase2() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) IsActive = false; if (Object.op_Implicit((Object)(object)_rb) && _rbHadConstraintsBackup) { _rb.constraints = _rbConstraintsBackup; } for (int i = 0; i < _anims.Length; i++) { if (Object.op_Implicit((Object)(object)_anims[i])) { _anims[i].applyRootMotion = _animRootMotionBackup[i]; } } if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = true; } SafeDestroyFxLeviathan(); MainPlugin.Log.LogInfo((object)"[Phase2] Faseo terminado."); } private void FixedUpdate() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (_deathRoarActive && Object.op_Implicit((Object)(object)_rb)) { _rb.MovePosition(_deathRoarLockPos); _rb.MoveRotation(_deathRoarLockRot); } } private void LateUpdate() { //IL_001a: 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_006b: 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_0084: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_010f: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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_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_01ac: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: 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_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) if (_deathRoarActive) { ((Component)this).transform.rotation = _deathRoarLockRot; _roarBoneLerpT = Mathf.Min(1f, _roarBoneLerpT + Time.deltaTime * 0.8f); float roarBoneLerpT = _roarBoneLerpT; if ((Object)(object)_roarSpine != (Object)null) { _roarSpine.localRotation = Quaternion.Slerp(_roarSpineInitRot, _roarSpineInitRot * Quaternion.Euler(22f, 0f, 0f), roarBoneLerpT); } if ((Object)(object)_roarSpine1 != (Object)null) { _roarSpine1.localRotation = Quaternion.Slerp(_roarSpine1InitRot, _roarSpine1InitRot * Quaternion.Euler(22f, 0f, 0f), roarBoneLerpT); } if ((Object)(object)_roarNeckBone != (Object)null) { _roarNeckBone.localRotation = Quaternion.Slerp(_roarNeckInitRot, _roarNeckInitRot * Quaternion.Euler(35f, 0f, 0f), roarBoneLerpT); } if ((Object)(object)_roarHeadBone != (Object)null) { _roarHeadBone.localRotation = Quaternion.Slerp(_roarHeadInitRot, _roarHeadInitRot * Quaternion.Euler(18f, 0f, 0f), roarBoneLerpT); } if ((Object)(object)_roarJawBone != (Object)null) { _roarJawBone.localRotation = Quaternion.Slerp(_roarJawInitRot, _roarJawInitRot * Quaternion.Euler(-45f, 0f, 0f), roarBoneLerpT); } if (_roarOriginalScale != Vector3.zero) { ((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, _roarOriginalScale * 2.8f, Time.deltaTime * 0.12f); } Vector3 val; if (Object.op_Implicit((Object)(object)_activeBeamGO) && (Object)(object)_roarJawBone != (Object)null) { val = Vector3.Slerp(_roarJawBone.up, Vector3.up, 0.35f); Vector3 normalized = ((Vector3)(ref val)).normalized; _activeBeamGO.transform.position = _roarJawBone.position + normalized * 0.4f; _activeBeamGO.transform.rotation = Quaternion.LookRotation(normalized); } else if (Object.op_Implicit((Object)(object)_activeBeamGO) && (Object)(object)_roarHeadBone != (Object)null) { val = Vector3.Slerp(_roarHeadBone.up, Vector3.up, 0.35f); Vector3 normalized2 = ((Vector3)(ref val)).normalized; _activeBeamGO.transform.position = _roarHeadBone.position + normalized2 * 1.5f; _activeBeamGO.transform.rotation = Quaternion.LookRotation(normalized2); } } } private void FireBeamAtSky() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_007e: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0108: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_beamPrefabCache == (Object)null) { ZNetScene instance = ZNetScene.instance; _beamPrefabCache = ((instance != null) ? instance.GetPrefab("vfx_goblinking_beam_OLD") : null); } if (Object.op_Implicit((Object)(object)_activeBeamGO)) { Object.Destroy((Object)(object)_activeBeamGO); _activeBeamGO = null; } Vector3 val; Vector3 val2; Quaternion val3; if ((Object)(object)_roarJawBone != (Object)null) { val = Vector3.Slerp(_roarJawBone.up, Vector3.up, 0.35f); Vector3 normalized = ((Vector3)(ref val)).normalized; val2 = _roarJawBone.position + normalized * 0.4f; val3 = Quaternion.LookRotation(normalized); } else if ((Object)(object)_roarHeadBone != (Object)null) { val = Vector3.Slerp(_roarHeadBone.up, Vector3.up, 0.35f); Vector3 normalized2 = ((Vector3)(ref val)).normalized; val2 = _roarHeadBone.position + normalized2 * 1.5f; val3 = Quaternion.LookRotation(normalized2); } else { val2 = ((Component)this).transform.position + Vector3.up * 3f; val3 = Quaternion.LookRotation(Vector3.up); } if ((Object)(object)_beamPrefabCache != (Object)null) { GameObject val4 = Object.Instantiate(_beamPrefabCache, val2, val3); Color val5 = default(Color); ((Color)(ref val5))..ctor(0f, 0.6f, 3.5f, 1f); Renderer[] componentsInChildren = val4.GetComponentsInChildren(true); foreach (Renderer val6 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val6)) { MaterialPropertyBlock val7 = new MaterialPropertyBlock(); val6.GetPropertyBlock(val7); val7.SetColor("_Color", val5); val7.SetColor("_TintColor", val5); val6.SetPropertyBlock(val7); } } ParticleSystem[] componentsInChildren2 = val4.GetComponentsInChildren(true); foreach (ParticleSystem val8 in componentsInChildren2) { MainModule main = val8.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).duration = 9999f; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; if (!val8.isPlaying) { val8.Play(true); } } TimedDestruction[] componentsInChildren3 = val4.GetComponentsInChildren(true); foreach (TimedDestruction val9 in componentsInChildren3) { Object.Destroy((Object)(object)val9); } ZNetView component = val4.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { Object.Destroy((Object)(object)component); } _activeBeamGO = val4; } MainPlugin.Log.LogInfo((object)"[FinalPhase] Rayo al cielo disparado."); } private void SpawnRainLightning() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0118: Unknown result type (might be due to invalid IL or missing references) if (!IsOwnerOrServer()) { return; } int num = Random.Range(2, 4); Vector3 position = ((Component)this).transform.position; int mask = LayerMask.GetMask(new string[5] { "Default", "piece", "terrain", "static_solid", "Default_small" }); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < num; i++) { Vector3 val = position + new Vector3(Random.Range(-22f, 22f), 0f, Random.Range(-22f, 22f)); if (Physics.Raycast(val + Vector3.up * 10f, Vector3.down, ref val2, 30f, mask)) { val = ((RaycastHit)(ref val2)).point + Vector3.up * 0.05f; } if (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid()) { _nview.InvokeRPC(ZNetView.Everybody, "NeckzillaThunderWarn", new object[1] { val }); } } } private IEnumerator TelegraphAndStrike(Vector3 pos, float delay) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) GameObject warn = GameObject.CreatePrimitive((PrimitiveType)0); warn.transform.position = pos + Vector3.up * 0.05f; warn.transform.localScale = new Vector3(2f, 0.15f, 2f); Object.Destroy((Object)(object)warn.GetComponent()); MeshRenderer mr = warn.GetComponent(); if (Object.op_Implicit((Object)(object)mr)) { Material mat = new Material(Shader.Find("Sprites/Default")); mat.color = new Color(0.2f, 0.6f, 1f, 0.7f); ((Renderer)mr).material = mat; } Object.Destroy((Object)(object)warn, delay); yield return (object)new WaitForSeconds(delay); ZNetScene instance = ZNetScene.instance; GameObject boltPrefab = ((instance != null) ? instance.GetPrefab(MainPlugin.P2_BOLT_PREFAB) : null); if (Object.op_Implicit((Object)(object)boltPrefab)) { Object.Instantiate(boltPrefab, pos + Vector3.up * 15f, Quaternion.identity); } } private void SpawnRainMeteors() { if ((Object)(object)_meteorPrefabCache == (Object)null) { ZNetScene instance = ZNetScene.instance; _meteorPrefabCache = ((instance != null) ? instance.GetPrefab("projectile_ashlandmeteor") : null); } if (Object.op_Implicit((Object)(object)_meteorPrefabCache)) { int total = Random.Range(6, 10); ((MonoBehaviour)this).StartCoroutine(MeteorShowerCoroutine(total)); } } private IEnumerator MeteorShowerCoroutine(int total) { if ((Object)(object)_meteorPrefabCache == (Object)null) { yield break; } Color blue = new Color(0f, 0.5f, 3f, 1f); for (int i = 0; i < total; i++) { Vector3 center = ((Component)this).transform.position; Vector3 offset = new Vector3(Random.Range(-28f, 28f), 0f, Random.Range(-28f, 28f)); Vector3 spawnPos = center + offset + Vector3.up * 60f; GameObject meteor = Object.Instantiate(_meteorPrefabCache, spawnPos, Quaternion.LookRotation(Vector3.down)); Renderer[] componentsInChildren = meteor.GetComponentsInChildren(true); foreach (Renderer r in componentsInChildren) { if (Object.op_Implicit((Object)(object)r)) { MaterialPropertyBlock mpb = new MaterialPropertyBlock(); r.GetPropertyBlock(mpb); mpb.SetColor("_Color", blue); mpb.SetColor("_TintColor", blue); r.SetPropertyBlock(mpb); } } ZNetView znv2 = meteor.GetComponent(); if ((Object)(object)znv2 != (Object)null) { znv2.m_persistent = false; } Projectile proj = meteor.GetComponent(); if ((Object)(object)proj != (Object)null) { HitData hd = new HitData(); hd.m_damage.m_fire = 60f; hd.m_damage.m_blunt = 40f; hd.m_pushForce = 60f; hd.m_blockable = true; MethodInfo setup = typeof(Projectile).GetMethod("Setup", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (setup != null) { int pcount = setup.GetParameters().Length; object[] args = ((pcount < 6) ? new object[5] { null, Vector3.down * 20f, 0f, hd, null } : new object[6] { null, Vector3.down * 20f, 0f, hd, null, null }); try { setup.Invoke(proj, args); } catch (Exception e) { MainPlugin.Log.LogWarning((object)("[Meteor] Setup: " + e.Message)); } } } Object.Destroy((Object)(object)meteor, 15f); yield return (object)new WaitForSeconds(Random.Range(0.4f, 0.9f)); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)_activeBeamGO)) { Object.Destroy((Object)(object)_activeBeamGO); _activeBeamGO = null; } if (Object.op_Implicit((Object)(object)_beamAudioGO)) { Object.Destroy((Object)(object)_beamAudioGO); _beamAudioGO = null; } Animator[] anims = _anims; foreach (Animator val in anims) { if (Object.op_Implicit((Object)(object)val)) { val.speed = 1f; } } SafeDestroyFxLeviathan(); RevertWeather(); SafeDestroyElectricAura(); SafeDestroyLightningAura(); if (!IsDedicatedServer()) { MainPlugin.StopBossMusic(); } } private void SafeDestroyFxLeviathan() { if (Object.op_Implicit((Object)(object)_fxLeviathanInst)) { Object.Destroy((Object)(object)_fxLeviathanInst); _fxLeviathanInst = null; } } private void SafeDestroyElectricAura() { if (Object.op_Implicit((Object)(object)_electricAuraRoot)) { ParticleSystem[] componentsInChildren = _electricAuraRoot.GetComponentsInChildren(true); foreach (ParticleSystem val in componentsInChildren) { val.Stop(true, (ParticleSystemStopBehavior)0); } _electricAuraRoot.transform.SetParent((Transform)null, true); Object.Destroy((Object)(object)_electricAuraRoot); _electricAuraRoot = null; } } private void SafeDestroyLightningAura() { if (Object.op_Implicit((Object)(object)_lightningAuraRoot)) { ParticleSystem[] componentsInChildren = _lightningAuraRoot.GetComponentsInChildren(true); foreach (ParticleSystem val in componentsInChildren) { val.Stop(true, (ParticleSystemStopBehavior)0); } _lightningAuraRoot.transform.SetParent((Transform)null, true); Object.Destroy((Object)(object)_lightningAuraRoot); _lightningAuraRoot = null; } } private void SpawnLightningAura() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) SafeDestroyLightningAura(); _lightningAuraRoot = new GameObject("NeckzillaLightningAura"); _lightningAuraRoot.transform.SetParent(((Component)this).transform, false); _lightningAuraRoot.transform.localPosition = Vector3.zero; SpawnAuraPrefab(_lightningAuraRoot.transform, new string[5] { "fx_Lightning", "fx_lightning", "Lightning_AOE", "lightningAOE", "fx_eikthyr_lightning_hit" }); } private void SpawnAuraPrefab(Transform parent, string[] candidates) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown GameObject val = null; foreach (string text in candidates) { if (PrefabManager.Instance != null) { val = PrefabManager.Instance.GetPrefab(text); } if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(text); } if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { MainPlugin.Log.LogWarning((object)("[Phase2] Prefab aura no encontrado: " + string.Join("/", candidates))); return; } GameObject val2 = Object.Instantiate(val, parent); val2.transform.localPosition = Vector3.zero; ZNetView[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (ZNetView val3 in componentsInChildren) { Object.Destroy((Object)(object)val3); } MeshRenderer[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (MeshRenderer val4 in componentsInChildren2) { if (!((Object)(object)val4 == (Object)null) && (Object)(object)((Component)val4).GetComponent() == (Object)null) { Object.Destroy((Object)(object)val4); } } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren3 = val2.GetComponentsInChildren(true); foreach (Component val5 in componentsInChildren3) { if ((Object)(object)val5 == (Object)null) { continue; } string name = ((object)val5).GetType().Name; if (name == "Aoe" || name == "DamageArea" || name == "CircleProjector") { Object.Destroy((Object)(object)val5); continue; } FieldInfo field = ((object)val5).GetType().GetField("m_damage", bindingAttr); if (field != null) { try { field.SetValue(val5, (object?)new HitData()); } catch { } } } ParticleSystem[] componentsInChildren4 = val2.GetComponentsInChildren(true); foreach (ParticleSystem val6 in componentsInChildren4) { MainModule main = val6.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).duration = 999f; } MainPlugin.Log.LogInfo((object)("[Phase2] Aura spawneada: " + ((Object)val).name)); } private void SpawnHimminAflOnce() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown string[] array = new string[3] { "fx_himminafl_aoe", "fx_Himminafl_aoe", "fx_himminaflAOE" }; GameObject val = null; string[] array2 = array; foreach (string text in array2) { if (PrefabManager.Instance != null) { val = PrefabManager.Instance.GetPrefab(text); } if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(text); } if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { return; } GameObject val2 = Object.Instantiate(val, ((Component)this).transform.position, Quaternion.identity); if ((Object)(object)val2 == (Object)null) { return; } ZNetView[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (ZNetView val3 in componentsInChildren) { Object.Destroy((Object)(object)val3); } MeshRenderer[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (MeshRenderer val4 in componentsInChildren2) { if ((Object)(object)val4 != (Object)null && (Object)(object)((Component)val4).GetComponent() == (Object)null) { Object.Destroy((Object)(object)val4); } } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren3 = val2.GetComponentsInChildren(true); foreach (Component val5 in componentsInChildren3) { if ((Object)(object)val5 == (Object)null) { continue; } string name = ((object)val5).GetType().Name; if (name == "Aoe" || name == "DamageArea" || name == "CircleProjector") { Object.Destroy((Object)(object)val5); continue; } FieldInfo field = ((object)val5).GetType().GetField("m_damage", bindingAttr); if (field != null) { try { field.SetValue(val5, (object?)new HitData()); } catch { } } } } private void SpawnBossLightning() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown string p2_BOLT_PREFAB = MainPlugin.P2_BOLT_PREFAB; GameObject val = null; if (PrefabManager.Instance != null) { val = PrefabManager.Instance.GetPrefab(p2_BOLT_PREFAB); } if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(p2_BOLT_PREFAB); } if ((Object)(object)val == (Object)null) { MainPlugin.Log.LogWarning((object)("[Phase2] Prefab rayo no encontrado: " + p2_BOLT_PREFAB)); return; } GameObject val2 = Object.Instantiate(val, ((Component)this).transform.position + Vector3.up * 2f, Quaternion.identity); if ((Object)(object)val2 == (Object)null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (Component val3 in componentsInChildren) { if ((Object)(object)val3 == (Object)null) { continue; } string name = ((object)val3).GetType().Name; if (name == "Aoe" || name == "DamageArea") { Object.Destroy((Object)(object)val3); continue; } FieldInfo field = ((object)val3).GetType().GetField("m_damage", bindingAttr); if (field != null && field.FieldType.Name == "HitData") { try { field.SetValue(val3, (object?)new HitData()); } catch { } } } MainPlugin.Log.LogInfo((object)("[Phase2] Rayo boss: " + p2_BOLT_PREFAB)); } private void SpawnElectricAura() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown SafeDestroyElectricAura(); string p2_BOLT_PREFAB = MainPlugin.P2_BOLT_PREFAB; GameObject val = null; if (PrefabManager.Instance != null) { val = PrefabManager.Instance.GetPrefab(p2_BOLT_PREFAB); } if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(p2_BOLT_PREFAB); } if ((Object)(object)val == (Object)null) { return; } _electricAuraRoot = new GameObject("NeckzillaElectricAura"); _electricAuraRoot.transform.SetParent(((Component)this).transform, false); _electricAuraRoot.transform.localPosition = Vector3.zero; GameObject val2 = Object.Instantiate(val, _electricAuraRoot.transform); val2.transform.localPosition = Vector3.zero; ZNetView[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (ZNetView val3 in componentsInChildren) { Object.Destroy((Object)(object)val3); } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (Component val4 in componentsInChildren2) { if ((Object)(object)val4 == (Object)null) { continue; } string name = ((object)val4).GetType().Name; if (name == "Aoe" || name == "DamageArea") { Object.Destroy((Object)(object)val4); continue; } FieldInfo field = ((object)val4).GetType().GetField("m_damage", bindingAttr); if (field != null && field.FieldType.Name == "HitData") { try { field.SetValue(val4, (object?)new HitData()); } catch { } } } ParticleSystem[] componentsInChildren3 = val2.GetComponentsInChildren(true); foreach (ParticleSystem val5 in componentsInChildren3) { MainModule main = val5.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; } MainPlugin.Log.LogInfo((object)"[Phase2] Aura electrica activa."); } private void TryForceStorm() { if (_stormForced) { return; } EnvMan instance = EnvMan.instance; if (!((Object)(object)instance == (Object)null)) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = ((object)instance).GetType().GetField("m_debugEnv", bindingAttr); if (field == null) { MainPlugin.Log.LogWarning((object)"[Phase2] Campo m_debugEnv no encontrado."); return; } field.SetValue(instance, "ThunderStorm"); _stormForced = true; MainPlugin.Log.LogInfo((object)"[Phase2] Clima ThunderStorm activado (transicion suave via m_debugEnv)."); } } private void TryForceModer() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0108: 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) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (_moderForced) { return; } EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null) { return; } Color val = default(Color); foreach (EnvSetup environment in instance.m_environments) { if (environment.m_name != "Moder") { continue; } environment.m_isFreezing = false; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = ((object)environment).GetType().GetField("m_rain", bindingAttr); FieldInfo field2 = ((object)environment).GetType().GetField("m_thunder", bindingAttr); if (field != null) { field.SetValue(environment, true); } if (field2 != null) { field2.SetValue(environment, true); } ((Color)(ref val))..ctor(0.3f, 0.4f, 0.55f); environment.m_fogColorDay = val; environment.m_fogColorNight = new Color(0.1f, 0.15f, 0.3f); environment.m_fogColorMorning = val; environment.m_fogColorEvening = val; environment.m_ambColorDay = new Color(0.35f, 0.45f, 0.6f); environment.m_ambColorNight = new Color(0.15f, 0.2f, 0.35f); break; } BindingFlags bindingAttr2 = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field3 = ((object)instance).GetType().GetField("m_debugEnv", bindingAttr2); if (!(field3 == null)) { field3.SetValue(instance, "Moder"); _moderForced = true; MainPlugin.Log.LogInfo((object)"[FinalPhase] Clima Moder azul/gris con lluvia y truenos activado."); } } private void RevertWeather() { EnvMan instance = EnvMan.instance; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo fieldInfo = ((object)instance)?.GetType().GetField("m_debugEnv", bindingAttr); if (_stormForced || _moderForced) { _stormForced = false; _moderForced = false; if (fieldInfo != null) { fieldInfo.SetValue(instance, ""); } MainPlugin.Log.LogInfo((object)"[Phase2] Clima restaurado."); } } private void StaggerPlayersInRadius(float radius) { //IL_0030: 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_00cc: Unknown result type (might be due to invalid IL or missing references) _scratch.Clear(); try { Character.GetCharactersInRange(((Component)this).transform.position, radius, _scratch); } catch { Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, radius, -1, (QueryTriggerInteraction)2); foreach (Collider val in array) { Character componentInParent = ((Component)val).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && !_scratch.Contains(componentInParent)) { _scratch.Add(componentInParent); } } } foreach (Character item in _scratch) { Player val2 = (Player)(object)((item is Player) ? item : null); if (Object.op_Implicit((Object)(object)val2) && !((Character)val2).IsDead()) { MainPlugin.SafeStagger((Character)(object)val2, ((Component)this).transform.position); } } } private static float GetHealthSafe(Character ch) { if (!Object.op_Implicit((Object)(object)ch)) { return 0f; } try { MethodInfo method = ((object)ch).GetType().GetMethod("GetHealth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { return (float)method.Invoke(ch, null); } } catch { } try { FieldInfo field = ((object)ch).GetType().GetField("m_health", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (float)field.GetValue(ch); } } catch { } return 0f; } private bool IsOwnerOrServer() { return (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) || (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner()); } private static bool IsDedicatedServer() { return Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsDedicated(); } } public class NeckzillaBombardment : MonoBehaviour { private Character _self; private BaseAI _ai; private ZNetView _nview; private float _timer; private GameObject _projPrefab; private static readonly string[] CANDIDATES = new string[6] { "DvergerStaffFire_clusterbomb_projectile", "dvergerstafffire_clusterbomb_projectile", "dvergerstaff_fire_clusterbomb_projectile", "dverger_staff_fire_clusterbomb_projectile", "DvergerStaff_clusterbomb_projectile", "Dverger_staff_fire_clusterbomb_projectile" }; private static readonly int SOLID_MASK = LayerMask.GetMask(new string[5] { "Default", "piece", "terrain", "static_solid", "Default_small" }); private bool IsOwnerOrServer() { return (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) || (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner()); } private void Start() { _self = ((Component)this).GetComponent(); _ai = ((Component)this).GetComponent(); _nview = ((Component)this).GetComponent(); _timer = Random.Range(0f, MainPlugin.BMB_CD * 0.5f); _projPrefab = ResolveProjectilePrefab(); if ((Object)(object)_projPrefab == (Object)null) { MainPlugin.Log.LogWarning((object)"[Bombard] No se encontró NINGÚN prefab candidato de clusterbomb."); } else { MainPlugin.Log.LogInfo((object)("[Bombard] Proyectil resuelto: " + ((Object)_projPrefab).name)); } } private GameObject ResolveProjectilePrefab() { PrefabManager instance = PrefabManager.Instance; string[] cANDIDATES = CANDIDATES; foreach (string text in cANDIDATES) { if (!string.IsNullOrWhiteSpace(text)) { GameObject val = null; if (instance != null) { val = instance.GetPrefab(text); } if ((Object)(object)val == (Object)null && Object.op_Implicit((Object)(object)ZNetScene.instance)) { val = ZNetScene.instance.GetPrefab(text); } if ((Object)(object)val != (Object)null) { return val; } } } return null; } private void Update() { if ((Object)(object)_self == (Object)null || !IsOwnerOrServer()) { return; } NeckzillaPhase2 component = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)component) && (component.IsActive || component.IsFinalPhase)) { return; } _timer -= Time.deltaTime; if (_timer > 0f) { return; } if ((Object)(object)_projPrefab == (Object)null) { _projPrefab = ResolveProjectilePrefab(); if ((Object)(object)_projPrefab == (Object)null) { _timer = 2f; return; } } Player val = PickFarthestPlayerInRange(MainPlugin.BMB_MIN, MainPlugin.BMB_MAX, requireLoS: true); if (!Object.op_Implicit((Object)(object)val)) { val = PickNearestWithin(MainPlugin.BMB_MIN, MainPlugin.BMB_MAX, requireLoS: true); } if (!Object.op_Implicit((Object)(object)val)) { val = PickNearestWithin(MainPlugin.BMB_MIN, MainPlugin.BMB_MAX, requireLoS: false); } if (!Object.op_Implicit((Object)(object)val)) { _timer = Mathf.Min(1f, MainPlugin.BMB_CD * 0.25f); return; } FireAt(val); _timer = MainPlugin.BMB_CD; } private Player PickFarthestPlayerInRange(float min, float max, bool requireLoS) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) List allPlayers = Player.GetAllPlayers(); Player result = null; float num = 0f; Vector3 position = ((Component)this).transform.position; for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if (!Object.op_Implicit((Object)(object)val) || ((Character)val).IsDead()) { continue; } float num2 = Vector3.Distance(position, ((Component)val).transform.position); if (num2 < min || num2 > max) { continue; } if (requireLoS) { Vector3 val2 = position + Vector3.up * 1f; Vector3 centerPoint = ((Character)val).GetCenterPoint(); if (Physics.Linecast(val2, centerPoint, SOLID_MASK)) { continue; } } if (num2 > num) { num = num2; result = val; } } return result; } private Player PickNearestWithin(float min, float max, bool requireLoS) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) List allPlayers = Player.GetAllPlayers(); Player result = null; float num = float.MaxValue; Vector3 position = ((Component)this).transform.position; for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if (!Object.op_Implicit((Object)(object)val) || ((Character)val).IsDead()) { continue; } float num2 = Vector3.Distance(position, ((Component)val).transform.position); if (num2 < min || num2 > max) { continue; } if (requireLoS) { Vector3 val2 = position + Vector3.up * 1f; Vector3 centerPoint = ((Character)val).GetCenterPoint(); if (Physics.Linecast(val2, centerPoint, SOLID_MASK)) { continue; } } if (num2 < num) { num = num2; result = val; } } return result; } private void FireAt(Player p) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0073: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) float ownerHorizontalRadius = GetOwnerHorizontalRadius(); float ownerHeight = GetOwnerHeight(); Vector3 val = ((Component)this).transform.position + Vector3.up * (Mathf.Max(1f, ownerHeight * 0.55f) + 3f) + ((Component)this).transform.forward * (ownerHorizontalRadius + 0.8f); Vector3 val2 = ((Character)p).GetCenterPoint() - val; Vector3 normalized = ((Vector3)(ref val2)).normalized; Quaternion val3 = Quaternion.LookRotation(normalized, Vector3.up); GameObject val4 = Object.Instantiate(_projPrefab, val, val3); IgnoreOwnerCollisions(val4); EnsureProjectileMoves(val4, normalized * MainPlugin.BMB_SPEED); Component val5 = FindProjectileComponent(val4); if ((Object)(object)val5 != (Object)null) { MainPlugin.TrySetField(val5, "m_owner", _self); MainPlugin.TrySetField(val5, "m_ttl", 8f); MainPlugin.TrySetField(val5, "m_gravity", 0f); } NeckzillaOnHitAoE neckzillaOnHitAoE = val4.AddComponent(); neckzillaOnHitAoE.Init(_self, MainPlugin.BMB_AOE, MainPlugin.BMB_FIRE, MainPlugin.BMB_BLUNT); } private void EnsureProjectileMoves(GameObject go, Vector3 velocity) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Rigidbody val = go.GetComponent(); if (!Object.op_Implicit((Object)(object)val)) { val = go.AddComponent(); } val.useGravity = false; val.isKinematic = false; val.collisionDetectionMode = (CollisionDetectionMode)2; RBCompat.Set(val, velocity); Component val2 = FindProjectileComponent(go); if ((Object)(object)val2 != (Object)null) { MainPlugin.TrySetField(val2, "m_vel", velocity); TryCallSetup(val2, velocity); } } private Component FindProjectileComponent(GameObject go) { Component[] components = go.GetComponents(); foreach (Component val in components) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "Projectile") { return val; } } return null; } private void TryCallSetup(Component proj, Vector3 velocity) { //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) Type type = ((object)proj).GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; MethodInfo method = type.GetMethod("Setup", bindingAttr); if (method != null) { ParameterInfo[] parameters = method.GetParameters(); try { if (parameters.Length == 4 && parameters[0].ParameterType.IsAssignableFrom(typeof(Character)) && parameters[1].ParameterType == typeof(Vector3) && parameters[2].ParameterType == typeof(float) && parameters[3].ParameterType == typeof(float)) { method.Invoke(proj, new object[4] { _self, velocity, 0f, 8f }); return; } if (parameters.Length == 2 && parameters[0].ParameterType == typeof(Vector3) && parameters[1].ParameterType == typeof(float)) { method.Invoke(proj, new object[2] { velocity, 8f }); return; } } catch { } } string[] array = new string[2] { "Launch", "SetVelocity" }; foreach (string name in array) { try { MethodInfo method2 = type.GetMethod(name, bindingAttr, null, new Type[1] { typeof(Vector3) }, null); if (method2 != null) { method2.Invoke(proj, new object[1] { velocity }); break; } } catch { } } } private void IgnoreOwnerCollisions(GameObject proj) { Collider[] componentsInChildren = proj.GetComponentsInChildren(true); Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { for (int j = 0; j < componentsInChildren2.Length; j++) { if (Object.op_Implicit((Object)(object)componentsInChildren[i]) && Object.op_Implicit((Object)(object)componentsInChildren2[j])) { Physics.IgnoreCollision(componentsInChildren[i], componentsInChildren2[j], true); } } } } private float GetOwnerHorizontalRadius() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_0071: 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_007b: Unknown result type (might be due to invalid IL or missing references) float num = 0.6f; CapsuleCollider componentInChildren = ((Component)this).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { num = Mathf.Max(num, componentInChildren.radius * Mathf.Max(((Component)this).transform.lossyScale.x, ((Component)this).transform.lossyScale.z)); } else { Collider componentInChildren2 = ((Component)this).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren2)) { Bounds bounds = componentInChildren2.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; num = Mathf.Max(num, Mathf.Max(extents.x, extents.z)); } } return num; } private float GetOwnerHeight() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) CapsuleCollider componentInChildren = ((Component)this).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { return componentInChildren.height * ((Component)this).transform.lossyScale.y; } Collider componentInChildren2 = ((Component)this).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren2)) { Bounds bounds = componentInChildren2.bounds; return ((Bounds)(ref bounds)).size.y; } return 2f; } } public class NeckzillaThunder : MonoBehaviour { private struct PendingStrike { public Vector3 pos; public float timeLeft; public GameObject circleGO; } private Character _self; private ZNetView _nview; private float _timer; private readonly List _pending = new List(); private static readonly int SOLID_MASK = LayerMask.GetMask(new string[5] { "Default", "piece", "terrain", "static_solid", "Default_small" }); private const float WARN_CIRCLE_RADIUS = 2.5f; private const int WARN_CIRCLE_SEGMENTS = 40; private const float WARN_CIRCLE_HEIGHT = 0.15f; private static readonly FieldInfo _nviewZdoField = typeof(ZNetView).GetField("m_zdo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo _sceneInstancesField = typeof(ZNetScene).GetField("m_instances", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private void OnDestroy() { foreach (PendingStrike item in _pending) { if (Object.op_Implicit((Object)(object)item.circleGO)) { Object.Destroy((Object)(object)item.circleGO); } } _pending.Clear(); } private void Start() { _self = ((Component)this).GetComponent(); _nview = ((Component)this).GetComponent(); _timer = MainPlugin.THU_COOLDOWN; if (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid()) { _nview.Register("NeckzillaThunderWarn", (Action)RPC_ThunderWarn); } } private bool IsAuthority() { return (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner()) || (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()); } private void Update() { //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_self) || _self.IsDead()) { return; } for (int num = _pending.Count - 1; num >= 0; num--) { PendingStrike value = _pending[num]; value.timeLeft -= Time.deltaTime; if (Object.op_Implicit((Object)(object)value.circleGO)) { float num2 = 1f - value.timeLeft / MainPlugin.THU_DELAY; float num3 = 1f + 0.12f * Mathf.Sin(num2 * (float)Math.PI * 8f); value.circleGO.transform.localScale = Vector3.one * num3; LineRenderer component = value.circleGO.GetComponent(); if ((Object)(object)component != (Object)null) { float num4 = 0.5f + 0.5f * Mathf.Sin(num2 * (float)Math.PI * 6f); component.startColor = new Color(0.7f, 0f, 1f, num4); component.endColor = new Color(0.7f, 0f, 1f, num4); } } _pending[num] = value; if (value.timeLeft <= 0f) { if (Object.op_Implicit((Object)(object)value.circleGO)) { Object.Destroy((Object)(object)value.circleGO); } _pending.RemoveAt(num); try { SpawnStrike(value.pos); } catch (Exception ex) { MainPlugin.Log.LogError((object)("[Thunder] SpawnStrike: " + ex.Message)); } if (IsAuthority()) { ApplyStrikeDamage(value.pos); } } } if (!IsAuthority()) { return; } NeckzillaPhase2 component2 = ((Component)this).GetComponent(); if ((Object)(object)component2 == (Object)null || !component2.ThunderUnlocked) { return; } _timer -= Time.deltaTime; if (_timer > 0f) { return; } _timer = MainPlugin.THU_COOLDOWN; Vector3 position = ((Component)this).transform.position; foreach (Player allPlayer in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)allPlayer) && !((Character)allPlayer).IsDead() && !(Vector3.Distance(position, ((Component)allPlayer).transform.position) > 35f)) { Vector3 val = SnapToGround(((Component)allPlayer).transform.position); if (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid()) { _nview.InvokeRPC(ZNetView.Everybody, "NeckzillaThunderWarn", new object[1] { val }); } else { RPC_ThunderWarn(0L, val); } } } } private void RPC_ThunderWarn(long sender, Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) GameObject circleGO = CreateWarningCircle(pos); _pending.Add(new PendingStrike { pos = pos, timeLeft = MainPlugin.THU_DELAY, circleGO = circleGO }); } private static GameObject CreateWarningCircle(Vector3 center) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0085: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("NeckzillaThunderWarning"); val.transform.position = center + Vector3.up * 0.15f; LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = false; val2.loop = true; val2.positionCount = 41; val2.startWidth = 0.18f; val2.endWidth = 0.18f; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; Material val3 = new Material(Shader.Find("Sprites/Default")); val3.color = new Color(0.7f, 0f, 1f, 1f); ((Renderer)val2).material = val3; val2.startColor = new Color(0.7f, 0f, 1f, 1f); val2.endColor = new Color(0.7f, 0f, 1f, 1f); float num = 2.5f; for (int i = 0; i <= 40; i++) { float num2 = (float)i / 40f * (float)Math.PI * 2f; val2.SetPosition(i, new Vector3(Mathf.Cos(num2) * num, 0f, Mathf.Sin(num2) * num)); } return val; } private void SpawnStrike(Vector3 pos) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_010a: Expected O, but got Unknown string tHU_STRIKE_PREFAB = MainPlugin.THU_STRIKE_PREFAB; GameObject val = null; if (PrefabManager.Instance != null) { val = PrefabManager.Instance.GetPrefab(tHU_STRIKE_PREFAB); } if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(tHU_STRIKE_PREFAB); } if ((Object)(object)val == (Object)null) { MainPlugin.Log.LogWarning((object)("[Thunder] Prefab no encontrado: " + tHU_STRIKE_PREFAB)); return; } GameObject val2 = Object.Instantiate(val, pos, Quaternion.identity); if ((Object)(object)val2 == (Object)null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (Component val3 in componentsInChildren) { if ((Object)(object)val3 == (Object)null || ((object)val3).GetType().Name != "Aoe") { continue; } FieldInfo field = ((object)val3).GetType().GetField("m_damage", bindingAttr); if (field != null) { try { field.SetValue(val3, (object?)new HitData()); } catch { } } } ZNetView component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { MakeLocalOnly(component); } } public static void MakeLocalOnlyStatic(ZNetView nv) { MakeLocalOnly(nv); } private static void MakeLocalOnly(ZNetView nv) { if ((Object)(object)nv == (Object)null) { return; } if (nv.IsValid()) { ZDO zDO = nv.GetZDO(); if ((Object)(object)ZNetScene.instance != (Object)null && _sceneInstancesField != null && _sceneInstancesField.GetValue(ZNetScene.instance) is IDictionary dictionary) { dictionary.Remove(zDO); } ZDOMan instance = ZDOMan.instance; if (instance != null) { instance.DestroyZDO(zDO); } _nviewZdoField?.SetValue(nv, null); } Object.Destroy((Object)(object)nv); } private void ApplyStrikeDamage(Vector3 pos) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) List list = new List(); try { Character.GetCharactersInRange(pos, MainPlugin.THU_RADIUS, list); } catch { Collider[] array = Physics.OverlapSphere(pos, MainPlugin.THU_RADIUS, -1, (QueryTriggerInteraction)2); foreach (Collider val in array) { Character componentInParent = ((Component)val).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && !list.Contains(componentInParent)) { list.Add(componentInParent); } } } foreach (Character item in list) { Player val2 = (Player)(object)((item is Player) ? item : null); if (Object.op_Implicit((Object)(object)val2) && !((Character)val2).IsDead()) { Vector3 val3 = ((Component)val2).transform.position - pos; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.001f) { val3 = Vector3.forward; } HitData val4 = new HitData { m_point = ((Character)val2).GetCenterPoint(), m_dir = ((Vector3)(ref val3)).normalized, m_pushForce = 15f, m_blockable = false }; val4.m_damage.m_lightning = MainPlugin.THU_DAMAGE; try { val4.SetAttacker(_self); } catch { } ((Character)val2).Damage(val4); } } } private static Vector3 SnapToGround(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(pos + Vector3.up * 5f, Vector3.down, ref val, 20f, SOLID_MASK)) { return ((RaycastHit)(ref val)).point + Vector3.up * 0.05f; } return pos; } } public class NeckzillaLavaField : MonoBehaviour { private Character _self; private ZNetView _nview; private GameObject _lavaPrefab; private bool _active; private float _timer; private static readonly int SOLID_MASK = LayerMask.GetMask(new string[6] { "Default", "piece", "terrain", "static_solid", "Default_small", "character" }); private bool _updateLoggedOnce; private float _diagTimer; public bool IsActive => _active; private void Start() { MainPlugin.Log.LogWarning((object)("[LavaField] *** Start() *** go=" + ((Object)((Component)this).gameObject).name + " IsServer=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsServer().ToString() : "ZNet=null") + " IsDedicated=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsDedicated().ToString() : "ZNet=null"))); _self = ((Component)this).GetComponent(); _nview = ((Component)this).GetComponent(); PrefabManager instance = PrefabManager.Instance; if (instance != null) { _lavaPrefab = instance.GetPrefab(MainPlugin.LAVA_PREFAB); } if ((Object)(object)_lavaPrefab == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { _lavaPrefab = ZNetScene.instance.GetPrefab(MainPlugin.LAVA_PREFAB); } if ((Object)(object)_lavaPrefab == (Object)null) { MainPlugin.Log.LogWarning((object)("[LavaField] Prefab NO encontrado: " + MainPlugin.LAVA_PREFAB)); } else { MainPlugin.Log.LogWarning((object)("[LavaField] Prefab OK: " + MainPlugin.LAVA_PREFAB + " | ZNetView: " + ((Object)(object)_lavaPrefab.GetComponent() != (Object)null))); } _timer = MainPlugin.LAVA_INTERVAL * 0.5f; } public void Activate() { MainPlugin.Log.LogWarning((object)("[LavaField] *** Activate() *** IsOwner=" + IsOwner() + " IsServer=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsServer().ToString() : "?"))); _active = true; _timer = 0f; } private void Update() { if (!_updateLoggedOnce) { _updateLoggedOnce = true; MainPlugin.Log.LogWarning((object)("[LavaField] Update() corriendo: _active=" + _active + " IsOwner=" + IsOwner() + " IsServer=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsServer().ToString() : "?") + " _self=" + (((Object)(object)_self != (Object)null) ? "OK" : "NULL"))); } if (!_active || (Object)(object)_self == (Object)null) { return; } if (_self.IsDead()) { _active = false; } else { if (!IsOwner()) { return; } _diagTimer -= Time.deltaTime; if (_diagTimer <= 0f) { _diagTimer = 5f; MainPlugin.Log.LogWarning((object)("[LavaField] Activo (owner), timer=" + _timer.ToString("F2") + " IsServer=" + (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.IsServer().ToString() : "?"))); } _timer -= Time.deltaTime; if (!(_timer > 0f)) { _timer = MainPlugin.LAVA_INTERVAL; MainPlugin.Log.LogWarning((object)("[LavaField] Burst de " + MainPlugin.LAVA_BURST + " rocas.")); for (int i = 0; i < MainPlugin.LAVA_BURST; i++) { TrySpawnOne(); } } } } private bool IsOwner() { return (Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.IsOwner(); } private void TrySpawnOne() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0105: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_lavaPrefab == (Object)null) { MainPlugin.Log.LogWarning((object)"[LavaField] TrySpawnOne: _lavaPrefab NULL!"); return; } Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(MainPlugin.LAVA_RMIN, MainPlugin.LAVA_RMAX); Vector3 position = ((Component)this).transform.position; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(position.x + val.x, position.y + 30f, position.z + val.y); RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(val2, Vector3.down, ref val3, 80f, SOLID_MASK)) { MainPlugin.Log.LogWarning((object)("[LavaField] TrySpawnOne: raycast sin hit en " + val2)); return; } Vector3 val4 = ((RaycastHit)(ref val3)).point + Vector3.up * 0.05f; float num = Random.Range(0f, 360f); Quaternion val5 = Quaternion.Euler(0f, num, 0f); MainPlugin.Log.LogWarning((object)("[LavaField] Spawneando LavaRock en " + val4)); if ((Object)(object)ZNetScene.instance != (Object)null) { ZNetScene.instance.SpawnObject(val4, val5, _lavaPrefab); return; } MainPlugin.Log.LogWarning((object)"[LavaField] ZNetScene NULL, usando Instantiate"); Object.Instantiate(_lavaPrefab, val4, val5); } } public class NeckzillaOnHitAoE : MonoBehaviour { private Character _owner; private float _radius; private float _fire; private float _blunt; private Vector3 _lastGroundPos; private bool _inited; public void Init(Character owner, float radius, float fire, float blunt) { _owner = owner; _radius = Mathf.Max(0.5f, radius); _fire = Mathf.Max(0f, fire); _blunt = Mathf.Max(0f, blunt); _inited = true; } private void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _lastGroundPos = ((Component)this).transform.position; } private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0096: 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) if (_inited) { Vector3 position = ((Component)this).transform.position; RaycastHit val = default(RaycastHit); if (Physics.Raycast(position + Vector3.up * 2f, Vector3.down, ref val, 10f, LayerMask.GetMask(new string[6] { "Default", "piece", "terrain", "static_solid", "Default_small", "character" }))) { _lastGroundPos = ((RaycastHit)(ref val)).point + Vector3.up * 0.05f; } else { _lastGroundPos = position; } } } private void OnCollisionEnter(Collision col) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (_inited) { ContactPoint contact = col.GetContact(0); _lastGroundPos = ((ContactPoint)(ref contact)).point + Vector3.up * 0.05f; } } private void OnDestroy() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_010c: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0127: Expected O, but got Unknown if (!_inited) { return; } List list = new List(); try { Character.GetCharactersInRange(_lastGroundPos, _radius, list); } catch { Collider[] array = Physics.OverlapSphere(_lastGroundPos, _radius, -1, (QueryTriggerInteraction)2); for (int i = 0; i < array.Length; i++) { Character componentInParent = ((Component)array[i]).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && !list.Contains(componentInParent)) { list.Add(componentInParent); } } } int num = 0; for (int j = 0; j < list.Count; j++) { Character obj2 = list[j]; Player val = (Player)(object)((obj2 is Player) ? obj2 : null); if (Object.op_Implicit((Object)(object)val) && !((Character)val).IsDead()) { Vector3 val2 = ((Component)val).transform.position - _lastGroundPos; val2.y = 0f; float num2 = Mathf.Max(0.05f, ((Vector3)(ref val2)).magnitude); HitData val3 = new HitData { m_point = ((Character)val).GetCenterPoint(), m_dir = val2 / num2 }; val3.m_damage.m_fire = _fire; val3.m_damage.m_blunt = _blunt; val3.m_pushForce = 10f; val3.m_blockable = true; try { val3.SetAttacker(_owner); } catch { } ((Character)val).Damage(val3); num++; } } } } internal static class RBCompat { private static readonly PropertyInfo LinearVelProp = typeof(Rigidbody).GetProperty("linearVelocity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); public static void Set(Rigidbody rb, Vector3 v) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)rb)) { if (LinearVelProp != null) { LinearVelProp.SetValue(rb, v, null); } else { rb.velocity = v; } } } public static Vector3 Get(Rigidbody rb) { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)rb)) { return Vector3.zero; } if (LinearVelProp != null) { return (Vector3)LinearVelProp.GetValue(rb, null); } return rb.velocity; } } } namespace GrukkarBossMod { [BepInPlugin("com.yournick.valheim.grukkar", "Grukkar el Devastador", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MainPlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__63_1; public static ConsoleEvent <>9__63_2; public static Action <>9__67_0; internal void b__63_1(ConsoleEventArgs _) { //IL_0077: 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_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_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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)instance)) { Log.LogError((object)"[Grukkar] ZNetScene no disponible."); return; } GameObject prefab = instance.GetPrefab("Boss_GoblinBrute_Grukkar"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"[Grukkar] Prefab 'Boss_GoblinBrute_Grukkar' no encontrado."); return; } Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer)) { Vector3 val = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 6f; Object.Instantiate(prefab, val, Quaternion.identity); Log.LogInfo((object)"[Grukkar] Spawneado."); } } internal void b__63_2(ConsoleEventArgs _) { ZNetScene instance = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)instance)) { Log.LogError((object)"[Grukkar] ZNetScene no disponible."); return; } foreach (GameObject prefab in instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null) && ((Object)prefab).name.ToLowerInvariant().Contains("goblin")) { Log.LogInfo((object)("[Grukkar][Prefab] " + ((Object)prefab).name)); } } } internal void b__67_0(AudioClip c) { MusicClip = c; } } public const string ModGuid = "com.yournick.valheim.grukkar"; public const string ModName = "Grukkar el Devastador"; public const string ModVersion = "1.0.0"; internal static MainPlugin Instance; internal static ManualLogSource Log; private Harmony _harmony; public const string BossPrefabName = "Boss_GoblinBrute_Grukkar"; private const string BasePrefabName = "GoblinBrute"; private ConfigEntry _cfgHealth; private ConfigEntry _cfgScale; private ConfigEntry _cfgTauntBuffDuration; private ConfigEntry _cfgTauntBuffMultiplier; private ConfigEntry _cfgTauntResistPercent; private ConfigEntry _cfgTauntAttackSpeedPercent; private ConfigEntry _cfgTauntHealBoss; private ConfigEntry _cfgTauntHealAllyPercent; private ConfigEntry _cfgTauntInterval; private ConfigEntry _cfgSwingDamage; private ConfigEntry _cfgSwingRange; private ConfigEntry _cfgSummonEnabled; private ConfigEntry _cfgFulingSummonCount; private ConfigEntry _cfgSummonInterval; private ConfigEntry _cfgMusicFile; private ConfigEntry _cfgMusicVolume; private ConfigEntry _cfgLoot1Item; private ConfigEntry _cfgLoot1Min; private ConfigEntry _cfgLoot1Max; private ConfigEntry _cfgLoot1Chance; private ConfigEntry _cfgLoot2Item; private ConfigEntry _cfgLoot2Min; private ConfigEntry _cfgLoot2Max; private ConfigEntry _cfgLoot2Chance; internal static AudioClip MusicClip; private static AudioSource _bossMusic; internal static bool BossMusicActive; private static readonly List _mutedVanillaSources = new List(); private static AudioMixerGroup _sfxMixerGroup; private static readonly FieldInfo _zdoDataFlagsField = typeof(ZDO).GetField("m_dataFlags", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); internal static float CfgHealth => Instance._cfgHealth.Value; internal static float CfgTauntBuffDuration => Instance._cfgTauntBuffDuration.Value; internal static float CfgTauntBuffMultiplier => Instance._cfgTauntBuffMultiplier.Value; internal static float CfgTauntResistPercent => Instance._cfgTauntResistPercent.Value; internal static float CfgTauntAttackSpeedPercent => Instance._cfgTauntAttackSpeedPercent.Value; internal static float CfgTauntHealBoss => Instance._cfgTauntHealBoss.Value; internal static float CfgTauntHealAllyPercent => Instance._cfgTauntHealAllyPercent.Value; internal static float CfgTauntInterval => Instance._cfgTauntInterval.Value; internal static float CfgSwingDamage => Instance._cfgSwingDamage.Value; internal static float CfgSwingRange => Instance._cfgSwingRange.Value; internal static bool CfgSummonEnabled => Instance._cfgSummonEnabled.Value; internal static int CfgFulingSummonCount => Instance._cfgFulingSummonCount.Value; internal static float CfgSummonInterval => Instance._cfgSummonInterval.Value; private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Expected O, but got Unknown //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Expected O, but got Unknown //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Expected O, but got Unknown //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Expected O, but got Unknown //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Expected O, but got Unknown //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Expected O, but got Unknown //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Expected O, but got Unknown //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Expected O, but got Unknown //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Expected O, but got Unknown //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Expected O, but got Unknown //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("com.yournick.valheim.grukkar"); _harmony.PatchAll(); _cfgHealth = ((BaseUnityPlugin)this).Config.Bind("Grukkar", "Health", 5000f, new ConfigDescription("Vida de Grukkar.", (AcceptableValueBase)(object)new AcceptableValueRange(100f, 100000f), Array.Empty())); _cfgScale = ((BaseUnityPlugin)this).Config.Bind("Grukkar", "Scale", 1.5f, new ConfigDescription("Tamaño del boss (1 = normal).", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 5f), Array.Empty())); _cfgTauntBuffDuration = ((BaseUnityPlugin)this).Config.Bind("Taunt", "BuffDuracion", 8f, new ConfigDescription("Segundos que dura el efecto visual/buff tras el Taunt (aplica a todos los tipos).", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 60f), Array.Empty())); _cfgTauntBuffMultiplier = ((BaseUnityPlugin)this).Config.Bind("Taunt", "Dano_Multiplicador", 1.5f, new ConfigDescription("[Buff Rojo] Multiplicador de daño (1.5 = +50%).", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); _cfgTauntResistPercent = ((BaseUnityPlugin)this).Config.Bind("Taunt", "Resistencia_Porcentaje", 25f, new ConfigDescription("[Buff Azul] % de reducción de daño recibido (25 = 25% menos daño de todo tipo).", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 90f), Array.Empty())); _cfgTauntAttackSpeedPercent = ((BaseUnityPlugin)this).Config.Bind("Taunt", "VelocidadAtaque_Porcentaje", 25f, new ConfigDescription("[Buff Amarillo] % de aumento de velocidad de ataque (25 = 25% más rápido).", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 200f), Array.Empty())); _cfgTauntHealBoss = ((BaseUnityPlugin)this).Config.Bind("Taunt", "Curacion_VidaJefe", 200f, new ConfigDescription("[Buff Verde] Puntos de vida que recupera Grukkar.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10000f), Array.Empty())); _cfgTauntHealAllyPercent = ((BaseUnityPlugin)this).Config.Bind("Taunt", "Curacion_PorcentajeAliados", 15f, new ConfigDescription("[Buff Verde] % de vida máxima que recuperan los aliados cercanos.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); _cfgTauntInterval = ((BaseUnityPlugin)this).Config.Bind("Taunt", "IntervaloSegundos", 60f, new ConfigDescription("Segundos entre cada Taunt automático.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 600f), Array.Empty())); _cfgSwingDamage = ((BaseUnityPlugin)this).Config.Bind("Ataques", "OndaDaño", 80f, new ConfigDescription("Daño del cono de onda en Attack1/Attack2.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5000f), Array.Empty())); _cfgSwingRange = ((BaseUnityPlugin)this).Config.Bind("Ataques", "OndaAlcance", 6f, new ConfigDescription("Alcance máximo del cono (metros).", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 20f), Array.Empty())); _cfgSummonEnabled = ((BaseUnityPlugin)this).Config.Bind("Invocación", "Habilitado", true, "true = activa las oleadas de Fulings, false = desactiva."); _cfgFulingSummonCount = ((BaseUnityPlugin)this).Config.Bind("Invocación", "FulingsPorOleada", 4, new ConfigDescription("Cantidad de Fulings por oleada.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 15), Array.Empty())); _cfgSummonInterval = ((BaseUnityPlugin)this).Config.Bind("Invocación", "IntervaloSegundos", 45f, new ConfigDescription("Segundos entre oleadas (solo si todos murieron).", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 300f), Array.Empty())); _cfgLoot1Item = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Item", "BlackMetal", "Nombre exacto del item del slot 1."); _cfgLoot1Min = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Min", 4, new ConfigDescription("Cantidad mínima.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot1Max = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Max", 8, new ConfigDescription("Cantidad máxima.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot1Chance = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Chance", 1f, new ConfigDescription("Probabilidad (0.0–1.0).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _cfgLoot2Item = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Item", "TrophyGoblinBrute", "Nombre exacto del item del slot 2. Vacío = desactivado."); _cfgLoot2Min = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Min", 1, new ConfigDescription("Cantidad mínima.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot2Max = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Max", 1, new ConfigDescription("Cantidad máxima.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot2Chance = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Chance", 1f, new ConfigDescription("Probabilidad (0.0–1.0).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _cfgMusicFile = ((BaseUnityPlugin)this).Config.Bind("Audio", "MusicFile", "grukkar_music.ogg", "Nombre del archivo de música del boss (ogg/wav/mp3) en la carpeta del plugin. Vacío = desactivado."); _cfgMusicVolume = ((BaseUnityPlugin)this).Config.Bind("Audio", "MusicVolume", 0.6f, new ConfigDescription("Volumen de la música del boss (0.0 = silencio, 1.0 = máximo).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _cfgMusicVolume.SettingChanged += delegate { if (Object.op_Implicit((Object)(object)_bossMusic)) { _bossMusic.volume = _cfgMusicVolume.Value; } }; ((MonoBehaviour)this).StartCoroutine(LoadAudioFiles()); ApplyMusicManPatches(); PrefabManager.OnVanillaPrefabsAvailable += CreateGrukkarPrefab; object obj = <>c.<>9__63_1; if (obj == null) { ConsoleEvent val = delegate { //IL_0077: 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_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_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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance2 = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)instance2)) { Log.LogError((object)"[Grukkar] ZNetScene no disponible."); } else { GameObject prefab = instance2.GetPrefab("Boss_GoblinBrute_Grukkar"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"[Grukkar] Prefab 'Boss_GoblinBrute_Grukkar' no encontrado."); } else { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer)) { Vector3 val3 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 6f; Object.Instantiate(prefab, val3, Quaternion.identity); Log.LogInfo((object)"[Grukkar] Spawneado."); } } } }; <>c.<>9__63_1 = val; obj = (object)val; } new ConsoleCommand("grukkar_spawn", "Invoca a Grukkar frente al jugador.", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__63_2; if (obj2 == null) { ConsoleEvent val2 = delegate { ZNetScene instance = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)instance)) { Log.LogError((object)"[Grukkar] ZNetScene no disponible."); return; } foreach (GameObject prefab2 in instance.m_prefabs) { if (!((Object)(object)prefab2 == (Object)null) && ((Object)prefab2).name.ToLowerInvariant().Contains("goblin")) { Log.LogInfo((object)("[Grukkar][Prefab] " + ((Object)prefab2).name)); } } }; <>c.<>9__63_2 = val2; obj2 = (object)val2; } new ConsoleCommand("grukkar_listprefabs", "Lista prefabs que contienen 'goblin' en el log.", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); Log.LogInfo((object)"[Grukkar] Cargado. Usa: spawn Boss_GoblinBrute_Grukkar o grukkar_spawn"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } PrefabManager.OnVanillaPrefabsAvailable -= CreateGrukkarPrefab; } private void CreateGrukkarPrefab() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= CreateGrukkarPrefab; if (Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("Boss_GoblinBrute_Grukkar"))) { return; } GameObject prefab = PrefabManager.Instance.GetPrefab("GoblinBrute"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"[Grukkar] Prefab 'GoblinBrute' no encontrado."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("Boss_GoblinBrute_Grukkar", prefab); Character component = val.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_name = "Grukkar, el Devastador"; component.m_boss = true; component.m_health = _cfgHealth.Value; component.m_faction = (Faction)7; component.m_staggerWhenBlocked = false; component.m_staggerDamageFactor = 0f; } val.transform.localScale = Vector3.one * _cfgScale.Value; Humanoid component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.m_randomArmor = (GameObject[])(object)new GameObject[0]; } val.AddComponent(); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, true)); Log.LogInfo((object)"[Grukkar] Boss_GoblinBrute_Grukkar registrado."); } internal static void ApplyLootDrops(GameObject go) { ObjectDB odb = ObjectDB.instance; CharacterDrop drop; if (Object.op_Implicit((Object)(object)odb)) { drop = go.GetComponent() ?? go.AddComponent(); drop.m_drops = new List(); TryAdd(Instance._cfgLoot1Item.Value, Instance._cfgLoot1Min.Value, Instance._cfgLoot1Max.Value, Instance._cfgLoot1Chance.Value); TryAdd(Instance._cfgLoot2Item.Value, Instance._cfgLoot2Min.Value, Instance._cfgLoot2Max.Value, Instance._cfgLoot2Chance.Value); } void TryAdd(string itemName, int min, int max, float chance) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown if (!string.IsNullOrWhiteSpace(itemName) && !(chance <= 0f)) { GameObject itemPrefab = odb.GetItemPrefab(itemName.Trim()); if (!Object.op_Implicit((Object)(object)itemPrefab)) { Log.LogWarning((object)("[Grukkar] Loot '" + itemName + "' no encontrado.")); } else { drop.m_drops.Add(new Drop { m_prefab = itemPrefab, m_amountMin = Mathf.Max(1, min), m_amountMax = Mathf.Max(min, max), m_chance = Mathf.Clamp01(chance), m_onePerPlayer = false, m_levelMultiplier = false }); } } } } private IEnumerator LoadAudioFiles() { string pluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Log.LogInfo((object)("[Grukkar][Audio] Carpeta del plugin: " + pluginDir)); if (!string.IsNullOrWhiteSpace(_cfgMusicFile.Value)) { string path = Path.Combine(pluginDir, _cfgMusicFile.Value.Trim()); Log.LogInfo((object)("[Grukkar][Audio] Buscando música en: " + path)); yield return LoadClip(path, delegate(AudioClip c) { MusicClip = c; }, "música"); } } private static IEnumerator LoadClip(string path, Action onLoaded, string label) { if (!File.Exists(path)) { Log.LogWarning((object)("[Grukkar][Audio] Archivo de " + label + " no encontrado: " + path)); yield break; } string ext = Path.GetExtension(path).ToLowerInvariant(); AudioType audioType = (AudioType)((ext == ".wav") ? 20 : ((ext == ".mp3") ? 13 : 14)); UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), audioType); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { Log.LogError((object)("[Grukkar][Audio] Error cargando " + label + ": " + req.error)); yield break; } AudioClip clip = DownloadHandlerAudioClip.GetContent(req); if ((Object)(object)clip != (Object)null) { ((Object)clip).name = "Grukkar_" + label; onLoaded(clip); Log.LogInfo((object)$"[Grukkar][Audio] '{label}' cargado: {clip.length:F1}s"); } } finally { ((IDisposable)req)?.Dispose(); } } private static AudioMixerGroup GetSFXMixerGroup() { if ((Object)(object)_sfxMixerGroup != (Object)null) { return _sfxMixerGroup; } string[] array = new string[2] { "sfx_hit", "sfx_swing_axe" }; foreach (string text in array) { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(text) : null); if (!((Object)(object)val == (Object)null)) { AudioSource componentInChildren = val.GetComponentInChildren(true); if ((Object)(object)((componentInChildren != null) ? componentInChildren.outputAudioMixerGroup : null) != (Object)null) { _sfxMixerGroup = componentInChildren.outputAudioMixerGroup; break; } } } return _sfxMixerGroup; } internal static void StartBossMusic() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown if ((Object)(object)MusicClip == (Object)null || (Object)(object)_bossMusic != (Object)null) { return; } _mutedVanillaSources.Clear(); if ((Object)(object)MusicMan.instance != (Object)null) { AudioSource[] componentsInChildren = ((Component)MusicMan.instance).GetComponentsInChildren(true); foreach (AudioSource val in componentsInChildren) { if ((Object)(object)val != (Object)null && val.volume > 0f) { val.volume = 0f; _mutedVanillaSources.Add(val); } } } BossMusicActive = true; GameObject val2 = new GameObject("GrukkarBossMusic"); Object.DontDestroyOnLoad((Object)(object)val2); AudioSource val3 = val2.AddComponent(); val3.clip = MusicClip; val3.loop = true; val3.spatialBlend = 0f; val3.volume = Instance._cfgMusicVolume.Value; val3.Play(); _bossMusic = val3; Log.LogInfo((object)"[Grukkar][Audio] Música de boss iniciada."); } internal static void StopBossMusic() { if ((Object)(object)_bossMusic == (Object)null) { return; } Object.Destroy((Object)(object)((Component)_bossMusic).gameObject); _bossMusic = null; BossMusicActive = false; foreach (AudioSource mutedVanillaSource in _mutedVanillaSources) { if ((Object)(object)mutedVanillaSource != (Object)null) { mutedVanillaSource.volume = 1f; } } _mutedVanillaSources.Clear(); Log.LogInfo((object)"[Grukkar][Audio] Música de boss detenida."); } private static bool MusicManBlockPrefix() { return !BossMusicActive; } private void ApplyMusicManPatches() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(MainPlugin).GetMethod("MusicManBlockPrefix", BindingFlags.Static | BindingFlags.NonPublic)); string[] array = new string[4] { "StartMusic", "StartRandomEventMusic", "UpdateMusic", "QueueMusic" }; foreach (string text in array) { try { MethodInfo method = typeof(MusicMan).GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { _harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { Log.LogWarning((object)("[Grukkar][Audio] No se pudo parchar MusicMan." + text + ": " + ex.Message)); } } } internal static void SetNonPersistent(ZNetView nview) { if ((Object)(object)nview == (Object)null) { return; } nview.m_persistent = false; if (!nview.IsValid() || _zdoDataFlagsField == null) { return; } try { ZDO zDO = nview.GetZDO(); object value = _zdoDataFlagsField.GetValue(zDO); int value2 = Convert.ToInt32(value) & -5; _zdoDataFlagsField.SetValue(zDO, Enum.ToObject(_zdoDataFlagsField.FieldType, value2)); } catch (Exception ex) { Log.LogWarning((object)("[Grukkar] SetNonPersistent falló (no crítico): " + ex.Message)); } } internal static Player FindNearestPlayer(Vector3 pos) { //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) Player result = null; float num = float.MaxValue; foreach (Player allPlayer in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)allPlayer)) { float num2 = Vector3.Distance(pos, ((Component)allPlayer).transform.position); if (num2 < num) { num = num2; result = allPlayer; } } } return result; } } public class GrukkarBrain : MonoBehaviour { private enum TauntType { Damage, Resistance, AttackSpeed, Healing } private Character _ch; private Animator _anim; private MonsterAI _ai; private bool _deathHandled = false; private bool _tauntBuffRunning = false; internal bool _tauntBuffActive = false; internal static readonly HashSet ResistBuffed = new HashSet(); private bool _summonRunning = false; private float _nextSummonTime = float.MaxValue; private float _nextTauntTime = float.MaxValue; private bool _musicStarted = false; private bool _phase2Triggered = false; private bool _phase2Active = false; private bool _inTransition = false; internal bool IsImmune = false; private string _animClip = ""; private bool _animFxFired = false; private GameObject _phase2FxInstance; private readonly List _summonedFulings = new List(); private static readonly Color RedTint = new Color(1f, 0.15f, 0.15f); private static readonly FieldInfo _dodgeInvincibleField = typeof(Player).GetField("m_dodgeInvincible", BindingFlags.Instance | BindingFlags.NonPublic); private void Awake() { _ch = ((Component)this).GetComponent(); _anim = ((Component)this).GetComponentInChildren(); _ai = ((Component)this).GetComponent(); MainPlugin.SetNonPersistent(((Component)this).GetComponent()); } private void Start() { ((MonoBehaviour)this).StartCoroutine(DelayedSetup()); } private IEnumerator DelayedSetup() { yield return null; yield return null; if (Object.op_Implicit((Object)(object)_ch)) { if (Object.op_Implicit((Object)(object)_ai)) { ((BaseAI)_ai).m_aggravatable = false; _ai.m_attackPlayerObjects = true; _ai.m_alertRange = 25f; } _ch.SetMaxHealth(MainPlugin.CfgHealth); _ch.SetHealth(MainPlugin.CfgHealth); MainPlugin.ApplyLootDrops(((Component)this).gameObject); _nextSummonTime = Time.time + MainPlugin.CfgSummonInterval; _nextTauntTime = Time.time + MainPlugin.CfgTauntInterval; ((MonoBehaviour)this).StartCoroutine(ForceMaxArmor()); } } private void Update() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { if (!_deathHandled) { _deathHandled = true; IsImmune = false; _inTransition = false; if (Object.op_Implicit((Object)(object)_phase2FxInstance)) { Object.Destroy((Object)(object)_phase2FxInstance); } if (!IsDedicatedServer()) { MainPlugin.StopBossMusic(); } CleanupSummons(); } return; } if (!_musicStarted && !IsDedicatedServer()) { Player val = MainPlugin.FindNearestPlayer(((Component)this).transform.position); if ((Object)(object)val != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) <= 25f) { _musicStarted = true; MainPlugin.StartBossMusic(); } } if (_inTransition) { return; } if (!_phase2Triggered && _ch.GetHealthPercentage() <= 0.5f) { _phase2Triggered = true; _inTransition = true; _tauntBuffRunning = false; _tauntBuffActive = false; _summonRunning = false; ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)this).StartCoroutine(Phase2Transition()); return; } CheckAnimations(); if (!_phase2Active && !_tauntBuffRunning && Time.time >= _nextTauntTime) { _nextTauntTime = Time.time + MainPlugin.CfgTauntInterval; ((MonoBehaviour)this).StartCoroutine(TauntBuff()); } if (MainPlugin.CfgSummonEnabled && !_summonRunning && Time.time >= _nextSummonTime) { _summonedFulings.RemoveAll((Character f) => !Object.op_Implicit((Object)(object)f) || f.IsDead()); if (_summonedFulings.Count == 0) { ((MonoBehaviour)this).StartCoroutine(SummonFulingWave()); } } } private void OnDestroy() { IsImmune = false; if (!IsDedicatedServer()) { MainPlugin.StopBossMusic(); } CleanupSummons(); } private static bool IsDedicatedServer() { return Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsDedicated(); } private void CleanupSummons() { ZNetScene instance = ZNetScene.instance; foreach (Character summonedFuling in _summonedFulings) { if (Object.op_Implicit((Object)(object)summonedFuling) && !summonedFuling.IsDead()) { if ((Object)(object)instance != (Object)null) { instance.Destroy(((Component)summonedFuling).gameObject); } else { Object.Destroy((Object)(object)((Component)summonedFuling).gameObject); } } } } private IEnumerator Phase2Transition() { IsImmune = true; if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = false; } Rigidbody rb = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)rb)) { rb.linearVelocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.isKinematic = true; } CleanupSummons(); _summonedFulings.Clear(); _summonRunning = false; ((MonoBehaviour)this).StartCoroutine(SmoothTintToRed(3f)); ZNetScene zns = ZNetScene.instance; if (Object.op_Implicit((Object)(object)zns)) { GameObject fxPrefab = zns.GetPrefab("fx_leviathanLava_leave"); if (Object.op_Implicit((Object)(object)fxPrefab)) { _phase2FxInstance = Object.Instantiate(fxPrefab, ((Component)this).transform.position, Quaternion.identity); } } float elapsed = 0f; float duration = 30f; float nextTauntLoop = 0f; float tauntInterval = 1f; float nextStagger = 2f; while (elapsed < duration) { yield return (object)new WaitForSeconds(0.1f); elapsed += 0.1f; if (Object.op_Implicit((Object)(object)rb)) { rb.linearVelocity = Vector3.zero; } if (elapsed >= nextTauntLoop) { nextTauntLoop += tauntInterval; if (Object.op_Implicit((Object)(object)_anim)) { _anim.CrossFade("Taunt", 0.05f, 0); } } if (elapsed >= nextStagger) { nextStagger += 2f; StaggerNearbyPlayers(10f); } } if (Object.op_Implicit((Object)(object)rb)) { rb.isKinematic = false; } IsImmune = false; _inTransition = false; _phase2Active = true; _tauntBuffActive = true; if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = true; } _nextSummonTime = Time.time + MainPlugin.CfgSummonInterval; _nextTauntTime = Time.time + MainPlugin.CfgTauntInterval; } private void StaggerNearbyPlayers(float radius) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_007b: Unknown result type (might be due to invalid IL or missing references) foreach (Player allPlayer in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)allPlayer) && !((Character)allPlayer).IsDead() && !(Vector3.Distance(((Component)this).transform.position, ((Component)allPlayer).transform.position) > radius)) { Vector3 val = ((Component)allPlayer).transform.position - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; ((Character)allPlayer).Stagger(normalized); } } } private void CheckAnimations() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_anim == (Object)null) { return; } string text = ""; float num = 0f; for (int i = 0; i < _anim.layerCount; i++) { AnimatorClipInfo[] currentAnimatorClipInfo = _anim.GetCurrentAnimatorClipInfo(i); if (currentAnimatorClipInfo.Length != 0 && !((Object)(object)((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip == (Object)null)) { text = ((Object)((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip).name; AnimatorStateInfo currentAnimatorStateInfo = _anim.GetCurrentAnimatorStateInfo(i); num = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime % 1f; break; } } if (!string.IsNullOrEmpty(text)) { if (text != _animClip) { _animClip = text; _animFxFired = false; } if (!_animFxFired && _phase2Active && (text == "Attack1" || text == "Attack2") && num > 0.4f) { _animFxFired = true; ((MonoBehaviour)this).StartCoroutine(ConeShockwave()); } if (!_animFxFired && _phase2Active && text == "AttackRage" && num > 0.05f) { _animFxFired = true; ((MonoBehaviour)this).StartCoroutine(SeismicRings()); } } } private IEnumerator TauntBuff() { _tauntBuffRunning = true; if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = false; } if (Object.op_Implicit((Object)(object)_anim)) { _anim.CrossFade("Taunt", 0.15f, 0); } yield return (object)new WaitForSeconds(1.5f); if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = true; } TauntType buffType = (TauntType)Random.Range(0, 4); List affectedGos = new List { ((Component)this).gameObject }; List affectedChs = new List(); if (Object.op_Implicit((Object)(object)_ch)) { affectedChs.Add(_ch); } foreach (Character ch in Character.GetAllCharacters()) { if (Object.op_Implicit((Object)(object)ch) && !ch.IsDead() && !((Object)(object)((Component)ch).GetComponent() != (Object)null) && (int)ch.m_faction == 7 && !(Vector3.Distance(((Component)this).transform.position, ((Component)ch).transform.position) > 15f)) { affectedGos.Add(((Component)ch).gameObject); affectedChs.Add(ch); } } Color tint = (Color)(buffType switch { TauntType.AttackSpeed => new Color(1f, 0.7f, 0.1f), TauntType.Resistance => new Color(0.2f, 0.4f, 1f), TauntType.Damage => new Color(1f, 0.15f, 0.15f), _ => new Color(0.2f, 1f, 0.3f), }); Dictionary originals = new Dictionary(); foreach (GameObject go2 in affectedGos) { ApplyTint(go2, tint, originals); } List<(Animator anim, float origSpeed)> animSnapshots = new List<(Animator, float)>(); switch (buffType) { case TauntType.Damage: _tauntBuffActive = true; break; case TauntType.Resistance: foreach (Character ch4 in affectedChs) { ResistBuffed.Add(ch4); } break; case TauntType.AttackSpeed: { float speedMult = 1f + MainPlugin.CfgTauntAttackSpeedPercent / 100f; foreach (GameObject go in affectedGos) { Animator anim = go.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)anim)) { animSnapshots.Add((anim, anim.speed)); anim.speed *= speedMult; } } break; } } if (buffType == TauntType.Healing) { int ticks = Mathf.Max(1, Mathf.RoundToInt(MainPlugin.CfgTauntBuffDuration)); float healPerTickBoss = MainPlugin.CfgTauntHealBoss / (float)ticks; float healPctPerTick = MainPlugin.CfgTauntHealAllyPercent / (float)ticks; for (int i = 0; i < ticks; i++) { yield return (object)new WaitForSeconds(1f); if (Object.op_Implicit((Object)(object)_ch) && !_ch.IsDead()) { _ch.Heal(healPerTickBoss, true); } foreach (Character ch3 in affectedChs) { if (!((Object)(object)ch3 == (Object)(object)_ch) && Object.op_Implicit((Object)(object)ch3) && !ch3.IsDead()) { ch3.Heal(ch3.GetMaxHealth() * healPctPerTick / 100f, true); } } } } else { yield return (object)new WaitForSeconds(MainPlugin.CfgTauntBuffDuration); } _tauntBuffActive = _phase2Active; foreach (Character ch2 in affectedChs) { ResistBuffed.Remove(ch2); } foreach (var snap in animSnapshots) { if (Object.op_Implicit((Object)(object)snap.anim)) { snap.anim.speed = snap.origSpeed; } } foreach (KeyValuePair kv in originals) { if (Object.op_Implicit((Object)(object)kv.Key)) { kv.Key.material.color = (_phase2Active ? RedTint : kv.Value); } } _tauntBuffRunning = false; } private static void ApplyTint(GameObject go, Color tint, Dictionary originals) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = go.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (val.material.HasProperty("_Color")) { originals[val] = val.material.color; val.material.color = tint; } } } private IEnumerator ConeShockwave() { ZNetScene zns = ZNetScene.instance; GameObject fxPrefab = ((zns != null) ? zns.GetPrefab("fx_goblinbrute_groundslam") : null); ZNetView znv = ((Component)this).GetComponent(); float[] distances = new float[3] { 2.5f, 4.5f, 6.5f }; float[] damageRanges = new float[3] { 3f, 5f, 7.5f }; float[] spreadAngles = new float[3] { -25f, 0f, 25f }; float halfAngle = 30f; HashSet alreadyHit = new HashSet(); HashSet alreadyHitChars = new HashSet(); Vector3 fwd = ((Component)this).transform.forward; bool dodging = default(bool); for (int w = 0; w < distances.Length; w++) { if (Object.op_Implicit((Object)(object)fxPrefab)) { float[] array = spreadAngles; foreach (float a in array) { Vector3 dir = Quaternion.Euler(0f, a, 0f) * fwd; Vector3 pos = ((Component)this).transform.position + dir * distances[w] + Vector3.up * 0.2f; Object.Instantiate(fxPrefab, pos, Quaternion.LookRotation(dir)); } } foreach (Player player in Player.GetAllPlayers()) { if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead() || alreadyHit.Contains(player)) { continue; } Vector3 toPlayer = ((Component)player).transform.position - ((Component)this).transform.position; if (((Vector3)(ref toPlayer)).magnitude > damageRanges[w] || Vector3.Angle(fwd, ((Vector3)(ref toPlayer)).normalized) > halfAngle) { continue; } int num; if (_dodgeInvincibleField != null) { object value = _dodgeInvincibleField.GetValue(player); if (value is bool) { dodging = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } if (((uint)num & (dodging ? 1u : 0u)) == 0) { alreadyHit.Add(player); HitData hit = new HitData(); hit.m_damage.m_blunt = MainPlugin.CfgSwingDamage; hit.m_pushForce = 30f; hit.m_staggerMultiplier = 10f; hit.m_dir = ((Vector3)(ref toPlayer)).normalized; hit.m_point = ((Component)player).transform.position; if (Object.op_Implicit((Object)(object)znv)) { hit.m_attacker = znv.GetZDO().m_uid; } ((Character)player).Damage(hit); toPlayer = default(Vector3); } } foreach (Character ch in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)ch) || ch.IsDead() || alreadyHitChars.Contains(ch) || (Object)(object)((Component)ch).GetComponent() != (Object)null || (int)ch.m_faction != 7) { continue; } Vector3 toChar = ((Component)ch).transform.position - ((Component)this).transform.position; if (!(((Vector3)(ref toChar)).magnitude > damageRanges[w]) && !(Vector3.Angle(fwd, ((Vector3)(ref toChar)).normalized) > halfAngle)) { alreadyHitChars.Add(ch); HitData hitCh = new HitData(); hitCh.m_damage.m_blunt = MainPlugin.CfgSwingDamage; hitCh.m_pushForce = 10f; hitCh.m_dir = ((Vector3)(ref toChar)).normalized; hitCh.m_point = ((Component)ch).transform.position; if (Object.op_Implicit((Object)(object)znv)) { hitCh.m_attacker = znv.GetZDO().m_uid; } ch.Damage(hitCh); toChar = default(Vector3); } } yield return (object)new WaitForSeconds(0.12f); } } private IEnumerator SeismicRings() { yield return (object)new WaitForSeconds(0.6f); ZNetScene zns = ZNetScene.instance; GameObject fxPrefab = ((zns != null) ? zns.GetPrefab("fx_goblinbrute_groundslam") : null); ZNetView znv = ((Component)this).GetComponent(); float[] innerRadii = new float[4] { 0f, 3f, 6f, 9f }; float[] outerRadii = new float[4] { 3f, 6f, 9f, 12f }; int fxPoints = 12; bool b = default(bool); for (int ring = 0; ring < 4; ring++) { float inner = innerRadii[ring]; float outer = outerRadii[ring]; float mid = (inner + outer) * 0.5f; if (Object.op_Implicit((Object)(object)fxPrefab)) { for (int i = 0; i < fxPoints; i++) { float angle = 360f / (float)fxPoints * (float)i; Vector3 dir = Quaternion.Euler(0f, angle, 0f) * Vector3.forward; Vector3 pos = ((Component)this).transform.position + dir * mid + Vector3.up * 0.1f; Object.Instantiate(fxPrefab, pos, Quaternion.LookRotation(dir)); } } foreach (Player player in Player.GetAllPlayers()) { if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead()) { continue; } float dist = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (dist < inner || dist > outer) { continue; } int num; if (_dodgeInvincibleField != null) { object value = _dodgeInvincibleField.GetValue(player); if (value is bool) { b = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } if (((uint)num & (b ? 1u : 0u)) == 0) { Vector3 toPlayer = ((Component)player).transform.position - ((Component)this).transform.position; HitData hit = new HitData(); hit.m_damage.m_blunt = MainPlugin.CfgSwingDamage; hit.m_pushForce = 20f; hit.m_staggerMultiplier = 6f; hit.m_dir = ((Vector3)(ref toPlayer)).normalized; hit.m_point = ((Component)player).transform.position; if (Object.op_Implicit((Object)(object)znv)) { hit.m_attacker = znv.GetZDO().m_uid; } ((Character)player).Damage(hit); toPlayer = default(Vector3); } } foreach (Character ch in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)ch) || ch.IsDead() || (Object)(object)((Component)ch).GetComponent() != (Object)null || (int)ch.m_faction != 7) { continue; } float distCh = Vector3.Distance(((Component)this).transform.position, ((Component)ch).transform.position); if (!(distCh < inner) && !(distCh > outer)) { Vector3 toChar = ((Component)ch).transform.position - ((Component)this).transform.position; HitData hitCh = new HitData(); hitCh.m_damage.m_blunt = MainPlugin.CfgSwingDamage; hitCh.m_pushForce = 15f; hitCh.m_dir = ((Vector3)(ref toChar)).normalized; hitCh.m_point = ((Component)ch).transform.position; if (Object.op_Implicit((Object)(object)znv)) { hitCh.m_attacker = znv.GetZDO().m_uid; } ch.Damage(hitCh); toChar = default(Vector3); } } if (ring < 3) { yield return (object)new WaitForSeconds(0.8f); } } } private IEnumerator SmoothTintToRed(float duration) { Renderer[] renderers = ((Component)this).GetComponentsInChildren(true); Dictionary startColors = new Dictionary(); Renderer[] array = renderers; foreach (Renderer r in array) { if (Object.op_Implicit((Object)(object)r) && r.material.HasProperty("_Color")) { startColors[r] = r.material.color; } } float elapsed = 0f; while (elapsed < duration) { yield return null; elapsed += Time.deltaTime; float pct = Mathf.Clamp01(elapsed / duration); foreach (KeyValuePair kv in startColors) { if (Object.op_Implicit((Object)(object)kv.Key)) { kv.Key.material.color = Color.Lerp(kv.Value, RedTint, pct); } } } foreach (KeyValuePair kv2 in startColors) { if (Object.op_Implicit((Object)(object)kv2.Key)) { kv2.Key.material.color = RedTint; } } } private IEnumerator ForceMaxArmor() { float deadline = Time.time + 10f; while (Time.time < deadline) { yield return (object)new WaitForSeconds(0.5f); SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (SkinnedMeshRenderer smr in componentsInChildren) { Transform t = ((Component)smr).transform; while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)((Component)this).transform) { if (!((Component)t).gameObject.activeSelf) { ((Component)t).gameObject.SetActive(true); } t = t.parent; } ((Renderer)smr).enabled = true; } } } private IEnumerator SummonFulingWave() { _summonRunning = true; ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { _summonRunning = false; yield break; } if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = false; } yield return (object)new WaitForSeconds(0.8f); int count = MainPlugin.CfgFulingSummonCount; string[] fulingTypes = new string[4] { "Goblin", "GoblinArcher", "Goblin", "GoblinShaman" }; for (int i = 0; i < count; i++) { string type = fulingTypes[i % fulingTypes.Length]; GameObject prefab = zns.GetPrefab(type); if (Object.op_Implicit((Object)(object)prefab)) { float angle = 360f / (float)count * (float)i; Vector3 offset = Quaternion.Euler(0f, angle, 0f) * Vector3.forward * 5f; Vector3 pos = ((Component)this).transform.position + offset; GameObject go = Object.Instantiate(prefab, pos, Quaternion.identity); ((Object)go).name = type + "_GrukkarSummon"; MainPlugin.SetNonPersistent(go.GetComponent()); CharacterDrop drop = go.GetComponent(); if (Object.op_Implicit((Object)(object)drop)) { drop.m_drops.Clear(); } if (_phase2Active) { ApplyTint(originals: new Dictionary(), go: go, tint: RedTint); } Character ch = go.GetComponent(); if (Object.op_Implicit((Object)(object)ch)) { ch.SetLevel(5); _summonedFulings.Add(ch); } yield return (object)new WaitForSeconds(0.15f); } } if (Object.op_Implicit((Object)(object)_ai)) { ((Behaviour)_ai).enabled = true; } _nextSummonTime = Time.time + MainPlugin.CfgSummonInterval; _summonRunning = false; } } [HarmonyPatch(typeof(Character), "SetLevel")] internal static class PatchGrukkarNoStars { private static bool Prefix(Character __instance, int level) { if (level > 1 && (Object)(object)((Component)__instance).GetComponent() != (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchGrukkarImmunity { private static bool Prefix(Character __instance) { GrukkarBrain component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && component.IsImmune) { return false; } return true; } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchGrukkarNoPushback { private static void Prefix(Character __instance, HitData hit) { if (hit != null && (Object)(object)((Component)__instance).GetComponent() != (Object)null) { hit.m_pushForce = 0f; } } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchGrukkarResistBuff { private static void Prefix(Character __instance, HitData hit) { if (hit != null && GrukkarBrain.ResistBuffed.Contains(__instance)) { float num = 1f - MainPlugin.CfgTauntResistPercent / 100f; hit.m_damage.m_blunt *= num; hit.m_damage.m_slash *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_chop *= num; hit.m_damage.m_pickaxe *= num; hit.m_damage.m_fire *= num; hit.m_damage.m_frost *= num; hit.m_damage.m_lightning *= num; hit.m_damage.m_poison *= num; hit.m_damage.m_spirit *= num; } } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchGrukkarTauntBuff { private static void Prefix(Character __instance, HitData hit) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!(__instance is Player) || hit == null) { return; } ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.FindInstance(hit.m_attacker) : null); if (Object.op_Implicit((Object)(object)val)) { GrukkarBrain component = val.GetComponent(); if (!((Object)(object)component == (Object)null) && component._tauntBuffActive) { float cfgTauntBuffMultiplier = MainPlugin.CfgTauntBuffMultiplier; hit.m_damage.m_blunt *= cfgTauntBuffMultiplier; hit.m_damage.m_slash *= cfgTauntBuffMultiplier; hit.m_damage.m_pierce *= cfgTauntBuffMultiplier; } } } } } namespace BlackbladeBossMod { [BepInPlugin("com.yournick.valheim.blackbladeboss", "Blackblade Boss", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MainPlugin : BaseUnityPlugin { public const string ModGuid = "com.yournick.valheim.blackbladeboss"; public const string ModName = "Blackblade Boss"; public const string ModVersion = "1.0.0"; internal static MainPlugin Instance; internal static ManualLogSource Log; private Harmony _harmony; private const string VariantPrefabName = "Skeleton_Variant_Blackblade"; private const string FallbackPrefabName = "Skeleton"; public const string BossPrefabName = "Boss_Skeleton_Blackblade"; private ConfigEntry _cfgHealth; private ConfigEntry _cfgScale; private ConfigEntry _cfgSpinDamagePct; private ConfigEntry _cfgFireTickDmg; private ConfigEntry _cfgFlameMeleePct; private ConfigEntry _cfgFlameFirePct; private ConfigEntry _cfgSlamDamagePct; private ConfigEntry _cfgPhase2Threshold; private ConfigEntry _cfgUlvPerWave; private ConfigEntry _cfgSummonInterval; private ConfigEntry _cfgUlvHealth; private ConfigEntry _cfgMeleeDmgMult; private ConfigEntry _cfgMusicFile; internal static AudioClip MusicClip; internal static bool BossMusicActive; private static AudioSource _bossMusic; private static readonly List _mutedVanillaSources = new List(); private ConfigEntry _cfgLoot1Item; private ConfigEntry _cfgLoot1Min; private ConfigEntry _cfgLoot1Max; private ConfigEntry _cfgLoot1Chance; private ConfigEntry _cfgLoot2Item; private ConfigEntry _cfgLoot2Min; private ConfigEntry _cfgLoot2Max; private ConfigEntry _cfgLoot2Chance; private ConfigEntry _cfgLoot3Item; private ConfigEntry _cfgLoot3Min; private ConfigEntry _cfgLoot3Max; private ConfigEntry _cfgLoot3Chance; private static readonly FieldInfo _zdoDataFlagsField = typeof(ZDO).GetField("m_dataFlags", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly string[] PassivePhrases = new string[10] { "Las cenizas... nunca olvidan.", "¿Vienes a despertar lo que duerme?", "He visto arder mil mundos... y quedar en nada.", "El calor... ya no lo recuerdo.", "El heraldo espera. Siempre espera.", "Pronto comprenderás el verdadero silencio.", "¿Buscas poder... o solo tu fin?", "El fuego que me consume no se apaga.", "Camino entre los vivos... pero pertenezco a las brasas.", "¿Lo sientes? La ceniza te llama también a ti." }; internal static float CfgPhase2Threshold => Instance._cfgPhase2Threshold.Value; internal static float CfgSummonInterval => Instance._cfgSummonInterval.Value; internal static int CfgUlvPerWave => Instance._cfgUlvPerWave.Value; internal static float CfgUlvHealth => Instance._cfgUlvHealth.Value; internal static float CfgMeleeDmgMult => Instance._cfgMeleeDmgMult.Value; internal static float CfgSpinDamagePct => Instance._cfgSpinDamagePct.Value; internal static float CfgFireTickDmg => Instance._cfgFireTickDmg.Value; internal static float CfgFlameMeleePct => Instance._cfgFlameMeleePct.Value; internal static float CfgFlameFirePct => Instance._cfgFlameFirePct.Value; internal static float CfgSlamDamagePct => Instance._cfgSlamDamagePct.Value; internal static float CfgHealth => Instance._cfgHealth.Value; internal static float CfgScale => Instance._cfgScale.Value; private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Expected O, but got Unknown //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Expected O, but got Unknown //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Expected O, but got Unknown //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Expected O, but got Unknown //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Expected O, but got Unknown //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Expected O, but got Unknown //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Expected O, but got Unknown //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Expected O, but got Unknown //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Expected O, but got Unknown //IL_05d0: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("com.yournick.valheim.blackbladeboss"); _harmony.PatchAll(); _cfgHealth = ((BaseUnityPlugin)this).Config.Bind("Blackblade", "Health", 6500f, new ConfigDescription("Vida de Blackblade (fase agresiva).", (AcceptableValueBase)(object)new AcceptableValueRange(100f, 50000f), Array.Empty())); _cfgScale = ((BaseUnityPlugin)this).Config.Bind("Blackblade", "Scale", 1.35f, new ConfigDescription("Tamaño del boss (1 = normal).", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 5f), Array.Empty())); _cfgPhase2Threshold = ((BaseUnityPlugin)this).Config.Bind("Blackblade", "Phase2Threshold", 0.6f, new ConfigDescription("Vida (%) para entrar en Fase 2 (ej: 0.60 = al 60%).", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 0.95f), Array.Empty())); _cfgMeleeDmgMult = ((BaseUnityPlugin)this).Config.Bind("Ataques", "DañoFisicoMultiplicador", 1.55f, new ConfigDescription("Multiplicador global del daño físico del boss (aplica a todos sus ataques). 1.0 = sin cambio, 1.5 = 50% más daño.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); _cfgSpinDamagePct = ((BaseUnityPlugin)this).Config.Bind("Ataques", "SpinDamagePorcentaje", 0.6f, new ConfigDescription("Porcentaje del daño del arma para el ataque giratorio (Atgeir360Attack).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); _cfgSlamDamagePct = ((BaseUnityPlugin)this).Config.Bind("Ataques", "SlamDamagePorcentaje", 0.6f, new ConfigDescription("Porcentaje del daño del arma para el slam cruzado (BaseAttack 3).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); _cfgFlameMeleePct = ((BaseUnityPlugin)this).Config.Bind("Ataques", "FlameMeleePorcentaje", 0f, new ConfigDescription("Porcentaje del daño del arma como corte en el golpe melee de Take 001.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); _cfgFlameFirePct = ((BaseUnityPlugin)this).Config.Bind("Ataques", "FlameFirePorcentaje", 1f, new ConfigDescription("Porcentaje del daño del arma como fuego en el golpe melee de Take 001.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); _cfgFireTickDmg = ((BaseUnityPlugin)this).Config.Bind("Ataques", "FuegoSueloDaño", 40f, new ConfigDescription("Daño por segundo del rastro de fuego en el suelo (Take 001).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 500f), Array.Empty())); _cfgUlvPerWave = ((BaseUnityPlugin)this).Config.Bind("Ulv", "UlvPorOleada", 3, new ConfigDescription("Cantidad de Ulv invocados por oleada en Fase 2.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10), Array.Empty())); _cfgSummonInterval = ((BaseUnityPlugin)this).Config.Bind("Ulv", "IntervaloOleadaSegundos", 40f, new ConfigDescription("Segundos entre oleadas de Ulv (solo si todos murieron).", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 300f), Array.Empty())); _cfgUlvHealth = ((BaseUnityPlugin)this).Config.Bind("Ulv", "UlvVida", 300f, new ConfigDescription("Vida de cada Ulv invocado.", (AcceptableValueBase)(object)new AcceptableValueRange(50f, 10000f), Array.Empty())); _cfgMusicFile = ((BaseUnityPlugin)this).Config.Bind("Audio", "MusicFile", "blackblade_music.ogg", "Nombre del archivo de música en la carpeta del plugin (ogg/wav/mp3). Dejar vacío para deshabilitar."); _cfgLoot1Item = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Item", "Flametal", "Nombre del item del slot 1 (exacto del juego). Vacío = desactivado."); _cfgLoot1Min = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Min", 3, new ConfigDescription("Cantidad mínima del drop 1.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot1Max = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Max", 6, new ConfigDescription("Cantidad máxima del drop 1.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot1Chance = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop1Chance", 1f, new ConfigDescription("Probabilidad del drop 1 (0.0–1.0).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _cfgLoot2Item = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Item", "TrophySkeleton", "Nombre del item del slot 2. Vacío = desactivado."); _cfgLoot2Min = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Min", 1, new ConfigDescription("Cantidad mínima del drop 2.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot2Max = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Max", 1, new ConfigDescription("Cantidad máxima del drop 2.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot2Chance = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop2Chance", 1f, new ConfigDescription("Probabilidad del drop 2 (0.0–1.0).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _cfgLoot3Item = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop3Item", "", "Nombre del item del slot 3. Vacío = desactivado."); _cfgLoot3Min = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop3Min", 1, new ConfigDescription("Cantidad mínima del drop 3.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot3Max = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop3Max", 1, new ConfigDescription("Cantidad máxima del drop 3.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); _cfgLoot3Chance = ((BaseUnityPlugin)this).Config.Bind("Loot", "Drop3Chance", 1f, new ConfigDescription("Probabilidad del drop 3 (0.0–1.0).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); ApplyMusicManPatches(); ((MonoBehaviour)this).StartCoroutine(LoadAudioFiles()); PrefabManager.OnVanillaPrefabsAvailable += CreateBlackbladePrefab; new ConsoleCommand("bb_spawn", "Invoca a Blackblade en fase pasiva frente al jugador.", (ConsoleEvent)delegate { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; ObjectDB odb = ObjectDB.instance; List items; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)odb)) { Log.LogError((object)"[Blackblade] ZNetScene/ObjectDB no disponibles."); } else { Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer)) { GameObject prefab = instance.GetPrefab("Skeleton"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"[Blackblade] Prefab 'Skeleton' no encontrado."); } else { Vector3 val = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 5f; GameObject val2 = Object.Instantiate(prefab, val, Quaternion.identity); ((Object)val2).name = "Boss_Skeleton_Blackblade_Passive"; SetNonPersistent(val2.GetComponent()); Character component = val2.GetComponent(); Humanoid component2 = val2.GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2)) { Object.Destroy((Object)(object)val2); } else { component.m_name = "Blackblade, Herald of Ash"; component.m_faction = (Faction)3; MonsterAI component3 = val2.GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { ((BaseAI)component3).m_aggravatable = false; component3.m_attackPlayerObjects = false; component3.m_alertRange = 0f; } items = new List(); TryAdd("ArmorMageChest_Ashlands"); TryAdd("ArmorMageLegs_Ashlands"); TryAdd("CapeFeather"); component2.m_defaultItems = items.ToArray(); val2.transform.localScale = Vector3.one * _cfgScale.Value; GameObject val3 = new GameObject("_InteractTrigger"); val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = Vector3.up * 1f; val3.layer = LayerMask.NameToLayer("Default"); SphereCollider val4 = val3.AddComponent(); ((Collider)val4).isTrigger = true; val4.radius = 0.9f; BlackbladeInteraction blackbladeInteraction = val3.AddComponent(); blackbladeInteraction.Plugin = this; blackbladeInteraction.CharacterGo = val2; ((MonoBehaviour)this).StartCoroutine(PostStartPassive(val2)); } } } } void TryAdd(string n) { GameObject itemPrefab = odb.GetItemPrefab(n); if (Object.op_Implicit((Object)(object)itemPrefab) && !items.Contains(itemPrefab)) { items.Add(itemPrefab); } } }, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); Log.LogInfo((object)"[Blackblade] Cargado. Usa 'devcommands' y luego 'bb_spawn'."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } PrefabManager.OnVanillaPrefabsAvailable -= CreateBlackbladePrefab; StopBossMusic(); } internal static void StartBossMusic() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown if ((Object)(object)MusicClip == (Object)null || (Object)(object)_bossMusic != (Object)null) { return; } _mutedVanillaSources.Clear(); if ((Object)(object)MusicMan.instance != (Object)null) { AudioSource[] componentsInChildren = ((Component)MusicMan.instance).GetComponentsInChildren(true); foreach (AudioSource val in componentsInChildren) { if ((Object)(object)val != (Object)null && val.volume > 0f) { val.volume = 0f; _mutedVanillaSources.Add(val); } } } BossMusicActive = true; GameObject val2 = new GameObject("BlackbladeBossMusic"); Object.DontDestroyOnLoad((Object)(object)val2); AudioSource val3 = val2.AddComponent(); val3.clip = MusicClip; val3.loop = true; val3.spatialBlend = 0f; val3.volume = 0.5f; val3.Play(); _bossMusic = val3; Log.LogInfo((object)"[Blackblade] Música de boss iniciada, vanilla silenciada."); } internal static void StopBossMusic() { if ((Object)(object)_bossMusic == (Object)null) { return; } Object.Destroy((Object)(object)((Component)_bossMusic).gameObject); _bossMusic = null; BossMusicActive = false; foreach (AudioSource mutedVanillaSource in _mutedVanillaSources) { if ((Object)(object)mutedVanillaSource != (Object)null) { mutedVanillaSource.volume = 1f; } } _mutedVanillaSources.Clear(); Log.LogInfo((object)"[Blackblade] Música de boss detenida, vanilla restaurada."); } private static bool MusicManBlockPrefix() { return !BossMusicActive; } private void ApplyMusicManPatches() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(MainPlugin).GetMethod("MusicManBlockPrefix", BindingFlags.Static | BindingFlags.NonPublic)); string[] array = new string[4] { "StartMusic", "StartRandomEventMusic", "UpdateMusic", "QueueMusic" }; foreach (string text in array) { try { MethodInfo method = typeof(MusicMan).GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { _harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)("[Blackblade] Parcheado MusicMan." + text)); } } catch (Exception ex) { Log.LogWarning((object)("[Blackblade] No se pudo parchar MusicMan." + text + ": " + ex.Message)); } } } private IEnumerator LoadAudioFiles() { string pluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? ""; if (!string.IsNullOrWhiteSpace(_cfgMusicFile.Value)) { string path = Path.Combine(pluginDir, _cfgMusicFile.Value.Trim()); yield return LoadClip(path, delegate(AudioClip c) { MusicClip = c; }, "música"); } } private static IEnumerator LoadClip(string path, Action onLoaded, string label) { if (!File.Exists(path)) { Log.LogWarning((object)("[Blackblade] Archivo de " + label + " no encontrado: " + path)); yield break; } string ext = Path.GetExtension(path).ToLowerInvariant(); AudioType audioType = (AudioType)14; if (ext == ".wav") { audioType = (AudioType)20; } else if (ext == ".mp3") { audioType = (AudioType)13; } UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), audioType); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { Log.LogError((object)("[Blackblade] Error cargando " + label + ": " + req.error)); yield break; } AudioClip clip = DownloadHandlerAudioClip.GetContent(req); if (Object.op_Implicit((Object)(object)clip)) { onLoaded(clip); Log.LogInfo((object)$"[Blackblade] '{label}' cargado: {clip.length:F1}s"); } } finally { ((IDisposable)req)?.Dispose(); } } internal static void ApplyLootDrops(GameObject go) { ObjectDB odb = ObjectDB.instance; CharacterDrop drop; if (Object.op_Implicit((Object)(object)odb)) { drop = go.GetComponent() ?? go.AddComponent(); drop.m_drops = new List(); TryAdd(Instance._cfgLoot1Item.Value, Instance._cfgLoot1Min.Value, Instance._cfgLoot1Max.Value, Instance._cfgLoot1Chance.Value); TryAdd(Instance._cfgLoot2Item.Value, Instance._cfgLoot2Min.Value, Instance._cfgLoot2Max.Value, Instance._cfgLoot2Chance.Value); TryAdd(Instance._cfgLoot3Item.Value, Instance._cfgLoot3Min.Value, Instance._cfgLoot3Max.Value, Instance._cfgLoot3Chance.Value); Log.LogInfo((object)$"[Blackblade] Loot configurado: {drop.m_drops.Count} drop(s)."); } void TryAdd(string itemName, int min, int max, float chance) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown if (!string.IsNullOrWhiteSpace(itemName) && !(chance <= 0f)) { GameObject itemPrefab = odb.GetItemPrefab(itemName.Trim()); if (!Object.op_Implicit((Object)(object)itemPrefab)) { Log.LogWarning((object)("[Blackblade] Loot item '" + itemName + "' no encontrado en ObjectDB.")); } else { drop.m_drops.Add(new Drop { m_prefab = itemPrefab, m_amountMin = Mathf.Max(1, min), m_amountMax = Mathf.Max(min, max), m_chance = Mathf.Clamp01(chance), m_onePerPlayer = false, m_levelMultiplier = false }); } } } } private void CreateBlackbladePrefab() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= CreateBlackbladePrefab; if (Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("Boss_Skeleton_Blackblade"))) { return; } GameObject prefab = PrefabManager.Instance.GetPrefab("Skeleton"); if (!Object.op_Implicit((Object)(object)prefab)) { Log.LogError((object)"[Blackblade] Prefab 'Skeleton' no encontrado para clonar."); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab("Boss_Skeleton_Blackblade", prefab); Character component = val.GetComponent(); Humanoid component2 = val.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_name = "Blackblade, Herald of Ash"; component.m_boss = true; component.m_health = _cfgHealth.Value; component.m_faction = (Faction)3; component.m_staggerWhenBlocked = false; component.m_staggerDamageFactor = 0f; } ObjectDB odb; List items; if (Object.op_Implicit((Object)(object)component2)) { odb = ObjectDB.instance; items = new List((IEnumerable)(((object)component2.m_defaultItems) ?? ((object)new GameObject[0]))); TryAdd("ArmorMageChest_Ashlands"); TryAdd("ArmorMageLegs_Ashlands"); TryAdd("CapeFeather"); component2.m_defaultItems = items.ToArray(); } val.transform.localScale = Vector3.one * _cfgScale.Value; val.AddComponent(); PrefabManager.Instance.AddPrefab(new CustomPrefab(val, true)); Log.LogInfo((object)"[Blackblade] Boss_Skeleton_Blackblade registrado. Usa: spawn Boss_Skeleton_Blackblade"); void TryAdd(string n) { ObjectDB obj = odb; GameObject val2 = ((obj != null) ? obj.GetItemPrefab(n) : null); if (Object.op_Implicit((Object)(object)val2) && !items.Contains(val2)) { items.Add(val2); } } } private IEnumerator TransformationEffects(Vector3 pos, float duration) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { yield break; } GameObject explosionPrefab = zns.GetPrefab("fx_Fader_CorpseExplosion"); GameObject bellPrefab = zns.GetPrefab("sfx_fader_bell"); float end = Time.time + duration; while (Time.time < end) { if (Object.op_Implicit((Object)(object)explosionPrefab)) { GameObject fx = Object.Instantiate(explosionPrefab, pos + Vector3.up * 0.5f, Quaternion.identity); BlackbladeBrain.PaintFxBlack(fx); ParticleSystem[] componentsInChildren = fx.GetComponentsInChildren(true); foreach (ParticleSystem ps in componentsInChildren) { MainModule main = ps.main; ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.5f, 0f, 0f, 1f), new Color(0.05f, 0f, 0f, 1f)); main = default(MainModule); } Object.Destroy((Object)(object)fx, 3f); } if (Object.op_Implicit((Object)(object)bellPrefab)) { Object.Destroy((Object)(object)Object.Instantiate(bellPrefab, pos, Quaternion.identity), 3f); } yield return (object)new WaitForSeconds(2f); } } internal static void SetNonPersistent(ZNetView nview) { if ((Object)(object)nview == (Object)null) { return; } nview.m_persistent = false; if (!nview.IsValid() || _zdoDataFlagsField == null) { return; } try { ZDO zDO = nview.GetZDO(); object value = _zdoDataFlagsField.GetValue(zDO); int value2 = Convert.ToInt32(value) & -5; _zdoDataFlagsField.SetValue(zDO, Enum.ToObject(_zdoDataFlagsField.FieldType, value2)); } catch (Exception ex) { Log.LogWarning((object)("[Blackblade] SetNonPersistent falló (no crítico): " + ex.Message)); } } internal IEnumerator TransformToAggressive(GameObject passiveGo) { ZNetScene zns = ZNetScene.instance; ObjectDB odb = ObjectDB.instance; if (!Object.op_Implicit((Object)(object)zns) || !Object.op_Implicit((Object)(object)odb)) { yield break; } Vector3 pos = passiveGo.transform.position; Quaternion rot = passiveGo.transform.rotation; Vector3 scale = passiveGo.transform.localScale; MonsterAI passiveAI = passiveGo.GetComponent(); if (Object.op_Implicit((Object)(object)passiveAI)) { ((Behaviour)passiveAI).enabled = false; } Character passiveCh = passiveGo.GetComponent(); if (Object.op_Implicit((Object)(object)passiveCh)) { passiveCh.SetHealth(999999f); } Rigidbody rb = passiveGo.GetComponent() ?? passiveGo.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)rb)) { rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.isKinematic = true; } typeof(Character).GetField("m_moveDir", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(passiveCh, Vector3.zero); StartBossMusic(); GameObject vfxPrefab = zns.GetPrefab("vfx_Tared"); if (Object.op_Implicit((Object)(object)vfxPrefab)) { GameObject vfxGo = Object.Instantiate(vfxPrefab, pos + Vector3.up * 1f, Quaternion.identity); vfxGo.transform.localScale = Vector3.one * 8f; ParticleSystem[] componentsInChildren = vfxGo.GetComponentsInChildren(); foreach (ParticleSystem ps in componentsInChildren) { MainModule main = ps.main; ((MainModule)(ref main)).loop = true; main = default(MainModule); } Object.Destroy((Object)(object)vfxGo, 16f); } else { Log.LogWarning((object)"[Blackblade] vfx_Tared no encontrado."); } ((MonoBehaviour)this).StartCoroutine(TransformationEffects(pos, 15f)); yield return (object)new WaitForSeconds(15f); Object.Destroy((Object)(object)passiveGo); GameObject variantPrefab = zns.GetPrefab("Skeleton_Variant_Blackblade") ?? zns.GetPrefab("Skeleton"); if (!Object.op_Implicit((Object)(object)variantPrefab)) { Log.LogError((object)"[Blackblade] Variante no encontrada para la transformación."); yield break; } GameObject go = Object.Instantiate(variantPrefab, pos, rot); ((Object)go).name = "Boss_Skeleton_Blackblade"; SetNonPersistent(go.GetComponent()); Character ch = go.GetComponent(); Humanoid hu = go.GetComponent(); if (!Object.op_Implicit((Object)(object)ch) || !Object.op_Implicit((Object)(object)hu)) { Object.Destroy((Object)(object)go); yield break; } ch.m_boss = true; ch.m_name = "Blackblade, Herald of Ash"; ch.m_health = _cfgHealth.Value; ch.m_faction = (Faction)3; ch.m_staggerWhenBlocked = false; ch.m_staggerDamageFactor = 0f; MonsterAI aggrAI = go.GetComponent(); if (Object.op_Implicit((Object)(object)aggrAI)) { ((BaseAI)aggrAI).m_aggravatable = false; aggrAI.m_attackPlayerObjects = false; aggrAI.m_alertRange = 0f; } List bossItems = new List((IEnumerable)(((object)hu.m_defaultItems) ?? ((object)new GameObject[0]))); TryAddBoss("ArmorMageChest_Ashlands"); TryAddBoss("ArmorMageLegs_Ashlands"); TryAddBoss("CapeFeather"); hu.m_defaultItems = bossItems.ToArray(); go.transform.localScale = scale; ((MonoBehaviour)this).StartCoroutine(PostStartSetup(go)); BlackbladeBrain brain = go.AddComponent(); brain.IsAggressiveSpawn = true; yield return (object)new WaitForSeconds(2f); if (Object.op_Implicit((Object)(object)go) && Object.op_Implicit((Object)(object)aggrAI)) { ((BaseAI)aggrAI).m_aggravatable = true; aggrAI.m_attackPlayerObjects = true; aggrAI.m_alertRange = 20f; } void TryAddBoss(string n) { GameObject itemPrefab = odb.GetItemPrefab(n); if (Object.op_Implicit((Object)(object)itemPrefab) && !bossItems.Contains(itemPrefab)) { bossItems.Add(itemPrefab); } } } private static IEnumerator PostStartPassive(GameObject go) { yield return (object)new WaitForSeconds(0.5f); if (!Object.op_Implicit((Object)(object)go)) { yield break; } ZNetScene zns = ZNetScene.instance; if (Object.op_Implicit((Object)(object)zns)) { GameObject skeletonPrefab = zns.GetPrefab("Skeleton"); Animator prefabAnim = ((skeletonPrefab != null) ? skeletonPrefab.GetComponentInChildren() : null); Animator instanceAnim = go.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)prefabAnim) && Object.op_Implicit((Object)(object)instanceAnim)) { instanceAnim.runtimeAnimatorController = prefabAnim.runtimeAnimatorController; } } Humanoid hu = go.GetComponent(); float unequipEnd = Time.time + 2f; while (Time.time < unequipEnd && Object.op_Implicit((Object)(object)go)) { if (Object.op_Implicit((Object)(object)hu)) { Inventory inv = hu.GetInventory(); if (inv != null) { foreach (ItemData item in new List(inv.GetAllItems())) { if (item.m_equipped) { ItemType t = item.m_shared.m_itemType; if ((int)t == 3 || (int)t == 14 || (int)t == 5) { hu.UnequipItem(item, false); } } } } } yield return (object)new WaitForSeconds(0.2f); } PaintBoss(go, new Color(0.05f, 0.05f, 0.05f), new Color(0.5f, 0.5f, 0.5f)); PaintEyesCyan(go); ((MonoBehaviour)Instance).StartCoroutine(SpeakPhrases(go)); } internal static IEnumerator SpeakPhrases(GameObject go) { yield return (object)new WaitForSeconds(4f); int idx = 0; while (Object.op_Implicit((Object)(object)go)) { Character ch = go.GetComponent(); if ((Object)(object)ch == (Object)null) { break; } if (Object.op_Implicit((Object)(object)Chat.instance)) { Chat.instance.SetNpcText(go, Vector3.up * 2.5f, 20f, 6f, "", PassivePhrases[idx % PassivePhrases.Length], false); } idx++; yield return (object)new WaitForSeconds(Random.Range(10f, 18f)); } } private IEnumerator PostStartSetup(GameObject go) { yield return null; yield return null; if (Object.op_Implicit((Object)(object)go)) { Character ch = go.GetComponent(); if (Object.op_Implicit((Object)(object)ch)) { ch.SetMaxHealth(_cfgHealth.Value); ch.SetHealth(_cfgHealth.Value); } PaintBoss(go, new Color(0.05f, 0.05f, 0.05f), new Color(0.5f, 0.5f, 0.5f)); PaintEyesRed(go); ApplyLootDrops(go); } } internal static void PaintBoss(GameObject root, Color skeletonColor, Color armorColor) { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0187: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)root)) { return; } Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } bool flag = false; string text = (((Object)val).name ?? "").ToLowerInvariant(); if (text.Contains("helmet") || text.Contains("cape") || text.Contains("armor") || text.Contains("chest") || text.Contains("legs") || text.Contains("shoulder") || text.Contains("cloak") || text.Contains("greaves") || text.Contains("gauntlet") || text.Contains("hood")) { flag = true; } else { Transform val2 = ((Component)val).transform; while ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).gameObject != (Object)(object)root) { if ((Object)(object)((Component)val2).GetComponent() != (Object)null) { flag = true; break; } val2 = val2.parent; } } Color val3 = (flag ? armorColor : skeletonColor); Material[] materials = val.materials; foreach (Material val4 in materials) { if (Object.op_Implicit((Object)(object)val4)) { if (val4.HasProperty("_Color")) { val4.color = val3; } if (val4.HasProperty("_BaseColor")) { val4.SetColor("_BaseColor", val3); } if (val4.HasProperty("_EmissionColor")) { val4.SetColor("_EmissionColor", val4.GetColor("_EmissionColor") * 0.25f); } } } val.materials = materials; } } internal static void PaintEyesCyan(GameObject root) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } string text = (((Object)val).name ?? "").ToLowerInvariant(); if (!text.Contains("head") && !text.Contains("eye")) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if (Object.op_Implicit((Object)(object)val2) && val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", new Color(0f, 0.8f, 1f, 1f)); } } RendererExtensions.UpdateGIMaterials(val); } } internal static void PaintEyesRed(GameObject root) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } string text = (((Object)val).name ?? "").ToLowerInvariant(); if (!text.Contains("head") && !text.Contains("eye")) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if (Object.op_Implicit((Object)(object)val2) && val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", new Color(1f, 0f, 0f, 1f)); } } RendererExtensions.UpdateGIMaterials(val); } } } public class BlackbladeBrain : MonoBehaviour { private Character _ch; private Humanoid _hu; private Animator _anim; private float _nextPulseTime; private string _lastClip = ""; private bool _attackFxFired = false; private bool _comboRunning = false; public bool IsAggressiveSpawn = false; private bool _phase2Triggered = false; private bool _phase2Active = false; private bool _deathHandled = false; private bool _summonRunning = false; private float _nextSummonTime = float.MaxValue; private readonly List _summonedUlv = new List(); private static readonly FieldInfo _dodgeInvincibleField = FindDodgeField(); private static readonly MethodInfo _inDodgeMethod = typeof(Player).GetMethod("InDodge", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); private static FieldInfo _nextAttackField; private static FieldInfo _lastAttackTimeField; private const float PulseInterval = 20f; private const float PulseOuterRadius = 30f; private const float PulseInnerRadius = 10f; private const float SpinRadius = 15f; private const float FlameLength = 12f; private const float FlameAngle = 30f; private const float BleedRadius = 5f; private static readonly MethodInfo _staggerMethod = typeof(Character).GetMethod("Stagger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Vector3) }, null); private static FieldInfo FindDodgeField() { string[] array = new string[6] { "m_dodgeInvincible", "m_inDodge", "m_noDodgeCooldown", "m_dodgeCooldown", "m_dodgeTimer", "m_dodging" }; string[] array2 = array; foreach (string name in array2) { FieldInfo fieldInfo = typeof(Player).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeof(Character).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo != null) { return fieldInfo; } } return null; } private static bool IsDodging(Character ch) { Player val = (Player)(object)((ch is Player) ? ch : null); if (val != null && _inDodgeMethod != null) { object obj = _inDodgeMethod.Invoke(val, null); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { return true; } } if (_dodgeInvincibleField != null) { object value = _dodgeInvincibleField.GetValue(ch); bool flag2 = default(bool); int num2; if (value is bool) { flag2 = (bool)value; num2 = 1; } else { num2 = 0; } if (((uint)num2 & (flag2 ? 1u : 0u)) != 0) { return true; } if (value is float num3 && num3 > 0f) { return true; } } Animator componentInChildren = ((Component)ch).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { for (int i = 0; i < componentInChildren.layerCount; i++) { AnimatorClipInfo[] currentAnimatorClipInfo = componentInChildren.GetCurrentAnimatorClipInfo(i); if (currentAnimatorClipInfo.Length != 0) { AnimationClip clip = ((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip; string text = ((clip == null) ? null : ((Object)clip).name?.ToLowerInvariant()) ?? ""; if (text.Contains("dodge") || text.Contains("roll") || text.Contains("sidestep")) { return true; } } } } return false; } private void Awake() { _ch = ((Component)this).GetComponent(); _hu = ((Component)this).GetComponent(); _anim = ((Component)this).GetComponentInChildren(); _nextPulseTime = Time.time + 20f; MainPlugin.SetNonPersistent(((Component)this).GetComponent()); string[] array = new string[4] { "m_lastAttackTime", "m_timeSinceAttacking", "m_attackCooldown", "m_lastAttack" }; string[] array2 = array; foreach (string name in array2) { FieldInfo field = typeof(MonsterAI).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null)) { _lastAttackTimeField = field; break; } } string[] array3 = new string[6] { "m_nextAttack", "m_currentAttackNr", "m_attackNr", "m_nextAttackNr", "m_currentAttack", "m_baseAttack" }; string[] array4 = array3; foreach (string name2 in array4) { FieldInfo field2 = typeof(Humanoid).GetField(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field2 == null)) { _nextAttackField = field2; break; } } } private void Start() { ((MonoBehaviour)this).StartCoroutine(DelayedSetup()); } private IEnumerator DelayedSetup() { yield return null; yield return null; if (!Object.op_Implicit((Object)(object)_ch)) { yield break; } if (IsAggressiveSpawn) { MonsterAI ai = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)ai)) { ((BaseAI)ai).m_aggravatable = false; ai.m_attackPlayerObjects = true; ai.m_alertRange = 20f; } MainPlugin.ApplyLootDrops(((Component)this).gameObject); MainPlugin.Log.LogInfo((object)"[Blackblade] DelayedSetup (agresivo) completado."); yield break; } _ch.m_boss = false; ((Component)this).gameObject.AddComponent(); MonsterAI ai2 = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)ai2)) { ((BaseAI)ai2).m_aggravatable = false; ai2.m_attackPlayerObjects = false; ai2.m_alertRange = 0f; } ObjectDB odb = ObjectDB.instance; if ((Object)(object)odb != (Object)null && (Object)(object)_hu != (Object)null) { List defaultList = new List((IEnumerable)(((object)_hu.m_defaultItems) ?? ((object)new GameObject[0]))); bool changed = false; string[] array = new string[3] { "ArmorMageChest_Ashlands", "ArmorMageLegs_Ashlands", "CapeFeather" }; foreach (string i in array) { GameObject it = odb.GetItemPrefab(i); if ((Object)(object)it != (Object)null && !defaultList.Contains(it)) { defaultList.Add(it); changed = true; } } if (changed) { _hu.m_defaultItems = defaultList.ToArray(); _hu.GiveDefaultItems(); } } if ((Object)(object)_hu != (Object)null) { Inventory inv = _hu.GetInventory(); if (inv != null) { foreach (ItemData item in new List(inv.GetAllItems())) { if (item.m_equipped) { ItemType t = item.m_shared.m_itemType; if ((int)t == 3 || (int)t == 14 || (int)t == 5) { _hu.UnequipItem(item, false); } } } } } yield return (object)new WaitForSeconds(0.5f); if (Object.op_Implicit((Object)(object)_ch)) { MainPlugin.PaintBoss(((Component)this).gameObject, new Color(0.05f, 0.05f, 0.05f), new Color(0.5f, 0.5f, 0.5f)); MainPlugin.PaintEyesCyan(((Component)this).gameObject); GameObject triggerGo = new GameObject("_InteractTrigger"); triggerGo.transform.SetParent(((Component)this).transform, false); triggerGo.transform.localPosition = Vector3.up * 1f; triggerGo.layer = LayerMask.NameToLayer("Default"); SphereCollider sph = triggerGo.AddComponent(); ((Collider)sph).isTrigger = true; sph.radius = 0.9f; BlackbladeInteraction interaction = triggerGo.AddComponent(); interaction.Plugin = MainPlugin.Instance; interaction.CharacterGo = ((Component)this).gameObject; ((MonoBehaviour)this).StartCoroutine(MainPlugin.SpeakPhrases(((Component)this).gameObject)); MainPlugin.Log.LogInfo((object)"[Blackblade] DelayedSetup (pasivo) completado. Presiona E para despertar."); } } private void Update() { if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { if (!_deathHandled) { _deathHandled = true; MainPlugin.StopBossMusic(); } } else { if (!IsAggressiveSpawn) { return; } if (Time.time >= _nextPulseTime) { _nextPulseTime = Time.time + 20f; ((MonoBehaviour)this).StartCoroutine(DarkPulse()); } CheckAttackAnimations(); if (!_phase2Triggered && _ch.GetHealthPercentage() <= MainPlugin.CfgPhase2Threshold) { _phase2Triggered = true; ((MonoBehaviour)this).StartCoroutine(EnterPhase2()); } if (_phase2Active && !_summonRunning && Time.time >= _nextSummonTime) { _summonedUlv.RemoveAll((Character u) => !Object.op_Implicit((Object)(object)u) || u.IsDead()); if (_summonedUlv.Count == 0) { ((MonoBehaviour)this).StartCoroutine(SummonUlvWave(isFirstWave: false)); } } } } private void OnDestroy() { if (IsAggressiveSpawn) { MainPlugin.StopBossMusic(); } ZNetScene instance = ZNetScene.instance; foreach (Character item in _summonedUlv) { if (Object.op_Implicit((Object)(object)item) && !item.IsDead()) { if ((Object)(object)instance != (Object)null) { instance.Destroy(((Component)item).gameObject); } else { Object.Destroy((Object)(object)((Component)item).gameObject); } } } } private void CheckAttackAnimations() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_anim)) { return; } int layerCount = _anim.layerCount; string text = ""; float num = 0f; AnimatorStateInfo currentAnimatorStateInfo; for (int i = 0; i < layerCount; i++) { AnimatorClipInfo[] currentAnimatorClipInfo = _anim.GetCurrentAnimatorClipInfo(i); if (currentAnimatorClipInfo.Length != 0) { AnimationClip clip = ((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip; if (!((Object)(object)clip == (Object)null)) { text = ((Object)clip).name; currentAnimatorStateInfo = _anim.GetCurrentAnimatorStateInfo(i); num = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime % 1f; break; } } } for (int j = 1; j < layerCount; j++) { AnimatorClipInfo[] currentAnimatorClipInfo2 = _anim.GetCurrentAnimatorClipInfo(j); if (currentAnimatorClipInfo2.Length == 0 || ((AnimatorClipInfo)(ref currentAnimatorClipInfo2[0])).weight < 0.5f) { continue; } AnimationClip clip2 = ((AnimatorClipInfo)(ref currentAnimatorClipInfo2[0])).clip; if (!((Object)(object)clip2 == (Object)null)) { string name = ((Object)clip2).name; if (name.Contains("Attack") || name.Contains("Greatsword") || name.Contains("Atgeir") || name.Contains("Melee") || name.Contains("sword") || name.Contains("BattleAxe")) { text = name; currentAnimatorStateInfo = _anim.GetCurrentAnimatorStateInfo(j); num = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime % 1f; break; } } } if (string.IsNullOrEmpty(text)) { return; } string text2 = "0:" + text; if (text2 != _lastClip) { _lastClip = text2; _attackFxFired = false; } if (_attackFxFired) { return; } switch (text) { case "Atgeir360Attack": if (num > 0.25f) { _attackFxFired = true; ((MonoBehaviour)this).StartCoroutine(SpinAttackFX()); } break; case "Greatsword BaseAttack (3)": if (num > 0.45f) { _attackFxFired = true; ((MonoBehaviour)this).StartCoroutine(SlamCrossFX()); } break; case "Greatsword BaseAttack (2)": if (num > 0.35f) { _attackFxFired = true; ((MonoBehaviour)this).StartCoroutine(GuardBreakFX()); if (!_comboRunning) { _comboRunning = true; ((MonoBehaviour)this).StartCoroutine(ComboIntoAttack1()); } } break; case "Take 001": if (num > 0.35f) { _attackFxFired = true; ((MonoBehaviour)this).StartCoroutine(FlamebreathFX()); } break; } } private IEnumerator ComboIntoAttack1() { float timeout = Time.time + 3f; while (Time.time < timeout) { yield return null; if (!Object.op_Implicit((Object)(object)_anim)) { break; } bool stillIn2 = false; for (int layer = 0; layer < _anim.layerCount; layer++) { AnimatorClipInfo[] infos = _anim.GetCurrentAnimatorClipInfo(layer); int num; if (infos.Length != 0) { AnimationClip clip = ((AnimatorClipInfo)(ref infos[0])).clip; num = ((((clip != null) ? ((Object)clip).name : null) == "Greatsword BaseAttack (2)") ? 1 : 0); } else { num = 0; } if (num != 0) { stillIn2 = true; break; } } if (!stillIn2) { break; } } if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { _comboRunning = false; yield break; } if ((Object)(object)_hu != (Object)null && _nextAttackField != null) { try { _nextAttackField.SetValue(_hu, 0); } catch { } } MonsterAI ai = ((Component)this).GetComponent(); if ((Object)(object)ai != (Object)null && _lastAttackTimeField != null) { try { _lastAttackTimeField.SetValue(ai, Time.time - 999f); } catch { } } if ((Object)(object)_hu != (Object)null) { Character targetCh = null; float minDist = float.MaxValue; foreach (Player p in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)p)) { float d = Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position); if (d < minDist) { minDist = d; targetCh = (Character)(object)p; } } } if ((Object)(object)targetCh != (Object)null) { try { ((Character)_hu).StartAttack(targetCh, false); } catch { } } } _comboRunning = false; } private IEnumerator EnterPhase2() { MainPlugin.Log.LogInfo((object)"[Blackblade] Entrando en Fase 2."); ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { yield break; } MonsterAI ai = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)ai)) { ((Behaviour)ai).enabled = false; } GameObject taredPrefab = zns.GetPrefab("vfx_Tared"); if (Object.op_Implicit((Object)(object)taredPrefab)) { GameObject vfx = Object.Instantiate(taredPrefab, ((Component)this).transform.position + Vector3.up * 0.5f, Quaternion.identity); vfx.transform.localScale = Vector3.one * 4f; ParticleSystem[] componentsInChildren = vfx.GetComponentsInChildren(); foreach (ParticleSystem ps in componentsInChildren) { MainModule main = ps.main; ((MainModule)(ref main)).loop = false; main = default(MainModule); } Object.Destroy((Object)(object)vfx, 4f); } yield return (object)new WaitForSeconds(2.5f); if (Object.op_Implicit((Object)(object)ai)) { ((Behaviour)ai).enabled = true; } yield return ((MonoBehaviour)this).StartCoroutine(SummonUlvWave(isFirstWave: true)); _phase2Active = true; _nextSummonTime = Time.time + MainPlugin.CfgSummonInterval; } private IEnumerator SummonUlvWave(bool isFirstWave) { _summonRunning = true; int ulvCount = MainPlugin.CfgUlvPerWave; MainPlugin.Log.LogInfo((object)$"[Blackblade] Invocando oleada de {ulvCount} Ulv."); ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { _summonRunning = false; yield break; } MonsterAI ai = ((Component)this).GetComponent(); if (isFirstWave && Object.op_Implicit((Object)(object)ai)) { ((Behaviour)ai).enabled = false; } BlackbladeBossImmunity immunityComp = null; if (Object.op_Implicit((Object)(object)_ch)) { immunityComp = ((Component)_ch).gameObject.AddComponent(); } GameObject bossTared = null; GameObject taredPrefab = zns.GetPrefab("vfx_Tared"); GameObject spawnFxPrefab = zns.GetPrefab("fx_summon_skeleton_spawn"); if (isFirstWave && Object.op_Implicit((Object)(object)taredPrefab) && Object.op_Implicit((Object)(object)_ch)) { bossTared = Object.Instantiate(taredPrefab, ((Component)_ch).transform.position + Vector3.up * 1f, Quaternion.identity); bossTared.transform.localScale = Vector3.one * 7f; } GameObject ulvPrefab = zns.GetPrefab("Ulv"); if (!Object.op_Implicit((Object)(object)ulvPrefab)) { MainPlugin.Log.LogWarning((object)"[Blackblade] Prefab 'Ulv' no encontrado."); if (Object.op_Implicit((Object)(object)bossTared)) { Object.Destroy((Object)(object)bossTared); } if (Object.op_Implicit((Object)(object)immunityComp)) { Object.Destroy((Object)(object)immunityComp); } if (isFirstWave && Object.op_Implicit((Object)(object)ai)) { ((Behaviour)ai).enabled = true; } _summonRunning = false; yield break; } Vector3[] spawnPositions = (Vector3[])(object)new Vector3[ulvCount]; for (int j = 0; j < ulvCount; j++) { float angle = -60f + (float)j * (120f / (float)Mathf.Max(1, ulvCount - 1)); Vector3 dir = Quaternion.Euler(0f, angle, 0f) * ((Component)this).transform.forward; spawnPositions[j] = ((Component)this).transform.position + dir * 5f; spawnPositions[j].y = ((Component)this).transform.position.y; } Vector3[] array = spawnPositions; foreach (Vector3 pos in array) { if (Object.op_Implicit((Object)(object)taredPrefab)) { GameObject tared = Object.Instantiate(taredPrefab, pos + Vector3.up * 0.5f, Quaternion.identity); tared.transform.localScale = Vector3.one * 4f; ParticleSystem[] componentsInChildren = tared.GetComponentsInChildren(); foreach (ParticleSystem ps in componentsInChildren) { MainModule main = ps.main; ((MainModule)(ref main)).loop = false; main = default(MainModule); } Object.Destroy((Object)(object)tared, 3f); } if (Object.op_Implicit((Object)(object)spawnFxPrefab)) { Object.Destroy((Object)(object)Object.Instantiate(spawnFxPrefab, pos, Quaternion.identity), 3f); } } yield return (object)new WaitForSeconds(1.5f); Character nearestPlayer = null; float minDist = float.MaxValue; foreach (Player p in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)p)) { float d = Vector3.Distance(((Component)this).transform.position, ((Component)p).transform.position); if (d < minDist) { minDist = d; nearestPlayer = (Character)(object)p; } } } for (int i = 0; i < ulvCount; i++) { if (!Object.op_Implicit((Object)(object)_ch)) { break; } if (_ch.IsDead()) { break; } GameObject ulvGo = Object.Instantiate(ulvPrefab, spawnPositions[i], Quaternion.identity); MainPlugin.SetNonPersistent(ulvGo.GetComponent()); CharacterDrop drops = ulvGo.GetComponent(); if (Object.op_Implicit((Object)(object)drops)) { drops.m_drops.Clear(); } ulvGo.AddComponent(); Character ulvCh = ulvGo.GetComponent(); if (Object.op_Implicit((Object)(object)ulvCh)) { ulvCh.SetMaxHealth(MainPlugin.CfgUlvHealth); ulvCh.SetHealth(MainPlugin.CfgUlvHealth); _summonedUlv.Add(ulvCh); } BaseAI ulvBaseAI = ulvGo.GetComponent(); MonsterAI ulvMonsterAI = ulvGo.GetComponent(); if (Object.op_Implicit((Object)(object)ulvBaseAI)) { typeof(BaseAI).GetMethod("SetAlerted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(ulvBaseAI, new object[1] { true }); } if ((Object)(object)nearestPlayer != (Object)null) { FieldInfo targetField = typeof(MonsterAI).GetField("m_targetCreature", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (targetField != null && (Object)(object)ulvMonsterAI != (Object)null) { targetField.SetValue(ulvMonsterAI, nearestPlayer); } } PaintUlvBlack(ulvGo); yield return (object)new WaitForSeconds(0.3f); } if (Object.op_Implicit((Object)(object)bossTared)) { Object.Destroy((Object)(object)bossTared); } if (Object.op_Implicit((Object)(object)immunityComp)) { Object.Destroy((Object)(object)immunityComp); } if (isFirstWave && Object.op_Implicit((Object)(object)ai)) { ((Behaviour)ai).enabled = true; } _summonRunning = false; _nextSummonTime = Time.time + MainPlugin.CfgSummonInterval; } private IEnumerator DarkPulse() { ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { yield break; } Vector3 pos = ((Component)this).transform.position; GameObject fxPrefab = zns.GetPrefab("fx_Fader_CorpseExplosion"); if (Object.op_Implicit((Object)(object)fxPrefab)) { GameObject fx = Object.Instantiate(fxPrefab, pos, ((Component)this).transform.rotation); PaintFxBlack(fx); Object.Destroy((Object)(object)fx, 5f); } else { MainPlugin.Log.LogWarning((object)"[Blackblade] fx_Fader_CorpseExplosion no encontrado."); } yield return (object)new WaitForSeconds(0.4f); foreach (Player player in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)player)) { float dist = Vector3.Distance(pos, ((Component)player).transform.position); if (dist >= 10f && dist <= 30f) { ApplySlow(player, 10f); } } } } private IEnumerator SpinAttackFX() { ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { yield break; } Vector3 pos = ((Component)this).transform.position; GameObject spinPrefab = zns.GetPrefab("fx_fallenfalkyrie_spin"); if (Object.op_Implicit((Object)(object)spinPrefab)) { GameObject fx = Object.Instantiate(spinPrefab, pos, Quaternion.identity); fx.transform.localScale = Vector3.one * 2.5f; PaintFxBlack(fx); Object.Destroy((Object)(object)fx, 3f); } else { MainPlugin.Log.LogWarning((object)"[Blackblade] fx_fallenfalkyrie_spin no encontrado."); } yield return (object)new WaitForSeconds(0.35f); if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { yield break; } float dmg = GetMeleeDamage() * MainPlugin.CfgSpinDamagePct; foreach (Player player in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)player) && !(Vector3.Distance(pos, ((Component)player).transform.position) > 15f) && !IsDodging((Character)(object)player)) { DealDamage(player, dmg); ApplySlow(player, 10f); } } } private IEnumerator FlamebreathFX() { ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { yield break; } Vector3 bossPos = ((Component)this).transform.position; Vector3 bossForward = ((Component)this).transform.forward; Vector3 val = new Vector3(bossForward.x, 0f, bossForward.z); Vector3 bossForwardFlat = ((Vector3)(ref val)).normalized; float tickDmg = MainPlugin.CfgFireTickDmg; GameObject prefab = zns.GetPrefab("DvergerStaffFire_clusterbomb_aoe"); if (!Object.op_Implicit((Object)(object)prefab)) { MainPlugin.Log.LogWarning((object)"[Blackblade] DvergerStaffFire_clusterbomb_aoe no encontrado."); yield break; } Gradient darkRedGrad = new Gradient(); darkRedGrad.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(new Color(0.55f, 0f, 0f), 0f), new GradientColorKey(new Color(0.15f, 0f, 0f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) }); MinMaxGradient darkRedMinMax = new MinMaxGradient(darkRedGrad); HashSet keepNames = new HashSet { "low_flames", "flames (1)", "flames (2)" }; if (Object.op_Implicit((Object)(object)_ch)) { ((Component)_ch).gameObject.AddComponent(); } yield return (object)new WaitForSeconds(0.25f); if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { yield break; } float meleeDmg = GetMeleeDamage(); foreach (Player player in Player.GetAllPlayers()) { if (!Object.op_Implicit((Object)(object)player)) { continue; } Vector3 toFlat = new Vector3(((Component)player).transform.position.x - bossPos.x, 0f, ((Component)player).transform.position.z - bossPos.z); float along = Vector3.Dot(toFlat, bossForwardFlat); if (!(along < 0f) && !(along > 3f)) { val = toFlat - bossForwardFlat * along; if (!(((Vector3)(ref val)).magnitude > 1.5f) && !IsDodging((Character)(object)player)) { DealDamage(player, meleeDmg * MainPlugin.CfgFlameMeleePct, meleeDmg * MainPlugin.CfgFlameFirePct); } } } for (int i = 0; i < 8; i++) { float t = (float)i / 7f; Vector3 firePos = bossPos + bossForwardFlat * (2f + 10f * t); firePos.y = bossPos.y; GameObject inst = Object.Instantiate(prefab, firePos, Quaternion.identity); inst.transform.localScale = Vector3.one * 0.95f; Aoe[] componentsInChildren = inst.GetComponentsInChildren(true); foreach (Aoe aoe in componentsInChildren) { aoe.m_damage = default(DamageTypes); aoe.m_damage.m_fire = tickDmg; aoe.m_hitInterval = 1f; aoe.m_blockable = false; aoe.m_dodgeable = true; aoe.m_triggerEnterOnly = false; aoe.m_ttl = 0f; } SphereCollider sphere = inst.GetComponent(); if (Object.op_Implicit((Object)(object)sphere)) { sphere.radius = 1.8f; } ParticleSystem[] componentsInChildren2 = inst.GetComponentsInChildren(true); foreach (ParticleSystem ps in componentsInChildren2) { if (keepNames.Contains(((Object)ps).name)) { ParticleSystemRenderer psr2 = ((Component)ps).GetComponent(); if (Object.op_Implicit((Object)(object)psr2)) { Material mat = ((Renderer)psr2).material; if ((Object)(object)mat != (Object)null) { if (mat.HasProperty("_TintColor")) { mat.SetColor("_TintColor", new Color(0.8f, 0f, 0f, 1f)); } if (mat.HasProperty("_Color")) { mat.color = new Color(0.8f, 0f, 0f, 1f); } } } ColorOverLifetimeModule col = ps.colorOverLifetime; ((ColorOverLifetimeModule)(ref col)).enabled = true; ((ColorOverLifetimeModule)(ref col)).color = darkRedMinMax; ps.Stop(false, (ParticleSystemStopBehavior)0); ps.Play(false); col = default(ColorOverLifetimeModule); } else { ParticleSystemRenderer psr = ((Component)ps).GetComponent(); if (Object.op_Implicit((Object)(object)psr)) { ((Renderer)psr).enabled = false; } ps.Stop(false, (ParticleSystemStopBehavior)0); } } LightFlicker[] componentsInChildren3 = inst.GetComponentsInChildren(true); foreach (LightFlicker lf in componentsInChildren3) { Object.Destroy((Object)(object)lf); } LightLod[] componentsInChildren4 = inst.GetComponentsInChildren(true); foreach (LightLod ll in componentsInChildren4) { Object.Destroy((Object)(object)ll); } Light[] componentsInChildren5 = inst.GetComponentsInChildren(true); foreach (Light light in componentsInChildren5) { if (Object.op_Implicit((Object)(object)light)) { ((Behaviour)light).enabled = true; light.color = new Color(0.9f, 0.05f, 0f); light.intensity = 2f; light.range = 3f; } } Object.Destroy((Object)(object)inst, 5f); yield return (object)new WaitForSeconds(0.08f); if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { break; } } } private IEnumerator SlamCrossFX() { ZNetScene zns = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)zns)) { yield break; } yield return (object)new WaitForSeconds(0.15f); if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { yield break; } GameObject fxPrefab = zns.GetPrefab("fx_goblinbrute_groundslam"); if (!Object.op_Implicit((Object)(object)fxPrefab)) { MainPlugin.Log.LogWarning((object)"[Blackblade] fx_goblinbrute_groundslam no encontrado."); yield break; } Vector3 bossPos = ((Component)this).transform.position; float dmg = GetMeleeDamage() * MainPlugin.CfgSlamDamagePct; float stepSize = 2f; int steps = 5; float stepDelay = 0.12f; Vector3[] dirs = (Vector3[])(object)new Vector3[4] { ((Component)this).transform.forward, -((Component)this).transform.forward, ((Component)this).transform.right, -((Component)this).transform.right }; HashSet hitPlayers = new HashSet(); for (int step = 0; step < steps; step++) { yield return (object)new WaitForSeconds(stepDelay); if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { break; } float dist = (float)(step + 1) * stepSize; Vector3[] array = dirs; foreach (Vector3 dir in array) { Vector3 fxPos = bossPos + dir * dist; fxPos.y = bossPos.y; GameObject fx = Object.Instantiate(fxPrefab, fxPos, Quaternion.LookRotation(dir)); PaintFxBlack(fx); Object.Destroy((Object)(object)fx, 1.5f); foreach (Player player in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)player) && !hitPlayers.Contains(player) && !(Vector3.Distance(fxPos, ((Component)player).transform.position) > stepSize * 0.9f)) { hitPlayers.Add(player); bool wasBlocking = ((Character)player).IsBlocking(); DealDamage(player, dmg); if (!wasBlocking) { Vector3 val = ((Component)player).transform.position - bossPos; ForceStagger((Character)(object)player, ((Vector3)(ref val)).normalized); } } } } } } private IEnumerator GuardBreakFX() { yield return (object)new WaitForSeconds(0.35f); if (!Object.op_Implicit((Object)(object)_ch) || _ch.IsDead()) { yield break; } Vector3 pos = ((Component)this).transform.position; foreach (Player player in Player.GetAllPlayers()) { if (Object.op_Implicit((Object)(object)player) && !(Vector3.Distance(pos, ((Component)player).transform.position) > 4f) && !IsDodging((Character)(object)player)) { Vector3 val = ((Component)player).transform.position - pos; ForceStagger((Character)(object)player, ((Vector3)(ref val)).normalized); typeof(Character).GetField("m_blocking", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(player, false); } } } private void ApplySlow(Player player, float duration) { ObjectDB instance = ObjectDB.instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } StatusEffect val = instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("Tared")) ?? instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("Slowed")); if ((Object)(object)val != (Object)null) { StatusEffect val2 = Object.Instantiate(val); val2.m_ttl = duration; ((Character)player).GetSEMan().AddStatusEffect(val2, false, 0, 0f); return; } BlackbladeSlowed component = ((Component)player).gameObject.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { ((Component)player).gameObject.AddComponent().Init(duration, 0.45f); } MainPlugin.Log.LogWarning((object)"[Blackblade] SE de slow no encontrado, usando fallback de velocidad."); } private void DealDamage(Player player, float slash = 0f, float fire = 0f, float blunt = 0f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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) HitData val = new HitData(); val.m_damage.m_slash = slash; val.m_damage.m_fire = fire; val.m_damage.m_blunt = blunt; val.m_point = ((Component)player).transform.position; Vector3 val2 = ((Component)player).transform.position - ((Component)this).transform.position; val.m_dir = ((Vector3)(ref val2)).normalized; ZNetView component = ((Component)_ch).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { val.m_attacker = component.GetZDO().m_uid; } ((Character)player).Damage(val); } private static void ForceStagger(Character target, Vector3 dir) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (_staggerMethod != null) { _staggerMethod.Invoke(target, new object[1] { dir }); } else { MainPlugin.Log.LogWarning((object)"[Blackblade] Método Stagger no encontrado vía reflexión."); } } private float GetMeleeDamage() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) Humanoid hu = _hu; ItemData val = ((hu != null) ? hu.GetCurrentWeapon() : null); if (val == null) { return 80f; } DamageTypes damage = val.GetDamage(); return damage.m_slash + damage.m_blunt + damage.m_pierce; } public static void PaintFxBlack(GameObject root) { //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_021e: 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_023e: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)root)) { return; } Color val = default(Color); ((Color)(ref val))..ctor(0.03f, 0.03f, 0.03f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.08f, 0.08f, 0.08f, 1f); Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val3 in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val3)) { continue; } Material[] materials = val3.materials; foreach (Material val4 in materials) { if (Object.op_Implicit((Object)(object)val4)) { if (val4.HasProperty("_Color")) { val4.color = val; } if (val4.HasProperty("_BaseColor")) { val4.SetColor("_BaseColor", val); } if (val4.HasProperty("_TintColor")) { val4.SetColor("_TintColor", val); } if (val4.HasProperty("_MainColor")) { val4.SetColor("_MainColor", val); } if (val4.HasProperty("_EmissionColor")) { val4.SetColor("_EmissionColor", val2); } } } val3.materials = materials; } ParticleSystem[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (ParticleSystem val5 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val5)) { MainModule main = val5.main; ((MainModule)(ref main)).startColor = new MinMaxGradient(val); } } Projector[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (Projector val6 in componentsInChildren3) { if (Object.op_Implicit((Object)(object)val6) && Object.op_Implicit((Object)(object)val6.material)) { Material material = val6.material; if (material.HasProperty("_Color")) { material.color = val; } if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", val); } if (material.HasProperty("_TintColor")) { material.SetColor("_TintColor", val); } if (material.HasProperty("_EmissionColor")) { material.SetColor("_EmissionColor", val2); } } } Light[] componentsInChildren4 = root.GetComponentsInChildren(true); foreach (Light val7 in componentsInChildren4) { if (Object.op_Implicit((Object)(object)val7)) { val7.color = new Color(0.05f, 0.05f, 0.05f); val7.intensity *= 0.1f; } } } private static void PaintUlvBlack(GameObject root) { //IL_00bd: 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_00fd: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)root)) { return; } Color val = default(Color); ((Color)(ref val))..ctor(0.05f, 0.05f, 0.05f); Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val2) || (((Object)val2).name ?? "").ToLowerInvariant().Contains("eye")) { continue; } Material[] materials = val2.materials; foreach (Material val3 in materials) { if (Object.op_Implicit((Object)(object)val3)) { if (val3.HasProperty("_Color")) { val3.color = val; } if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", val); } if (val3.HasProperty("_EmissionColor")) { val3.SetColor("_EmissionColor", Color.black); } } } val2.materials = materials; } } } public class BlackbladeBossImmunity : MonoBehaviour { } public class BlackbladePassive : MonoBehaviour { } public class BlackbladeSummonedUlv : MonoBehaviour { } public class BlackbladeSlowed : MonoBehaviour { private float _duration; private float _factor; private Character _ch; private float _origWalk; private float _origRun; public void Init(float duration, float factor) { _duration = duration; _factor = factor; _ch = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)_ch)) { _origWalk = _ch.m_walkSpeed; _origRun = _ch.m_runSpeed; _ch.m_walkSpeed = _origWalk * _factor; _ch.m_runSpeed = _origRun * _factor; } ((MonoBehaviour)this).StartCoroutine(RemoveSlow()); } private IEnumerator RemoveSlow() { yield return (object)new WaitForSeconds(_duration); if (Object.op_Implicit((Object)(object)_ch)) { _ch.m_walkSpeed = _origWalk; _ch.m_runSpeed = _origRun; } Object.Destroy((Object)(object)this); } } public class BlackbladeFireImmunity : MonoBehaviour { private void Start() { ((MonoBehaviour)this).StartCoroutine(Remove()); } private IEnumerator Remove() { yield return (object)new WaitForSeconds(7f); Object.Destroy((Object)(object)this); } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchBlockAllDamageOnImmune { private static bool Prefix(Character __instance) { if ((Object)(object)((Component)__instance).GetComponent() != (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchBlockBossFireImmunity { private static bool Prefix(Character __instance, HitData hit) { if (!(hit.m_damage.m_fire > 0f) || hit.m_damage.m_slash != 0f || hit.m_damage.m_blunt != 0f || hit.m_damage.m_pierce != 0f) { return true; } if ((Object)(object)((Component)__instance).GetComponent() != (Object)null) { return false; } if ((Object)(object)((Component)__instance).GetComponent() != (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[] { typeof(Character), typeof(Character) })] internal static class PatchBlackbladeIsEnemy { private static void Postfix(Character a, Character b, ref bool __result) { if (__result) { bool flag = (Object)(object)a != (Object)null && ((Object)((Component)a).gameObject).name.StartsWith("Boss_Skeleton_Blackblade"); bool flag2 = (Object)(object)b != (Object)null && ((Object)((Component)b).gameObject).name.StartsWith("Boss_Skeleton_Blackblade"); bool flag3 = (Object)(object)a != (Object)null && (Object)(object)((Component)a).GetComponent() != (Object)null; bool flag4 = (Object)(object)b != (Object)null && (Object)(object)((Component)b).GetComponent() != (Object)null; bool flag5 = (Object)(object)a != (Object)null && (Object)(object)((Component)a).GetComponent() != (Object)null; bool flag6 = (Object)(object)b != (Object)null && (Object)(object)((Component)b).GetComponent() != (Object)null; if (flag3 || flag4) { __result = false; } else if (flag && !(b is Player)) { __result = false; } else if (flag2 && !(a is Player)) { __result = false; } else if (flag5 && !(b is Player)) { __result = false; } else if (flag6 && !(a is Player)) { __result = false; } } } } [HarmonyPatch(typeof(Character), "IsTamed", new Type[] { })] internal static class PatchBlackbladeIsTamed { private static void Postfix(Character __instance, ref bool __result) { if (((Object)((Component)__instance).gameObject).name.StartsWith("Boss_Skeleton_Blackblade_Passive") || (Object)(object)((Component)__instance).GetComponent() != (Object)null) { __result = true; } } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchBlackbladeDamageMultiplier { private static void Prefix(Character __instance, HitData hit) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!(__instance is Player) || hit == null) { return; } float cfgMeleeDmgMult = MainPlugin.CfgMeleeDmgMult; if (!Mathf.Approximately(cfgMeleeDmgMult, 1f)) { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.FindInstance(hit.m_attacker) : null); if (Object.op_Implicit((Object)(object)val) && !((Object)(object)val.GetComponent() == (Object)null)) { hit.m_damage.m_slash *= cfgMeleeDmgMult; hit.m_damage.m_blunt *= cfgMeleeDmgMult; hit.m_damage.m_pierce *= cfgMeleeDmgMult; } } } } [HarmonyPatch(typeof(Character), "Damage")] internal static class PatchBlackbladeNoPushback { private static void Prefix(Character __instance, HitData hit) { if ((Object)(object)((Component)__instance).GetComponent() != (Object)null && (Object)(object)((Component)__instance).GetComponent() == (Object)null) { hit.m_pushForce = 0f; } } } [HarmonyPatch(typeof(Character), "SetLevel")] internal static class PatchBlackbladeNoStars { private static bool Prefix(Character __instance, int level) { if (level > 1 && (Object)(object)((Component)__instance).GetComponent() != (Object)null) { return false; } return true; } } public class BlackbladeInteraction : MonoBehaviour, Hoverable, Interactable { public MainPlugin Plugin; public GameObject CharacterGo; private bool _triggered = false; public string GetHoverName() { return "Blackblade, Herald of Ash"; } public string GetHoverText() { if (_triggered) { return ""; } return "[E] Despertar"; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || _triggered) { return false; } _triggered = true; ((MonoBehaviour)Plugin).StartCoroutine(Plugin.TransformToAggressive(CharacterGo)); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } } }