From 32990e19a54c4417ca8a85a83309c93da1f33ac3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 18 Feb 2025 14:59:46 -0500 Subject: [PATCH] v3.0.0: fixed stasis buff durations, and added life linking in stasis --- .../shatteredpixeldungeon/actors/Actor.java | 7 ++++- .../actors/hero/spells/BeamingRay.java | 8 +++-- .../actors/hero/spells/LifeLinkSpell.java | 31 +++++++++++++------ .../actors/hero/spells/Stasis.java | 9 ++++-- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java index 6a0e4ca78..e5cb59d04 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java @@ -91,7 +91,12 @@ public abstract class Actor implements Bundlable { } public void clearTime() { - time = 0; + spendConstant(-Actor.now()); + if (this instanceof Char){ + for (Buff b : ((Char) this).buffs()){ + b.spendConstant(-Actor.now()); + } + } } public void timeToNow() { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BeamingRay.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BeamingRay.java index a119f382f..28e195a91 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BeamingRay.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/BeamingRay.java @@ -24,7 +24,9 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.hero.spells; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LifeLink; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.cleric.PowerOfMany; @@ -119,13 +121,15 @@ public class BeamingRay extends TargetedClericSpell { } if (ally == Stasis.getStasisAlly()){ - //TODO buffs ally.pos = telePos; - ally.clearTime(); GameScene.add((Mob) ally); hero.buff(Stasis.StasisBuff.class).detach(); hero.sprite.parent.add( new Beam.SunRay(hero.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(telePos))); + + if (ally.buff(LifeLink.class) != null){ + Buff.prolong(Dungeon.hero, LifeLink.class, ally.buff(LifeLink.class).cooldown()).object = ally.id(); + } } else { hero.sprite.parent.add( new Beam.SunRay(ally.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(telePos))); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/LifeLinkSpell.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/LifeLinkSpell.java index a0bfaa9b1..3976ce8c5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/LifeLinkSpell.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/LifeLinkSpell.java @@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.cleric.Pow import com.shatteredpixel.shatteredpixeldungeon.effects.Beam; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HolyTome; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.HeroIcon; @@ -54,7 +55,7 @@ public class LifeLinkSpell extends ClericSpell { public boolean canCast(Hero hero) { return super.canCast(hero) && hero.hasTalent(Talent.LIFE_LINK) - && PowerOfMany.getPoweredAlly() != null; + && (PowerOfMany.getPoweredAlly() != null || Stasis.getStasisAlly() != null); } @Override @@ -65,19 +66,31 @@ public class LifeLinkSpell extends ClericSpell { @Override public void onCast(HolyTome tome, Hero hero) { - Char ally = PowerOfMany.getPoweredAlly(); - - hero.sprite.zap(ally.pos); - hero.sprite.parent.add( - new Beam.HealthRay(hero.sprite.center(), ally.sprite.center())); - int duration = 4 + 2*hero.pointsInTalent(Talent.LIFE_LINK); - Buff.prolong(hero, LifeLink.class, duration).object = ally.id(); - Buff.prolong(ally, LifeLink.class, duration).object = hero.id(); + Char ally = PowerOfMany.getPoweredAlly(); + if (ally != null) { + hero.sprite.zap(ally.pos); + hero.sprite.parent.add( + new Beam.HealthRay(hero.sprite.center(), ally.sprite.center())); + + Buff.prolong(hero, LifeLink.class, duration).object = ally.id(); + } else { + ally = Stasis.getStasisAlly(); + hero.sprite.operate(hero.pos); + hero.sprite.parent.add( + new Beam.HealthRay(DungeonTilemap.tileCenterToWorld(hero.pos), hero.sprite.center())); + } + + Buff.prolong(ally, LifeLink.class, duration).object = hero.id(); Buff.prolong(ally, LifeLinkSpellBuff.class, duration); + if (ally == Stasis.getStasisAlly()){ + ally.buff(LifeLink.class).clearTime(); + ally.buff(LifeLinkSpellBuff.class).clearTime(); + } + hero.spendAndNext(Actor.TICK); onSpellCast(tome, hero); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Stasis.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Stasis.java index 5fb3b777f..f54555e51 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Stasis.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/spells/Stasis.java @@ -93,7 +93,6 @@ public class Stasis extends ClericSpell { hero.sprite.zap(ally.pos); MagicMissile.boltFromChar(hero.sprite.parent, MagicMissile.LIGHT_MISSILE, ally.sprite, hero.pos, null); - //TODO need to preserve buffs properly, this half works, makes durations wacky (based on current Actor.now values) LinkedHashSet buffs = ally.buffs(); Actor.remove(ally); ally.sprite.killAndErase(); @@ -104,6 +103,7 @@ public class Stasis extends ClericSpell { ally.add(b); } } + ally.clearTime(); Buff.prolong(hero, StasisBuff.class, 20 + 20*hero.pointsInTalent(Talent.STASIS)).stasisAlly = (Mob)ally; Sample.INSTANCE.play(Assets.Sounds.TELEPORT); @@ -112,7 +112,7 @@ public class Stasis extends ClericSpell { hero.buff(LifeLink.class).detach(); } - //TODO need code in beaming ray and life link to work here, also life link cleric spells? + //TODO life link cleric spells? hero.spendAndNext(Actor.TICK); Dungeon.observe(); @@ -162,13 +162,16 @@ public class Stasis extends ClericSpell { spawnPoints.add(target.pos + PathFinder.NEIGHBOURS8[Random.Int(8)]); } stasisAlly.pos = Random.element(spawnPoints); - stasisAlly.clearTime(); GameScene.add(stasisAlly); if (stasisAlly instanceof DirectableAlly){ ((DirectableAlly) stasisAlly).clearDefensingPos(); } + if (stasisAlly.buff(LifeLink.class) != null){ + Buff.prolong(Dungeon.hero, LifeLink.class, stasisAlly.buff(LifeLink.class).cooldown()).object = stasisAlly.id(); + } + ScrollOfTeleportation.appear(stasisAlly, stasisAlly.pos); Sample.INSTANCE.play(Assets.Sounds.TELEPORT);