v0.8.0: adjusted various effects so they can be used in new contexts

This commit is contained in:
Evan Debenham
2019-11-11 23:46:03 -05:00
parent 7114887282
commit 309ef7806e
4 changed files with 71 additions and 58 deletions
@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls; package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging;
@@ -62,8 +63,8 @@ public class ScrollOfRecharging extends Scroll {
Buff.append(curUser, Recharging.class, BUFF_DURATION/3f); Buff.append(curUser, Recharging.class, BUFF_DURATION/3f);
} }
public static void charge( Hero hero ) { public static void charge( Char user ) {
hero.sprite.centerEmitter().burst( EnergyParticle.FACTORY, 15 ); user.sprite.centerEmitter().burst( EnergyParticle.FACTORY, 15 );
} }
@Override @Override
@@ -108,6 +108,10 @@ public class ScrollOfTeleportation extends Scroll {
} }
public static void teleportHero( Hero hero ) { public static void teleportHero( Hero hero ) {
teleportChar( hero );
}
public static void teleportChar( Char ch ) {
if (Dungeon.bossLevel()){ if (Dungeon.bossLevel()){
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") ); GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") );
@@ -129,12 +133,15 @@ public class ScrollOfTeleportation extends Scroll {
} else { } else {
appear( ch, pos );
Dungeon.level.occupyCell( ch );
if (ch == Dungeon.hero) {
GLog.i( Messages.get(ScrollOfTeleportation.class, "tele") ); GLog.i( Messages.get(ScrollOfTeleportation.class, "tele") );
appear( hero, pos );
Dungeon.level.occupyCell(hero );
Dungeon.observe(); Dungeon.observe();
GameScene.updateFog(); GameScene.updateFog();
}
} }
} }
@@ -82,7 +82,7 @@ public class CursedWand {
private static float RARE_CHANCE = 0.09f; private static float RARE_CHANCE = 0.09f;
private static float VERY_RARE_CHANCE = 0.01f; private static float VERY_RARE_CHANCE = 0.01f;
public static void cursedZap(final Item origin, final Hero user, final Ballistica bolt, final Callback afterZap){ public static void cursedZap(final Item origin, final Char user, final Ballistica bolt, final Callback afterZap){
switch (Random.chances(new float[]{COMMON_CHANCE, UNCOMMON_CHANCE, RARE_CHANCE, VERY_RARE_CHANCE})){ switch (Random.chances(new float[]{COMMON_CHANCE, UNCOMMON_CHANCE, RARE_CHANCE, VERY_RARE_CHANCE})){
case 0: case 0:
default: default:
@@ -100,7 +100,7 @@ public class CursedWand {
} }
} }
private static void commonEffect(final Item origin, final Hero user, final Ballistica bolt, final Callback afterZap){ private static void commonEffect(final Item origin, final Char user, final Ballistica bolt, final Callback afterZap){
switch(Random.Int(4)){ switch(Random.Int(4)){
//anti-entropy //anti-entropy
@@ -139,32 +139,15 @@ public class CursedWand {
case 2: case 2:
switch(Random.Int(2)){ switch(Random.Int(2)){
case 0: case 0:
ScrollOfTeleportation.teleportHero(user); ScrollOfTeleportation.teleportChar(user);
afterZap.call(); afterZap.call();
break; break;
case 1: case 1:
cursedFX(user, bolt, new Callback() { cursedFX(user, bolt, new Callback() {
public void call() { public void call() {
Char ch = Actor.findChar( bolt.collisionPos ); Char ch = Actor.findChar( bolt.collisionPos );
if (ch == user){ if (ch != null && !ch.properties().contains(Char.Property.IMMOVABLE)) {
ScrollOfTeleportation.teleportHero(user); ScrollOfTeleportation.teleportChar(user);
} else if (ch != null && !ch.properties().contains(Char.Property.IMMOVABLE)) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1 || Dungeon.bossLevel()) {
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") );
} else {
ch.pos = pos;
if (((Mob) ch).state == ((Mob) ch).HUNTING)((Mob) ch).state = ((Mob) ch).WANDERING;
ch.sprite.place(ch.pos);
ch.sprite.visible = Dungeon.level.heroFOV[pos];
}
} }
afterZap.call(); afterZap.call();
} }
@@ -196,7 +179,7 @@ public class CursedWand {
} }
private static void uncommonEffect(final Item origin, final Hero user, final Ballistica bolt, final Callback afterZap){ private static void uncommonEffect(final Item origin, final Char user, final Ballistica bolt, final Callback afterZap){
switch(Random.Int(4)){ switch(Random.Int(4)){
//Random plant //Random plant
@@ -228,26 +211,37 @@ public class CursedWand {
if (target != null) { if (target != null) {
cursedFX(user, bolt, new Callback() { cursedFX(user, bolt, new Callback() {
public void call() { public void call() {
int damage = user.lvl * 2; int damage = Dungeon.depth * 2;
Char toHeal, toDamage;
switch (Random.Int(2)) { switch (Random.Int(2)) {
case 0: case 0: default:
user.HP = Math.min(user.HT, user.HP + damage); toHeal = user;
user.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3); toDamage = target;
target.damage(damage, origin);
target.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10);
break; break;
case 1: case 1:
user.damage( damage, this ); toHeal = target;
user.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10); toDamage = user;
target.HP = Math.min(target.HT, target.HP + damage);
target.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3);
Sample.INSTANCE.play(Assets.SND_CURSED);
if (!user.isAlive() && origin != null) {
Dungeon.fail( origin.getClass() );
GLog.n(Messages.get(CursedWand.class, "ondeath", origin.name()));
}
break; break;
} }
toHeal.HP = Math.min(toHeal.HT, toHeal.HP + damage);
toHeal.sprite.emitter().burst(Speck.factory(Speck.HEALING), 3);
toDamage.damage(damage, origin == null ? toHeal : origin);
toDamage.sprite.emitter().start(ShadowParticle.UP, 0.05f, 10);
if (toDamage == Dungeon.hero){
Sample.INSTANCE.play(Assets.SND_CURSED);
if (!toDamage.isAlive()) {
if (origin != null) {
Dungeon.fail( origin.getClass() );
GLog.n( Messages.get( CursedWand.class, "ondeath", origin.name() ) );
} else {
Dungeon.fail( toHeal.getClass() );
}
}
} else {
Sample.INSTANCE.play(Assets.SND_BURNING);
}
afterZap.call(); afterZap.call();
} }
}); });
@@ -279,11 +273,16 @@ public class CursedWand {
} }
private static void rareEffect(final Item origin, final Hero user, final Ballistica bolt, final Callback afterZap){ private static void rareEffect(final Item origin, final Char user, final Ballistica bolt, final Callback afterZap){
switch(Random.Int(4)){ switch(Random.Int(4)){
//sheep transformation //sheep transformation
case 0: case 0:
if (user != Dungeon.hero){
cursedZap(origin, user, bolt, afterZap);
return;
}
cursedFX(user, bolt, new Callback() { cursedFX(user, bolt, new Callback() {
public void call() { public void call() {
Char ch = Actor.findChar( bolt.collisionPos ); Char ch = Actor.findChar( bolt.collisionPos );
@@ -310,13 +309,13 @@ public class CursedWand {
//curses! //curses!
case 1: case 1:
CursingTrap.curse(user); if (user instanceof Hero) CursingTrap.curse( (Hero) user );
afterZap.call(); afterZap.call();
break; break;
//inter-level teleportation //inter-level teleportation
case 2: case 2:
if (Dungeon.depth > 1 && !Dungeon.bossLevel()) { if (Dungeon.depth > 1 && !Dungeon.bossLevel() && user == Dungeon.hero) {
//each depth has 1 more weight than the previous depth. //each depth has 1 more weight than the previous depth.
float[] depths = new float[Dungeon.depth-1]; float[] depths = new float[Dungeon.depth-1];
@@ -335,7 +334,7 @@ public class CursedWand {
Game.switchScene(InterlevelScene.class); Game.switchScene(InterlevelScene.class);
} else { } else {
ScrollOfTeleportation.teleportHero(user); ScrollOfTeleportation.teleportChar(user);
} }
afterZap.call(); afterZap.call();
@@ -349,7 +348,7 @@ public class CursedWand {
} }
} }
private static void veryRareEffect(final Item origin, final Hero user, final Ballistica bolt, final Callback afterZap){ private static void veryRareEffect(final Item origin, final Char user, final Ballistica bolt, final Callback afterZap){
switch(Random.Int(4)){ switch(Random.Int(4)){
//great forest fire! //great forest fire!
@@ -394,6 +393,12 @@ public class CursedWand {
//crashes the game, yes, really. //crashes the game, yes, really.
case 2: case 2:
if (user != Dungeon.hero){
cursedZap(origin, user, bolt, afterZap);
return;
}
try { try {
Dungeon.saveAll(); Dungeon.saveAll();
if(Messages.lang() != Languages.ENGLISH){ if(Messages.lang() != Languages.ENGLISH){
@@ -427,11 +432,11 @@ public class CursedWand {
//random transmogrification //random transmogrification
case 3: case 3:
//skips this effect if there is no item to transmogrify //skips this effect if there is no item to transmogrify
if (origin == null || !Dungeon.hero.belongings.contains(origin)){ if (origin == null || user != Dungeon.hero || !Dungeon.hero.belongings.contains(origin)){
cursedZap(origin, user, bolt, afterZap); cursedZap(origin, user, bolt, afterZap);
return; return;
} }
origin.detach(user.belongings.backpack); origin.detach(Dungeon.hero.belongings.backpack);
Item result; Item result;
do { do {
result = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR, result = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR,
@@ -450,7 +455,7 @@ public class CursedWand {
} }
} }
private static void cursedFX(final Hero user, final Ballistica bolt, final Callback callback){ private static void cursedFX(final Char user, final Ballistica bolt, final Callback callback){
MagicMissile.boltFromChar( user.sprite.parent, MagicMissile.boltFromChar( user.sprite.parent,
MagicMissile.RAINBOW, MagicMissile.RAINBOW,
user.sprite, user.sprite,
@@ -50,9 +50,9 @@ public class Shocking extends Weapon.Enchantment {
if (Random.Int( level + 3 ) >= 2) { if (Random.Int( level + 3 ) >= 2) {
affected.clear(); affected.clear();
arcs.clear(); arcs.clear();
arc(attacker, defender, 2);
arc(attacker, defender, 2, affected, arcs);
affected.remove(defender); //defender isn't hurt by lightning affected.remove(defender); //defender isn't hurt by lightning
for (Char ch : affected) { for (Char ch : affected) {
@@ -77,7 +77,7 @@ public class Shocking extends Weapon.Enchantment {
private ArrayList<Lightning.Arc> arcs = new ArrayList<>(); private ArrayList<Lightning.Arc> arcs = new ArrayList<>();
private void arc( Char attacker, Char defender, int dist ) { public static void arc( Char attacker, Char defender, int dist, ArrayList<Char> affected, ArrayList<Lightning.Arc> arcs ) {
affected.add(defender); affected.add(defender);
@@ -90,7 +90,7 @@ public class Shocking extends Weapon.Enchantment {
Char n = Actor.findChar(i); Char n = Actor.findChar(i);
if (n != null && n != attacker && !affected.contains(n)) { if (n != null && n != attacker && !affected.contains(n)) {
arcs.add(new Lightning.Arc(defender.sprite.center(), n.sprite.center())); arcs.add(new Lightning.Arc(defender.sprite.center(), n.sprite.center()));
arc(attacker, n, (Dungeon.level.water[n.pos] && !n.flying) ? 2 : 1); arc(attacker, n, (Dungeon.level.water[n.pos] && !n.flying) ? 2 : 1, affected, arcs);
} }
} }
} }