v0.4.0: cleaned up weapon imbuing code
This commit is contained in:
parent
586e038dc4
commit
fee1868999
|
@ -68,7 +68,25 @@ abstract public class Weapon extends KindOfWeapon {
|
||||||
public int RCH = 1; // Reach modifier (only applies to melee hits)
|
public int RCH = 1; // Reach modifier (only applies to melee hits)
|
||||||
|
|
||||||
public enum Imbue {
|
public enum Imbue {
|
||||||
NONE, LIGHT, HEAVY
|
NONE (1.0f, 1.00f),
|
||||||
|
LIGHT (0.7f, 0.67f),
|
||||||
|
HEAVY (1.5f, 1.67f);
|
||||||
|
|
||||||
|
private float damageFactor;
|
||||||
|
private float delayFactor;
|
||||||
|
|
||||||
|
Imbue(float dmg, float dly){
|
||||||
|
damageFactor = dmg;
|
||||||
|
delayFactor = dly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int damageFactor(int dmg){
|
||||||
|
return Math.round(dmg * damageFactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float delayFactor(float dly){
|
||||||
|
return dly * delayFactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public Imbue imbue = Imbue.NONE;
|
public Imbue imbue = Imbue.NONE;
|
||||||
|
|
||||||
|
@ -145,7 +163,7 @@ abstract public class Weapon extends KindOfWeapon {
|
||||||
encumrance -= 2;
|
encumrance -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
float DLY = this.DLY * (imbue == Imbue.LIGHT ? 0.667f : (imbue == Imbue.HEAVY ? 1.667f : 1.0f));
|
float DLY = imbue.delayFactor(this.DLY);
|
||||||
|
|
||||||
int bonus = 0;
|
int bonus = 0;
|
||||||
for (Buff buff : hero.buffs(RingOfFuror.Furor.class)) {
|
for (Buff buff : hero.buffs(RingOfFuror.Furor.class)) {
|
||||||
|
@ -175,7 +193,7 @@ abstract public class Weapon extends KindOfWeapon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(damage * (imbue == Imbue.LIGHT ? 0.7f : (imbue == Imbue.HEAVY ? 1.5f : 1f)));
|
return imbue.damageFactor(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int STRReq(){
|
public int STRReq(){
|
||||||
|
|
|
@ -38,9 +38,9 @@ public class Lucky extends Weapon.Enchantment {
|
||||||
if (Random.Int(100) < (50 + level)){
|
if (Random.Int(100) < (50 + level)){
|
||||||
int exStr = 0;
|
int exStr = 0;
|
||||||
if (attacker == Dungeon.hero) exStr = Math.max(0, Dungeon.hero.STR() - weapon.STRReq());
|
if (attacker == Dungeon.hero) exStr = Math.max(0, Dungeon.hero.STR() - weapon.STRReq());
|
||||||
damage = weapon.max() + exStr - Random.IntRange(0, defender.dr());
|
damage = weapon.imbue.damageFactor(weapon.max()) + exStr - Random.IntRange(0, defender.dr());
|
||||||
} else {
|
} else {
|
||||||
damage = weapon.min() - Random.IntRange(0, defender.dr());
|
damage = weapon.imbue.damageFactor(weapon.min()) - Random.IntRange(0, defender.dr());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.max(0, damage);
|
return Math.max(0, damage);
|
||||||
|
|
|
@ -63,8 +63,7 @@ public class MeleeWeapon extends Weapon {
|
||||||
String info = desc();
|
String info = desc();
|
||||||
|
|
||||||
if (levelKnown) {
|
if (levelKnown) {
|
||||||
float dmgfactor = (imbue == Imbue.LIGHT ? 0.7f : imbue == Imbue.HEAVY ? 1.5f : 1);
|
info += "\n\n" + Messages.get(MeleeWeapon.class, "stats_known", tier, imbue.damageFactor(min()), imbue.damageFactor(max()), STRReq());
|
||||||
info += "\n\n" + Messages.get(MeleeWeapon.class, "stats_known", tier, Math.round(min()*dmgfactor), Math.round(max()*dmgfactor), STRReq());
|
|
||||||
if (STRReq() > Dungeon.hero.STR()) {
|
if (STRReq() > Dungeon.hero.STR()) {
|
||||||
info += " " + Messages.get(Weapon.class, "too_heavy");
|
info += " " + Messages.get(Weapon.class, "too_heavy");
|
||||||
} else if (Dungeon.hero.STR() > STRReq()){
|
} else if (Dungeon.hero.STR() > STRReq()){
|
||||||
|
|
|
@ -145,7 +145,7 @@ abstract public class MissileWeapon extends Weapon {
|
||||||
|
|
||||||
String info = desc();
|
String info = desc();
|
||||||
|
|
||||||
info += "\n\n" + Messages.get( MissileWeapon.class, "stats", min(), max(), STRReq());
|
info += "\n\n" + Messages.get( MissileWeapon.class, "stats", imbue.damageFactor(min()), imbue.damageFactor(max()), STRReq());
|
||||||
|
|
||||||
if (STRReq() > Dungeon.hero.STR()) {
|
if (STRReq() > Dungeon.hero.STR()) {
|
||||||
info += " " + Messages.get(Weapon.class, "too_heavy");
|
info += " " + Messages.get(Weapon.class, "too_heavy");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user