Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BomDeMurro v1.0.8
BomDeMurro.dll
Decompiled an hour agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace BomDeMurro; [BepInPlugin("yuri.BomDeMurro", "Bom de Murro", "1.0.8")] public class Plugin : BaseUnityPlugin { public static ConfigEntry<bool> Ligado; public static ConfigEntry<float> Janela; public static ConfigEntry<float> Dano; public static ConfigEntry<float> Folego; private static Plugin eu; private static bool guardado; private static float velBase; private static float giroBase; private static float danoBase; private static float forcaBase; private static float tomboBase; private static float folegoBase; private static float alcanceBase; private static float arcoBase; private static int cadeiaBase; private static int sorteioBase; private static string animBase; private static int ultimo = -1; private static float ultima; private static int pendente; private static string animUsada; private static readonly string[][] AnimGolpe = new string[6][] { new string[1] { "unarmed_attack0" }, new string[2] { "unarmed_attack1", "knife_stab0" }, new string[3] { "swing_longsword1", "swing_longsword2", "swing_longsword0" }, new string[2] { "mace_secondary", "swing_sledge0" }, new string[1] { "unarmed_kick" }, new string[1] { "unarmed_kick" } }; private static float giroComeca; private static float giroDuracao; private static float ociosoDesde = -1f; private static readonly string[] NomeGolpe = new string[6] { "Leve", "Direto", "Cruzado", "Foguete", "Chute", "Chute giratorio" }; private static readonly float[] Vel = new float[6] { 1.5f, 1.2f, 1.05f, 0.82f, 1.1f, 0.9f }; private static readonly float[] DanoPasso = new float[6] { 1.1f, 1.3f, 1.45f, 1.85f, 1.5f, 1.75f }; private static readonly float[] Forca = new float[6] { 0.6f, 1f, 1.25f, 1.7f, 1.35f, 1.9f }; private static readonly float[] Tombo = new float[6] { 0.7f, 1f, 1.35f, 1.65f, 1.3f, 2f }; private static readonly float[] Custo = new float[6] { 0.55f, 0.75f, 0.95f, 1.2f, 0.9f, 1.25f }; private static readonly float[] Alcance = new float[6] { 1f, 1.05f, 1.1f, 1.12f, 1.2f, 1.3f }; private static readonly float[] Arco = new float[6] { 0.8f, 1f, 1.35f, 1.1f, 1.2f, 2.4f }; private static readonly string[] GatilhosSoco = new string[10] { "unarmed_attack", "unarmed_attack0", "unarmed_attack1", "unarmed_attack2", "swing_longsword0", "swing_longsword1", "swing_longsword2", "mace_secondary", "swing_sledge0", "knife_stab0" }; private void Awake() { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_014a: 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_0172: Expected O, but got Unknown //IL_0172: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown eu = this; Ligado = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Ligado", true, "Liga o combo desarmado so neste jogo. O servidor nao precisa do mod. Com arma na mao, nada muda. O personagem nao anda sozinho."); Janela = ((BaseUnityPlugin)this).Config.Bind<float>("Combo", "Janela", 0.22f, "Segundos de folga depois que o golpe acaba. Passou disso, o proximo clique volta no jab. Nao guarda o especial numa pausa."); Dano = ((BaseUnityPlugin)this).Config.Bind<float>("Combo", "Dano", 1f, "Multiplica o dano do combo. 1 e o padrao."); Folego = ((BaseUnityPlugin)this).Config.Bind<float>("Combo", "Folego", 1f, "Multiplica o gasto de folego. Menor gasta menos."); Type[] array = new Type[9] { typeof(Humanoid), typeof(Rigidbody), typeof(ZSyncAnimation), typeof(CharacterAnimEvent), typeof(VisEquipment), typeof(ItemData), typeof(Attack), typeof(float), typeof(float) }; Harmony val = new Harmony("yuri.BomDeMurro"); val.Patch((MethodBase)AccessTools.Method(typeof(Attack), "Start", array, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("Antes", BindingFlags.Static | BindingFlags.NonPublic)), new HarmonyMethod(typeof(Plugin).GetMethod("Depois", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Character), "RPC_Damage", new Type[2] { typeof(long), typeof(HitData) }, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("DanoReal", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void DanoReal(Character __instance, HitData hit) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 if (hit == null || (Object)(object)__instance == (Object)null || !__instance.IsPlayer() || (int)hit.m_skill != 11) { return; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null || !attacker.IsPlayer() || (Object)(object)attacker == (Object)(object)__instance) { return; } float totalDamage = hit.GetTotalDamage(); if (totalDamage < 0.05f) { return; } float bodyArmor = __instance.GetBodyArmor(); if (!(bodyArmor <= 0f)) { float num = (float)Math.Sqrt(totalDamage * bodyArmor * 4f); if (bodyArmor < num * 0.5f) { num = totalDamage + bodyArmor; } if (!(num <= totalDamage)) { ((DamageTypes)(ref hit.m_damage)).Modify(num / totalDamage); } } } private void LateUpdate() { MarcarPausa(); VarrerPerna(); } private static void Antes(Attack __instance, Humanoid character, ZSyncAnimation zanim, ItemData weapon) { //IL_005b: 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_0069: Invalid comparison between Unknown and I4 pendente = -1; animUsada = null; if (Ligado == null || !Ligado.Value) { return; } Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val == (Object)null || (Object)(object)Player.m_localPlayer != (Object)(object)val || ((int)__instance.m_attackType != 0 && (int)__instance.m_attackType != 1)) { return; } ItemData val2 = weapon; if (val2 == null) { val2 = ((Humanoid)val).GetCurrentWeapon(); } if (!EhPunho(val, val2)) { return; } Guardar(__instance); int golpe = Proximo(); if (((Character)val).HaveStamina(CustoDo(golpe))) { string text = Escolher(zanim, golpe); if (text != null) { __instance.m_attackAnimation = text; __instance.m_attackChainLevels = 1; __instance.m_attackRandomAnimations = 0; animUsada = text; } Aplicar(__instance, val, golpe); pendente = golpe; } } private static void Depois(Attack __instance, ZSyncAnimation zanim, bool __result) { if (pendente < 0) { return; } if (!__result) { Restaurar(__instance); pendente = -1; return; } ultimo = pendente; ultima = Time.time; ociosoDesde = -1f; if (pendente == 5 && animUsada == "unarmed_kick") { giroDuracao = 0.72f; giroComeca = Time.time; CalarSoco(zanim); } if ((Object)(object)eu != (Object)null) { ((BaseUnityPlugin)eu).Logger.LogInfo((object)("Golpe " + NomeGolpe[pendente] + " " + ((animUsada == null) ? "soco do jogo" : animUsada))); } pendente = -1; } private static void CalarSoco(ZSyncAnimation zanim) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Animator componentInChildren = ((Component)localPlayer).GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren == (Object)null) { return; } for (int i = 0; i < GatilhosSoco.Length; i++) { if ((Object)(object)zanim != (Object)null && zanim.HasParameter(GatilhosSoco[i], (AnimatorControllerParameterType)9)) { componentInChildren.ResetTrigger(GatilhosSoco[i]); } } if ((Object)(object)zanim != (Object)null) { zanim.SetTrigger("unarmed_kick"); } int num = Animator.StringToHash("unarmed_kick"); if (componentInChildren.HasState(0, num)) { componentInChildren.CrossFadeInFixedTime(num, 0.05f, 0, 0f); } } private static void VarrerPerna() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) if (giroDuracao <= 0f) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { giroDuracao = 0f; return; } float num = (Time.time - giroComeca) / giroDuracao; if (num >= 1f) { giroDuracao = 0f; } else { if (num < 0f) { return; } Animator componentInChildren = ((Component)localPlayer).GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren == (Object)null) { return; } Transform boneTransform = componentInChildren.GetBoneTransform((HumanBodyBones)2); if (!((Object)(object)boneTransform == (Object)null)) { float num2 = num * num * (3f - 2f * num); float num3 = Mathf.Lerp(-70f, 200f, num2); float num4 = Mathf.Sin(num * 3.14159f) * 48f; boneTransform.rotation = Quaternion.AngleAxis(num3, Vector3.up) * Quaternion.AngleAxis(0f - num4, ((Component)localPlayer).transform.right) * boneTransform.rotation; Transform boneTransform2 = componentInChildren.GetBoneTransform((HumanBodyBones)4); if ((Object)(object)boneTransform2 != (Object)null) { float num5 = Mathf.Lerp(75f, 6f, num2); boneTransform2.rotation = Quaternion.AngleAxis(0f - num5, boneTransform2.right) * boneTransform2.rotation; } } } } private static string Escolher(ZSyncAnimation zanim, int golpe) { if ((Object)(object)zanim == (Object)null || golpe < 0 || golpe >= AnimGolpe.Length) { return null; } string[] array = AnimGolpe[golpe]; for (int i = 0; i < array.Length; i++) { if (zanim.HasParameter(array[i], (AnimatorControllerParameterType)9)) { return array[i]; } } return null; } private static bool EhPunho(Player jogador, ItemData arma) { if ((Object)(object)((Humanoid)jogador).m_unarmedWeapon == (Object)null || ((Humanoid)jogador).m_unarmedWeapon.m_itemData == null) { return false; } if (arma == null || arma.m_shared == null) { return false; } ItemData itemData = ((Humanoid)jogador).m_unarmedWeapon.m_itemData; if (arma == itemData) { return true; } if (itemData.m_shared == null) { return false; } if (arma.m_shared == itemData.m_shared) { return true; } return arma.m_shared.m_name == itemData.m_shared.m_name; } private static int Proximo() { if (ultimo < 0) { return 0; } if (ociosoDesde < 0f) { return (ultimo + 1) % 6; } if (Time.time - ociosoDesde <= Folga()) { return (ultimo + 1) % 6; } return 0; } private static float Folga() { float num = Janela.Value; if (num > 0.45f) { num = 0.22f; } if (num < 0.08f) { num = 0.08f; } return num; } private static void MarcarPausa() { if (ultimo < 0) { ociosoDesde = -1f; return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && EmGolpe(localPlayer)) { ociosoDesde = -1f; } else if (ociosoDesde < 0f) { ociosoDesde = Time.time; } } private static bool EmGolpe(Player jogador) { //IL_003e: 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) if (Time.time - ultima < DuracaoDo(ultimo)) { return true; } Animator componentInChildren = ((Component)jogador).GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren == (Object)null) { return false; } if (TemTagAtaque(componentInChildren.GetCurrentAnimatorStateInfo(0))) { return true; } if (componentInChildren.IsInTransition(0) && TemTagAtaque(componentInChildren.GetNextAnimatorStateInfo(0))) { return true; } return false; } private static bool TemTagAtaque(AnimatorStateInfo info) { return ((AnimatorStateInfo)(ref info)).IsTag("attack"); } private static float DuracaoDo(int golpe) { float num = 1f; if (golpe >= 0 && golpe < Vel.Length) { num = Vel[golpe]; } if (num < 0.2f) { num = 0.2f; } return 0.72f / num; } private static float CustoDo(int golpe) { float num = Folego.Value; if (num < 0f) { num = 0f; } return folegoBase * Custo[golpe] * num; } private static void Guardar(Attack ataque) { if (!guardado) { velBase = ataque.m_speedFactor; if (velBase < 0.05f) { velBase = 1f; } giroBase = ataque.m_speedFactorRotation; if (giroBase < 0.05f) { giroBase = 1f; } danoBase = ataque.m_damageMultiplier; if (danoBase < 1f) { danoBase = 1f; } forcaBase = ataque.m_forceMultiplier; if (forcaBase < 0.05f) { forcaBase = 1f; } tomboBase = ataque.m_staggerMultiplier; if (tomboBase < 0.05f) { tomboBase = 1f; } folegoBase = ataque.m_attackStamina; alcanceBase = ataque.m_attackRange; arcoBase = ataque.m_attackAngle; cadeiaBase = ataque.m_attackChainLevels; sorteioBase = ataque.m_attackRandomAnimations; animBase = ataque.m_attackAnimation; if (string.IsNullOrEmpty(animBase)) { animBase = "unarmed_attack"; } guardado = true; } } private static void Aplicar(Attack ataque, Player jogador, int golpe) { float num = ((Character)jogador).GetSkillLevel((SkillType)11) / 100f; if (num < 0f) { num = 0f; } if (num > 1f) { num = 1f; } float num2 = Dano.Value; if (num2 < 0f) { num2 = 0f; } ataque.m_speedFactor = velBase * Vel[golpe] * (1f + num * 0.1f); ataque.m_speedFactorRotation = giroBase; ataque.m_damageMultiplier = danoBase * DanoPasso[golpe] * (1f + num * 0.45f) * num2; ataque.m_forceMultiplier = forcaBase * Forca[golpe] * (1f + num * 0.15f); ataque.m_staggerMultiplier = tomboBase * Tombo[golpe]; ataque.m_attackStamina = CustoDo(golpe); if (alcanceBase > 0.2f) { ataque.m_attackRange = alcanceBase * Alcance[golpe]; } if (arcoBase > 1f) { ataque.m_attackAngle = arcoBase * Arco[golpe]; } } private static void Restaurar(Attack ataque) { if (guardado) { ataque.m_attackAnimation = animBase; ataque.m_speedFactor = velBase; ataque.m_speedFactorRotation = giroBase; ataque.m_damageMultiplier = danoBase; ataque.m_forceMultiplier = forcaBase; ataque.m_staggerMultiplier = tomboBase; ataque.m_attackStamina = folegoBase; ataque.m_attackRange = alcanceBase; ataque.m_attackAngle = arcoBase; ataque.m_attackChainLevels = cadeiaBase; ataque.m_attackRandomAnimations = sorteioBase; } } }