From 6083465b8e6166f2070b61a0d87437062cb96cc8 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 14 Mar 2022 23:42:53 -0400 Subject: [PATCH] v1.2.0: implemented buffs to summon elemental --- .../assets/messages/items/items.properties | 4 +-- .../actors/mobs/Elemental.java | 33 +++++++++++++++++-- .../items/spells/SummonElemental.java | 23 ++++++++----- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 8e7eb0543..7e13de0ba 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1103,8 +1103,8 @@ items.spells.summonelemental.name=summon elemental items.spells.summonelemental.ac_imbue=IMBUE items.spells.summonelemental.summon_limit=You can only have one elemental summoned at a time. items.spells.summonelemental.imbue_prompt=Imbue an item -items.spells.summonelemental.desc=This spell channels the energy of the elemental embers used to make it, and will allow you to summon a friendly elemental to fight with you! Only one elemental can be summoned at a time. -items.spells.summonelemental.desc_newborn=The spell is currently unimbued, and will summon a weaker _newborn elemental_. You can imbue an identified potion of liquid flame, potion of frost, scroll of recharging, or scroll of transmutation to power the spell up, causing its next summon to be a full power elemental! +items.spells.summonelemental.desc=This spell channels the energy of the elemental embers used to make it, and will allow you to summon a friendly elemental to fight with you! Only one elemental can be summoned at a time, but the spell can be re-cast to return the elemental to you at no cost. +items.spells.summonelemental.desc_newborn=The spell is currently unimbued, and will summon a _newborn elemental_. You can imbue an identified potion of liquid flame, potion of frost, scroll of recharging, or scroll of transmutation to power the spell up, causing its next summon to be a full power elemental! items.spells.summonelemental.desc_fire=The spell is currently hot to the touch, its next summon will be a _fire elemental_. You can imbue a different item, but the spell will lose its current imbue. items.spells.summonelemental.desc_frost=The spell is currently cold to the touch, its next summon will be a _frost elemental_. You can imbue a different item, but the spell will lose its current imbue. items.spells.summonelemental.desc_shock=The spell is currently radiating static energy, its next summon will be a _shock elemental_. You can imbue a different item, but the spell will lose its current imbue. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java index 988f077a8..888e00917 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java @@ -59,15 +59,35 @@ public abstract class Elemental extends Mob { flying = true; } + + private boolean summonedALly; @Override public int damageRoll() { - return Random.NormalIntRange( 20, 25 ); + if (!summonedALly) { + return Random.NormalIntRange(20, 25); + } else { + int regionScale = Math.max(2, (1 + Dungeon.depth/5)); + return Random.NormalIntRange(5*regionScale, 5 + 5*regionScale); + } } @Override public int attackSkill( Char target ) { - return 25; + if (!summonedALly) { + return 25; + } else { + int regionScale = Math.max(2, (1 + Dungeon.depth/5)); + return 5 + 5*regionScale; + } + } + + public void setSummonedALly(){ + summonedALly = true; + //sewers are prison are equivalent, otherwise scales as normal (2/2/3/4/5) + int regionScale = Math.max(2, (1 + Dungeon.depth/5)); + defenseSkill = 5*regionScale; + HT = 15*regionScale; } @Override @@ -155,11 +175,13 @@ public abstract class Elemental extends Mob { protected ArrayList> harmfulBuffs = new ArrayList<>(); private static final String COOLDOWN = "cooldown"; + private static final String SUMMONED_ALLY = "summoned_ally"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); bundle.put( COOLDOWN, rangedCooldown ); + bundle.put( SUMMONED_ALLY, summonedALly); } @Override @@ -168,6 +190,10 @@ public abstract class Elemental extends Mob { if (bundle.contains( COOLDOWN )){ rangedCooldown = bundle.getInt( COOLDOWN ); } + summonedALly = bundle.getBoolean( SUMMONED_ALLY ); + if (summonedALly){ + setSummonedALly(); + } } public static class FireElemental extends Elemental { @@ -233,10 +259,11 @@ public abstract class Elemental extends Mob { } - //not a miniboss, otherwise a newborn elemental + //not a miniboss, fully HP, otherwise a newborn elemental public static class AllyNewBornElemental extends NewbornFireElemental { { + HP = HT; properties.remove(Property.MINIBOSS); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/SummonElemental.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/SummonElemental.java index 8731641f9..17e45607f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/SummonElemental.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/SummonElemental.java @@ -87,13 +87,6 @@ public class SummonElemental extends Spell { @Override protected void onCast(Hero hero) { - for (Char ch : Actor.chars()){ - if (ch instanceof Elemental && ch.buff(InvisAlly.class) != null){ - GLog.w(Messages.get(this, "summon_limit")); - return; - } - } - ArrayList spawnPoints = new ArrayList<>(); for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) { @@ -105,10 +98,22 @@ public class SummonElemental extends Spell { if (!spawnPoints.isEmpty()){ + for (Char ch : Actor.chars()){ + if (ch instanceof Elemental && ch.buff(InvisAlly.class) != null){ + ScrollOfTeleportation.appear( ch, Random.element(spawnPoints) ); + ((Elemental) ch).state = ((Elemental) ch).HUNTING; + curUser.spendAndNext(Actor.TICK); + return; + } + } + Elemental elemental = Reflection.newInstance(summonClass); GameScene.add( elemental ); Buff.affect(elemental, InvisAlly.class); + elemental.setSummonedALly(); + elemental.HP = elemental.HT; ScrollOfTeleportation.appear( elemental, Random.element(spawnPoints) ); + curUser.spendAndNext(Actor.TICK); summonClass = Elemental.AllyNewBornElemental.class; @@ -223,10 +228,10 @@ public class SummonElemental extends Spell { inputs = new Class[]{Embers.class, ArcaneCatalyst.class}; inQuantity = new int[]{1, 1}; - cost = 8; + cost = 6; output = SummonElemental.class; - outQuantity = 3; + outQuantity = 5; } }