v0.3.5: added support for longer reach weapons
This commit is contained in:
@@ -75,8 +75,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMight;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfTenacity;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
@@ -800,7 +800,11 @@ public class Hero extends Char {
|
||||
|
||||
enemy = action.target;
|
||||
|
||||
if (Level.adjacent( pos, enemy.pos ) && enemy.isAlive() && !isCharmedBy( enemy )) {
|
||||
boolean inRange = belongings.weapon != null ?
|
||||
Level.distance( pos, enemy.pos ) <= belongings.weapon.reachFactor(this)
|
||||
: Level.adjacent( pos, enemy.pos );
|
||||
|
||||
if (inRange && enemy.isAlive() && !isCharmedBy( enemy )) {
|
||||
|
||||
spend( attackDelay() );
|
||||
sprite.attack( enemy.pos );
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
@@ -97,6 +94,10 @@ abstract public class KindOfWeapon extends EquipableItem {
|
||||
public float speedFactor( Hero hero ) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
public int reachFactor( Hero hero ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void proc( Char attacker, Char defender, int damage ) {
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Spear extends MeleeWeapon {
|
||||
@@ -27,7 +28,12 @@ public class Spear extends MeleeWeapon {
|
||||
{
|
||||
image = ItemSpriteSheet.SPEAR;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int reachFactor(Hero hero) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public Spear() {
|
||||
super( 2, 1f, 1.5f );
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ items.weapon.melee.shortsword.ac_reforge=REFORGE
|
||||
items.weapon.melee.shortsword.desc=It is indeed quite short, just a few inches longer, than a dagger.
|
||||
|
||||
items.weapon.melee.spear.name=spear
|
||||
items.weapon.melee.spear.stats_desc=This is a rather slow weapon.
|
||||
items.weapon.melee.spear.stats_desc=This is a rather slow weapon.\nThis weapon has extra reach.
|
||||
items.weapon.melee.spear.desc=A slender wooden rod tipped with sharpened iron.
|
||||
|
||||
items.weapon.melee.sword.name=sword
|
||||
|
||||
@@ -96,13 +96,15 @@ public class AttackIndicator extends Tag {
|
||||
}
|
||||
|
||||
private void checkEnemies() {
|
||||
|
||||
|
||||
int heroPos = Dungeon.hero.pos;
|
||||
candidates.clear();
|
||||
int v = Dungeon.hero.visibleEnemies();
|
||||
for (int i=0; i < v; i++) {
|
||||
Mob mob = Dungeon.hero.visibleEnemy( i );
|
||||
if (Level.adjacent( heroPos, mob.pos )) {
|
||||
if (Dungeon.hero.belongings.weapon != null ?
|
||||
Level.distance( heroPos, mob.pos ) <= Dungeon.hero.belongings.weapon.reachFactor(Dungeon.hero)
|
||||
: Level.adjacent( heroPos, mob.pos )) {
|
||||
candidates.add( mob );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user