static void Postfix(UnitPartMagus __instance, UnitDescriptor unit, ref bool __result) { if (__result == false) { __result = unit.Body.SecondaryHand.HasItem && Helpers.hasFreeHand(unit.Body.SecondaryHand); } }
static bool Prefix(UnitCommand command) { if (IsInCombat() && command.Executor.IsInCombat) { if (command is UnitAttack unitAttack) { if (command.Executor.PreparedSpellCombat()) { UnitPartMagus unitPartMagus = command.Executor.Get <UnitPartMagus>(); unitAttack.IgnoreCooldown(unitPartMagus.AttackIgnoringCooldownBeforeTime); unitPartMagus.Owner.AddBuff( BlueprintRoot.Instance.SystemMechanics.MagusSpellCombatBuff, unitPartMagus.Owner.Unit, 1.Rounds().Seconds, null); } else if (command.Executor.PreparedSpellStrike()) { UnitPartMagus unitPartMagus = command.Executor.Get <UnitPartMagus>(); unitAttack.IgnoreCooldown(unitPartMagus.AttackIgnoringCooldownBeforeTime); unitAttack.IsSingleAttack = true; } } return(false); } return(true); }
public static void Postfix(ref bool __result, UnitPartMagus __instance) { if (settings.toggleAlwaysAllowSpellCombat && __instance.Owner != null && __instance.Owner.IsPartyOrPet()) { __result = true; } }
public static bool PreparedSpellCombat(this UnitEntityData unit) { UnitPartMagus unitPartMagus = unit.Get <UnitPartMagus>(); return(unitPartMagus != null && unitPartMagus.IsCastMagusSpellInThisRound && unitPartMagus.LastCastedMagusSpellTime > unitPartMagus.LastAttackTime && unitPartMagus.CanUseSpellCombatInThisRound); }
static void Postfix(UnitPartMagus __instance, AbilityData spell, ref bool __result) { var spell1 = spell.StickyTouch != null ? spell.StickyTouch : spell; if (__result == false && spell1?.Blueprint?.Parent != null) { var blueprint = spell1.Blueprint.Parent; __result = blueprint.IsInSpellList(__instance.Spellbook.Blueprint.SpellList) || __instance.Spellbook.IsKnown(blueprint); } }
static void Postfix(UnitPartMagus __instance, AbilityData spell, ref bool __result) { if (Mod.Enabled && FixSpellstrikeWithMetamagicReach && !__result) { if (__instance.Spellbook.Blueprint.SpellList.SpellsByLevel.Any(list => list.Spells.Any(item => item.StickyTouch?.TouchDeliveryAbility == spell.Blueprint))) { __result = true; } } }
internal static bool canUseSpellForSpellCombat(UnitPartMagus unit_part_magus, AbilityData ability) { if (unit_part_magus.Owner.HasFact(ray_spell_combat)) { return(unit_part_magus.IsSuitableForEldritchArcherSpellStrike(ability)); } else { return(unit_part_magus.IsSpellFromMagusSpellList(ability)); } }
public static bool PreparedSpellStrike(this UnitEntityData unit) { UnitPartMagus unitPartMagus = unit.Get <UnitPartMagus>(); return(unitPartMagus != null && unitPartMagus.IsCastMagusSpellInThisRound && unitPartMagus.LastCastedMagusSpellTime > unitPartMagus.LastAttackTime && unitPartMagus.Spellstrike.Active && (unitPartMagus.EldritchArcherSpell != null || (unit.Get <UnitPartTouch>()?.Ability.Data is AbilityData abilityData && unitPartMagus.IsSpellFromMagusSpellList(abilityData)))); }
static bool Prefix(UnitPartMagus __instance, bool checkMovement, ref bool __result) { if (IsInCombat() && __instance.Owner.Unit.IsInCombat) { __result = (__instance.EldritchArcher ? __instance.IsRangedWeapon(__instance.Owner.Unit.GetFirstWeapon()) : __instance.HasOneHandedMeleeWeaponAndFreehand(__instance.Owner)) && Game.Instance.TimeController.GameTime - __instance.LastSpellCombatOpportunityTime < 1.Rounds().Seconds&& (!checkMovement || __instance.Owner.Unit.HasMoveAction()); return(false); } return(true); }
static void Postfix(UnitPartMagus __instance, AbilityData spell, ref bool __result) { if (__result == true) { return; } if (spell.Blueprint.GetComponent <AbilityDeliverTouch>() != null && (spell.HasMetamagic(Metamagic.Reach) || ((spell.Blueprint.AvailableMetamagic & Metamagic.Reach) != 0) && __instance.Owner.HasFact(reach_spellstrike)) ) { __result = __instance.IsSpellFromMagusSpellList(spell); } }
internal static bool canUseSpellForSpellCombat(UnitPartMagus unit_part_magus, AbilityData ability) { if (ability.ActionType != CommandType.Standard || ability.RequireFullRoundAction) { return(false); } if (unit_part_magus.Owner.HasFact(ray_spell_combat)) { return(unit_part_magus.IsSuitableForEldritchArcherSpellStrike(ability)); } else { return(unit_part_magus.IsSpellFromMagusSpellList(ability)); } }
static void Postfix(UnitPartMagus __instance, AbilityData spell, ref bool __result) { var spell1 = spell.StickyTouch != null ? spell.StickyTouch : spell; if (__result == false && spell1?.Blueprint?.Parent != null) { var blueprint = spell1.Blueprint.Parent; __result = blueprint.IsInSpellList(__instance.Spellbook.Blueprint.SpellList) || __instance.Spellbook.IsKnown(blueprint); } if (__instance.Spellbook.Blueprint.SpellList.SpellsByLevel.Any(list => list.Spells.Any(item => item.StickyTouch?.TouchDeliveryAbility == spell.Blueprint))) { __result = true; } }
static void Postfix(ItemEntityWeapon __instance, ref bool __result) { bool spell_combat = false; UnitPartMagus unit_part_magus = __instance.Wielder?.Get <UnitPartMagus>(); if ((bool)(unit_part_magus) && unit_part_magus.SpellCombat.Active) { spell_combat = true; } if (__instance.Blueprint.IsTwoHanded || (__instance.Blueprint.IsOneHandedWhichCanBeUsedWithTwoHands && __result == false)) { var unit_part = __instance.Wielder?.Get <UnitPartCanHold2hWeaponIn1h>(); if (!spell_combat) {//check if we can hold the 2h weapon in 1h if (unit_part == null) { return; } __result = unit_part.canBeUsedAs2h(__instance); } else { if (unit_part != null && unit_part.canBeUsedOn(__instance)) {//weapon is being held as one-handed __result = false; return; } //normally we can not 2h with spell combat, so we check only magus specific feature that would allow us var use_spell_combat_part = __instance.Wielder?.Get <UnitPartCanUseSpellCombat>(); if (use_spell_combat_part == null) { return; } var pair_slot = (__instance.HoldingSlot as HandSlot)?.PairSlot; __result = use_spell_combat_part.canBeUsedOn(__instance.HoldingSlot as HandSlot, pair_slot, true); } } }
static bool Prefix(MagusController __instance, RuleCheckCastingDefensively evt) { if (!evt.Success) { return(false); } foreach (UnitEntityData attacker in evt.Initiator.CombatState.EngagedBy) { UnitPartMagus unitPartMagus = attacker.Get <UnitPartMagus>(); if (unitPartMagus != null && (bool)unitPartMagus.Counterstrike) { Game.Instance.CombatEngagementController.ForceAttackOfOpportunity(attacker, evt.Initiator); } else if ((attacker.Get <UnitPartSpellbreaker>()?.active()).GetValueOrDefault()) { Game.Instance.CombatEngagementController.ForceAttackOfOpportunity(attacker, evt.Initiator); } } return(false); }
static void Postfix(ItemEntityWeapon __instance, ref bool __result) { bool spell_combat = false; UnitPartMagus unit_part_magus = __instance.Wielder?.Get <UnitPartMagus>(); if ((bool)(unit_part_magus) && unit_part_magus.SpellCombat.Active) { spell_combat = true; } var unit_part = __instance.Owner?.Get <UnitPartCanHold2hWeaponIn1h>(); if (unit_part == null) { return; } if (__instance.Blueprint.IsTwoHanded || (__instance.Blueprint.IsOneHandedWhichCanBeUsedWithTwoHands && __result == false && !spell_combat)) { __result = unit_part.canBeUsedAs2h(__instance); } }
public static bool IsRangedWeapon(this UnitPartMagus unitPartMagus, ItemEntityWeapon weapon) { return(GetMethod <UnitPartMagus, Func <UnitPartMagus, ItemEntityWeapon, bool> > ("IsRangedWeapon")(unitPartMagus, weapon)); }
public static bool HasOneHandedMeleeWeaponAndFreehand(this UnitPartMagus unitPartMagus, UnitDescriptor unit) { return(GetMethod <UnitPartMagus, Func <UnitPartMagus, UnitDescriptor, bool> > ("HasOneHandedMeleeWeaponAndFreehand")(unitPartMagus, unit)); }