V0.2.0: refactored/corrected Ring of Sharpshooting logic

This commit is contained in:
Evan Debenham 2014-09-12 11:07:27 -04:00
parent 5eea9c6cfc
commit 04b1ace7a7
4 changed files with 21 additions and 12 deletions

View File

@ -257,14 +257,8 @@ public class Hero extends Char {
@Override @Override
public int attackSkill( Char target ) { public int attackSkill( Char target ) {
if (belongings.weapon != null && !usingRanged) { if (belongings.weapon != null) {
return (int) (attackSkill * belongings.weapon.acuracyFactor(this)); return (int) (attackSkill * belongings.weapon.acuracyFactor(this));
} else if (usingRanged){
int bonus = 0;
for (Buff buff : buffs(RingOfSharpshooting.Aim.class)) {
bonus += ((RingOfSharpshooting.Aim)buff).level;
}
return (int)(attackSkill * Math.pow(1.1, bonus));
} else { } else {
return attackSkill; return attackSkill;
} }

View File

@ -4,7 +4,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings;
* Created by debenhame on 10/09/2014. * Created by debenhame on 10/09/2014.
*/ */
public class RingOfSharpshooting extends Ring { public class RingOfSharpshooting extends Ring {
//TODO: numbers tweaking, acc logic refactor, does this work with boomerang? //TODO: numbers tweaking
{ {
name = "Ring of Sharpshooting"; name = "Ring of Sharpshooting";
} }
@ -18,7 +18,7 @@ public class RingOfSharpshooting extends Ring {
public String desc() { public String desc() {
return isKnown() ? return isKnown() ?
"This ring enhances the wearer's precision and aim, which will " + "This ring enhances the wearer's precision and aim, which will " +
"make all projectile weapons hit harder and last longer. " + "make all projectile weapons more accurate and durable. " +
"A cursed ring will have the opposite effect.": "A cursed ring will have the opposite effect.":
super.desc(); super.desc();
} }

View File

@ -19,10 +19,12 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.*; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.*;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
@ -93,9 +95,16 @@ public class Weapon extends KindOfWeapon {
break; break;
default: default:
} }
int bonus = 0;
for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) {
bonus += ((RingOfSharpshooting.Aim)buff).level;
}
float ACUbonus = (float)(Math.pow(1.1, bonus));
return encumbrance > 0 ? (float)((ACU * ACUbonus) / Math.pow( 1.5, encumbrance )) : ACU * ACUbonus;
} }
return encumbrance > 0 ? (float)(ACU / Math.pow( 1.5, encumbrance )) : ACU; return encumbrance > 0 ? (float)((ACU) / Math.pow( 1.5, encumbrance )) : ACU;
} }
@Override @Override

View File

@ -60,7 +60,7 @@ public class MissileWeapon extends Weapon {
protected void onThrow( int cell ) { protected void onThrow( int cell ) {
Char enemy = Actor.findChar( cell ); Char enemy = Actor.findChar( cell );
if (enemy == null || enemy == curUser) { if (enemy == null || enemy == curUser) {
super.onThrow( cell ); miss( cell );
} else { } else {
if (!curUser.shoot( enemy, this )) { if (!curUser.shoot( enemy, this )) {
miss( cell ); miss( cell );
@ -76,6 +76,12 @@ public class MissileWeapon extends Weapon {
} }
protected void miss( int cell ) { protected void miss( int cell ) {
int bonus = 0;
for (Buff buff : curUser.buffs(RingOfSharpshooting.Aim.class)) {
bonus += ((RingOfSharpshooting.Aim)buff).level;
}
if (Random.Float() > Math.pow(0.7, -bonus))
super.onThrow( cell ); super.onThrow( cell );
} }