v0.6.1: adjusted weapon/armor code so npcs and mobs can better use them
This commit is contained in:
parent
6a0a7ae450
commit
dc7d59c65f
|
@ -88,27 +88,27 @@ public class Statue extends Mob {
|
|||
|
||||
@Override
|
||||
public int damageRoll() {
|
||||
return Random.NormalIntRange( weapon.min(), weapon.max() );
|
||||
return weapon.damageRoll(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int attackSkill( Char target ) {
|
||||
return (int)((9 + Dungeon.depth) * weapon.ACC);
|
||||
return (int)((9 + Dungeon.depth) * weapon.accuracyFactor(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float attackDelay() {
|
||||
return weapon.DLY;
|
||||
return weapon.speedFactor( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAttack(Char enemy) {
|
||||
return Dungeon.level.distance( pos, enemy.pos ) <= weapon.RCH;
|
||||
return Dungeon.level.distance( pos, enemy.pos ) <= weapon.reachFactor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drRoll() {
|
||||
return Random.NormalIntRange(0, Dungeon.depth + weapon.defenseFactor(null));
|
||||
return Random.NormalIntRange(0, Dungeon.depth + weapon.defenseFactor(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,23 +89,23 @@ abstract public class KindOfWeapon extends EquipableItem {
|
|||
abstract public int min(int lvl);
|
||||
abstract public int max(int lvl);
|
||||
|
||||
public int damageRoll( Hero owner ) {
|
||||
public int damageRoll( Char owner ) {
|
||||
return Random.NormalIntRange( min(), max() );
|
||||
}
|
||||
|
||||
public float accuracyFactor(Hero hero ) {
|
||||
public float accuracyFactor( Char owner ) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
public float speedFactor( Hero hero ) {
|
||||
public float speedFactor( Char owner ) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
public int reachFactor( Hero hero ){
|
||||
public int reachFactor( Char owner ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int defenseFactor(Hero hero ) {
|
||||
public int defenseFactor( Char owner ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Flow;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Obfuscation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Swiftness;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfPsionicBlast;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
|
@ -415,7 +420,13 @@ public class DriedRose extends Artifact {
|
|||
@Override
|
||||
public int attackSkill(Char target) {
|
||||
//same accuracy as the hero.
|
||||
return (defenseSkill/2)+5;
|
||||
int acc = (defenseSkill/2)+5;
|
||||
|
||||
if (weapon != null){
|
||||
acc *= weapon.accuracyFactor(this);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
//FIXME currently many effects on weapons/armor are ignored
|
||||
|
@ -424,7 +435,7 @@ public class DriedRose extends Artifact {
|
|||
@Override
|
||||
protected float attackDelay() {
|
||||
if (weapon != null){
|
||||
return weapon.DLY;
|
||||
return weapon.speedFactor(this);
|
||||
} else {
|
||||
return super.attackDelay();
|
||||
}
|
||||
|
@ -433,7 +444,7 @@ public class DriedRose extends Artifact {
|
|||
@Override
|
||||
protected boolean canAttack(Char enemy) {
|
||||
if (weapon != null) {
|
||||
return Dungeon.level.distance(pos, enemy.pos) <= weapon.RCH;
|
||||
return Dungeon.level.distance(pos, enemy.pos) <= weapon.reachFactor(this);
|
||||
} else {
|
||||
return super.canAttack(enemy);
|
||||
}
|
||||
|
@ -443,14 +454,80 @@ public class DriedRose extends Artifact {
|
|||
public int damageRoll() {
|
||||
int dmg = 0;
|
||||
if (weapon != null){
|
||||
dmg += Random.NormalIntRange(weapon.min(), weapon.max());
|
||||
dmg += weapon.damageRoll(this);
|
||||
} else {
|
||||
dmg += Random.NormalIntRange(0, 5);
|
||||
}
|
||||
|
||||
return dmg;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int attackProc(Char enemy, int damage) {
|
||||
if (weapon != null) {
|
||||
return weapon.proc( enemy, this, damage );
|
||||
} else {
|
||||
return super.attackProc(enemy, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int defenseProc(Char enemy, int damage) {
|
||||
if (armor != null) {
|
||||
return armor.proc( enemy, this, damage );
|
||||
} else {
|
||||
return super.defenseProc(enemy, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int dmg, Object src) {
|
||||
//TODO improve this when I have proper damage source logic
|
||||
if (armor != null && armor.hasGlyph(AntiMagic.class)
|
||||
&& RingOfElements.FULL.contains(src.getClass())){
|
||||
dmg -= Random.NormalIntRange(armor.DRMin(), armor.DRMax())/3;
|
||||
}
|
||||
|
||||
super.damage( dmg, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float speed() {
|
||||
float speed = super.speed();
|
||||
|
||||
if (armor != null){
|
||||
if (armor.hasGlyph(Swiftness.class)) {
|
||||
speed *= (1.1f + 0.01f * armor.level());
|
||||
} else if (armor.hasGlyph(Flow.class) && Level.water[pos]){
|
||||
speed *= (1.5f + 0.05f * armor.level());
|
||||
}
|
||||
}
|
||||
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int defenseSkill(Char enemy) {
|
||||
int defense = super.defenseSkill(enemy);
|
||||
|
||||
if (armor != null && armor.hasGlyph(Swiftness.class)){
|
||||
defense += 5 + armor.level()*1.5f;
|
||||
}
|
||||
|
||||
return defense;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stealth() {
|
||||
int stealth = super.stealth();
|
||||
|
||||
if (armor != null && armor.hasGlyph(Obfuscation.class)){
|
||||
stealth += armor.level();
|
||||
}
|
||||
|
||||
return stealth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drRoll() {
|
||||
int block = 0;
|
||||
|
@ -458,7 +535,7 @@ public class DriedRose extends Artifact {
|
|||
block += Random.NormalIntRange( armor.DRMin(), armor.DRMax());
|
||||
}
|
||||
if (weapon != null){
|
||||
block += Random.NormalIntRange( 0, weapon.defenseFactor( null ));
|
||||
block += Random.NormalIntRange( 0, weapon.defenseFactor( this ));
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
|
|
@ -136,9 +136,13 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public float accuracyFactor( Hero hero ) {
|
||||
public float accuracyFactor( Char owner ) {
|
||||
|
||||
int encumbrance = STRReq() - hero.STR();
|
||||
int encumbrance = 0;
|
||||
|
||||
if( owner instanceof Hero ){
|
||||
encumbrance = STRReq() - ((Hero)owner).STR();
|
||||
}
|
||||
|
||||
if (hasEnchant(Wayward.class))
|
||||
encumbrance = Math.max(3, encumbrance+3);
|
||||
|
@ -146,40 +150,44 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
float ACC = this.ACC;
|
||||
|
||||
if (this instanceof MissileWeapon) {
|
||||
ACC *= RingOfSharpshooting.accuracyMultiplier( hero );
|
||||
ACC *= RingOfSharpshooting.accuracyMultiplier( owner );
|
||||
}
|
||||
|
||||
return encumbrance > 0 ? (float)(ACC / Math.pow( 1.5, encumbrance )) : ACC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float speedFactor( Hero hero ) {
|
||||
public float speedFactor( Char owner ) {
|
||||
|
||||
int encumrance = STRReq() - hero.STR();
|
||||
if (this instanceof MissileWeapon && hero.heroClass == HeroClass.HUNTRESS) {
|
||||
encumrance -= 2;
|
||||
int encumbrance = 0;
|
||||
if (owner instanceof Hero) {
|
||||
encumbrance = STRReq() - ((Hero)owner).STR();
|
||||
if (this instanceof MissileWeapon && ((Hero)owner).heroClass == HeroClass.HUNTRESS) {
|
||||
encumbrance -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
float DLY = imbue.delayFactor(this.DLY);
|
||||
|
||||
DLY = RingOfFuror.modifyAttackDelay(DLY, hero);
|
||||
DLY = RingOfFuror.modifyAttackDelay(DLY, owner);
|
||||
|
||||
return
|
||||
(encumrance > 0 ? (float)(DLY * Math.pow( 1.2, encumrance )) : DLY);
|
||||
return (encumbrance > 0 ? (float)(DLY * Math.pow( 1.2, encumbrance )) : DLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int reachFactor(Hero hero) {
|
||||
public int reachFactor(Char owner) {
|
||||
return hasEnchant(Projecting.class) ? RCH+1 : RCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageRoll( Hero hero ) {
|
||||
public int damageRoll( Char owner ) {
|
||||
|
||||
int damage = super.damageRoll( hero );
|
||||
int damage = super.damageRoll( owner );
|
||||
|
||||
if (this instanceof MeleeWeapon || (this instanceof MissileWeapon && hero.heroClass == HeroClass.HUNTRESS)) {
|
||||
int exStr = hero.STR() - STRReq();
|
||||
if (owner instanceof Hero &&
|
||||
(this instanceof MeleeWeapon
|
||||
|| (this instanceof MissileWeapon && ((Hero)owner).heroClass == HeroClass.HUNTRESS))) {
|
||||
int exStr = ((Hero)owner).STR() - STRReq();
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange( 0, exStr );
|
||||
}
|
||||
|
|
|
@ -42,18 +42,21 @@ public class AssassinsBlade extends MeleeWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int damageRoll(Hero hero) {
|
||||
Char enemy = hero.enemy();
|
||||
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
|
||||
//deals avg damage to max on surprise, instead of min to max.
|
||||
int damage = imbue.damageFactor(Random.NormalIntRange((min() + max()) / 2, max()));
|
||||
int exStr = hero.STR() - STRReq();
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange( 0, exStr );
|
||||
public int damageRoll(Char owner) {
|
||||
if (owner instanceof Hero) {
|
||||
Hero hero = (Hero)owner;
|
||||
Char enemy = hero.enemy();
|
||||
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
|
||||
//deals avg damage to max on surprise, instead of min to max.
|
||||
int damage = imbue.damageFactor(Random.NormalIntRange((min() + max()) / 2, max()));
|
||||
int exStr = hero.STR() - STRReq();
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange(0, exStr);
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
return damage;
|
||||
} else
|
||||
return super.damageRoll(hero);
|
||||
}
|
||||
return super.damageRoll(owner);
|
||||
}
|
||||
|
||||
}
|
|
@ -40,19 +40,23 @@ public class Dagger extends MeleeWeapon {
|
|||
return 4*(tier+1) + //8 base, down from 10
|
||||
lvl*(tier+1); //scaling unchanged
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int damageRoll(Hero hero) {
|
||||
Char enemy = hero.enemy();
|
||||
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
|
||||
//deals avg damage to max on surprise, instead of min to max.
|
||||
int damage = imbue.damageFactor(Random.NormalIntRange((min() + max()) / 2, max()));
|
||||
int exStr = hero.STR() - STRReq();
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange( 0, exStr );
|
||||
public int damageRoll(Char owner) {
|
||||
if (owner instanceof Hero) {
|
||||
Hero hero = (Hero)owner;
|
||||
Char enemy = hero.enemy();
|
||||
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
|
||||
//deals avg damage to max on surprise, instead of min to max.
|
||||
int damage = imbue.damageFactor(Random.NormalIntRange((min() + max()) / 2, max()));
|
||||
int exStr = hero.STR() - STRReq();
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange(0, exStr);
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
return damage;
|
||||
} else
|
||||
return super.damageRoll(hero);
|
||||
}
|
||||
return super.damageRoll(owner);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,19 +40,23 @@ public class Dirk extends MeleeWeapon {
|
|||
return 4*(tier+1) + //12 base, down from 15
|
||||
lvl*(tier+1); //scaling unchanged
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int damageRoll(Hero hero) {
|
||||
Char enemy = hero.enemy();
|
||||
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
|
||||
//deals avg damage to max on surprise, instead of min to max.
|
||||
int damage = imbue.damageFactor(Random.NormalIntRange((min() + max()) / 2, max()));
|
||||
int exStr = hero.STR() - STRReq();
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange( 0, exStr );
|
||||
public int damageRoll(Char owner) {
|
||||
if (owner instanceof Hero) {
|
||||
Hero hero = (Hero)owner;
|
||||
Char enemy = hero.enemy();
|
||||
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
|
||||
//deals avg damage to max on surprise, instead of min to max.
|
||||
int damage = imbue.damageFactor(Random.NormalIntRange((min() + max()) / 2, max()));
|
||||
int exStr = hero.STR() - STRReq();
|
||||
if (exStr > 0) {
|
||||
damage += Random.IntRange(0, exStr);
|
||||
}
|
||||
return damage;
|
||||
}
|
||||
return damage;
|
||||
} else
|
||||
return super.damageRoll(hero);
|
||||
}
|
||||
return super.damageRoll(owner);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Greatshield extends MeleeWeapon {
|
||||
|
@ -39,7 +39,7 @@ public class Greatshield extends MeleeWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int defenseFactor(Hero hero) {
|
||||
public int defenseFactor( Char owner ) {
|
||||
return 10+3*level(); //10 extra defence, plus 3 per level;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,9 +138,11 @@ public class MagesStaff extends MeleeWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int reachFactor(Hero hero) {
|
||||
int reach = super.reachFactor(hero);
|
||||
if (wand instanceof WandOfDisintegration && hero.subClass == HeroSubClass.BATTLEMAGE){
|
||||
public int reachFactor(Char owner) {
|
||||
int reach = super.reachFactor(owner);
|
||||
if (owner instanceof Hero
|
||||
&& wand instanceof WandOfDisintegration
|
||||
&& ((Hero)owner).subClass == HeroSubClass.BATTLEMAGE){
|
||||
reach++;
|
||||
}
|
||||
return reach;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Quarterstaff extends MeleeWeapon {
|
||||
|
@ -39,7 +39,7 @@ public class Quarterstaff extends MeleeWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int defenseFactor(Hero hero) {
|
||||
public int defenseFactor( Char owner ) {
|
||||
return 3; //3 extra defence
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class RoundShield extends MeleeWeapon {
|
||||
|
@ -39,7 +39,7 @@ public class RoundShield extends MeleeWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int defenseFactor(Hero hero) {
|
||||
public int defenseFactor( Char owner ) {
|
||||
return 5+2*level(); //5 extra defence, plus 2 per level;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Sai extends MeleeWeapon {
|
||||
|
@ -40,7 +40,7 @@ public class Sai extends MeleeWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int defenseFactor(Hero hero) {
|
||||
public int defenseFactor( Char owner ) {
|
||||
return 3; //3 extra defence
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user