From 23bfbfd3e70dd924a01dcf6717b799b06032f251 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 3 Dec 2014 16:49:27 -0500 Subject: [PATCH] v0.2.3: reworked ring of evasion, again --- .../actors/hero/Hero.java | 9 +++-- .../actors/mobs/Mob.java | 5 +++ .../items/rings/RingOfEvasion.java | 36 ++++++++++--------- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index f495e7101..bccaf59f9 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -282,7 +282,7 @@ public class Hero extends Char { bonus += ((RingOfEvasion.Evasion)buff).effectiveLevel; } - float evasion = bonus == 0 ? 1 : (float)Math.pow( 1.15, bonus ); + float evasion = (float)Math.pow( 1.15, bonus ); if (paralysed) { evasion /= 2; } @@ -1183,8 +1183,11 @@ public class Hero extends Char { @Override public int stealth() { - //no logic here since removal of Ring of Shadows, may do something here in future. - return super.stealth(); + int stealth = super.stealth(); + for (Buff buff : buffs( RingOfEvasion.Evasion.class )) { + stealth += ((RingOfEvasion.Evasion)buff).effectiveLevel; + } + return stealth; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 2057de822..4e983b40a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -431,6 +431,11 @@ public abstract class Mob extends Char { GLog.n( "%s: \"%s\" ", name, str ); } + //returns true when a mob sees the hero, and is currently targeting them. + public boolean focusingHero() { + return enemySeen && (target == Dungeon.hero.pos); + } + public interface AiState { public boolean act( boolean enemyInFOV, boolean justAlerted ); public String status(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java index 0752ca3c2..675f48a84 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java @@ -17,7 +17,9 @@ */ package com.shatteredpixel.shatteredpixeldungeon.items.rings; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; public class RingOfEvasion extends Ring { @@ -33,9 +35,10 @@ public class RingOfEvasion extends Ring { @Override public String desc() { return isKnown() ? - "This ring increases the wearer's ability to focus and anticipate the movements of an enemy. " + - "The longer the wearer stands still, the more focused they will become. " + - "A degraded ring will instead make dodging harder." : + "This ring obfuscates the true position of the wearer, making them harder to detect and attack." + + "This ring is much stronger while the user remains undetected, and if the user is targeted the power of " + + "evasion will slowly fade away, remaining undetected will restore the ring's effectiveness." + + "A degraded ring will instead make the user easier to detect and strike.": super.desc(); } @@ -55,22 +58,23 @@ public class RingOfEvasion extends Ring { @Override public boolean act() { - if (level >= 0) { - if (pos == target.pos && effectiveLevel < level) { - effectiveLevel++; - } else if (pos != target.pos) { - effectiveLevel = 0; - pos = target.pos; - } - } else if (level < 0) { - if (pos == target.pos && effectiveLevel < 0) { - effectiveLevel++; - } else if (pos != target.pos) { - effectiveLevel = level; - pos = target.pos; + boolean seen = false; + + for (Mob enemy : Dungeon.level.mobs.toArray(new Mob[0])){ + if (enemy.focusingHero()) { + seen = true; + break; } } + if (level < 1){ + effectiveLevel = level; + } else if (seen) { + effectiveLevel = Math.max(effectiveLevel - 1, 0); + } else { + effectiveLevel = Math.min(effectiveLevel + 1, level); + } + return super.act(); } }