From ac8d44c6fdf5a4488f3e0879bd505925996e7e0a Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 12 Feb 2020 18:53:33 -0500 Subject: [PATCH] v0.8.0: fixed various errors with life link --- .../shatteredpixeldungeon/actors/Char.java | 2 +- .../actors/buffs/LifeLink.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 891bcf7af..889d49554 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -423,7 +423,7 @@ public abstract class Char extends Actor { link.detach(); } } - dmg /= (links.size()+1); + dmg = (int)Math.ceil(dmg / (float)(links.size()+1)); for (LifeLink link : links){ Char ch = (Char)Actor.findById(link.object); ch.damage(dmg, LifeLink.class); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/LifeLink.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/LifeLink.java index d3b1bd989..fcd472234 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/LifeLink.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/LifeLink.java @@ -21,6 +21,8 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.watabou.utils.Bundle; @@ -36,6 +38,19 @@ public class LifeLink extends FlavourBuff { announced = true; } + @Override + public void detach() { + super.detach(); + Char ch = (Char)Actor.findById(object); + if (!target.isAlive() && ch != null){ + for (LifeLink l : ch.buffs(LifeLink.class)){ + if (l.object == target.id()){ + l.detach(); + } + } + } + } + @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle );