Example #1
0
        public static void CombatHUDWeaponSlot_UpdateToolTipsFiring_Postfix(CombatHUDWeaponSlot __instance, ICombatant target, CombatGameState ___Combat, CombatHUD ___HUD, int ___modifier)
        {
            if (___HUD.SelectionHandler.ActiveState.SelectionType == SelectionType.FireMorale)
            {
                Mod.Log.Trace("CHUDWS:UTTF:Post entered.");

                AbstractActor attacker = ___HUD.SelectedActor;

                // Calculate called shot modifier
                int pilotValue = PilotHelper.GetCalledShotModifier(___HUD.SelectedActor.GetPilot());

                int unitMod = 0;
                if (attacker.StatCollection.ContainsStatistic(ModStats.CalledShotMod))
                {
                    unitMod = attacker.StatCollection.GetStatistic(ModStats.CalledShotMod).Value <int>();
                }

                int calledShotMod = pilotValue + unitMod;
                Mod.Log.Debug($"   Called Shot from pilot:{attacker.GetPilot().Name} => pilotValue:{pilotValue} + unitMod:0 = calledShotMod:{calledShotMod}");

                if (calledShotMod != 0)
                {
                    AddMoraleToolTip(__instance, ___Combat.Constants.CombatUIConstants.MoraleAttackDescription.Name, calledShotMod);
                }
            }
        }
Example #2
0
        public static void ToHit_GetAllModifiers_Postfix(ToHit __instance, ref float __result, bool isCalledShot, AbstractActor attacker, Weapon weapon, ICombatant target)
        {
            if (isCalledShot)
            {
                Mod.Log.Trace("TH:GAM entered.");

                // Calculate called shot modifier
                int pilotValue = PilotHelper.GetCalledShotModifier(attacker.GetPilot());

                int unitMod = 0;
                if (attacker.StatCollection.ContainsStatistic(ModStats.CalledShotMod))
                {
                    unitMod = attacker.StatCollection.GetStatistic(ModStats.CalledShotMod).Value <int>();
                }

                int calledShotMod = pilotValue + unitMod;
                Mod.Log.Debug($"   Called Shot from pilot:{attacker.GetPilot().Name} => pilotValue:{pilotValue} + unitMod:{unitMod} = calledShotMod:{calledShotMod}");

                __result = __result + calledShotMod;
            }
        }
Example #3
0
        public static void ToHit_GetAllModifiersDescription_Postfix(ToHit __instance, ref string __result, bool isCalledShot, AbstractActor attacker, Weapon weapon, ICombatant target)
        {
            if (isCalledShot)
            {
                Mod.Log.Trace("TH:GAMD entered.");

                // Calculate called shot modifier
                int pilotValue = PilotHelper.GetCalledShotModifier(attacker.GetPilot());

                int unitMod = 0;
                if (attacker.StatCollection.ContainsStatistic(ModStats.CalledShotMod))
                {
                    unitMod = attacker.StatCollection.GetStatistic(ModStats.CalledShotMod).Value <int>();
                }

                int calledShotMod = pilotValue + unitMod;
                Mod.Log.Debug($"   Called Shot from pilot:{attacker.GetPilot().Name} => pilotValue:{pilotValue} + unitMod:{unitMod} = calledShotMod:{calledShotMod}");

                if (calledShotMod != 0)
                {
                    __result = string.Format("{0}CALLED-SHOT {1:+#;-#}; ", __result, (int)calledShotMod);
                }
            }
        }
Example #4
0
        public ActorInitiative(AbstractActor actor)
        {
            //SkillBasedInit.Logger.Log($"Initializing ActorInitiative for {actor.DisplayName} with GUID {actor.GUID}.");

            if (actor.GetType() == typeof(Mech))
            {
                this.type = ActorType.Mech;
            }
            else if (actor.GetType() == typeof(Vehicle))
            {
                this.type = ActorType.Vehicle;
            }
            else
            {
                this.type = ActorType.Turret;
            }

            // --- UNIT IMPACTS ---
            // Static initiative from tonnage
            float tonnage    = UnitHelper.GetUnitTonnage(actor);
            int   tonnageMod = UnitHelper.GetTonnageModifier(tonnage);

            // Any special modifiers by type
            int typeMod = UnitHelper.GetTypeModifier(actor);

            // Any modifiers that come from the chassis/mech/vehicle defs
            int componentsMod = UnitHelper.GetNormalizedComponentModifier(actor);

            // Modifier from the engine
            int engineMod = UnitHelper.GetEngineModifier(actor);

            // --- PILOT IMPACTS ---
            Pilot pilot = actor.GetPilot();

            PilotHelper.LogPilotStats(pilot);

            // Normalize skills so that values above 10 don't screw the system
            this.gunneryEffectMod = PilotHelper.GetGunneryModifier(pilot);

            this.gutsEffectMod = PilotHelper.GetGutsModifier(pilot);
            this.injuryBounds  = PilotHelper.GetInjuryBounds(pilot);

            this.pilotingEffectMod = PilotHelper.GetPilotingModifier(pilot);
            this.randomnessBounds  = PilotHelper.GetRandomnessBounds(pilot);

            this.tacticsEffectMod = PilotHelper.GetTacticsModifier(pilot);

            int pilotTagsMod = PilotHelper.GetTagsModifier(pilot);

            this.calledShotMod = PilotHelper.GetCalledShotModifier(pilot);
            this.vigilianceMod = PilotHelper.GetVigilanceModifier(pilot);

            // --- COMBO IMPACTS --
            // Determine the melee modifier
            int[] meleeMods = PilotHelper.GetMeleeModifiers(pilot, tonnage);
            this.meleeAttackMod  = meleeMods[0];
            this.meleeDefenseMod = meleeMods[1];
            Mod.Log.Debug($"Actor:{actor.DisplayName}_{pilot.Name} has meleeAttackMod:{meleeAttackMod} meleeDefenseMod:{meleeDefenseMod}");

            // Log the full view for testing
            roundInitBase  = tonnageMod;
            roundInitBase += typeMod;
            roundInitBase += componentsMod;
            roundInitBase += engineMod;
            roundInitBase += tacticsEffectMod;
            roundInitBase += pilotTagsMod;

            Mod.Log.Info($"Actor:{actor.DisplayName}_{pilot.Name} has " +
                         $"roundInitBase:{roundInitBase} = (tonnage:{tonnageMod} + typeMod:{typeMod} + components:{componentsMod} + engine:{engineMod} " +
                         $"tactics:{tacticsEffectMod} + pilotTags:{pilotTagsMod}) " +
                         $"randomness:({randomnessBounds[0]}-{randomnessBounds[1]}) " +
                         $"injuryBounds:({injuryBounds[0]}-{injuryBounds[1]}) " +
                         $"gutsMod:{gutsEffectMod} pilotingMod:{pilotingEffectMod} tacticsMod:{tacticsEffectMod}");
        }