public static void Postfix(AbstractActor __instance, ref int __result, StatCollection ___statCollection) { CombatGameState ___Combat = (CombatGameState)Traverse.Create(__instance).Property("Combat").GetValue(); if (___Combat.TurnDirector.IsInterleaved) { CombatHUD ___HUD = (CombatHUD)Traverse.Create(__instance).Property("HUD").GetValue(); int baseInit = ___statCollection.GetValue <int>("BaseInitiative"); int phaseMod = ___statCollection.GetValue <int>("PhaseModifier"); int modifiedInit = baseInit + phaseMod; //SkillBasedInit.Logger.LogIfDebug($"Actor:({__instance.DisplayName}_{__instance.GetPilot().Name}) has stats BaseInit:{baseInit} / PhaseMod:{phaseMod}"); if (modifiedInit < Mod.MinPhase) { Mod.Log.Info($"Actor:({CombatantHelper.LogLabel(__instance)}) being set to {Mod.MinPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}"); __result = Mod.MinPhase; } else if (modifiedInit > Mod.MaxPhase) { Mod.Log.Info($"Actor:({CombatantHelper.LogLabel(__instance)}) being set to {Mod.MaxPhase} due to BaseInit:{baseInit} + PhaseMod:{phaseMod}"); __result = Mod.MaxPhase; } else { __result = modifiedInit; //SkillBasedInit.Logger.Log($"Actor:({__instance.DisplayName}_{__instance.GetPilot().Name}) has stats BaseInit:{baseInit} + PhaseMod:{phaseMod} = modifiedInit:{modifiedInit}."); } } }
public static void Postfix(AbstractActor __instance, bool __result) { bool isValid = __instance.Initiative >= Mod.MinPhase && __instance.Initiative <= Mod.MaxPhase; if (!isValid) { Mod.Log.Info($"Actor:{CombatantHelper.LogLabel(__instance)} has invalid initiative {__instance.Initiative}!"); } __result = isValid; Mod.Log.Debug($"AbstractActor:HasValidInitiative returning {__result} for {__instance.Initiative}"); }
public static void Postfix(AbstractActor __instance) { //SkillBasedInit.Logger.Log($"AbstractActor:DeferUnit:"); int reservePenalty = Mod.Random.Next(Mod.Config.ReservedPenaltyBounds[0], Mod.Config.ReservedPenaltyBounds[1]); Mod.Log.Debug($" Deferring Actor:({CombatantHelper.LogLabel(__instance)}) " + $"initiative:{__instance.Initiative} by:{reservePenalty} to:{__instance.Initiative + reservePenalty}"); __instance.Initiative += reservePenalty; if (__instance.Initiative > Mod.MaxPhase) { __instance.Initiative = Mod.MaxPhase; } // Save some part of the reserve surplus as a penalty for the next round ActorInitiative actorInit = ActorInitiativeHolder.GetOrCreate(__instance); actorInit.reservedCount++; Mod.Log.Debug($" Actor:({CombatantHelper.LogLabel(__instance)}) reservedCount incremented to:{actorInit.reservedCount}"); }