v1.4.0: adjusted enemy invis logic in the rare cases it applies to them
This commit is contained in:
@@ -469,6 +469,11 @@ public abstract class Char extends Actor {
|
||||
float acuStat = attacker.attackSkill( defender );
|
||||
float defStat = defender.defenseSkill( attacker );
|
||||
|
||||
//invisible chars always hit (for the hero this is surprise attacking)
|
||||
if (attacker.invisible > 0 && attacker.canSurpriseAttack()){
|
||||
acuStat = INFINITE_ACCURACY;
|
||||
}
|
||||
|
||||
//if accuracy or evasion are large enough, treat them as infinite.
|
||||
//note that infinite evasion beats infinite accuracy
|
||||
if (defStat >= INFINITE_EVASION){
|
||||
@@ -539,6 +544,11 @@ public abstract class Char extends Actor {
|
||||
if ( buff( Dread.class ) != null) speed *= 2f;
|
||||
return speed;
|
||||
}
|
||||
|
||||
//currently only used by invisible chars, or by the hero
|
||||
public boolean canSurpriseAttack(){
|
||||
return true;
|
||||
}
|
||||
|
||||
//used so that buffs(Shieldbuff.class) isn't called every time unnecessarily
|
||||
private int cachedShield = 0;
|
||||
|
||||
@@ -94,26 +94,31 @@ public class Invisibility extends FlavourBuff {
|
||||
public static void dispel() {
|
||||
if (Dungeon.hero == null) return;
|
||||
|
||||
for ( Buff invis : Dungeon.hero.buffs( Invisibility.class )){
|
||||
dispel(Dungeon.hero);
|
||||
}
|
||||
|
||||
public static void dispel(Char ch){
|
||||
|
||||
for ( Buff invis : ch.buffs( Invisibility.class )){
|
||||
invis.detach();
|
||||
}
|
||||
CloakOfShadows.cloakStealth cloakBuff = Dungeon.hero.buff( CloakOfShadows.cloakStealth.class );
|
||||
CloakOfShadows.cloakStealth cloakBuff = ch.buff( CloakOfShadows.cloakStealth.class );
|
||||
if (cloakBuff != null) {
|
||||
cloakBuff.dispel();
|
||||
}
|
||||
|
||||
//these aren't forms of invisibilty, but do dispel at the same time as it.
|
||||
TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff( TimekeepersHourglass.timeFreeze.class );
|
||||
|
||||
//these aren't forms of invisibility, but do dispel at the same time as it.
|
||||
TimekeepersHourglass.timeFreeze timeFreeze = ch.buff( TimekeepersHourglass.timeFreeze.class );
|
||||
if (timeFreeze != null) {
|
||||
timeFreeze.detach();
|
||||
}
|
||||
|
||||
Preparation prep = Dungeon.hero.buff( Preparation.class );
|
||||
|
||||
Preparation prep = ch.buff( Preparation.class );
|
||||
if (prep != null){
|
||||
prep.detach();
|
||||
}
|
||||
|
||||
Swiftthistle.TimeBubble bubble = Dungeon.hero.buff( Swiftthistle.TimeBubble.class );
|
||||
|
||||
Swiftthistle.TimeBubble bubble = ch.buff( Swiftthistle.TimeBubble.class );
|
||||
if (bubble != null){
|
||||
bubble.detach();
|
||||
}
|
||||
|
||||
@@ -578,12 +578,13 @@ public class Hero extends Char {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurpriseAttack(){
|
||||
if (belongings.weapon() == null || !(belongings.weapon() instanceof Weapon)) return true;
|
||||
if (STR() < ((Weapon)belongings.weapon()).STRReq()) return false;
|
||||
if (belongings.weapon() instanceof Flail) return false;
|
||||
|
||||
return true;
|
||||
return super.canSurpriseAttack();
|
||||
}
|
||||
|
||||
public boolean canAttack(Char enemy){
|
||||
@@ -1100,7 +1101,7 @@ public class Hero extends Char {
|
||||
|
||||
enemy = action.target;
|
||||
|
||||
if (enemy.isAlive() && canAttack( enemy ) && !isCharmedBy( enemy )) {
|
||||
if (enemy.isAlive() && canAttack( enemy ) && !isCharmedBy( enemy ) && enemy.invisible == 0) {
|
||||
|
||||
sprite.attack( enemy.pos );
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
||||
@@ -89,7 +90,8 @@ public class DM100 extends Mob implements Callback {
|
||||
} else {
|
||||
|
||||
spend( TIME_TO_ZAP );
|
||||
|
||||
|
||||
Invisibility.dispel(this);
|
||||
if (hit( this, enemy, true )) {
|
||||
int dmg = Random.NormalIntRange(3, 10);
|
||||
dmg = Math.round(dmg * AscensionChallenge.statModifier(this));
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost;
|
||||
@@ -144,7 +145,8 @@ public abstract class Elemental extends Mob {
|
||||
|
||||
private void zap() {
|
||||
spend( 1f );
|
||||
|
||||
|
||||
Invisibility.dispel(this);
|
||||
if (hit( this, enemy, true )) {
|
||||
|
||||
rangedProc( enemy );
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Light;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PurpleParticle;
|
||||
@@ -162,6 +163,7 @@ public class Eye extends Mob {
|
||||
|
||||
boolean terrainAffected = false;
|
||||
|
||||
Invisibility.dispel(this);
|
||||
for (int pos : beam.subPath(1, beam.dist)) {
|
||||
|
||||
if (Dungeon.level.flamable[pos]) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
@@ -190,6 +191,7 @@ public class Goo extends Mob {
|
||||
((GooSprite)sprite).triggerEmitters();
|
||||
}
|
||||
attack( enemy );
|
||||
Invisibility.dispel(this);
|
||||
spend( attackDelay() );
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Dread;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Preparation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Sleep;
|
||||
@@ -572,6 +573,7 @@ public abstract class Mob extends Char {
|
||||
|
||||
} else {
|
||||
attack( enemy );
|
||||
Invisibility.dispel(this);
|
||||
spend( attackDelay() );
|
||||
return true;
|
||||
}
|
||||
@@ -580,6 +582,7 @@ public abstract class Mob extends Char {
|
||||
@Override
|
||||
public void onAttackComplete() {
|
||||
attack( enemy );
|
||||
Invisibility.dispel(this);
|
||||
spend( attackDelay() );
|
||||
super.onAttackComplete();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hex;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vulnerable;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
@@ -109,7 +110,8 @@ public abstract class Shaman extends Mob {
|
||||
|
||||
private void zap() {
|
||||
spend( 1f );
|
||||
|
||||
|
||||
Invisibility.dispel(this);
|
||||
if (hit( this, enemy, true )) {
|
||||
|
||||
if (Random.Int( 2 ) == 0) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Degrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
@@ -102,7 +103,8 @@ public class Warlock extends Mob implements Callback {
|
||||
|
||||
protected void zap() {
|
||||
spend( TIME_TO_ZAP );
|
||||
|
||||
|
||||
Invisibility.dispel(this);
|
||||
if (hit( this, enemy, true )) {
|
||||
//TODO would be nice for this to work on ghost/statues too
|
||||
if (enemy == Dungeon.hero && Random.Int( 2 ) == 0) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Amok;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Dread;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Light;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
|
||||
@@ -220,6 +221,7 @@ public class YogDzewa extends Mob {
|
||||
if (terrainAffected) {
|
||||
Dungeon.observe();
|
||||
}
|
||||
Invisibility.dispel(this);
|
||||
for (Char ch : affected) {
|
||||
|
||||
if (hit( this, ch, true )) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Light;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
|
||||
@@ -312,6 +313,7 @@ public abstract class YogFist extends Mob {
|
||||
protected void zap() {
|
||||
spend( 1f );
|
||||
|
||||
Invisibility.dispel(this);
|
||||
if (hit( this, enemy, true )) {
|
||||
|
||||
Buff.affect( enemy, Roots.class, 3f );
|
||||
@@ -468,6 +470,7 @@ public abstract class YogFist extends Mob {
|
||||
protected void zap() {
|
||||
spend( 1f );
|
||||
|
||||
Invisibility.dispel(this);
|
||||
if (hit( this, enemy, true )) {
|
||||
|
||||
enemy.damage( Random.NormalIntRange(10, 20), new LightBeam() );
|
||||
@@ -532,6 +535,7 @@ public abstract class YogFist extends Mob {
|
||||
protected void zap() {
|
||||
spend( 1f );
|
||||
|
||||
Invisibility.dispel(this);
|
||||
if (hit( this, enemy, true )) {
|
||||
|
||||
enemy.damage( Random.NormalIntRange(10, 20), new DarkBolt() );
|
||||
|
||||
Reference in New Issue
Block a user