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.rings.RingOfTenacity;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
|
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.ScrollOfMagicalInfusion;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
@@ -800,7 +800,11 @@ public class Hero extends Char {
|
|||||||
|
|
||||||
enemy = action.target;
|
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() );
|
spend( attackDelay() );
|
||||||
sprite.attack( enemy.pos );
|
sprite.attack( enemy.pos );
|
||||||
|
|||||||
@@ -20,9 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items;
|
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.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
@@ -98,6 +95,10 @@ abstract public class KindOfWeapon extends EquipableItem {
|
|||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int reachFactor( Hero hero ){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public void proc( Char attacker, Char defender, int damage ) {
|
public void proc( Char attacker, Char defender, int damage ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
|
||||||
public class Spear extends MeleeWeapon {
|
public class Spear extends MeleeWeapon {
|
||||||
@@ -28,6 +29,11 @@ public class Spear extends MeleeWeapon {
|
|||||||
image = ItemSpriteSheet.SPEAR;
|
image = ItemSpriteSheet.SPEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int reachFactor(Hero hero) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public Spear() {
|
public Spear() {
|
||||||
super( 2, 1f, 1.5f );
|
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.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.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.spear.desc=A slender wooden rod tipped with sharpened iron.
|
||||||
|
|
||||||
items.weapon.melee.sword.name=sword
|
items.weapon.melee.sword.name=sword
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ public class AttackIndicator extends Tag {
|
|||||||
int v = Dungeon.hero.visibleEnemies();
|
int v = Dungeon.hero.visibleEnemies();
|
||||||
for (int i=0; i < v; i++) {
|
for (int i=0; i < v; i++) {
|
||||||
Mob mob = Dungeon.hero.visibleEnemy( 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 );
|
candidates.add( mob );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user