v0.4.0: refactor to ring logic
This commit is contained in:
parent
912fd447d0
commit
16a3e5932b
src/com/shatteredpixel/shatteredpixeldungeon
actors
items
rings
weapon
levels
|
@ -176,9 +176,7 @@ public class Hero extends Char {
|
|||
public int STR() {
|
||||
int STR = this.STR;
|
||||
|
||||
for (Buff buff : buffs(RingOfMight.Might.class)) {
|
||||
STR += ((RingOfMight.Might)buff).level;
|
||||
}
|
||||
STR += RingOfMight.getBonus(this, RingOfMight.Might.class);
|
||||
|
||||
return weakened ? STR - 2 : STR;
|
||||
}
|
||||
|
@ -276,10 +274,7 @@ public class Hero extends Char {
|
|||
@Override
|
||||
public int defenseSkill( Char enemy ) {
|
||||
|
||||
int bonus = 0;
|
||||
for (Buff buff : buffs( RingOfEvasion.Evasion.class )) {
|
||||
bonus += ((RingOfEvasion.Evasion)buff).effectiveLevel;
|
||||
}
|
||||
int bonus = RingOfEvasion.getBonus(this, RingOfEvasion.Evasion.class);
|
||||
|
||||
float evasion = (float)Math.pow( 1.15, bonus );
|
||||
if (paralysed > 0) {
|
||||
|
@ -318,10 +313,7 @@ public class Hero extends Char {
|
|||
public int damageRoll() {
|
||||
KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon;
|
||||
int dmg;
|
||||
int bonus = 0;
|
||||
for (Buff buff : buffs( RingOfForce.Force.class )) {
|
||||
bonus += ((RingOfForce.Force)buff).level;
|
||||
}
|
||||
int bonus = RingOfForce.getBonus(this, RingOfForce.Force.class);
|
||||
|
||||
if (wep != null) {
|
||||
dmg = wep.damageRoll( this ) + bonus;
|
||||
|
@ -344,10 +336,7 @@ public class Hero extends Char {
|
|||
|
||||
float speed = super.speed();
|
||||
|
||||
int hasteLevel = 0;
|
||||
for (Buff buff : buffs( RingOfHaste.Haste.class )) {
|
||||
hasteLevel += ((RingOfHaste.Haste)buff).level;
|
||||
}
|
||||
int hasteLevel = RingOfHaste.getBonus(this, RingOfHaste.Haste.class);
|
||||
|
||||
if (hasteLevel != 0)
|
||||
speed *= Math.pow(1.2, hasteLevel);
|
||||
|
@ -419,10 +408,7 @@ public class Hero extends Char {
|
|||
//Normally putting furor speed on unarmed attacks would be unnecessary
|
||||
//But there's going to be that one guy who gets a furor+force ring combo
|
||||
//This is for that one guy, you shall get your fists of fury!
|
||||
int bonus = 0;
|
||||
for (Buff buff : buffs(RingOfFuror.Furor.class)) {
|
||||
bonus += ((RingOfFuror.Furor)buff).level;
|
||||
}
|
||||
int bonus = RingOfFuror.getBonus(this, RingOfFuror.Furor.class);
|
||||
return (float)(0.25 + (1 - 0.25)*Math.pow(0.8, bonus));
|
||||
}
|
||||
}
|
||||
|
@ -949,10 +935,7 @@ public class Hero extends Char {
|
|||
dmg = thorns.proc(dmg, (src instanceof Char ? (Char)src : null), this);
|
||||
}
|
||||
|
||||
int tenacity = 0;
|
||||
for (Buff buff : buffs(RingOfTenacity.Tenacity.class)) {
|
||||
tenacity += ((RingOfTenacity.Tenacity)buff).level;
|
||||
}
|
||||
int tenacity = RingOfTenacity.getBonus(this, RingOfTenacity.Tenacity.class);
|
||||
if (tenacity != 0) //(HT - HP)/HT = heroes current % missing health.
|
||||
dmg = (int)Math.ceil((float)dmg * Math.pow(0.9, tenacity*((float)(HT - HP)/HT)));
|
||||
|
||||
|
@ -1201,11 +1184,7 @@ public class Hero extends Char {
|
|||
GLog.w(msg);
|
||||
}
|
||||
|
||||
if (buff instanceof RingOfMight.Might) {
|
||||
if (((RingOfMight.Might) buff).level > 0) {
|
||||
HT += ((RingOfMight.Might) buff).level * 5;
|
||||
}
|
||||
} else if (buff instanceof Paralysis || buff instanceof Vertigo) {
|
||||
if (buff instanceof Paralysis || buff instanceof Vertigo) {
|
||||
interrupt();
|
||||
}
|
||||
|
||||
|
@ -1217,14 +1196,7 @@ public class Hero extends Char {
|
|||
@Override
|
||||
public void remove( Buff buff ) {
|
||||
super.remove( buff );
|
||||
|
||||
if (buff instanceof RingOfMight.Might){
|
||||
if (((RingOfMight.Might)buff).level > 0){
|
||||
HT -= ((RingOfMight.Might) buff).level * 5;
|
||||
HP = Math.min(HT, HP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BuffIndicator.refreshHero();
|
||||
}
|
||||
|
||||
|
|
|
@ -342,10 +342,7 @@ public abstract class Mob extends Char {
|
|||
boolean seen = enemySeen || (enemy == Dungeon.hero && Dungeon.hero.encumbered());
|
||||
if (seen && paralysed == 0) {
|
||||
int defenseSkill = this.defenseSkill;
|
||||
int penalty = 0;
|
||||
for (Buff buff : enemy.buffs(RingOfAccuracy.Accuracy.class)) {
|
||||
penalty += ((RingOfAccuracy.Accuracy) buff).level;
|
||||
}
|
||||
int penalty = RingOfAccuracy.getBonus(enemy, RingOfAccuracy.Accuracy.class);
|
||||
if (penalty != 0 && enemy == Dungeon.hero)
|
||||
defenseSkill *= Math.pow(0.75, penalty);
|
||||
return defenseSkill;
|
||||
|
@ -448,11 +445,7 @@ public abstract class Mob extends Char {
|
|||
super.die( cause );
|
||||
|
||||
float lootChance = this.lootChance;
|
||||
int bonus = 0;
|
||||
for (Buff buff : Dungeon.hero.buffs(RingOfWealth.Wealth.class)) {
|
||||
bonus += ((RingOfWealth.Wealth) buff).level;
|
||||
}
|
||||
|
||||
int bonus = RingOfWealth.getBonus(Dungeon.hero, RingOfWealth.Wealth.class);
|
||||
lootChance *= Math.pow(1.1, bonus);
|
||||
|
||||
if (Random.Float() < lootChance && Dungeon.hero.lvl <= maxLvl + 2) {
|
||||
|
|
|
@ -239,6 +239,14 @@ public class Ring extends KindofMisc {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getBonus(Char target, Class<?extends RingBuff> type){
|
||||
int bonus = 0;
|
||||
for (RingBuff buff : target.buffs(type)) {
|
||||
bonus += buff.level();
|
||||
}
|
||||
return bonus;
|
||||
}
|
||||
|
||||
public class RingBuff extends Buff {
|
||||
|
||||
@Override
|
||||
|
@ -270,5 +278,6 @@ public class Ring extends KindofMisc {
|
|||
public int level(){
|
||||
return Ring.this.level();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class RingOfElements extends Ring {
|
|||
public class Resistance extends RingBuff {
|
||||
|
||||
public HashSet<Class<?>> resistances() {
|
||||
if (Random.Int( level + 2 ) >= 2) {
|
||||
if (Random.Int( level() + 2 ) >= 2) {
|
||||
return FULL;
|
||||
} else {
|
||||
return EMPTY;
|
||||
|
@ -62,7 +62,7 @@ public class RingOfElements extends Ring {
|
|||
}
|
||||
|
||||
public float durationFactor() {
|
||||
return level < 0 ? 1 : (1 + 0.5f * level) / (1 + level);
|
||||
return level() < 0 ? 1 : (1 + 0.5f * level()) / (1 + level());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,13 +34,11 @@ public class RingOfEvasion extends Ring {
|
|||
//yup, the only ring in the game with logic inside of its class
|
||||
public class Evasion extends RingBuff {
|
||||
public int effectiveLevel;
|
||||
private int pos;
|
||||
|
||||
@Override
|
||||
public boolean attachTo( Char target ) {
|
||||
|
||||
pos = target.pos;
|
||||
effectiveLevel = Math.min(0, level());
|
||||
effectiveLevel = Math.min(0, RingOfEvasion.this.level());
|
||||
return super.attachTo(target);
|
||||
}
|
||||
|
||||
|
@ -56,15 +54,20 @@ public class RingOfEvasion extends Ring {
|
|||
}
|
||||
}
|
||||
|
||||
if (level() < 1){
|
||||
effectiveLevel = level();
|
||||
if (RingOfEvasion.this.level() < 1){
|
||||
effectiveLevel = RingOfEvasion.this.level();
|
||||
} else if (seen) {
|
||||
effectiveLevel = Math.max(effectiveLevel - 1, 0);
|
||||
} else {
|
||||
effectiveLevel = Math.min(effectiveLevel + 1, level());
|
||||
effectiveLevel = Math.min(effectiveLevel + 1, RingOfEvasion.this.level());
|
||||
}
|
||||
|
||||
return super.act();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int level() {
|
||||
return effectiveLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.utils.Random;
|
||||
|
@ -38,10 +37,7 @@ public class RingOfForce extends Ring {
|
|||
}
|
||||
|
||||
public static int damageRoll( Hero hero ){
|
||||
int level = 0;
|
||||
for (Buff buff : hero.buffs( RingOfForce.Force.class )) {
|
||||
level += ((RingOfForce.Force)buff).level;
|
||||
}
|
||||
int level = getBonus(hero, Force.class);
|
||||
float tier = tier(hero.STR());
|
||||
return Random.NormalIntRange(min(level, tier), max(level, tier));
|
||||
}
|
||||
|
|
|
@ -21,8 +21,54 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
|
||||
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
|
||||
public class RingOfMight extends Ring {
|
||||
|
||||
@Override
|
||||
public boolean doEquip(Hero hero) {
|
||||
if (super.doEquip(hero)){
|
||||
hero.HT += level()*5;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
|
||||
|
||||
if (super.doUnequip(hero, collect, single)){
|
||||
hero.HT -= level()*5;
|
||||
hero.HP = Math.min(hero.HP, hero.HT);
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
if (buff != null && buff.target != null){
|
||||
buff.target.HT += 5;
|
||||
}
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void level(int value) {
|
||||
if (buff != null && buff.target != null){
|
||||
buff.target.HT -= level()*5;
|
||||
}
|
||||
super.level(value);
|
||||
if (buff != null && buff.target != null){
|
||||
buff.target.HT += level()*5;
|
||||
buff.target.HP = Math.min(buff.target.HP, buff.target.HT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RingBuff buff( ) {
|
||||
return new Might();
|
||||
|
|
|
@ -147,10 +147,7 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
float ACC = this.ACC;
|
||||
|
||||
if (this instanceof MissileWeapon) {
|
||||
int bonus = 0;
|
||||
for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) {
|
||||
bonus += ((RingOfSharpshooting.Aim)buff).level;
|
||||
}
|
||||
int bonus = RingOfSharpshooting.getBonus(hero, RingOfSharpshooting.Aim.class);
|
||||
ACC *= (float)(Math.pow(1.1, bonus));
|
||||
}
|
||||
|
||||
|
@ -167,10 +164,7 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
|
||||
float DLY = imbue.delayFactor(this.DLY);
|
||||
|
||||
int bonus = 0;
|
||||
for (Buff buff : hero.buffs(RingOfFuror.Furor.class)) {
|
||||
bonus += ((RingOfFuror.Furor)buff).level;
|
||||
}
|
||||
int bonus = RingOfFuror.getBonus(hero, RingOfFuror.Furor.class);
|
||||
|
||||
DLY = (float)(0.25 + (DLY - 0.25)*Math.pow(0.8, bonus));
|
||||
|
||||
|
|
|
@ -79,10 +79,8 @@ abstract public class MissileWeapon extends Weapon {
|
|||
if (!curUser.shoot( enemy, this )) {
|
||||
miss( cell );
|
||||
} else if (!(this instanceof Boomerang)){
|
||||
int bonus = 0;
|
||||
|
||||
for (Buff buff : curUser.buffs(RingOfSharpshooting.Aim.class))
|
||||
bonus += ((RingOfSharpshooting.Aim)buff).level;
|
||||
int bonus = RingOfSharpshooting.getBonus(curUser, RingOfSharpshooting.Aim.class);
|
||||
|
||||
if (curUser.heroClass == HeroClass.HUNTRESS && enemy.buff(PinCushion.class) == null)
|
||||
bonus += 3;
|
||||
|
@ -99,10 +97,7 @@ abstract public class MissileWeapon extends Weapon {
|
|||
}
|
||||
|
||||
protected void miss( int cell ) {
|
||||
int bonus = 0;
|
||||
for (Buff buff : curUser.buffs(RingOfSharpshooting.Aim.class)) {
|
||||
bonus += ((RingOfSharpshooting.Aim)buff).level;
|
||||
}
|
||||
int bonus = RingOfSharpshooting.getBonus(curUser, RingOfSharpshooting.Aim.class);
|
||||
|
||||
//degraded ring of sharpshooting will even make missed shots break.
|
||||
if (Random.Float() < Math.pow(0.6, -bonus))
|
||||
|
|
|
@ -211,10 +211,7 @@ public abstract class Level implements Bundlable {
|
|||
Dungeon.limitedDrops.arcaneStyli.count++;
|
||||
}
|
||||
|
||||
int bonus = 0;
|
||||
for (Buff buff : Dungeon.hero.buffs(RingOfWealth.Wealth.class)) {
|
||||
bonus += ((RingOfWealth.Wealth) buff).level;
|
||||
}
|
||||
int bonus = RingOfWealth.getBonus(Dungeon.hero, RingOfWealth.Wealth.class);
|
||||
if (Random.Float() > Math.pow(0.95, bonus)){
|
||||
if (Random.Int(2) == 0)
|
||||
addItemToSpawn( new ScrollOfMagicalInfusion() );
|
||||
|
|
|
@ -663,10 +663,8 @@ public abstract class RegularLevel extends Level {
|
|||
protected void createItems() {
|
||||
|
||||
int nItems = 3;
|
||||
int bonus = 0;
|
||||
for (Buff buff : Dungeon.hero.buffs(RingOfWealth.Wealth.class)) {
|
||||
bonus += ((RingOfWealth.Wealth) buff).level;
|
||||
}
|
||||
int bonus = RingOfWealth.getBonus(Dungeon.hero, RingOfWealth.Wealth.class);
|
||||
|
||||
//just incase someone gets a ridiculous ring, cap this at 80%
|
||||
bonus = Math.min(bonus, 10);
|
||||
while (Random.Float() < (0.3f + bonus*0.05f)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user