Example #1
0
        public static bool Prefix(Weapon __instance, RaycastHit _hit, Vector3 _dir)
        {
            Hitbox hitbox            = _hit.collider.GetComponent <Hitbox>();
            var    owner             = __instance.OwnerCharacter;
            var    target            = hitbox.OwnerChar;
            var    m_alreadyHitChars = At.GetValue(typeof(Weapon), __instance, "m_alreadyHitChars") as List <Character>;

            if (!m_alreadyHitChars.Contains(target) && HookUtil.IsElligable(__instance, owner, target))
            {
                bool  blocked = false;
                float num     = Vector3.Angle(hitbox.OwnerChar.transform.forward, owner.transform.position - hitbox.OwnerChar.transform.position);

                if (!__instance.Unblockable && hitbox.OwnerChar.Blocking && num < (float)(hitbox.OwnerChar.ShieldEquipped ? Weapon.SHIELD_BLOCK_ANGLE : Weapon.BLOCK_ANGLE))
                {
                    blocked = true;
                }
                if (!blocked)
                {
                    var getID = At.GetValue(typeof(Weapon), __instance, "m_attackID");
                    if (getID is int attackID && attackID >= 0)
                    {
                        DamageList damages = __instance.GetDamage(attackID).Clone();

                        target.Stats.GetMitigatedDamage(null, ref damages);

                        DamageLabels.AddDamageLabel(damages, _hit.point, target);
                    }
                }
            }

            return(true);
        }
Example #2
0
        public static bool Prefix(Weapon __instance, RaycastHit _hit, Vector3 _dir)
        {
            Hitbox hitbox = _hit.collider?.GetComponent <Hitbox>();

            if (!hitbox)
            {
                return(true);
            }

            var owner  = __instance.OwnerCharacter;
            var target = hitbox.OwnerChar;

            if (!target || !owner)
            {
                return(true);
            }

            var m_alreadyHitChars = (List <Character>)At.GetField(__instance, "m_alreadyHitChars");

            if (!m_alreadyHitChars.Contains(target) && HookUtil.IsElligable(__instance, owner, target))
            {
                bool  blocked = false;
                float num     = Vector3.Angle(hitbox.OwnerChar.transform.forward, owner.transform.position - hitbox.OwnerChar.transform.position);

                if (!__instance.Unblockable && hitbox.OwnerChar.Blocking && num < (float)(hitbox.OwnerChar.ShieldEquipped ? Weapon.SHIELD_BLOCK_ANGLE : Weapon.BLOCK_ANGLE))
                {
                    blocked = true;
                }
                if (!blocked)
                {
                    var attackID = (int)At.GetField(__instance, "m_attackID");
                    if (attackID >= 0)
                    {
                        DamageList damages = __instance.GetDamage(attackID).Clone();

                        //target.Stats.GetMitigatedDamage(null, ref damages, false);
                        At.Invoke(target, "ProcessDamageReduction", new object[] { __instance, damages, false });

                        DamageLabels.AddDamageLabel(damages, _hit.point, target);
                    }
                }
            }

            return(true);
        }