示例#1
0
        static void Prefix(Mech __instance, ArmorLocation aLoc, float totalArmorDamage, float directStructureDamage)
        {
            if (aLoc == ArmorLocation.Head)
            {
                //var sim = UnityGameInstance.BattleTechGame.Simulation;
                //if (sim.CompanyTags.Contains("FewerHeadInjuriesDisabled"))
                //    return;

                var currentArmor = __instance.GetCurrentArmor(aLoc);
                var maxArmor     = __instance.GetMaxArmor(aLoc);
                if (Math.Abs(__instance.GetCurrentArmor(aLoc)) < float.Epsilon)
                {
                    return;
                }

                if (currentArmor - totalArmorDamage + directStructureDamage <= 0)
                {
                    return;
                }

                var Modifier =
                    UnityGameInstance.BattleTechGame.Simulation.GetCareerModeOverallDifficultyMod();
                var rng = new Random().Next(1, 101);
                if (rng <= currentArmor / maxArmor * 100 * Modifier)
                {
                    IgnoreNextHeadHit.Add(__instance.pilot);
                }
            }
        }
示例#2
0
        // true implies injury occurs
        static bool Prefix(Pilot __instance, InjuryReason reason)
        {
            try
            {
                if (reason != InjuryReason.SideTorsoDestroyed &&
                    reason == InjuryReason.HeadHit && IgnoreNextHeadHit.Contains(__instance))
                {
                    //var sim = UnityGameInstance.BattleTechGame.Simulation;
                    //if (sim.CompanyTags.Contains("FewerHeadInjuriesDisabled"))
                    //    return true;

                    UnityGameInstance.BattleTechGame.Combat.MessageCenter.PublishMessage(
                        new AddSequenceToStackMessage(
                            new ShowActorInfoSequence(
                                __instance.ParentActor,
                                "INJURY AVOIDED",
                                FloatieMessage.MessageNature.Inspiration,
                                false)
                            )
                        );
                    IgnoreNextHeadHit.Remove(__instance);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Log(ex.ToString());
            }

            return(true);
        }