static bool Prefix(FlankedAttackBonus __instance, RuleCalculateAttackBonus evt) { bool isFlatFooted = Rulebook.Trigger <RuleCheckTargetFlatFooted>(new RuleCheckTargetFlatFooted(evt.Initiator, evt.Target)).IsFlatFooted; bool is_flanked = false; foreach (var u in evt.Target.CombatState.EngagedBy) { is_flanked = evt.Target.isFlankedByAttacker(u); if (is_flanked) { break; } } if (is_flanked || isFlatFooted) { evt.AddBonus(__instance.AttackBonus * __instance.Fact.GetRank(), __instance.Fact); } return(false); }
static bool Prefix(FlankedAttackBonus __instance, RuleCalculateAttackBonus evt) { Main.Logger?.Write("FlankedAttackBonus event triggered"); UnitCombatState_get_IsFlanked_Patch.PushFlankingParameters(new FlankingParameters(typeof(FlankedAttackBonus_OnEventAboutToTrigger_Patch), __instance.Owner.Unit)); return(true); }