From 28015c7282fdba6703abad31416a956aa051f69a Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 23 May 2022 13:57:55 -0400 Subject: [PATCH] v1.3.0: replaced fragile curse with explosive curse --- .../assets/messages/items/items.properties | 9 +- .../ShatteredPixelDungeon.java | 5 + .../items/weapon/Weapon.java | 4 +- .../items/weapon/curses/Explosive.java | 133 ++++++++++++++++++ .../items/weapon/curses/Fragile.java | 64 --------- .../items/weapon/melee/MeleeWeapon.java | 2 +- 6 files changed, 148 insertions(+), 69 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Explosive.java delete mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Fragile.java diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index dfdefe6fc..5f04fa69f 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1358,8 +1358,13 @@ items.weapon.curses.displacing.desc=Displacing weapons are infused with chaotic items.weapon.curses.exhausting.name=exhausting %s items.weapon.curses.exhausting.desc=Exhausting weapons take great effort to use, and will periodically weaken the wearer as a result. -items.weapon.curses.fragile.name=fragile %s -items.weapon.curses.fragile.desc=Fragile weapons start out just as strong as their normal counterparts, but rapidly decrease in effectiveness as they are used. +items.weapon.curses.explosive.name=explosive %s +items.weapon.curses.explosive.warm=Warm... +items.weapon.curses.explosive.hot=Hot! +items.weapon.curses.explosive.desc=Explosive weapons steadily build up power and explode, damaging the wearer and enemy. +items.weapon.curses.explosive.desc_cool=Your weapon is currently cool to the touch. +items.weapon.curses.explosive.desc_warm=Your weapon is building energy and getting warm... +items.weapon.curses.explosive.desc_hot=_Your weapon is hot! It's about to explode!_ items.weapon.curses.friendly.name=friendly %s items.weapon.curses.friendly.desc=Friendly weapons are best suited for pacifists, occasionally triggering magic that makes it impossible to fight. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index d95e55211..9d5057034 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -46,6 +46,11 @@ public class ShatteredPixelDungeon extends Game { public ShatteredPixelDungeon( PlatformSupport platform ) { super( sceneClass == null ? WelcomeScene.class : sceneClass, platform ); + //v1.3.0 + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Explosive.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Fragile" ); + //v1.2.0 com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.CleansingDart.class, diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java index c1510c933..67d5e9124 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/Weapon.java @@ -34,7 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Annoying; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Displacing; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Exhausting; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Fragile; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Explosive; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Friendly; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Polarized; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses.Sacrificial; @@ -353,7 +353,7 @@ abstract public class Weapon extends KindOfWeapon { }; private static final Class[] curses = new Class[]{ - Annoying.class, Displacing.class, Exhausting.class, Fragile.class, + Annoying.class, Displacing.class, Exhausting.class, Explosive.class, Sacrificial.class, Wayward.class, Polarized.class, Friendly.class }; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Explosive.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Explosive.java new file mode 100644 index 000000000..1d8199762 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Explosive.java @@ -0,0 +1,133 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2022 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses; + +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.effects.particles.BlastParticle; +import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SmokeParticle; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.bombs.Bomb; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.utils.Bundle; +import com.watabou.utils.Random; + +public class Explosive extends Weapon.Enchantment { + + private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 ); + private static ItemSprite.Glowing WARM = new ItemSprite.Glowing( 0x000000, 0.5f ); + private static ItemSprite.Glowing HOT = new ItemSprite.Glowing( 0x000000, 0.25f ); + private int durability = 100; + + @Override + public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { + + //average value of 5, or 20 hits to an explosion + int durToReduce = Random.IntRange(0, 10); + int currentDurability = durability; + durability -= durToReduce; + + if (currentDurability > 50 && durability <= 50){ + attacker.sprite.showStatus(CharSprite.WARNING, Messages.get(this, "warm")); + GLog.w(Messages.get(this, "desc_warm")); + attacker.sprite.emitter().burst(SmokeParticle.FACTORY, 4); + Item.updateQuickslot(); + } else if (currentDurability > 10 && durability <= 10){ + attacker.sprite.showStatus(CharSprite.NEGATIVE, Messages.get(this, "hot")); + GLog.n(Messages.get(this, "desc_hot")); + attacker.sprite.emitter().burst(BlastParticle.FACTORY, 5); + Item.updateQuickslot(); + } else if (durability <= 0) { + //explosion position is either the attacker's position (when attacker and defender are adjacent) + //or the closest cell to the defender on a straight path to them otherwise + int explosionPos = -1; + if (Dungeon.level.adjacent(attacker.pos, defender.pos)){ + explosionPos = attacker.pos; + } else { + Ballistica path = new Ballistica(attacker.pos, defender.pos, Ballistica.PROJECTILE); + if (path.dist == 0){ + explosionPos = attacker.pos; + } else { + explosionPos = path.path.get(path.dist-1); + } + } + + new Bomb().explode(explosionPos); + + durability = 100; + Item.updateQuickslot(); + } + + return damage; + } + + @Override + public boolean curse() { + return true; + } + + @Override + public ItemSprite.Glowing glowing() { + if (durability > 50){ + return BLACK; + } else if (durability > 10){ + return WARM; + } else { + return HOT; + } + } + + @Override + public String desc() { + String desc = super.desc(); + if (durability > 50){ + desc += " " + Messages.get(this, "desc_cool"); + } else if (durability > 10){ + desc += " " + Messages.get(this, "desc_warm"); + } else { + desc += " " + Messages.get(this, "desc_hot"); + } + return desc; + } + + private static final String DURABILITY = "durability"; + + @Override + public void restoreFromBundle( Bundle bundle ) { + durability = bundle.getInt(DURABILITY); + //pre-1.3 saves + if (durability <= 0){ + durability = 100; + } + } + + @Override + public void storeInBundle( Bundle bundle ) { + bundle.put(DURABILITY, durability); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Fragile.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Fragile.java deleted file mode 100644 index 9c7f6e3ec..000000000 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Fragile.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2022 Evan Debenham - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses; - -import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; -import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; -import com.watabou.utils.Bundle; - -public class Fragile extends Weapon.Enchantment { - - private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 ); - private int hits = 0; - - @Override - public int proc( Weapon weapon, Char attacker, Char defender, int damage ) { - //degrades from 100% to 25% damage over 150 hits - damage *= (1f - hits*0.005f); - if (hits < 150) hits++; - return damage; - } - - @Override - public boolean curse() { - return true; - } - - @Override - public ItemSprite.Glowing glowing() { - return BLACK; - } - - private static final String HITS = "hits"; - - @Override - public void restoreFromBundle( Bundle bundle ) { - hits = bundle.getInt(HITS); - } - - @Override - public void storeInBundle( Bundle bundle ) { - bundle.put(HITS, hits); - } - -} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java index b8571234d..d9c5889d7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java @@ -96,7 +96,7 @@ public class MeleeWeapon extends Weapon { if (enchantment != null && (cursedKnown || !enchantment.curse())){ info += "\n\n" + Messages.get(Weapon.class, "enchanted", enchantment.name()); - info += " " + Messages.get(enchantment, "desc"); + info += " " + enchantment.desc(); } if (cursed && isEquipped( Dungeon.hero )) {