示例#1
0
        public override void CombatStarts()
        {
            CombatResolutionConstantsDef con = CombatConstants.ResolutionConstants;

            if (CritChanceMin != con.MinCritChance)
            {
                con.MinCritChance = CritChanceMin;
                typeof(CombatGameConstants).GetProperty("ResolutionConstants").SetValue(CombatConstants, con, null);
            }
        }
示例#2
0
            public static void Postfix(Mech __instance, WeaponHitInfo hitInfo, Weapon weapon, MeleeAttackType meleeAttackType)
            {
                Mod.Log.Trace("M:RWD entered.");

                AttackDirector.AttackSequence attackSequence = __instance.Combat.AttackDirector.GetAttackSequence(hitInfo.attackSequenceId);
                AbstractActor actor = __instance.Combat.FindActorByGUID(hitInfo.targetId);

                if (actor is Mech target)
                {
                    CombatResolutionConstantsDef crcd = __instance.Combat.Constants.ResolutionConstants;
                    float stabilityDamage             = hitInfo.ConsolidateInstability(hitInfo.targetId, weapon.Instability(),
                                                                                       crcd.GlancingBlowDamageMultiplier, crcd.NormalBlowDamageMultiplier, crcd.SolidBlowDamageMultiplier);

                    stabilityDamage *= __instance.StatCollection.GetValue <float>("ReceivedInstabilityMultiplier");
                    stabilityDamage *= __instance.EntrenchedMultiplier;

                    Mod.Log.Debug($" == Checking Piloting Stability");
                    Mod.Log.Debug($"   target:{CombatantHelper.LogLabel(target)} isMech:{(actor is Mech)} IsDead:{target.IsDead} IsUnsteady:{target.IsUnsteady} IsOrWillBeProne:{target.IsOrWillBeProne}");
                    Mod.Log.Debug($"   weapon stability damage:{stabilityDamage}");

                    if (stabilityDamage > 0 && !target.IsDead && target.IsUnsteady && !target.IsOrWillBeProne)
                    {
                        float skillBonus = (float)target.SkillPiloting / __instance.Combat.Constants.PilotingConstants.PilotingDivisor;

                        float skillRoll  = __instance.Combat.NetworkRandom.Float();
                        float skillTotal = skillRoll + skillBonus;

                        Mod.Log.Debug($" Skill check -> bonus: {skillBonus}  roll: {skillRoll}  rollTotal: {skillTotal}  target:{Mod.Config.PilotStabilityCheck}");

                        if (skillTotal < Mod.Config.PilotStabilityCheck)
                        {
                            Mod.Log.Debug(string.Format(" Skill Check Failed! Flagging for Knockdown"));
                            bool showMessage = !target.IsFlaggedForKnockdown;

                            target.FlagForKnockdown();
                            if (Mod.Config.ShowAllStabilityRolls || showMessage)
                            {
                                target.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(target, $"Stability Check: Failed!", FloatieMessage.MessageNature.Debuff, true)));
                            }
                        }
                        else
                        {
                            Mod.Log.Debug(string.Format(" Skill Check Succeeded!"));
                            if (Mod.Config.ShowAllStabilityRolls)
                            {
                                target.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(target, $"Stability Check: Passed!", FloatieMessage.MessageNature.Buff, true)));
                            }
                        }
                    }
                    else
                    {
                        Mod.Log.Debug($"  target has no stability damage, is not unsteady, or is dead or prone - skipping");
                    }
                }
            }
 public override void CombatStarts()
 {
     if (Settings.AllowNetBonusModifier)
     {
         CombatResolutionConstantsDef con = CombatConstants.ResolutionConstants;
         con.AllowTotalNegativeModifier = true;
         typeof(CombatGameConstants).GetProperty("ResolutionConstants").SetValue(CombatConstants, con, null);
     }
     if (Settings.AllowLowElevationPenalty)
     {
         ToHitConstantsDef con = CombatConstants.ToHit;
         con.ToHitElevationApplyPenalties = true;
         typeof(CombatGameConstants).GetProperty("ToHit").SetValue(CombatConstants, con, null);
     }
     if (Settings.AllowNetBonusModifier && steppingModifier == null && !Settings.DiminishingHitChanceModifier)
     {
         TryRun(ModLog, FillSteppedModifiers);
     }
 }
            public static void Postfix(Mech __instance, WeaponHitInfo hitInfo, Weapon weapon, MeleeAttackType meleeAttackType)
            {
                Mod.Log.Trace("M:RWD entered.");

                AttackDirector.AttackSequence attackSequence = __instance.Combat.AttackDirector.GetAttackSequence(hitInfo.attackSequenceId);
                AbstractActor target = __instance.Combat.FindActorByGUID(hitInfo.targetId);

                if (target is Mech targetMech)
                {
                    // Feature: Piloting Skill Check from instability
                    // TODO: Let instability represent this?
                    CombatResolutionConstantsDef crcd = target.Combat.Constants.ResolutionConstants;
                    float stabilityDamage             = hitInfo.ConsolidateInstability(hitInfo.targetId, weapon.Instability(),
                                                                                       crcd.GlancingBlowDamageMultiplier, crcd.NormalBlowDamageMultiplier, crcd.SolidBlowDamageMultiplier);
                    stabilityDamage *= __instance.StatCollection.GetValue <float>("ReceivedInstabilityMultiplier");
                    stabilityDamage *= __instance.EntrenchedMultiplier;
                    MechHelper.PilotCheckOnInstabilityDamage(targetMech, stabilityDamage);
                }
            }