v0.7.4a: fixed visual errors with ranged enemy attacks

This commit is contained in:
Evan Debenham 2019-07-24 17:39:45 -04:00
parent e95a61dc15
commit af7bb632ea
3 changed files with 20 additions and 3 deletions

View File

@ -165,7 +165,7 @@ public class MagicMissile extends Emitter {
public static void boltFromChar(Group group, int type, Visual sprite, int to, Callback callback){ public static void boltFromChar(Group group, int type, Visual sprite, int to, Callback callback){
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class )); MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
if (Actor.findChar(to) != null){ if (Actor.findChar(to) != null){
missile.reset(type, sprite, Actor.findChar(to).sprite, callback); missile.reset(type, sprite.center(), Actor.findChar(to).sprite.destinationCenter(), callback);
} else { } else {
missile.reset(type, sprite, to, callback); missile.reset(type, sprite, to, callback);
} }

View File

@ -91,7 +91,7 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
protected Callback animCallback; protected Callback animCallback;
protected Tweener motion; protected PosTweener motion;
protected Emitter burning; protected Emitter burning;
protected Emitter chilled; protected Emitter chilled;
@ -200,6 +200,15 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
} }
//returns where the center of this sprite will be after it completes any motion in progress
public PointF destinationCenter(){
if (motion != null){
return new PointF(motion.end.x + width()/2f, motion.end.y + height()/2f);
} else {
return center();
}
}
public void interruptMotion() { public void interruptMotion() {
if (motion != null) { if (motion != null) {
motion.stop(false); motion.stop(false);

View File

@ -22,6 +22,8 @@
package com.shatteredpixel.shatteredpixeldungeon.sprites; package com.shatteredpixel.shatteredpixeldungeon.sprites;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Shaman; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Shaman;
import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning; import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning;
import com.watabou.noosa.TextureFilm; import com.watabou.noosa.TextureFilm;
@ -54,7 +56,13 @@ public class ShamanSprite extends MobSprite {
public void zap( int pos ) { public void zap( int pos ) {
parent.add( new Lightning( ch.pos, pos, (Shaman)ch ) ); Char enemy = Actor.findChar(pos);
if (enemy != null) {
parent.add(new Lightning(center(), enemy.sprite.destinationCenter(), (Shaman) ch));
} else {
parent.add(new Lightning(center(), pos, (Shaman) ch));
}
turnTo( ch.pos, pos ); turnTo( ch.pos, pos );
play( zap ); play( zap );