protected override void WriteNewHooks() { if (DoubleTapHitLowerSpecialCooldown.Value && DoubleTapHitLowerSpecialCooldownPercent.IsNotDefault()) { Type gsType = typeof(GenericSkill); FieldInfo finalRechargeInterval = gsType.GetField("finalRechargeInterval", BindingFlags.NonPublic | BindingFlags.Instance); IL.EntityStates.Commando.CommandoWeapon.FirePistol2.FireBullet += il => { ILCursor c = new ILCursor(il); c.GotoNext(x => x.MatchCallvirt(typeof(RoR2.BulletAttack).FullName, "Fire")); c.EmitDelegate <Func <BulletAttack, BulletAttack> >((BulletAttack ba) => { ba.hitCallback = (ref BulletAttack.BulletHit info) => { bool result = ba.DefaultHitCallback(ref info); if (info.entityObject?.GetComponent <HealthComponent>()) { SkillLocator skillLocator = ba.owner.GetComponent <SkillLocator>(); GenericSkill special = skillLocator.special; if (special.IsReady()) { return(result); } special.rechargeStopwatch = special.rechargeStopwatch + (float)finalRechargeInterval.GetValue(special) * DoubleTapHitLowerSpecialCooldownPercent.Value; } return(result); }; return(ba); }); }; } }
// Token: 0x06002137 RID: 8503 RVA: 0x0008F978 File Offset: 0x0008DB78 public BaseAI.SkillDriverEvaluation EvaluateSkillDrivers() { this.UpdateTargets(); BaseAI.SkillDriverEvaluation result = default(BaseAI.SkillDriverEvaluation); float num = 1f; if (this.bodyHealthComponent) { num = this.bodyHealthComponent.combinedHealthFraction; } float positiveInfinity = float.PositiveInfinity; if (this.bodySkillLocator) { for (int i = 0; i < this.skillDrivers.Length; i++) { AISkillDriver aiskillDriver = this.skillDrivers[i]; if (!aiskillDriver.noRepeat || !(this.skillDriverEvaluation.dominantSkillDriver == aiskillDriver)) { BaseAI.Target target = null; if (!aiskillDriver.requireEquipmentReady || this.body.equipmentSlot.stock > 0) { if (aiskillDriver.skillSlot != SkillSlot.None) { GenericSkill skill = this.bodySkillLocator.GetSkill(aiskillDriver.skillSlot); if ((aiskillDriver.requireSkillReady && (!skill || !skill.IsReady())) || (aiskillDriver.requiredSkill && (!skill || !(skill.skillDef == aiskillDriver.requiredSkill)))) { goto IL_327; } } if (aiskillDriver.minUserHealthFraction <= num && aiskillDriver.maxUserHealthFraction >= num) { switch (aiskillDriver.moveTargetType) { case AISkillDriver.TargetType.CurrentEnemy: if (this.GameObjectPassesSkillDriverFilters(this.currentEnemy, aiskillDriver, out positiveInfinity)) { target = this.currentEnemy; } break; case AISkillDriver.TargetType.NearestFriendlyInSkillRange: if (this.bodyInputBank) { this.buddySearch.teamMaskFilter = TeamMask.none; this.buddySearch.teamMaskFilter.AddTeam(this.master.teamIndex); this.buddySearch.sortMode = BullseyeSearch.SortMode.Distance; this.buddySearch.minDistanceFilter = aiskillDriver.minDistanceSqr; this.buddySearch.maxDistanceFilter = aiskillDriver.maxDistance; this.buddySearch.searchOrigin = this.bodyInputBank.aimOrigin; this.buddySearch.searchDirection = this.bodyInputBank.aimDirection; this.buddySearch.maxAngleFilter = 180f; this.buddySearch.filterByLoS = aiskillDriver.activationRequiresTargetLoS; this.buddySearch.RefreshCandidates(); if (this.body) { this.buddySearch.FilterOutGameObject(this.body.gameObject); } this.buddySearch.FilterCandidatesByHealthFraction(aiskillDriver.minTargetHealthFraction, aiskillDriver.maxTargetHealthFraction); HurtBox hurtBox = this.buddySearch.GetResults().FirstOrDefault <HurtBox>(); if (hurtBox && hurtBox.healthComponent) { this.buddy.gameObject = hurtBox.healthComponent.gameObject; this.buddy.bestHurtBox = hurtBox; } if (this.GameObjectPassesSkillDriverFilters(this.buddy, aiskillDriver, out positiveInfinity)) { target = this.buddy; } } break; case AISkillDriver.TargetType.CurrentLeader: if (this.GameObjectPassesSkillDriverFilters(this.leader, aiskillDriver, out positiveInfinity)) { target = this.leader; } break; case AISkillDriver.TargetType.Custom: if (this.GameObjectPassesSkillDriverFilters(this.customTarget, aiskillDriver, out positiveInfinity)) { target = this.customTarget; } break; } if (target != null) { result.dominantSkillDriver = aiskillDriver; result.target = target; result.separationSqrMagnitude = positiveInfinity; break; } } } } IL_327 :; } } return(result); }