public override void OverrideGameValues() { TurretMaxDeployCount.UpdateDescription(2); ShieldMaxDeployCount.UpdateDescription(1); On.RoR2.CharacterMaster.GetDeployableSameSlotLimit += (orig, self, slot) => { if (TurretMaxDeployCount.IsNotDefault() && slot == DeployableSlot.EngiTurret) { return(TurretMaxDeployCount.Value); } if (ShieldMaxDeployCount.IsNotDefault() && slot == DeployableSlot.EngiBubbleShield) { return(ShieldMaxDeployCount.Value); } return(orig(self, slot)); }; // Workaround for more than 8 max grenades if (GrenadeMinFireAmount.ConfigEntryDescriptionWrapper.Value >= 8 || GrenadeMaxFireAmount.ConfigEntryDescriptionWrapper.Value >= 8) { On.EntityStates.Engi.EngiWeapon.FireGrenades.OnEnter += (orig, self) => { Assembly assembly = self.GetType().Assembly; Type fireGrenades = assembly.GetClass("EntityStates.Engi.EngiWeapon", "FireGrenades"); orig(self); self.SetFieldValue("duration", fireGrenades.GetFieldValue <float>("baseDuration") * self.GetFieldValue <int>("grenadeCountMax") / 8f / self.GetFieldValue <float>("attackSpeedStat") ); }; } On.RoR2.RoR2Application.Start += (orig, self) => { orig(self); Assembly assembly = self.GetType().Assembly; Type shieldDeployed = typeof(EntityStates.Engi.EngiBubbleShield.Deployed); ShieldDeployedFields.ForEach(changer => changer.Apply(shieldDeployed)); if (ShieldEndlessDuration.Value) { EntityStates.Engi.EngiBubbleShield.Deployed.lifetime = float.PositiveInfinity; } Type chargeGrenades = assembly.GetClass("EntityStates.Engi.EngiWeapon", "ChargeGrenades"); ChargeGrenadesFields.ForEach(changer => changer.Apply(chargeGrenades)); if (GrenadeSetChargeCountToFireAmount.Value && GrenadeMaxFireAmount.ConfigEntryDescriptionWrapper.IsNotDefault()) { chargeGrenades.SetFieldValue("maxCharges", GrenadeMaxFireAmount.ConfigEntryDescriptionWrapper.Value); } }; }
public override void WriteNewHooks() { On.EntityStates.Commando.CommandoWeapon.FireFMJ.OnEnter += (orig, self) => { PhaseRoundFields.ForEach(changer => changer.Apply(self)); orig(self); }; // On.EntityStates.Commando.DodgeState.OnEnter += (orig, self) => // { // orig(self); // // if (DashInvulnerability.Value) // { // if (DashInvulnerabilityTimer.IsDefault()) // { // Transform transform = self.InvokeMethod<Transform>("GetModelTransform"); // // HurtBoxGroup hurtBoxGroup = transform.GetComponent<HurtBoxGroup>(); // ++hurtBoxGroup.hurtBoxesDeactivatorCounter; // } // else // { // self.outer.commonComponents.characterBody.AddTimedBuff(BuffIndex.HiddenInvincibility, // DashInvulnerabilityTimer.Value); // } // } // }; // On.EntityStates.Commando.DodgeState.OnExit += (orig, self) => // { // if (DashInvulnerability.Value && DashInvulnerabilityTimer.IsDefault()) // { // Transform transform = self.InvokeMethod<Transform>("GetModelTransform"); // // HurtBoxGroup hurtBoxGroup = transform.GetComponent<HurtBoxGroup>(); // --hurtBoxGroup.hurtBoxesDeactivatorCounter; // } // // orig(self); // }; 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; special.rechargeStopwatch = special.rechargeStopwatch + (float)finalRechargeInterval.GetValue(special) * DoubleTapHitLowerSpecialCooldownPercent.Value; } return(result); }; return(ba); }); }; } }