Esempio n. 1
0
 public static void ShowBaseMeleeChance(CombatHUDWeaponSlot __instance, ICombatant target)
 {
     try {
         if (HUD.SelectedActor is Mech mech)
         {
             float baseChance = RollModifier.StepHitChance(Combat.ToHit.GetBaseMeleeToHitChance(mech)) * 100;
             __instance.ToolTipHoverElement.BuffStrings.Add(new Text("{0} {1} = " + BaseChanceFormat, Translate(Pilot.PILOTSTAT_PILOTING), mech.SkillPiloting, baseChance));
         }
     }                 catch (Exception ex) { Error(ex); }
 }
        public static Func <AttackModifier> GetCommonModifierFactor(string factorId)
        {
            switch (factorId)
            {
            case "direction":
                return(() => {
                    AttackDirection dir = Combat.HitLocation.GetAttackDirection(AttackPos, Target);
                    if (Target is Mech mech)
                    {
                        if (mech.IsProne)
                        {
                            return new AttackModifier();           // Prone is another modifier
                        }
                        if (dir == AttackDirection.FromFront)
                        {
                            return new AttackModifier("FRONT ATTACK", Settings.ToHitMechFromFront);
                        }
                        if (dir == AttackDirection.FromLeft || dir == AttackDirection.FromRight)
                        {
                            return new AttackModifier("SIDE ATTACK", Settings.ToHitMechFromSide);
                        }
                        if (dir == AttackDirection.FromBack)
                        {
                            return new AttackModifier("REAR ATTACK", Settings.ToHitMechFromRear);
                        }
                    }
                    else if (Target is Vehicle vehicle)
                    {
                        if (dir == AttackDirection.FromFront)
                        {
                            return new AttackModifier("FRONT ATTACK", Settings.ToHitVehicleFromFront);
                        }
                        if (dir == AttackDirection.FromLeft || dir == AttackDirection.FromRight)
                        {
                            return new AttackModifier("SIDE ATTACK", Settings.ToHitVehicleFromSide);
                        }
                        if (dir == AttackDirection.FromBack)
                        {
                            return new AttackModifier("REAR ATTACK", Settings.ToHitVehicleFromRear);
                        }
                    }
                    return new AttackModifier();
                });

            case "inspired":
                return(() => new AttackModifier("INSPIRED", Math.Min(0f, Hit.GetAttackerAccuracyModifier(Attacker))));

            case "jumped":
                return(() => new AttackModifier("JUMPED", RollModifier.GetJumpedModifier(Attacker)));

            case "selfheat":
                return(() => new AttackModifier("OVERHEAT", Hit.GetHeatModifier(Attacker)));

            case "selfstoodup":
                return(() => new AttackModifier("STOOD UP", Hit.GetStoodUpModifier(Attacker)));

            case "selfterrain":
                return(() => new AttackModifier("TERRAIN", Hit.GetSelfTerrainModifier(AttackPos, false)));

            case "selfterrainmelee":
                return(() => new AttackModifier("TERRAIN", Hit.GetSelfTerrainModifier(AttackPos, true)));

            case "sensorimpaired":
                return(() => new AttackModifier("SENSOR IMPAIRED", Math.Max(0f, Hit.GetAttackerAccuracyModifier(Attacker))));

            case "sprint":
                return(() => new AttackModifier("SPRINTED", Hit.GetSelfSprintedModifier(Attacker)));

            case "targeteffect":
                return(() => new AttackModifier("TARGET EFFECTS", Hit.GetEnemyEffectModifier(Target)));

            case "targetsize":
                return(() => new AttackModifier("TARGET SIZE", Hit.GetTargetSizeModifier(Target)));

            case "targetterrain":
                return(() => new AttackModifier("TARGET TERRAIN", Hit.GetTargetTerrainModifier(Target, TargetPos, false)));

            case "targetterrainmelee":
                return(() => new AttackModifier("TARGET TERRAIN", Hit.GetTargetTerrainModifier(Target, TargetPos, true)));

            case "walked":
                return(() => new AttackModifier("MOVED", Hit.GetSelfSpeedModifier(Attacker)));

            case "weaponaccuracy":
                return(() => new AttackModifier("WEAPON ACCURACY", Hit.GetWeaponAccuracyModifier(Attacker, AttackWeapon)));
            }
            return(null);
        }