From 5d31446c54372e6b0c082ef9c7b870126fea490e Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 11 Sep 2022 23:33:22 +0200 Subject: [PATCH] You can use generosity to make the shield spell placeable --- .../ability/magic/spell/effect/ShieldSpell.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java index 3cdbe28f..1024978e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ShieldSpell.java @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.Situation; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; +import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.particle.MagicParticleEffect; import com.minelittlepony.unicopia.particle.ParticleHandle; import com.minelittlepony.unicopia.particle.SphereParticleEffect; @@ -44,6 +45,14 @@ public class ShieldSpell extends AbstractSpell { super(type, traits); } + @Override + public boolean apply(Caster source) { + if (getTraits().get(Trait.GENEROSITY) > 0) { + return toPlaceable().apply(source); + } + return super.apply(source); + } + @Override public void setDead() { super.setDead(); @@ -108,9 +117,13 @@ public class ShieldSpell extends AbstractSpell { * Calculates the maximum radius of the shield. aka The area of effect. */ public double getDrawDropOffRange(Caster source) { - float multiplier = source.getMaster() != null && source.getMaster().isSneaking() ? 1 : 2; + float multiplier = source instanceof Pony pony && pony.getMaster().isSneaking() ? 1 : 2; float min = 4 + getTraits().get(Trait.POWER); - return (min + (source.getLevel().getScaled(4) * 2)) / multiplier; + double range = (min + (source.getLevel().getScaled(4) * 2)) / multiplier; + if (source instanceof Pony && range > 2) { + range = Math.sqrt(range); + } + return range; } protected boolean isValidTarget(Caster source, Entity entity) {