Пример #1
0
        static void Postfix(ItemEntityWeapon __instance, bool forDollRoom, ref WeaponAnimationStyle __result)
        {
            if (__instance == null)
            {
                return;
            }
            if ((__instance.Blueprint.IsTwoHanded && !__instance.HoldInTwoHands) || //2h that is held as 1h
                ((__instance.Blueprint.IsTwoHanded || __instance.Blueprint.IsOneHandedWhichCanBeUsedWithTwoHands) && forDollRoom))    // make weapon look 1h in the doll room to see the shield if possible
            {
                var pair_slot = (__instance.HoldingSlot as HandSlot)?.PairSlot;
                if (!(pair_slot?.HasItem).GetValueOrDefault())
                {
                    return;
                }

                switch (__result)
                {
                case WeaponAnimationStyle.AxeTwoHanded:
                    __result = WeaponAnimationStyle.SlashingOneHanded;
                    break;

                case WeaponAnimationStyle.PiercingTwoHanded:
                    __result = WeaponAnimationStyle.PiercingOneHanded;
                    break;

                case WeaponAnimationStyle.SlashingTwoHanded:
                    __result = WeaponAnimationStyle.SlashingOneHanded;
                    break;

                default:
                    break;
                }
            }
        }
Пример #2
0
        public void OnEventDidTrigger(RuleDealDamage evt)
        {
            ItemEntityWeapon weapon = evt.DamageBundle.Weapon;

            if (evt.Initiator == this.Owner.Unit || weapon == null || (!weapon.Blueprint.IsMelee || !this.Owner.Unit.CombatState.EngagedUnits.Contains <UnitEntityData>(evt.Target)))
            {
                return;
            }
            int max_extra_attacks = num_extra_attacks.Calculate(this.Fact.MaybeContext);

            if (this.m_LastUseTime + 1.Rounds().Seconds > Game.Instance.TimeController.GameTime)
            {
                if (extra_attacks_used < max_extra_attacks)
                {
                    extra_attacks_used++;
                }
                else
                {
                    return;
                }
            }
            else
            {
                this.m_LastUseTime = Game.Instance.TimeController.GameTime;
                extra_attacks_used = 0;
            }

            Game.Instance.CombatEngagementController.ForceAttackOfOpportunity(this.Owner.Unit, evt.Target);
        }
        static bool Prefix(TwoWeaponFightingDamagePenalty __instance, RuleCalculateWeaponStats evt)
        {
            ItemEntityWeapon maybeWeapon1 = evt.Initiator.Body.PrimaryHand.MaybeWeapon;
            ItemEntityWeapon maybeWeapon2 = evt.Initiator.Body.SecondaryHand.MaybeWeapon;

            var brawler_part = evt.Initiator?.Get <Brawler.UnitPartBrawler>();

            if ((brawler_part?.checkTwoWeapponFlurry()).GetValueOrDefault())
            {
                is_off_hand = false;
                return(false);
            }

            if (evt.Weapon == null ||
                maybeWeapon1 == null ||
                maybeWeapon2 == null ||
                (maybeWeapon1.Blueprint.IsNatural && (!maybeWeapon1.Blueprint.IsUnarmed || Aux.isMainHandUnarmedAndCanBeIgnored(maybeWeapon1.Blueprint, evt.Initiator.Descriptor))) ||
                (maybeWeapon2.Blueprint.IsNatural && (!maybeWeapon2.Blueprint.IsUnarmed || Aux.isOffHandUnarmedAndCanBeIgnored(maybeWeapon2.Blueprint, evt.Initiator.Descriptor))) ||
                maybeWeapon2 != evt.Weapon ||
                (bool)evt.Initiator.Descriptor.State.Features.DoubleSlice ||
                ((evt.Weapon?.Blueprint.IsUnarmed).GetValueOrDefault() && !is_off_hand)
                )
            {
                is_off_hand = false;
                return(false);
            }
            evt.SecondaryWeapon = true;
            is_off_hand         = false;
            return(false);
        }
Пример #4
0
        public bool canBeUsedAs2h(ItemEntityWeapon weapon)
        {
            bool can_use_at_all = false;

            foreach (var b in buffs)
            {
                bool can_use = false;
                bool can_2h  = false;
                b.CallComponents <CanUse2hWeaponAs1hBase>(c => { can_2h = c.canBeUsedAs2h(weapon); can_use = c.canBeUsedOn(weapon); });
                if (can_use && can_2h)
                {
                    return(true);
                }
                can_use_at_all = can_use_at_all || can_use;
            }

            if (!can_use_at_all)
            {
                HandSlot pair_slot = (weapon?.HoldingSlot as HandSlot)?.PairSlot;
                if (pair_slot != null)
                {
                    return(!pair_slot.HasItem);
                }
                return(false);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        public override bool canBeUsedOn(ItemEntityWeapon weapon)
        {
            if (!weapon.Blueprint.IsTwoHanded)
            {
                return(false);
            }
            HandSlot holding_slot = weapon?.HoldingSlot as HandSlot;

            if (holding_slot == null)
            {
                return(false);
            }

            if (!holding_slot.PairSlot.HasItem)
            {
                return(false);
            }

            if (holding_slot.PairSlot.MaybeShield == null)
            {
                return(false);
            }

            var shield_proficiency = holding_slot.PairSlot.MaybeShield.ArmorComponent.Blueprint.ProficiencyGroup;

            if (shield_proficiency == Kingmaker.Blueprints.Items.Armors.ArmorProficiencyGroup.Buckler)
            {
                return(false);
            }

            return(weapon.Blueprint.FighterGroup == WeaponFighterGroup.Spears || weapon.Blueprint.FighterGroup == WeaponFighterGroup.Polearms);
        }
Пример #6
0
        public static bool checkHasFeralCombat(UnitEntityData unit, ItemEntityWeapon weapon, bool allow_ki_focus = false, bool allow_crusaders_flurry = false)
        {
            if (weapon == null || unit == null)
            {
                return(false);
            }
            if (weapon.Blueprint.Category == WeaponCategory.UnarmedStrike)
            {
                return(true);
            }

            if (allow_crusaders_flurry && unit.Descriptor.Progression.Features.Enumerable.Where(p => p.Blueprint == crusaders_flurry).Any(p => (p.Param == weapon.Blueprint.Category)))
            {
                return(true);
            }

            if (allow_ki_focus && unit.Descriptor.Progression.Features.Enumerable.Where(p => p.Blueprint == ki_focus_weapon).Any(p => (p.Param == weapon.Blueprint.Category)))
            {
                return(true);
            }

            if (!natural_weapon_type_fact_map.Keys.Contains(weapon.Blueprint.Category))
            {
                return(false);
            }
            return(unit.Descriptor.HasFact(natural_weapon_type_fact_map[weapon.Blueprint.Category]));
            //return unit.Descriptor.Progression.Features.HasFact(natural_weapon_type_fact_map[weapon.Blueprint.Category]);
        }
Пример #7
0
 static void Postfix(ItemEntityWeapon __instance, ref bool __result)
 {
     if (__result)
     {
         __result = __instance?.Blueprint.GetComponent <ForcePrimary>() == null;
     }
 }
        static public void Postfix(UnitPartWeaponTraining __instance, ItemEntityWeapon weapon, ref int __result)
        {
            if (weapon == null)
            {
                return;
            }

            if (!weapon.Blueprint.IsTwoHanded || !weapon.Blueprint.IsMelee)
            {
                return;
            }

            var fact = __instance.Owner.GetFact(two_handed_weapon_training);

            if (fact == null)
            {
                return;
            }
            var rank2h = fact.GetRank();

            if (rank2h > __result)
            {
                __result = rank2h;
            }
        }
 public bool CheckWeapon(ItemEntityWeapon weapon)
 {
     if (!this.AllNaturalAndUnarmed || !weapon.Blueprint.IsNatural && !weapon.Blueprint.IsUnarmed)
     {
         return(weapon.Blueprint.Category == this.Category);
     }
     return(true);
 }
Пример #10
0
        public static void toggleThrown(ItemEntityWeapon weapon, UnitEntityData wielder)
        {
            weapon.OnWillUnequip();
            var new_blueprint = weapon.Blueprint.GetComponent <WeaponBlueprintHolder>().blueprint_weapon;

            Helpers.SetField(weapon, "m_Blueprint", new_blueprint);
            weapon.OnDidEquipped(wielder.Descriptor);
        }
Пример #11
0
 public static void Postfix(ItemEntityWeapon __instance, UnitDescriptor owner, ref bool __result)
 {
     if (settings.toggleEquipmentRestrictions)
     {
         var blueprint = __instance.Blueprint as BlueprintItemEquipment;
         __result = blueprint == null ? false : blueprint.CanBeEquippedBy(owner);
     }
 }
Пример #12
0
        public bool worksOn(ItemEntityWeapon weapon)
        {
            bool res = false;

            fact?.CallComponents <KineticistEnergizeWeapon>(c => res = c.worksOn(weapon));

            return(res);
        }
Пример #13
0
        public override bool canBeUsedOn(ItemEntityWeapon weapon)
        {
            if (weapon == null)
            {
                return(false);
            }

            return(weapon.Blueprint.Category == WeaponCategory.SpikedHeavyShield || weapon.Blueprint.Category == WeaponCategory.WeaponHeavyShield);
        }
Пример #14
0
        private bool checkWeapon([CanBeNull] ItemEntityWeapon weapon)
        {
            if (weapon == null)
            {
                return(false);
            }

            return(required_categories.Contains(weapon.Blueprint.Category));
        }
Пример #15
0
        public override bool canBeUsedOn(ItemEntityWeapon weapon)
        {
            if (weapon == null)
            {
                return(false);
            }

            return(categories.Contains(weapon.Blueprint.Category));
        }
        public override bool Bypassed(BaseDamage damage, ItemEntityWeapon weapon)
        {
            EnergyDamage energyDamage = damage as EnergyDamage;

            if (energyDamage != null)
            {
                return(energyDamage.EnergyType != this.Type);
            }
            return(true);
        }
Пример #17
0
        int getBonus(ItemEntityWeapon weapon)
        {
            var num          = this.Context.MaybeCaster?.Get <UnitPartWeaponTraining>()?.GetWeaponRank(weapon);
            var caster_bonus = (int)(num.GetValueOrDefault() * multiplier);

            var num2          = this.Owner?.Get <UnitPartWeaponTraining>()?.GetWeaponRank(weapon);
            var wielder_bonus = num2.GetValueOrDefault();

            return(caster_bonus - wielder_bonus);
        }
        public override void OnFactActivate()
        {
            m_unlock = false;
            var unit = this.Owner;

            if (unit == null)
            {
                return;
            }

            var weapon = unit.Body.PrimaryHand.HasWeapon ? unit.Body.PrimaryHand.MaybeWeapon : unit.Body.EmptyHandWeapon;

            if (weapon == null)
            {
                return;
            }

            if (!allowed_types.Empty() && !allowed_types.Contains(weapon.Blueprint.Type))
            {
                return;
            }
            int bonus = getRemainingGroupSize() - 1;

            if (bonus < 0)
            {
                return;
            }

            if (bonus >= enchantments.Length)
            {
                bonus = enchantments.Length - 1;
            }


            if (weapon.Enchantments.HasFact(enchantments[bonus]))
            {
                return;
            }

            if (weapon.EnchantmentValue != 0 && only_non_magical)
            {
                return;
            }
            m_Enchantment = weapon.AddEnchantment(enchantments[bonus], Context, new Rounds?());



            if (lock_slot && !weapon.IsNonRemovable)
            {
                weapon.IsNonRemovable = true;
                m_unlock = true;
            }
            //m_Enchantment.RemoveOnUnequipItem = remove_on_unequip;
            m_Weapon = weapon;
        }
Пример #19
0
        public override bool canBeUsedOn(ItemEntityWeapon weapon)
        {
            if (require_full_proficiency &&
                !(weapon.Owner?.Get <WeaponsFix.UnitPartFullProficiency>()?.hasFullProficiency(category)).GetValueOrDefault())
            {
                return(false);
            }

            return((weapon.Blueprint?.Category).GetValueOrDefault() == category &&
                   !except_types.Contains(weapon?.Blueprint?.Type));
        }
Пример #20
0
        public override bool canBeUsedAs2h(ItemEntityWeapon weapon)
        {
            HandSlot holding_slot = weapon?.HoldingSlot as HandSlot;

            if (holding_slot == null)
            {
                return(false);
            }

            return(Helpers.hasFreeHand(holding_slot.PairSlot));
        }
        public override void OnFactActivate()
        {
            m_unlock = false;
            var unit = this.Owner;

            if (unit == null)
            {
                return;
            }

            var weapon = unit.Body.PrimaryHand.HasWeapon ? unit.Body.PrimaryHand.MaybeWeapon : unit.Body.EmptyHandWeapon;

            if (weapon == null)
            {
                return;
            }

            if (!allowed_types.Empty() && !allowed_types.Contains(weapon.Blueprint.Type))
            {
                return;
            }

            if (!Context.HasMetamagic(metamagic))
            {
                return;
            }

            if (weapon.Enchantments.HasFact(enchantment))
            {
                return;
            }

            /*var fact = weapon.Enchantments.Find(x => x.Blueprint == enchantment);
             * if (fact != null)
             * {
             *  weapon.RemoveEnchantment(fact);
             * }*/

            if (weapon.EnchantmentValue != 0 && only_non_magical)
            {
                return;
            }

            m_Enchantment = weapon.AddEnchantment(enchantment, Context, new Rounds?());

            if (lock_slot && !weapon.IsNonRemovable)
            {
                weapon.IsNonRemovable = true;
                m_unlock = true;
            }
            //m_Enchantment.RemoveOnUnequipItem = remove_on_unequip;
            m_Weapon = weapon;
        }
Пример #22
0
        public override void OnTrigger(RulebookEventContext context)
        {
            if (!Weapon.IsMelee)
            {
                return;
            }

            Result = Initiator.GetActiveCombatManeuverToggle();

            if (Result == CombatManeuver.Trip)
            {
                UnitState state = Target.Descriptor.State;
                // same checks as in UnitProneController, if this is true (and the unit is not in a cutscene), state.Prone.Active will be true on the next tick and we also don't want to trip again.
                if (state.Prone.Active || state.Prone.ShouldBeActive || !state.IsConscious || state.HasCondition(UnitCondition.Prone) || state.HasCondition(UnitCondition.Sleeping) || state.HasCondition(UnitCondition.Unconscious))
                {
                    Result = CombatManeuver.None;
                }
            }
            else if (Result == CombatManeuver.Disarm)
            {
                bool canBeDisarmed = false;
                // same checks as in RuleCombatManeuver. If the unit cannot be disarmed (further), don't attempt to disarm.
                ItemEntityWeapon maybeWeapon  = Target.Body.PrimaryHand.MaybeWeapon;
                ItemEntityWeapon maybeWeapon2 = Target.Body.SecondaryHand.MaybeWeapon;

                if (maybeWeapon != null && !maybeWeapon.Blueprint.IsUnarmed && !maybeWeapon.Blueprint.IsNatural && !Target.Descriptor.Buffs.HasFact(BlueprintRoot.Instance.SystemMechanics.DisarmMainHandBuff))
                {
                    canBeDisarmed = true;
                }
                else if (maybeWeapon2 != null && !maybeWeapon2.Blueprint.IsUnarmed && !maybeWeapon2.Blueprint.IsNatural && !Target.Descriptor.Buffs.HasFact(BlueprintRoot.Instance.SystemMechanics.DisarmOffHandBuff))
                {
                    canBeDisarmed = true;
                }

                if (!canBeDisarmed)
                {
                    Result = CombatManeuver.None;
                }
            }
            else if (Result == CombatManeuver.SunderArmor)
            {
                if (Target.Descriptor.Buffs.HasFact(BlueprintRoot.Instance.SystemMechanics.SunderArmorBuff))
                {
                    Result = CombatManeuver.None;
                }
            }

            if (ForceNormalAttack)
            {
                Result = CombatManeuver.None;
            }
        }
        public static Concealment Calculate([NotNull] UnitEntityData initiator, [NotNull] UnitEntityData target, bool attack = false)
        {
            UnitPartConcealment         unitPartConcealment         = initiator.Get <UnitPartConcealment>();
            UnitPartOutgoingConcealment unitPartOutgoingConcealment = initiator.Get <UnitPartOutgoingConcealment>();

            if (unitPartOutgoingConcealment?.m_Concealments == null)
            {
                return(Concealment.None); //no concelement update
            }

            bool        has_true_seeing = initiator.Descriptor.State.HasCondition(UnitCondition.TrueSeeing);
            Concealment a = Concealment.None;
            var         ignore_fog_concealement_part = initiator.Get <UnitPartIgnoreFogConcealement>();

            foreach (UnitPartConcealment.ConcealmentEntry concealment in unitPartOutgoingConcealment.m_Concealments)
            {
                if (concealment.Descriptor == ConcealmentDescriptor.Fog && ignore_fog_concealement_part != null && ignore_fog_concealement_part.active())
                {
                    continue;
                }

                if (concealment.Descriptor != ConcealmentDescriptor.Fog && concealment.Descriptor != ConcealmentDescriptor.InitiatorIsBlind && has_true_seeing)
                {
                    continue;
                }

                if (!concealment.OnlyForAttacks || attack)
                {
                    if (concealment.DistanceGreater > 0.Feet())
                    {
                        float num1 = initiator.DistanceTo(target);
                        float num2 = initiator.View.Corpulence + target.View.Corpulence;
                        if ((double)num1 <= (double)concealment.DistanceGreater.Meters + (double)num2)
                        {
                            continue;
                        }
                    }
                    if (concealment.RangeType.HasValue)
                    {
                        RuleAttackRoll   ruleAttackRoll   = Rulebook.CurrentContext.LastEvent <RuleAttackRoll>();
                        ItemEntityWeapon itemEntityWeapon = ruleAttackRoll == null?initiator.GetFirstWeapon() : ruleAttackRoll.Weapon;

                        if (itemEntityWeapon == null || !AttackTypeAttackBonus.CheckRangeType(itemEntityWeapon.Blueprint, concealment.RangeType.Value))
                        {
                            continue;
                        }
                    }
                    a = UnitPartOutgoingConcealment.Max(a, concealment.Concealment);
                }
            }
            return(a);
        }
        static void Postfix(ItemEntityWeapon __instance, UnitDescriptor owner, ref bool __result)
        {
            if (__result)
            {
                return;
            }

            bool?nullable = (__instance.Blueprint as BlueprintItemEquipment)?.CanBeEquippedBy(owner);

            if (nullable.HasValue && nullable.Value)
            {
                __result = Helpers.isSummoned(__instance);
            }
        }
Пример #25
0
        public bool worksOn(ItemEntityWeapon weapon)
        {
            if (weapon == null)
            {
                return(false);
            }

            if (kinetic_fist)
            {
                return(weapon.Blueprint.IsNatural || weapon.Blueprint.IsUnarmed);
            }
            else
            {
                return(weapon == this.Owner.Body?.PrimaryHand?.MaybeWeapon);
            }
        }
 public static bool checkHasFeralCombat(UnitEntityData unit, ItemEntityWeapon weapon)
 {
     if (weapon == null || unit == null)
     {
         return(false);
     }
     if (weapon.Blueprint.Category == WeaponCategory.UnarmedStrike)
     {
         return(true);
     }
     if (!natural_weapon_type_fact_map.Keys.Contains(weapon.Blueprint.Category))
     {
         return(false);
     }
     return(unit.Descriptor.Progression.Features.HasFact(natural_weapon_type_fact_map[weapon.Blueprint.Category]));
 }
        private void deactivateEnchants()
        {
            if (m_PrimaryHandEnchantment != null && m_PriamryHandWeapon != null)
            {
                m_PrimaryHandEnchantment.Owner?.RemoveEnchantment(this.m_PrimaryHandEnchantment);
                m_PrimaryHandEnchantment = null;
                m_PriamryHandWeapon      = null;
            }

            if (m_SecondaryHandEnchantment != null && m_SecondaryHandWeapon != null)
            {
                m_SecondaryHandEnchantment.Owner?.RemoveEnchantment(this.m_SecondaryHandEnchantment);
                m_SecondaryHandEnchantment = null;
                m_SecondaryHandWeapon      = null;
            }
        }
        public override void OnFactDeactivate()
        {
            base.OnFactDeactivate();
            if (this.m_Applied == null)
            {
                return;
            }

            if (disable_aoo)
            {
                this.Owner.State.RemoveCondition(UnitCondition.DisableAttacksOfOpportunity);
            }
            this.m_Applied.HoldingSlot?.Lock.Release();
            this.m_Applied.HoldingSlot?.RemoveItem();
            ItemsCollection.DoWithoutEvents((Action)(() => this.m_Applied.Collection?.Remove((ItemEntity)this.m_Applied)));
            this.m_Applied = (ItemEntityWeapon)null;
        }
        static public void Postfix(UnitPartWeaponTraining __instance, ItemEntityWeapon weapon, ref int __result)
        {
            if (weapon == null)
            {
                return;
            }
            //allow weapon training, arsenal chaplain weapon training and two-handed fighter weapon training to stack
            if (weapon.Blueprint.IsTwoHanded && weapon.Blueprint.IsMelee)
            {
                __result += (__instance.Owner.GetFact(two_handed_weapon_training)?.GetRank()).GetValueOrDefault();
            }

            if (checkFeature(__instance.Owner, weapon.Blueprint.Category, weapon_focus, NewFeats.deity_favored_weapon))
            {
                __result += (__instance.Owner.GetFact(Warpriest.arsenal_chaplain_weapon_training)?.GetRank()).GetValueOrDefault();
            }
        }
Пример #30
0
        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);
                }
            }
        }