public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState, ref bool __result)
 {
     if (Core.Settings.StoodUpPilotingRoll == false)
     {
         return(true);
     }
     try {
         __result = true;
         Mech actorByGuid = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech;
         if (actorByGuid == null)
         {
             Log.LogWrite("MechStartupInvocation.Invoke failed! Unable to Mech!\n");
             return(true);
         }
         Log.LogWrite("Mech stoodup roll\n");
         float limit = actorByGuid.StoodUpRoll();
         float roll  = Random.Range(0f, 1f);
         Log.LogWrite(" roll = " + roll + " against " + limit + "\n");
         if (roll < limit)
         {
             Log.LogWrite(" success\n");
             return(true);
         }
         else
         {
             Log.LogWrite(" fail to stand up\n");
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new FloatieMessage(__instance.MechGUID, __instance.MechGUID, "__/CAE.StandUpFail/__", FloatieMessage.MessageNature.Buff));
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage(actorByGuid.DoneNoAnimation()));
         }
         return(false);
     } catch (Exception e) {
         Log.LogWrite(e.ToString() + "\n");
     }
     return(true);
 }
 public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState, ref bool __result)
 {
     if (Core.Settings.StartupByHeatControl == false)
     {
         return(true);
     }
     try {
         __result = true;
         Mech actorByGuid = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech;
         if (actorByGuid == null)
         {
             Log.LogWrite("MechStartupInvocation.Invoke failed! Unable to Mech!\n");
             return(true);
         }
         if (actorByGuid.CurrentHeatAsRatio >= Core.Settings.StartupMinHeatRatio)
         {
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new FloatieMessage(__instance.MechGUID, __instance.MechGUID, "__/CAE.ReactroTooHot/__", FloatieMessage.MessageNature.Buff));
             combatGameState.MessageCenter.PublishMessage((MessageCenterMessage) new AddSequenceToStackMessage(actorByGuid.DoneNoAnimation()));
         }
         else
         {
             return(true);
         }
         return(false);
     } catch (Exception e) {
         Log.LogWrite(e.ToString() + "\n");
     }
     return(true);
 }
예제 #3
0
        public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState)
        {
            Mech mech = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech;

            if (mech == null)
            {
                return(true);
            }

            // Check to see if we should restart automatically
            float heatCheck          = mech.HeatCheckMod(Mod.Config.Piloting.SkillMulti);
            int   futureHeat         = mech.CurrentHeat - mech.AdjustedHeatsinkCapacity;
            bool  passedStartupCheck = CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.Shutdown, futureHeat, mech, heatCheck, ModConfig.FT_Check_Startup);

            if (passedStartupCheck)
            {
                return(true);
            }                                        // Do the normal startup process

            Mod.Log.Debug($"Mech: {CombatantUtils.Label(mech)} failed a startup roll, venting heat but remaining offline.");

            QuipHelper.PublishQuip(mech, Mod.Config.Qips.Startup);

            DoneWithActorSequence doneWithActorSequence = (DoneWithActorSequence)mech.GetDoneWithActorOrders();
            MechHeatSequence      mechHeatSequence      = new MechHeatSequence(mech, true, true, "STARTUP");

            doneWithActorSequence.AddChildSequence(mechHeatSequence, mechHeatSequence.MessageIndex);

            InvocationStackSequenceCreated message = new InvocationStackSequenceCreated(doneWithActorSequence, __instance);

            combatGameState.MessageCenter.PublishMessage(message);
            AddSequenceToStackMessage.Publish(combatGameState.MessageCenter, doneWithActorSequence);

            //mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(mechHeatSequence));

            //mech.OnStartupComplete(mechHeatSequence.SequenceGUID);
            //mech.DoneWithActor();

            return(false);
        }
예제 #4
0
        public static bool Prefix(MechStartupInvocation __instance, CombatGameState combatGameState)
        {
            Mech mech = combatGameState.FindActorByGUID(__instance.MechGUID) as Mech;

            if (mech == null)
            {
                return(true);
            }

            Mod.Log.Info?.Write($"Processing startup for Mech: {CombatantUtils.Label(mech)}");

            // Check to see if we should restart automatically
            float heatCheck          = mech.HeatCheckMod(Mod.Config.SkillChecks.ModPerPointOfGuts);
            int   futureHeat         = mech.CurrentHeat - mech.AdjustedHeatsinkCapacity;
            bool  passedStartupCheck = CheckHelper.DidCheckPassThreshold(Mod.Config.Heat.Shutdown, futureHeat, mech, heatCheck, ModText.FT_Check_Startup);

            Mod.Log.Info?.Write($"  -- futureHeat: {futureHeat} = current: {mech.CurrentHeat} - HSCapacity: {mech.AdjustedHeatsinkCapacity} vs. heatCheck: {heatCheck} => passedStartup: {passedStartupCheck}");

            bool failedInjuryCheck = CheckHelper.ResolvePilotInjuryCheck(mech, futureHeat, -1, -1, heatCheck);

            if (failedInjuryCheck)
            {
                Mod.Log.Info?.Write("  -- unit did not pass injury check!");
            }

            bool failedSystemFailureCheck = CheckHelper.ResolveSystemFailureCheck(mech, futureHeat, -1, heatCheck);

            if (failedSystemFailureCheck)
            {
                Mod.Log.Info?.Write("  -- unit did not pass system failure check!");
            }

            bool failedAmmoCheck = CheckHelper.ResolveRegularAmmoCheck(mech, futureHeat, -1, heatCheck);

            if (failedAmmoCheck)
            {
                Mod.Log.Info?.Write("  -- unit did not pass ammo explosion check!");
            }

            bool failedVolatileAmmoCheck = CheckHelper.ResolveVolatileAmmoCheck(mech, futureHeat, -1, heatCheck);

            if (failedVolatileAmmoCheck)
            {
                Mod.Log.Info?.Write("  -- unit did not pass volatile ammo explosion check!");
            }

            if (passedStartupCheck)
            {
                Mod.Log.Debug?.Write($" -- passed startup roll, going through regular MechStartupSequence.");
                return(true);
            }

            Mod.Log.Info?.Write($" -- failed startup roll, venting heat but remaining offline.");

            DoneWithActorSequence doneWithActorSequence = (DoneWithActorSequence)mech.GetDoneWithActorOrders();
            MechHeatSequence      mechHeatSequence      = new MechHeatSequence(OwningMech: mech, performHeatSinkStep: true, applyStartupHeatSinks: false, instigatorID: "STARTUP");

            doneWithActorSequence.AddChildSequence(mechHeatSequence, mechHeatSequence.MessageIndex);

            QuipHelper.PublishQuip(mech, Mod.LocalizedText.Quips.Startup);

            InvocationStackSequenceCreated message = new InvocationStackSequenceCreated(doneWithActorSequence, __instance);

            combatGameState.MessageCenter.PublishMessage(message);
            AddSequenceToStackMessage.Publish(combatGameState.MessageCenter, doneWithActorSequence);

            Mod.Log.Debug?.Write($" -- sent sequence to messageCenter");
            return(false);
        }