Exemple #1
0
        static bool Prefix(MechMeleeSequence __instance)
        {
            // attacker second instability check during melee whiff
            var attacker = __instance.OwningMech;

            attacker.CheckForInstability();
            HandleFall.Say(attacker);  // only one I couldn't get to trigger, but I believe is correctly placed
            attacker.HandleKnockdown(__instance.RootSequenceGUID, attacker.GUID, Vector2.one, null);

            // second target instability check during melee hit if can go to ground in one hit
            if (Core.ModSettings.AllowSteadyToKnockdownForMelee)
            {
                if (!__instance.MeleeTarget.IsDead)
                {
                    var target = __instance.MeleeTarget as AbstractActor;
                    if (target != null)
                    {
                        target.NeedsInstabilityCheck = true;
                        target.CheckForInstability();
                        target.HandleKnockdown(__instance.RootSequenceGUID, attacker.GUID, Vector2.one, null);
                    }
                }
            }

            Logger.Debug($"did we fall? {attacker.IsProne}");
            Logger.Debug($"did they fall? {__instance.MeleeTarget.IsProne}");
            return(true);
        }
Exemple #2
0
        static void Postfix(ref MessageCenterMessage message, MechMeleeSequence __instance)
        {
            Logger.Debug($"checking for miss: {(message as AttackCompleteMessage).attackSequence.attackCompletelyMissed}");

            if (Core.ModSettings.AttackMissInstability)
            {
                // Deal with attacker missing
                var attackCompleteMessage = (AttackCompleteMessage)message;
                var attacker = __instance.OwningMech;
                if (attackCompleteMessage.attackSequence.attackCompletelyMissed)
                {
                    Logger.Debug($"melee pre-miss stability: {attacker.CurrentStability}");
                    var rawInstabilityToAdd = attacker.IsLegged
                        ? Core.ModSettings.AttackMissInstabilityLeggedPercent
                        : Core.ModSettings.AttackMissInstabilityPercent;
                    var instabilityToAdd = rawInstabilityToAdd;
                    if (Core.ModSettings.pilotingSkillInstabilityMitigation)
                    {
                        var mitigation        = Calculator.PilotingMitigation(attacker);
                        var mitigationPercent = Mathf.RoundToInt(mitigation * 100);
                        instabilityToAdd = rawInstabilityToAdd - rawInstabilityToAdd * mitigation;
                        Logger.Debug($"melee miss numbers\n" +
                                     $"pilotSkill: {attacker.SkillPiloting}\n" +
                                     $"mitigation: {mitigation}\n" +
                                     $"rawInstabilityToAdd: {rawInstabilityToAdd}\n" +
                                     $"mitigationPercent: {mitigationPercent}\n" +
                                     $"instabilityToAdd: {instabilityToAdd}");
                        attacker.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(attacker, $"Pilot Check: Avoided {mitigationPercent}% Instability!", FloatieMessage.MessageNature.Neutral, true)));
                    }

                    attacker.AddRelativeInstability(instabilityToAdd, StabilityChangeSource.Attack, attacker.GUID);
                    Logger.Debug($"melee post-miss stability: {attacker.CurrentStability}");
                    attacker.NeedsInstabilityCheck = true;
                    if (Core.ModSettings.AllowSteadyToKnockdownForMelee)
                    {
                        attacker.CheckForInstability();
                        attacker.NeedsInstabilityCheck = true;
                    }
                }
            }

            // Deal with target needing additional checks if we want to be able to knock over
            // mechs in a single round from one attack.
            if (Core.ModSettings.AllowSteadyToKnockdownForMelee)
            {
                if (!__instance.MeleeTarget.IsDead)
                {
                    var target = __instance.MeleeTarget as AbstractActor;
                    if (target != null)
                    {
                        target.NeedsInstabilityCheck = true;
                        target.CheckForInstability();
                        var attacker = __instance.OwningMech;
                        HandleFall.Say(attacker);
                        target.HandleKnockdown(__instance.RootSequenceGUID, attacker.GUID, Vector2.one, null);
                    }
                }
            }
        }
Exemple #3
0
        static void Postfix(ref MessageCenterMessage message, MechMeleeSequence __instance)
        {
            if (Core.ModSettings.DfaMissInstability)
            {
                Logger.Debug($"checking for miss: {(message as AttackCompleteMessage).attackSequence.attackCompletelyMissed}");
                var attackCompleteMessage = (AttackCompleteMessage)message;
                var attacker = __instance.OwningMech;
                if (attackCompleteMessage.attackSequence.attackCompletelyMissed)
                {
                    Logger.Debug("We missed!");
                    Logger.Debug($"flagged for knockdown? {attacker.IsFlaggedForKnockdown}");
                    var rawInstabilityToAdd = attacker.IsLegged
                        ? Core.ModSettings.DfaMissInstabilityLeggedPercent
                        : Core.ModSettings.DfaMissInstabilityPercent;
                    var instabilityToAdd = rawInstabilityToAdd;
                    if (Core.ModSettings.PilotingSkillInstabilityMitigation)
                    {
                        var mitigation        = Calculator.PilotingMitigation(attacker);
                        var mitigationPercent = Mathf.RoundToInt(mitigation * 100);
                        instabilityToAdd = rawInstabilityToAdd - rawInstabilityToAdd * mitigation;
                        Logger.Debug($"dfa miss numbers\n" +
                                     $"pilotSkill: {attacker.SkillPiloting}\n" +
                                     $"mitigation: {mitigation}\n" +
                                     $"rawInstabilityToAdd: {rawInstabilityToAdd}\n" +
                                     $"mitigationPercent: {mitigationPercent}\n" +
                                     $"instabilityToAdd: {instabilityToAdd}");
                        attacker.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(attacker, $"Pilot Check: Avoided {mitigationPercent}% Instability!", FloatieMessage.MessageNature.Neutral, true)));
                    }

                    attacker.AddRelativeInstability(instabilityToAdd, StabilityChangeSource.DFA, attacker.GUID);
                    attacker.NeedsInstabilityCheck = true;
                    attacker.CheckForInstability();
                    Logger.Debug($"flagged for knockdown? {attacker.IsFlaggedForKnockdown}");
                    if (Core.ModSettings.AllowSteadyToKnockdownForMelee)
                    {
                        attacker.NeedsInstabilityCheck = true;
                        attacker.CheckForInstability();
                        Logger.Debug($"flagged for knockdown? {attacker.IsFlaggedForKnockdown}");
                    }
                }

                HandleFall.Say(attacker);
            }
        }