use of com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon in project shattered-pixel-dungeon-gdx by 00-Evan.
the class DisarmingTrap method activate.
@Override
public void activate() {
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
int cell = Dungeon.level.randomRespawnCell();
if (cell != -1) {
Item item = heap.pickUp();
Dungeon.level.drop(item, cell).seen = true;
for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
GameScene.updateFog();
Sample.INSTANCE.play(Assets.SND_TELEPORT);
CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
}
}
if (Dungeon.hero.pos == pos) {
Hero hero = Dungeon.hero;
KindOfWeapon weapon = hero.belongings.weapon;
if (weapon != null && !(weapon instanceof Knuckles) && !weapon.cursed) {
int cell = Dungeon.level.randomRespawnCell();
if (cell != -1) {
hero.belongings.weapon = null;
Dungeon.quickslot.clearItem(weapon);
weapon.updateQuickslot();
Dungeon.level.drop(weapon, cell).seen = true;
for (int i : PathFinder.NEIGHBOURS9) Dungeon.level.visited[cell + i] = true;
GameScene.updateFog();
GLog.w(Messages.get(this, "disarm"));
Sample.INSTANCE.play(Assets.SND_TELEPORT);
CellEmitter.get(pos).burst(Speck.factory(Speck.LIGHT), 4);
}
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method canAttack.
public boolean canAttack(Char enemy) {
if (enemy == null || pos == enemy.pos)
return false;
// can always attack adjacent enemies
if (Dungeon.level.adjacent(pos, enemy.pos))
return true;
KindOfWeapon wep = Dungeon.hero.belongings.weapon;
if (wep != null && Dungeon.level.distance(pos, enemy.pos) <= wep.reachFactor(this)) {
boolean[] passable = BArray.not(Dungeon.level.solid, null);
for (Mob m : Dungeon.level.mobs) passable[m.pos] = false;
PathFinder.buildDistanceMap(enemy.pos, passable, wep.reachFactor(this));
return PathFinder.distance[pos] <= wep.reachFactor(this);
} else {
return false;
}
}
Aggregations