public bool CheckConditions(RuleCalculateWeaponStats evt) { if (this.FullAttack == ConditionEnum.Only && (evt.AttackWithWeapon == null || !evt.AttackWithWeapon.IsFullAttack) || this.FullAttack == ConditionEnum.Not && (evt.AttackWithWeapon == null || evt.AttackWithWeapon.IsFullAttack) || (this.FirstAttack == ConditionEnum.Only && (evt.AttackWithWeapon == null || !evt.AttackWithWeapon.IsFirstAttack) || this.FirstAttack == ConditionEnum.Not && (evt.AttackWithWeapon == null || evt.AttackWithWeapon.IsFirstAttack))) { return(false); } if (this.CheckCategory) { WeaponCategory?category = evt.Weapon?.Blueprint.Category; if (((category.GetValueOrDefault() != this.Category ? 1 : (!category.HasValue ? 1 : 0)) != 0) && !checkHasFeralCombat(evt.Initiator, evt.Weapon)) { return(false); } } return(!this.CheckTwoHanded || evt.Weapon != null && evt.Weapon.HoldInTwoHands && AttackTypeAttackBonus.CheckRangeType(evt.Weapon.Blueprint, AttackTypeAttackBonus.WeaponRangeType.Melee)); }
static bool getResult(RestrictionCanGatherPower __instance) { UnitPartKineticist unitPartKineticist = __instance.Owner.Get <UnitPartKineticist>(); if (unitPartKineticist == null) { return(false); } UnitBody body = __instance.Owner.Body; if (body.IsPolymorphed) { return(false); } ItemEntity maybeItem1 = body.PrimaryHand.MaybeItem; WeaponCategory?category = (maybeItem1 as ItemEntityWeapon)?.Blueprint.Category; bool flag = category.GetValueOrDefault() == WeaponCategory.KineticBlast && category.HasValue; if (maybeItem1 != null && !flag) { return(false); } ItemEntity maybeItem2 = body.SecondaryHand.MaybeItem; if (maybeItem2 == null) { return(true); } ArmorProficiencyGroup?proficiencyGroup = body.SecondaryHand.MaybeShield?.Blueprint.Type.ProficiencyGroup; if (proficiencyGroup.HasValue && (proficiencyGroup.GetValueOrDefault() != ArmorProficiencyGroup.TowerShield)) { return(unitPartKineticist.CanGatherPowerWithShield || Helpers.hasFreeHand(body.SecondaryHand)); } return(false); }
static bool Prefix(Demoralize __instance) { var tr = Harmony12.Traverse.Create(__instance); var target = tr.Property("Target").GetValue <TargetWrapper>(); MechanicsContext.Data data = ElementsContext.GetData <MechanicsContext.Data>(); MechanicsContext mechanicsContext = (data != null) ? data.Context : null; UnitEntityData unitEntityData = (mechanicsContext != null) ? mechanicsContext.MaybeCaster : null; if (unitEntityData == null || !target.IsUnit) { UberDebug.LogError(__instance, "Unable to apply buff: no context found", Array.Empty <object>()); return(false); } int num = 10 + target.Unit.Descriptor.Progression.CharacterLevel + target.Unit.Stats.Wisdom.Bonus; ModifiableValue.Modifier modifier = null; try { if (__instance.DazzlingDisplay && unitEntityData.Descriptor.State.Features.SwordlordWeaponProwess) { int num2 = 0; foreach (var feature in unitEntityData.Descriptor.Progression.Features) { var param = feature.Param; bool flag; if (param == null) { flag = false; } else { WeaponCategory?weaponCategory = param.WeaponCategory; WeaponCategory weaponCategory2 = WeaponCategory.DuelingSword; flag = (weaponCategory.GetValueOrDefault() == weaponCategory2 & weaponCategory != null); } if (flag) { num2++; } } modifier = unitEntityData.Stats.CheckIntimidate.AddModifier(num2, null, ModifierDescriptor.None); } var ruleSkillCheck = new RuleSkillCheck(unitEntityData, StatType.CheckIntimidate, num); var demoralize_bonus_part = mechanicsContext.MaybeCaster.Get <UnitPartDemoralizeBonus>(); if (demoralize_bonus_part != null) { ruleSkillCheck.Bonus.AddModifier(demoralize_bonus_part.getBonus(), null, ModifierDescriptor.UntypedStackable); } ruleSkillCheck = mechanicsContext.TriggerRule <RuleSkillCheck>(ruleSkillCheck); if (ruleSkillCheck.IsPassed) { int num3 = 1 + (ruleSkillCheck.RollResult - num) / 5 + (unitEntityData.Descriptor.State.Features.FrighteningThug ? 1 : 0); if (unitEntityData.Descriptor.State.Features.FrighteningThug && num3 >= 4) { target.Unit.Descriptor.AddBuff(__instance.GreaterBuff, mechanicsContext, new TimeSpan?(1.Rounds().Seconds)); } Buff buff = target.Unit.Descriptor.AddBuff(__instance.Buff, mechanicsContext, new TimeSpan?(num3.Rounds().Seconds)); if (unitEntityData.Descriptor.HasFact(__instance.ShatterConfidenceFeature) && buff != null) { Buff fact = target.Unit.Descriptor.AddBuff(__instance.ShatterConfidenceBuff, mechanicsContext, new TimeSpan?(num3.Rounds().Seconds)); buff.StoreFact(fact); } unitEntityData.Get <UnitPartActionOnDemoralize>()?.runActions(mechanicsContext, target.Unit, num, ruleSkillCheck.RollResult); var scoped_actions = (mechanicsContext?.SourceAbility?.GetComponents <ScopedDemoralizeActions>()).EmptyIfNull(); foreach (var s in scoped_actions) { s.actions.Run(); } } } finally { if (modifier != null) { modifier.Remove(); } } return(false); }