Ejemplo n.º 1
0
        private IEnumerator StopBlockingCoroutine(Character character)
        {
            yield return(new WaitForSeconds(0.05f)); // 50ms wait (1 or 2 frames)

            At.Invoke(character, "StopBlocking");
            At.SetField(character, "m_blockDesired", false);
        }
Ejemplo n.º 2
0
        private void SendDodge(Character self, float staminaCost, Vector3 _direction)
        {
            float f = (float)At.GetField(self.Stats, "m_stamina");

            if (f >= staminaCost)
            {
                //At.SetValue(f - staminaCost, typeof(CharacterStats), self.Stats, "m_stamina");
                self.Stats.UseStamina(TagSourceManager.Dodge, staminaCost);

                At.SetField(self, "m_dodgeAllowedInAction", 0);

                if (self.CharacterCamera && self.CharacterCamera.InZoomMode)
                {
                    self.SetZoomMode(false);
                }

                self.ForceCancel(false, true);
                self.ResetCastType();

                self.photonView.RPC("SendDodgeTriggerTrivial", PhotonTargets.All, new object[] { _direction });

                At.Invoke(self, "ActionPerformed", false);

                self.Invoke("ResetDodgeTrigger", 0.5f);
            }
        }
Ejemplo n.º 3
0
            public static bool Prefix(Character __instance, int _type, int _id = 0)
            {
                var self = __instance;

                if (self.IsLocalPlayer && (bool)CombatOverhaul.config.GetValue(Settings.Attack_Cancels_Blocking) && !self.IsAI && self.Blocking)
                {
                    Instance.StartCoroutine(Instance.StopBlockingCoroutine(self));
                    At.Invoke(self, "StopBlocking");
                    At.SetField(self, "m_blockDesired", false);
                }


                return(true);
            }
Ejemplo n.º 4
0
            public static bool Prefix(Character __instance, int _type, int _id = 0)
            {
                var self = __instance;

                if (self.IsLocalPlayer && CombatTweaksMod.Blocking_CancelledByAttack.Value && !self.IsAI && self.Blocking)
                {
                    CombatTweaksMod.Instance.StartCoroutine(StopBlockingCoroutine(self));
                    At.Invoke(self, "StopBlocking");
                    At.SetField(self, "m_blockDesired", false);
                }


                return(true);
            }
Ejemplo n.º 5
0
            public static bool Prefix(Character __instance, Vector3 _direction)
            {
                var self = __instance;

                if (!(bool)CombatOverhaul.config.GetValue(Settings.Custom_Bag_Burden))
                {
                    return(true);
                }

                if (self.CurrentWeapon)
                {
                    if (self.HasDodgeDirection)
                    {
                        self.Animator.SetFloat("DodgeBlend", !self.DodgeRestricted ? 0.0f : Instance.GetDodgeRestriction(self));
                    }
                }

                self.Animator.SetTrigger("Dodge");

                if (self.CurrentlyChargingAttack)
                {
                    //self.SendCancelCharging();
                    At.Invoke(self, "SendCancelCharging");
                }

                // get sound player with null coalescing operator
                (At.GetField(self, "m_dodgeSoundPlayer") as SoundPlayer)?.Play(false);

                //self.m_dodging = true;
                At.SetField(self, "m_dodging", true);

                //self.StopBlocking();
                At.Invoke(self, "StopBlocking");

                // null coalescing OnDodgeEvent invoke
                self.OnDodgeEvent?.Invoke();

                if (At.GetField(self, "m_characterSoundManager") is CharacterSoundManager charSounds)
                {
                    Global.AudioManager.PlaySoundAtPosition(charSounds.GetDodgeSound(), self.transform, 0f, 1f, 1f, 1f, 1f);
                }

                self.SendMessage("DodgeTrigger", _direction, SendMessageOptions.DontRequireReceiver);


                return(false);
            }
Ejemplo n.º 6
0
            public static bool Prefix(Character __instance, bool _down, Vector3 _dir)
            {
                var self = __instance;

                var _base = self as Photon.MonoBehaviour;

                if (At.GetField(self, "m_stability") is float m_stability)
                {
                    float staggerVal = Mathf.Clamp(m_stability - (float)CombatOverhaul.config.GetValue(Settings.Stagger_Threshold),
                                                   1f,
                                                   100 - (float)CombatOverhaul.config.GetValue(Settings.Stagger_Threshold));

                    At.Invoke(self, "StabilityHit", new object[]
                    {
                        (!_down) ? staggerVal : m_stability,
                        Vector3.Angle(_base.transform.forward, -_dir),
                        _down,
                        null
                    });
                }

                return(false);
            }
Ejemplo n.º 7
0
            public static void Postfix(Character __instance, Vector3 _direction, bool ___m_pendingDeath, ref int ___m_dodgeAllowedInAction)
            {
                if (!CombatTweaksMod.Dodge_Cancelling.Value)
                {
                    return;
                }

                if (!__instance.IsPhotonPlayerLocal || __instance.IsAI || __instance.Dodging)
                {
                    return;
                }

                if (___m_pendingDeath)
                {
                    return;
                }

                // check player has enough stamina
                if (!(bool)At.Invoke(__instance, "HasEnoughStamina", (float)__instance.DodgeStamCost))
                {
                    return;
                }

                if (PlayerLastHitTimes.ContainsKey(__instance.UID) &&
                    Time.time - PlayerLastHitTimes[__instance.UID] < CombatTweaksMod.Dodge_DelayAfterPlayerHits.Value)
                {
                    //  Debug.Log("Player has hit within the last few seconds. Dodge not allowed!");
                    return;
                }

                Character.HurtType hurtType = (Character.HurtType)At.GetField(__instance, "m_hurtType");

                // manual fix (game sometimes does not reset HurtType to NONE when animation ends.
                float timeout;

                if (hurtType == Character.HurtType.Knockdown)
                {
                    timeout = CombatTweaksMod.Dodge_DelayAfterKnockdown.Value;
                }
                else
                {
                    timeout = CombatTweaksMod.Dodge_DelayAfterStagger.Value;
                }

                if ((float)At.GetField(__instance, "m_timeOfLastStabilityHit") is float lasthit &&
                    Time.time - lasthit > timeout)
                {
                    hurtType = Character.HurtType.NONE;
                    At.SetField(__instance, "m_hurtType", hurtType);
                }

                // if we're not currently staggered, force an animation cancel dodge (provided we have enough stamina).
                if (hurtType == Character.HurtType.NONE)
                {
                    //SendDodge(__instance, __instance.DodgeStamCost, _direction);

                    __instance.Stats.UseStamina(TagSourceManager.Dodge, __instance.DodgeStamCost);

                    ___m_dodgeAllowedInAction = 0;

                    if (__instance.CharacterCamera && __instance.CharacterCamera.InZoomMode)
                    {
                        __instance.SetZoomMode(false);
                    }

                    __instance.ForceCancel(false, true);
                    __instance.ResetCastType();

                    __instance.photonView.RPC("SendDodgeTriggerTrivial", PhotonTargets.All, new object[]
                    {
                        _direction
                    });

                    At.Invoke(__instance, "ActionPerformed", true);


                    __instance.Invoke("ResetDodgeTrigger", 0.5f);
                }

                // send a fix to force m_dodging to false after a short delay.
                // this is a fix for if the player dodges while airborne, the game wont reset their m_dodging to true when they land.
                CombatTweaksMod.Instance.StartCoroutine(DodgeLateFix(__instance));
            }
Ejemplo n.º 8
0
            public static bool Prefix(Character __instance, float _knockValue, float _angle, bool _block, Character _dealerChar)
            {
                var self  = __instance;
                var _base = self as Photon.MonoBehaviour;

                if (At.GetField(self, "m_impactImmune") is bool m_impactImmune &&
                    At.GetField(self, "m_shieldStability") is float m_shieldStability &&
                    At.GetField(self, "m_stability") is float m_stability &&
                    At.GetField(self, "m_knockbackCount") is float m_knockbackCount &&
                    At.GetField(self, "m_knockHurtAllowed") is bool m_knockHurtAllowed &&
                    At.GetField(self, "m_currentlyChargingAttack") is bool m_currentlyChargingAttack &&
                    At.GetField(self, "m_animator") is Animator m_animator)
                {
                    // Begin actual stability hit function
                    var hit = _knockValue;
                    if (hit < 0)
                    {
                        hit = 0;
                    }

                    if (!m_impactImmune && hit > 0f)
                    {
                        //Debug.Log("--------- " + self.Name + " ---------");

                        // check stagger immunity dictionary (custom)
                        float lastStagger = -1;
                        if (Instance.LastStaggerTimes.ContainsKey(self.UID))
                        {
                            lastStagger = Instance.LastStaggerTimes[self.UID];
                        }

                        // if you run out of stamina and get hit, you will always get staggered. (unchanged, except to reflect custom stagger threshold)
                        if (self.Stats.CurrentStamina < 1f)
                        {
                            float hitToStagger = m_shieldStability + m_stability - (100 - (float)CombatOverhaul.config.GetValue(Settings.Stagger_Threshold));
                            if (hit < hitToStagger)
                            {
                                hit = hitToStagger;
                            }
                            //Debug.LogError("Stamina autostagger called! hitToStagger: " + hitToStagger + ", hit: " + hit);
                        }

                        At.SetField(self, "m_timeOfLastStabilityHit", Time.time);
                        // Debug.Log("Set " + Time.time + " as character's last stability hit");

                        if (self.CharacterCamera != null && hit > 0f)
                        {
                            self.CharacterCamera.Hit(hit * 6f);
                        }

                        // check shield stability if blocking (unchanged)
                        if (_block && m_shieldStability > 0f)
                        {
                            if (hit > m_shieldStability)
                            {
                                var num2 = m_stability - (hit - m_shieldStability);
                                At.SetField(self, "m_stability", num2);
                                m_stability = num2;
                            }
                            var num3 = Mathf.Clamp(m_shieldStability - hit, 0f, 50f);
                            At.SetField(self, "m_shieldStability", num3);
                            m_shieldStability = num3;
                        }
                        // check non-blocking stability (unchanged)
                        else
                        {
                            var num2 = Mathf.Clamp(m_stability - hit, 0f, 100f);
                            At.SetField(self, "m_stability", num2);
                            m_stability = num2;
                        }
                        // if hit takes us below knockdown threshold, or if AI auto-knockdown stagger count was reached...
                        if (m_stability <= (float)CombatOverhaul.config.GetValue(Settings.Knockdown_Threshold) ||
                            (self.IsAI && m_knockbackCount >= (float)CombatOverhaul.config.GetValue(Settings.Enemy_AutoKD_Count)))
                        {
                            //Debug.LogError("Knockdown! Hit Value: " + _knockValue + ", current stability: " + m_stability);

                            if ((!self.IsAI && _base.photonView.isMine) || (self.IsAI && (_dealerChar == null || _dealerChar.photonView.isMine)))
                            {
                                _base.photonView.RPC("SendKnock", PhotonTargets.All, new object[]
                                {
                                    true,
                                    m_stability
                                });
                            }
                            else
                            {
                                At.Invoke(self, "Knock", true);
                            }
                            At.SetField(self, "m_stability", 0f);
                            m_stability = 0f;
                            if (self.IsPhotonPlayerLocal)
                            {
                                self.BlockInput(false);
                            }
                        }
                        // else if hit is a stagger...
                        else if (m_stability <= (float)CombatOverhaul.config.GetValue(Settings.Stagger_Threshold) && (Time.time - lastStagger > (float)CombatOverhaul.config.GetValue(Settings.Stagger_Immunity_Period)))
                        {
                            // Debug.LogWarning("Stagger! Hit Value: " + _knockValue + ", current stability: " + m_stability);

                            // update Stagger Immunity dictionary
                            if (!Instance.LastStaggerTimes.ContainsKey(self.UID))
                            {
                                Instance.LastStaggerTimes.Add(self.UID, Time.time);
                            }
                            else
                            {
                                Instance.LastStaggerTimes[self.UID] = Time.time;
                            }

                            if ((!self.IsAI && _base.photonView.isMine) || (self.IsAI && (_dealerChar == null || _dealerChar.photonView.isMine)))
                            {
                                _base.photonView.RPC("SendKnock", PhotonTargets.All, new object[]
                                {
                                    false,
                                    m_stability
                                });
                            }
                            else
                            {
                                At.Invoke(self, "Knock", true);
                            }
                            if (self.IsPhotonPlayerLocal && _block)
                            {
                                self.BlockInput(false);
                            }
                        }
                        // else if we are not blocking...
                        else if (!_block)
                        {
                            // Debug.Log("Value: " + _knockValue + ", new stability: " + m_stability);
                            if (m_knockHurtAllowed)
                            {
                                At.SetField(self, "m_hurtType", Character.HurtType.Hurt);

                                if (m_currentlyChargingAttack)
                                {
                                    self.CancelCharging();
                                }

                                m_animator.SetTrigger("Knockhurt");
                                _base.StopCoroutine("KnockhurtRoutine");

                                MethodInfo  _knockhurtRoutine = self.GetType().GetMethod("KnockhurtRoutine", BindingFlags.NonPublic | BindingFlags.Instance);
                                IEnumerator _knockEnum        = (IEnumerator)_knockhurtRoutine.Invoke(self, new object[] { hit });
                                _base.StartCoroutine(_knockEnum);
                            }

                            if (m_stability <= (float)CombatOverhaul.config.GetValue(Settings.Stagger_Immunity_Period))
                            {
                                // Debug.LogError(self.Name + " would have staggered. Current delta: " + (Time.time - lastStagger));
                            }
                        }
                        else // hit was blocked and no stagger
                        {
                            Instance.StaggerAttacker(self, m_animator, _dealerChar);
                        }
                        m_animator.SetInteger("KnockAngle", (int)_angle);
                        self.StabilityHitCall?.Invoke();
                    }
                    else if (!m_impactImmune && _block) // hit dealt 0 impact and was blocked
                    {
                        Instance.StaggerAttacker(self, m_animator, _dealerChar);
                    }
                }

                return(false);
            }