v1.4.0: fixed various char positioning errors with warp effects

This commit is contained in:
Evan Debenham
2022-08-21 13:13:19 -04:00
parent 5eef092e0a
commit 42197fdbad
3 changed files with 37 additions and 21 deletions

View File

@@ -429,7 +429,7 @@ public class Dungeon {
level.addRespawner();
for(Mob m : level.mobs){
if (m.pos == hero.pos){
if (m.pos == hero.pos && !Char.hasProp(m, Char.Property.IMMOVABLE)){
//displace mob
for(int i : PathFinder.NEIGHBOURS8){
if (Actor.findChar(m.pos+i) == null && level.passable[m.pos + i]){

View File

@@ -119,8 +119,6 @@ public class WarpBeacon extends ArmorAbility {
if (tracker.depth == Dungeon.depth && tracker.branch == Dungeon.branch){
Char existing = Actor.findChar(tracker.pos);
ScrollOfTeleportation.appear(hero, tracker.pos);
if (existing != null && existing != hero){
if (hero.hasTalent(Talent.TELEFRAG)){
int heroHP = hero.HP + hero.shielding();
@@ -150,13 +148,20 @@ public class WarpBeacon extends ArmorAbility {
Random.shuffle(candidates);
if (!candidates.isEmpty()){
ScrollOfTeleportation.appear(hero, tracker.pos);
Actor.addDelayed( new Pushing( toPush, toPush.pos, candidates.get(0) ), -1 );
toPush.pos = candidates.get(0);
Dungeon.level.occupyCell(toPush);
hero.next();
} else {
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") );
}
} else {
ScrollOfTeleportation.appear(hero, tracker.pos);
}
} else {
ScrollOfTeleportation.appear(hero, tracker.pos);
}
Invisibility.dispel();

View File

@@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfPassage;
@@ -43,6 +44,9 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class BeaconOfReturning extends Spell {
@@ -112,28 +116,35 @@ public class BeaconOfReturning extends Spell {
if (returnDepth == Dungeon.depth && returnBranch == Dungeon.branch) {
Char moving = Actor.findChar(returnPos);
if (moving != null){
moving.pos = returnPos+1;
}
Char existing = Actor.findChar(returnPos);
if (existing != null && existing != hero){
Char toPush = !Char.hasProp(existing, Char.Property.IMMOVABLE) ? hero : existing;
if (ScrollOfTeleportation.teleportToLocation(hero, returnPos)){
if (moving != null){
moving.pos = returnPos;
for(int i : PathFinder.NEIGHBOURS8){
if (Actor.findChar(moving.pos+i) == null
&& Dungeon.level.passable[moving.pos + i]
&& (!Char.hasProp(moving, Char.Property.LARGE) || Dungeon.level.openSpace[moving.pos + i])){
moving.pos += i;
moving.sprite.point(moving.sprite.worldToCamera(moving.pos));
break;
}
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
int cell = returnPos + n;
if (!Dungeon.level.solid[cell] && Actor.findChar( cell ) == null
&& (!Char.hasProp(toPush, Char.Property.LARGE) || Dungeon.level.openSpace[cell])) {
candidates.add( cell );
}
}
} else {
if (moving != null) {
moving.pos = returnPos;
Random.shuffle(candidates);
if (!candidates.isEmpty()){
if (toPush == hero){
returnPos = candidates.get(0);
} else {
Actor.addDelayed( new Pushing( toPush, toPush.pos, candidates.get(0) ), -1 );
toPush.pos = candidates.get(0);
Dungeon.level.occupyCell(toPush);
}
} else {
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") );
return;
}
}
if (!ScrollOfTeleportation.teleportToLocation(hero, returnPos)){
return;
}