v2.0.0: fixed various bugs with charged shot and displacing darts

This commit is contained in:
Evan Debenham
2023-02-22 19:38:46 -05:00
parent 4ddd16ee33
commit 06207dd8e2
2 changed files with 18 additions and 8 deletions

View File

@@ -141,7 +141,7 @@ public class Dart extends MissileWeapon {
int dmg = super.proc(attacker, defender, damage);
if (!processingChargedShot) {
processChargedShot(defender.pos, damage);
processChargedShot(defender, damage);
}
return dmg;
}
@@ -155,17 +155,22 @@ public class Dart extends MissileWeapon {
@Override
protected void onThrow(int cell) {
updateCrossbow();
//we have to set this here, as on-hit effects can move the target we aim at
chargedShotPos = cell;
super.onThrow(cell);
}
private boolean processingChargedShot = false;
protected void processChargedShot( int cell, int dmg ){
private int chargedShotPos;
protected void processChargedShot( Char target, int dmg ){
//don't update xbow here, as dart may be the active weapon atm
processingChargedShot = true;
if (bow != null && Dungeon.hero.buff(Crossbow.ChargedShot.class) != null) {
PathFinder.buildDistanceMap(cell, Dungeon.level.passable, 1);
if (chargedShotPos != -1 && bow != null && Dungeon.hero.buff(Crossbow.ChargedShot.class) != null) {
PathFinder.buildDistanceMap(chargedShotPos, Dungeon.level.passable, 1);
//necessary to clone as some on-hit effects use Pathfinder
int[] distance = PathFinder.distance.clone();
for (Char ch : Actor.chars()){
if (ch.pos == cell){
if (ch == target){
Actor.add(new Actor() {
{ actPriority = VFX_PRIO; }
@Override
@@ -177,11 +182,12 @@ public class Dart extends MissileWeapon {
return true;
}
});
} else if (PathFinder.distance[ch.pos] != Integer.MAX_VALUE){
} else if (distance[ch.pos] != Integer.MAX_VALUE){
proc(Dungeon.hero, ch, dmg);
}
}
}
chargedShotPos = -1;
processingChargedShot = false;
}

View File

@@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.watabou.utils.PathFinder;
@@ -91,10 +92,13 @@ public class DisplacingDart extends TippedDart {
if (chosenPos != -1){
ScrollOfTeleportation.appear( defender, chosenPos );
if (!Dungeon.level.heroFOV[chosenPos]){
Dungeon.level.occupyCell(defender );
if (defender == Dungeon.hero){
Dungeon.observe();
GameScene.updateFog();
} else if (!Dungeon.level.heroFOV[chosenPos]){
Buff.affect(attacker, TalismanOfForesight.CharAwareness.class, 5f).charID = defender.id();
}
Dungeon.level.occupyCell(defender );
}
}