v0.9.2b: fixed cases where vfx/sfx were playing for non-visible combat

This commit is contained in:
Evan Debenham 2021-03-17 17:23:19 -04:00
parent 2d61a65a84
commit 68f879a4ff
6 changed files with 99 additions and 73 deletions

View File

@ -86,18 +86,16 @@ public class DM100 extends Mob implements Callback {
} else {
if (sprite != null && (sprite.visible || enemy.sprite.visible)) {
sprite.zap( enemy.pos );
}
spend( TIME_TO_ZAP );
if (hit( this, enemy, true )) {
int dmg = Random.NormalIntRange(3, 10);
enemy.damage( dmg, new LightningBolt() );
enemy.sprite.centerEmitter().burst( SparkParticle.FACTORY, 3 );
enemy.sprite.flash();
if (enemy.sprite.visible) {
enemy.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
enemy.sprite.flash();
}
if (enemy == Dungeon.hero) {
@ -112,7 +110,7 @@ public class DM100 extends Mob implements Callback {
enemy.sprite.showStatus( CharSprite.NEUTRAL, enemy.defenseVerb() );
}
if (sprite != null && sprite.visible) {
if (sprite != null && (sprite.visible || enemy.sprite.visible)) {
sprite.zap( enemy.pos );
return false;
} else {

View File

@ -158,8 +158,10 @@ public class Goo extends Mob {
sprite.attack(enemy.pos);
}
} else {
if (pumpedUp >= 2){
((GooSprite)sprite).triggerEmitters();
}
attack( enemy );
((GooSprite)sprite).triggerEmitters();
}
spend( attackDelay() );

View File

@ -90,32 +90,41 @@ public class Guard extends Mob {
} else {
final int newPosFinal = newPos;
this.target = newPos;
yell( Messages.get(this, "scorpion") );
new Item().throwSound();
Sample.INSTANCE.play( Assets.Sounds.CHAINS );
sprite.parent.add(new Chains(sprite.center(), enemy.sprite.center(), new Callback() {
public void call() {
Actor.addDelayed(new Pushing(enemy, enemy.pos, newPosFinal, new Callback(){
public void call() {
enemy.pos = newPosFinal;
Dungeon.level.occupyCell(enemy);
Cripple.prolong(enemy, Cripple.class, 4f);
if (enemy == Dungeon.hero) {
Dungeon.hero.interrupt();
Dungeon.observe();
GameScene.updateFog();
if (sprite.visible || enemy.sprite.visible) {
yell(Messages.get(this, "scorpion"));
new Item().throwSound();
Sample.INSTANCE.play(Assets.Sounds.CHAINS);
sprite.parent.add(new Chains(sprite.center(), enemy.sprite.center(), new Callback() {
public void call() {
Actor.addDelayed(new Pushing(enemy, enemy.pos, newPosFinal, new Callback() {
public void call() {
pullEnemy(enemy, newPosFinal);
}
}
}), -1);
next();
}
}));
}), -1);
next();
}
}));
} else {
pullEnemy(enemy, newPos);
}
}
}
chainsUsed = true;
return true;
}
private void pullEnemy( Char enemy, int pullPos ){
enemy.pos = pullPos;
Dungeon.level.occupyCell(enemy);
Cripple.prolong(enemy, Cripple.class, 4f);
if (enemy == Dungeon.hero) {
Dungeon.hero.interrupt();
Dungeon.observe();
GameScene.updateFog();
}
}
@Override
public int attackSkill( Char target ) {
return 12;
@ -167,7 +176,7 @@ public class Guard extends Mob {
&& Random.Int(3) == 0
&& chain(enemy.pos)){
return false;
return !(sprite.visible || enemy.sprite.visible);
} else {
return super.act( enemyInFOV, justAlerted );
}

View File

@ -21,7 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
@ -30,7 +29,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.ChampionEnemy;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption;
import com.shatteredpixel.shatteredpixeldungeon.effects.Beam;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
@ -39,8 +37,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportat
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.NecromancerSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.SkeletonSprite;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.particles.Emitter;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
@ -65,8 +61,7 @@ public class Necromancer extends Mob {
}
public boolean summoning = false;
private Emitter summoningEmitter = null;
private int summoningPos = -1;
public int summoningPos = -1;
private boolean firstSummon = true;
@ -81,20 +76,6 @@ public class Necromancer extends Mob {
}
return super.act();
}
@Override
public void updateSpriteState() {
super.updateSpriteState();
if (summoning && summoningEmitter == null){
summoningEmitter = CellEmitter.get( summoningPos );
summoningEmitter.pour(Speck.factory(Speck.RATTLE), 0.2f);
sprite.zap( summoningPos );
} else if (!summoning && summoningEmitter != null){
summoningEmitter.on = false;
summoningEmitter = null;
}
}
@Override
public int drRoll() {
@ -127,11 +108,6 @@ public class Necromancer extends Mob {
mySkeleton.die(null);
}
if (summoningEmitter != null){
summoningEmitter.on = false;
summoningEmitter = null;
}
super.die(cause);
}
@ -184,9 +160,9 @@ public class Necromancer extends Mob {
}
mySkeleton.HP = Math.min(mySkeleton.HP + 5, mySkeleton.HT);
mySkeleton.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
if (mySkeleton.sprite.visible) mySkeleton.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
//otherwise give it adrenaline
//otherwise give it adrenaline
} else if (mySkeleton.buff(Adrenaline.class) == null) {
if (sprite.visible || mySkeleton.sprite.visible) {
@ -253,9 +229,7 @@ public class Necromancer extends Mob {
mySkeleton.pos = summoningPos;
GameScene.add( mySkeleton );
Dungeon.level.occupyCell( mySkeleton );
Sample.INSTANCE.play(Assets.Sounds.BONES);
summoningEmitter.burst(Speck.factory(Speck.RATTLE), 5);
sprite.idle();
((NecromancerSprite)sprite).finishSummoning();
if (buff(Corruption.class) != null){
Buff.affect(mySkeleton, Corruption.class);
@ -291,9 +265,6 @@ public class Necromancer extends Mob {
if (summoningPos != -1){
summoning = true;
summoningEmitter = CellEmitter.get(summoningPos);
summoningEmitter.pour(Speck.factory(Speck.RATTLE), 0.2f);
sprite.zap( summoningPos );
spend( firstSummon ? TICK : 2*TICK );

View File

@ -220,14 +220,6 @@ public class NewTengu extends Mob {
return new Ballistica( pos, enemy.pos, Ballistica.PROJECTILE).collisionPos == enemy.pos;
}
//tengu's attack is always visible
@Override
protected boolean doAttack(Char enemy) {
sprite.attack( enemy.pos );
spend( attackDelay() );
return false;
}
private void jump() {
//in case tengu hasn't had a chance to act yet

View File

@ -22,13 +22,19 @@
package com.shatteredpixel.shatteredpixeldungeon.sprites;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Necromancer;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.watabou.noosa.TextureFilm;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.particles.Emitter;
public class NecromancerSprite extends MobSprite {
private Animation charging;
private Emitter summoningBones;
public NecromancerSprite(){
super();
@ -55,7 +61,49 @@ public class NecromancerSprite extends MobSprite {
idle();
}
@Override
public void link(Char ch) {
super.link(ch);
if (ch instanceof Necromancer && ((Necromancer) ch).summoning){
zap(((Necromancer) ch).summoningPos);
}
}
@Override
public void update() {
super.update();
if (summoningBones != null){
summoningBones.visible = Dungeon.level.heroFOV[((Necromancer) ch).summoningPos];
}
}
@Override
public void die() {
super.die();
if (summoningBones != null){
summoningBones.on = false;
}
}
@Override
public void kill() {
super.kill();
if (summoningBones != null){
summoningBones.killAndErase();
}
}
public void finishSummoning(){
if (summoningBones.visible) {
Sample.INSTANCE.play(Assets.Sounds.BONES);
summoningBones.burst(Speck.factory(Speck.RATTLE), 5);
} else {
summoningBones.on = false;
}
idle();
}
public void charge(){
play(charging);
}
@ -63,8 +111,14 @@ public class NecromancerSprite extends MobSprite {
@Override
public void zap(int cell) {
super.zap(cell);
if (visible && ch instanceof Necromancer && ((Necromancer) ch).summoning){
Sample.INSTANCE.play( Assets.Sounds.CHARGEUP, 1f, 0.8f );
if (ch instanceof Necromancer && ((Necromancer) ch).summoning){
if (summoningBones != null){
summoningBones.on = false;
}
summoningBones = CellEmitter.get(((Necromancer) ch).summoningPos);
summoningBones.pour(Speck.factory(Speck.RATTLE), 0.2f);
summoningBones.visible = Dungeon.level.heroFOV[((Necromancer) ch).summoningPos];
if (visible || summoningBones.visible ) Sample.INSTANCE.play( Assets.Sounds.CHARGEUP, 1f, 0.8f );
}
}