Skip to content

Commit

Permalink
Make sure vanilla skills run only on that variant.
Browse files Browse the repository at this point in the history
Realised this was happening because any scepter skill on Acrid did the
funny Plague thing.
While the other ones would only happen on states inheriting from the
vanilla one instead of all of them,might as well get them right too.
  • Loading branch information
yekoc committed Sep 22, 2022
1 parent 08388e4 commit 6722191
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/ArtificerFlamethrower2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private void IL_FlamethrowerFireGauntlet(ILContext il)
{
c.Emit(OpCodes.Ldarg_0);
c.EmitDelegate<Func<BulletAttack, EntityStates.Mage.Weapon.Flamethrower, BulletAttack>>((origAttack, state) => {
if (AncientScepterItem.instance.GetCount(state.outer.commonComponents.characterBody) < 1) return origAttack;
if (state.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef != myDef) return origAttack;
origAttack.hitCallback = (BulletAttack self, ref BulletAttack.BulletHit h) => {
ProjectileManager.instance.FireProjectile(new FireProjectileInfo
{
Expand Down
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/ArtificerFlyUp2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void On_FlyUpStateEnter(On.EntityStates.Mage.FlyUpState.orig_OnEnter ori
{
var origRadius = FlyUpState.blastAttackRadius;
var origDamage = FlyUpState.blastAttackDamageCoefficient;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
FlyUpState.blastAttackRadius *= 4f;
FlyUpState.blastAttackDamageCoefficient *= 2f;
Expand Down
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/Bandit2ResetRevolver2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void BaseFireSidearmRevolverState_OnEnter(On.EntityStates.Bandit2.Weapon
{
orig(self);
bool isScepter = self is EntityStates.Bandit2.Weapon.FireSidearmResetRevolver
&& AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0;
&& self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef;
if (isScepter)
{
Ray aimRay = self.GetAimRay();
Expand Down
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/Bandit2SkullRevolver2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage
{
if ((damageInfo.damageType & DamageType.GiveSkullOnKill) == DamageType.GiveSkullOnKill)
{
if (self.body && self.body.master && damageInfo.attacker && damageInfo.attacker.GetComponent<HealthComponent>() && AncientScepterItem.instance.GetCount(damageInfo.attacker.GetComponent<CharacterBody>()) > 0)
if (self.body && self.body.master && damageInfo.attacker && damageInfo.attacker.GetComponent<HealthComponent>() && damageInfo.attacker.GetComponent<CharacterBody>().skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
var attackerHC = damageInfo.attacker.GetComponent<HealthComponent>();
var baseAI = self.body.master.GetComponent<RoR2.CharacterAI.BaseAI>();
Expand Down
6 changes: 3 additions & 3 deletions AncientScepter/ScepterSkills/CaptainAirstrike2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private bool On_CallAirstrikeBaseKeyIsDown(On.EntityStates.Captain.Weapon.CallAi
var isAirstrike = self is CallAirstrike1
|| self is CallAirstrike2
|| self is CallAirstrike3;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0 && isAirstrike) return false;
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef && isAirstrike) return false;
return orig(self);
}

Expand Down Expand Up @@ -123,7 +123,7 @@ private void On_CallAirstrikeBaseEnter(On.EntityStates.Captain.Weapon.CallAirstr
|| self is CallAirstrike2
|| self is CallAirstrike3;

if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0 && isAirstrike)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef && isAirstrike)
{
self.damageCoefficient = 5f;
self.AddRecoil(-1f, 1f, -1f, 1f);
Expand All @@ -133,7 +133,7 @@ private void On_CallAirstrikeBaseEnter(On.EntityStates.Captain.Weapon.CallAirstr
private void On_SetupAirstrikeStateEnter(On.EntityStates.Captain.Weapon.SetupAirstrike.orig_OnEnter orig, EntityStates.Captain.Weapon.SetupAirstrike self) //exc
{
var origOverride = SetupAirstrike.primarySkillDef;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
SetupAirstrike.primarySkillDef = myCallDef;
}
Expand Down
6 changes: 3 additions & 3 deletions AncientScepter/ScepterSkills/CaptainAirstrikeAlt2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ internal override void UnloadBehavior()
private void CallAirstrikeAlt_ModifyProjectile(On.EntityStates.Captain.Weapon.CallAirstrikeAlt.orig_ModifyProjectile orig, CallAirstrikeAlt self, ref FireProjectileInfo fireProjectileInfo)
{
orig(self, ref fireProjectileInfo);
bool isScepter = AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0;
bool isScepter = self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef;
if (isScepter)
{
fireProjectileInfo.projectilePrefab = airstrikePrefab;
Expand All @@ -245,7 +245,7 @@ private void GlobalEventManager_OnHitEnemy(On.RoR2.GlobalEventManager.orig_OnHit
private void On_CallAirstrikeBaseEnter(On.EntityStates.Captain.Weapon.CallAirstrikeBase.orig_OnEnter orig, CallAirstrikeBase self)
{
orig(self);
bool isScepter = AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0
bool isScepter = self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef
&& self is EntityStates.Captain.Weapon.CallAirstrikeAlt;
if (isScepter)
{
Expand All @@ -256,7 +256,7 @@ private void On_CallAirstrikeBaseEnter(On.EntityStates.Captain.Weapon.CallAirstr
private void On_SetupAirstrikeStateEnter(On.EntityStates.Captain.Weapon.SetupAirstrike.orig_OnEnter orig, EntityStates.Captain.Weapon.SetupAirstrike self) //exc
{
var origOverride = SetupAirstrike.primarySkillDef;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
SetupAirstrike.primarySkillDef = myCallDef;
}
Expand Down
10 changes: 5 additions & 5 deletions AncientScepter/ScepterSkills/CommandoBarrage2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal override void LoadBehavior()

private void FireSweepBarrage_FixedUpdate(On.EntityStates.Commando.CommandoWeapon.FireSweepBarrage.orig_FixedUpdate orig, FireSweepBarrage self)
{
if (AncientScepterItem.instance.GetCount(self.characterBody) > 0)
if (self.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
self.FixedUpdate();
self.fireTimer -= Time.fixedDeltaTime;
Expand All @@ -98,7 +98,7 @@ private void FireSweepBarrage_FixedUpdate(On.EntityStates.Commando.CommandoWeapo

private void FireSweepBarrage_Fire(On.EntityStates.Commando.CommandoWeapon.FireSweepBarrage.orig_Fire orig, FireSweepBarrage self)
{
if (AncientScepterItem.instance.GetCount(self.characterBody) > 0)
if (self.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
if (self.totalBulletsFired < self.totalBulletsToFire)
{
Expand Down Expand Up @@ -178,7 +178,7 @@ private void FireSweepBarrage_Fire(On.EntityStates.Commando.CommandoWeapon.FireS
private void FireSweepBarrage_OnEnter(On.EntityStates.Commando.CommandoWeapon.FireSweepBarrage.orig_OnEnter orig, FireSweepBarrage self)
{
orig(self);
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
if (self.targetHurtboxes.Count == 0)
{
Expand All @@ -200,7 +200,7 @@ internal override void UnloadBehavior()
private void On_FireBarrage_Enter(On.EntityStates.Commando.CommandoWeapon.FireBarrage.orig_OnEnter orig, FireBarrage self)
{
orig(self);
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
self.durationBetweenShots /= 2f;
self.bulletCount *= 2;
Expand All @@ -209,7 +209,7 @@ private void On_FireBarrage_Enter(On.EntityStates.Commando.CommandoWeapon.FireBa

private void On_FireBarrage_FireBullet(On.EntityStates.Commando.CommandoWeapon.FireBarrage.orig_FireBullet orig, FireBarrage self)
{
bool hasScep = AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0;
bool hasScep = self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef;
var origAmp = FireBarrage.recoilAmplitude;
var origRadius = FireBarrage.bulletRadius;
if (hasScep)
Expand Down
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/CommandoGrenade2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void On_FireFMJFire(On.EntityStates.GenericProjectileBaseState.orig_Fire
var cc = self.outer.commonComponents;
bool isBoosted = self is ThrowGrenade
&& Util.HasEffectiveAuthority(self.outer.networkIdentity)
&& AncientScepterItem.instance.GetCount(cc.characterBody) > 0;
&& cc.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef;
if (isBoosted) self.projectilePrefab = projReplacer;
orig(self);
if (isBoosted)
Expand Down
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/CrocoDisease2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal override void UnloadBehavior()
private void On_LightningOrbArrival(On.RoR2.Orbs.LightningOrb.orig_OnArrival orig, LightningOrb self)
{
orig(self);
if (self.lightningType != LightningOrb.LightningType.CrocoDisease || AncientScepterItem.instance.GetCount(self.attacker?.GetComponent<CharacterBody>()) < 1) return;
if (self.lightningType != LightningOrb.LightningType.CrocoDisease || self.attacker?.GetComponent<CharacterBody>().skillLocator.GetSkill(targetSlot).skillDef != myDef) return;
if (!self.target || !self.target.healthComponent) return;

var cpt = self.target.healthComponent.gameObject.GetComponentInChildren<DiseaseWard>()?.gameObject;
Expand Down
6 changes: 3 additions & 3 deletions AncientScepter/ScepterSkills/HuntressBallista2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal override void UnloadBehavior()
private void On_FireArrowSnipeFire(On.EntityStates.Huntress.Weapon.FireArrowSnipe.orig_FireBullet orig, FireArrowSnipe self, Ray aimRay)
{
orig(self, aimRay);
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) < 1) return;
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef != myDef) return;

for (var i = 1; i < 6; i++)
{
Expand All @@ -105,7 +105,7 @@ private void On_AimArrowSnipeEnter(On.EntityStates.Huntress.AimArrowSnipe.orig_O
orig(self);
var sloc = self.outer.commonComponents.skillLocator;
if (!sloc || !sloc.primary) return;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
sloc.primary.UnsetSkillOverride(self, AimArrowSnipe.primarySkillDef, GenericSkill.SkillOverridePriority.Contextual);
sloc.primary.SetSkillOverride(self, myCtxDef, GenericSkill.SkillOverridePriority.Contextual);
Expand All @@ -117,7 +117,7 @@ private void On_AimArrowSnipeExit(On.EntityStates.Huntress.AimArrowSnipe.orig_On
orig(self);
var sloc = self.outer.commonComponents.skillLocator;
if (!sloc || !sloc.primary) return;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
sloc.primary.UnsetSkillOverride(self, myCtxDef, GenericSkill.SkillOverridePriority.Contextual);
}
}
Expand Down
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/HuntressRain2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal override void UnloadBehavior()
private void On_ArrowRain_DoFireArrowRain(On.EntityStates.Huntress.ArrowRain.orig_DoFireArrowRain orig, ArrowRain self)
{
var origPrefab = ArrowRain.projectilePrefab;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0) ArrowRain.projectilePrefab = projReplacer;
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef) ArrowRain.projectilePrefab = projReplacer;
orig(self);
ArrowRain.projectilePrefab = origPrefab;
}
Expand Down
4 changes: 2 additions & 2 deletions AncientScepter/ScepterSkills/LoaderChargeFist2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void on_BaseSwingChargedFistEnter(On.EntityStates.Loader.BaseSwingCharge
{
orig(self);
if (!(self is SwingChargedFist)) return;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
self.minPunchForce *= 7f;
self.maxPunchForce *= 7f;
Expand All @@ -78,7 +78,7 @@ private void on_BaseSwingChargedFistEnter(On.EntityStates.Loader.BaseSwingCharge

private void BaseSwingChargedFist_OnMeleeHitAuthority(On.EntityStates.Loader.BaseSwingChargedFist.orig_OnMeleeHitAuthority orig, BaseSwingChargedFist self)
{
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) < 1) return;
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef != myDef) return;
var mTsf = self.outer.commonComponents.modelLocator?.modelTransform?.GetComponent<ChildLocator>()?.FindChild(self.swingEffectMuzzleString);
EffectManager.SpawnEffect(Resources.Load<GameObject>("prefabs/effects/omnieffect/OmniExplosionVFXCommandoGrenade"),
new EffectData
Expand Down
4 changes: 2 additions & 2 deletions AncientScepter/ScepterSkills/LoaderChargeZapFist2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal override void UnloadBehavior()
private void On_BaseChargeFistEnter(On.EntityStates.Loader.BaseChargeFist.orig_OnEnter orig, BaseChargeFist self)
{
orig(self);
if (!(self is ChargeZapFist) || AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) < 1) return;
if (!(self is ChargeZapFist) || self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef != myDef) return;
var mTsf = self.outer.commonComponents.modelLocator?.modelTransform?.GetComponent<ChildLocator>()?.FindChild(BaseChargeFist.chargeVfxChildLocatorName);
EffectManager.SpawnEffect(Resources.Load<GameObject>("prefabs/effects/MageLightningBombExplosion"),
new EffectData
Expand All @@ -96,7 +96,7 @@ private void IL_SwingZapFistMeleeHit(ILContext il)
c.Emit(OpCodes.Ldarg_0);
c.EmitDelegate<Func<GameObject, SwingZapFist, GameObject>>((origProj, state) =>
{
if (AncientScepterItem.instance.GetCount(state.outer.commonComponents.characterBody) < 1) return origProj;
if (state.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef != myDef) return origProj;
var mTsf = state.outer.commonComponents.modelLocator?.modelTransform?.GetComponent<ChildLocator>()?.FindChild(state.swingEffectMuzzleString);
EffectManager.SpawnEffect(Resources.Load<GameObject>("prefabs/effects/ImpactEffects/LightningStrikeImpact"),
new EffectData
Expand Down
4 changes: 2 additions & 2 deletions AncientScepter/ScepterSkills/MercEvis2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal override void UnloadBehavior()
private void Evt_GEMOnCharacterDeathGlobal(DamageReport rep)
{
var attackerState = rep.attackerBody?.GetComponent<EntityStateMachine>()?.state;
if (attackerState is Evis asEvis && AncientScepterItem.instance.GetCount(rep.attackerBody) > 0
if (attackerState is Evis asEvis && rep.attackerBody.skillLocator.GetSkill(targetSlot).skillDef == myDef
&& Vector3.Distance(rep.attackerBody.transform.position, rep.victim.transform.position) < Evis.maxRadius)
{
if (rep.attackerBody.inputBank.skill4.down == false)
Expand All @@ -81,7 +81,7 @@ private void Evt_GEMOnCharacterDeathGlobal(DamageReport rep)
private void On_EvisFixedUpdate(On.EntityStates.Merc.Evis.orig_FixedUpdate orig, Evis self)
{
var origDuration = Evis.duration;
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0) Evis.duration *= 2f;
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef) Evis.duration *= 2f;
orig(self);
Evis.duration = origDuration;
}
Expand Down
2 changes: 1 addition & 1 deletion AncientScepter/ScepterSkills/MercEvisProjectile2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal override void UnloadBehavior()
private void On_FireFMJEnter(On.EntityStates.GenericProjectileBaseState.orig_OnEnter orig, EntityStates.GenericProjectileBaseState self)
{
orig(self);
if (!(self is EntityStates.Merc.Weapon.ThrowEvisProjectile) || AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) < 1) return;
if (!(self is EntityStates.Merc.Weapon.ThrowEvisProjectile) || self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef != myDef) return;
if (!self.outer.commonComponents.skillLocator?.special) return;
var fireCount = self.outer.commonComponents.skillLocator.special.stock;
self.outer.commonComponents.skillLocator.special.stock = 0;
Expand Down
4 changes: 2 additions & 2 deletions AncientScepter/ScepterSkills/RailgunnerCryo2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void GlobalEventManager_OnHitEnemy(On.RoR2.GlobalEventManager.orig_OnHit
private void BaseFireSnipe_OnExit(On.EntityStates.Railgunner.Weapon.BaseFireSnipe.orig_OnExit orig, EntityStates.Railgunner.Weapon.BaseFireSnipe self)
{
orig(self);
if (self is EntityStates.Railgunner.Weapon.FireSnipeCryo && AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self is EntityStates.Railgunner.Weapon.FireSnipeCryo && self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
var cb = self.outer.commonComponents.characterBody;
if (cb)
Expand All @@ -107,7 +107,7 @@ private void BaseFireSnipe_OnExit(On.EntityStates.Railgunner.Weapon.BaseFireSnip
private void FireSnipeCryo_ModifyBullet(On.EntityStates.Railgunner.Weapon.FireSnipeCryo.orig_ModifyBullet orig, EntityStates.Railgunner.Weapon.FireSnipeCryo self, BulletAttack bulletAttack)
{
orig(self, bulletAttack);
if (AncientScepterItem.instance.GetCount(self.outer.commonComponents.characterBody) > 0)
if (self.outer.commonComponents.characterBody.skillLocator.GetSkill(targetSlot).skillDef == myDef)
{
bulletAttack.AddModdedDamageType(CustomDamageTypes.ScepterSlow80For30DT);

Expand Down
Loading

0 comments on commit 6722191

Please sign in to comment.