Beispiel #1
0
        private bool ValidateAttack(Mech attacker, AbstractActor target, HashSet <MeleeAttackType> validAnimations)
        {
            ActorMeleeCondition meleeCondition = ModState.GetMeleeCondition(attacker);

            if (!meleeCondition.CanKick())
            {
                Mod.MeleeLog.Info?.Write($"Attacker cannot kick, skipping.");
                return(false);
            }

            // If neither kick (mech) or stomp (vehicle) - we're not a valid attack.
            if (!validAnimations.Contains(MeleeAttackType.Kick) && !validAnimations.Contains(MeleeAttackType.Stomp))
            {
                Mod.MeleeLog.Info?.Write("Animations do not include a kick or stomp, cannot kick.");
                return(false);
            }

            if (target.UnaffectedPathing())
            {
                Mod.MeleeLog.Info?.Write($"Target is unaffected by pathing, likely a VTOL or LAM in flight. Cannot melee it!");
                return(false);
            }

            // If distance > walkSpeed, disable kick/physical weapon/punch
            if (!state.HasWalkAttackNodes)
            {
                Mod.MeleeLog.Info?.Write($"No walking nodes found for melee attack!");
                return(false);
            }

            Mod.MeleeLog.Info?.Write("KICK ATTACK validated");
            return(true);
        }
        public static float KickInstability(this Mech mech)
        {
            ActorMeleeCondition attackerCondition = ModState.GetMeleeCondition(mech);

            if (!attackerCondition.CanKick())
            {
                return(0);
            }

            float raw = (float)Math.Ceiling(Mod.Config.Melee.Kick.TargetInstabilityPerAttackerTon * mech.tonnage);

            Mod.MeleeLog.Debug?.Write($"KICK baseStability: {Mod.Config.Melee.Punch.TargetInstabilityPerAttackerTon} x " +
                                      $"attacker tonnage: {mech.tonnage} = {raw}");

            // Modifiers
            float mod = mech.StatCollection.ContainsStatistic(ModStats.KickTargetInstabilityMod) ?
                        mech.StatCollection.GetValue <int>(ModStats.KickTargetInstabilityMod) : 0f;
            float multi = mech.StatCollection.ContainsStatistic(ModStats.KickTargetInstabilityMulti) ?
                          mech.StatCollection.GetValue <float>(ModStats.KickTargetInstabilityMulti) : 1f;

            // Leg actuator damage
            float leftReductionMulti = 1f;
            int   damagedLeftCount   = 2 - attackerCondition.LeftLegActuatorsCount;

            for (int i = 0; i < damagedLeftCount; i++)
            {
                leftReductionMulti *= Mod.Config.Melee.Kick.LegActuatorDamageReduction;
            }
            Mod.MeleeLog.Debug?.Write($" - Left actuator damage multi is: {leftReductionMulti}");

            float rightReductionMulti = 1f;
            int   damagedRight        = 2 - attackerCondition.RightLegActuatorsCount;

            for (int i = 0; i < damagedRight; i++)
            {
                rightReductionMulti *= Mod.Config.Melee.Kick.LegActuatorDamageReduction;
            }
            Mod.MeleeLog.Debug?.Write($" - Right actuator damage multi is: {rightReductionMulti}");

            float actuatorMulti = leftReductionMulti >= rightReductionMulti ? leftReductionMulti : rightReductionMulti;

            Mod.MeleeLog.Debug?.Write($" - Using actuator damage multi of: {actuatorMulti}");

            // Roll up instability
            float final = (float)Math.Ceiling((raw + mod) * multi * actuatorMulti);

            Mod.MeleeLog.Debug?.Write($" - Target instability => final: {final} = (raw: {raw} + mod: {mod}) x " +
                                      $"multi: {multi} x actuatorMulti: {actuatorMulti}");

            return(final);
        }