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