From 2bb18fcd14b5e30aad816623a228731a4a63374c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 24 Dec 2015 03:47:13 -0500 Subject: [PATCH] v0.3.3a: bugfixes and safety checks to tengu and ranged attacks --- .../shatteredpixeldungeon/actors/Char.java | 2 ++ .../shatteredpixeldungeon/sprites/TenguSprite.java | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index b4d5d58ed..66f61d65e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -113,6 +113,8 @@ public abstract class Char extends Actor { } public boolean attack( Char enemy ) { + + if (enemy == null || !enemy.isAlive()) return false; boolean visibleFight = Dungeon.visible[pos] || Dungeon.visible[enemy.pos]; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java index e673ccae2..353cd586b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java @@ -20,6 +20,8 @@ */ package com.shatteredpixel.shatteredpixeldungeon.sprites; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.watabou.noosa.TextureFilm; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Shuriken; @@ -74,12 +76,15 @@ public class TenguSprite extends MobSprite { @Override public void attack( int cell ) { if (!Level.adjacent( cell, ch.pos )) { - + + final Char enemy = Actor.findChar(cell); + ((MissileSprite)parent.recycle( MissileSprite.class )). reset( ch.pos, cell, new Shuriken(), new Callback() { @Override public void call() { - ch.onAttackComplete(); + ch.next(); + if (enemy != null) ch.attack(enemy); } } );