v0.8.0: added large character logic to randomDestination

This commit is contained in:
Evan Debenham 2019-12-12 19:40:11 -05:00
parent 87012ef1de
commit 8919b068c8
7 changed files with 13 additions and 12 deletions

View File

@ -176,7 +176,7 @@ public class Ghoul extends Mob {
target = enemy.pos;
} else if (enemy == null) {
state = WANDERING;
target = Dungeon.level.randomDestination();
target = Dungeon.level.randomDestination( Ghoul.this );
return true;
}
@ -193,7 +193,7 @@ public class Ghoul extends Mob {
spend( TICK );
sprite.showLost();
state = WANDERING;
target = Dungeon.level.randomDestination();
target = Dungeon.level.randomDestination( Ghoul.this );
//try to move closer to partner if they can't move to hero
} else if (partner != null && getCloser(partner.pos)) {

View File

@ -794,7 +794,7 @@ public abstract class Mob extends Char {
spend( 1 / speed() );
return moveSprite( oldPos, pos );
} else {
target = Dungeon.level.randomDestination();
target = Dungeon.level.randomDestination( Mob.this );
spend( TICK );
}
@ -820,7 +820,7 @@ public abstract class Mob extends Char {
target = enemy.pos;
} else if (enemy == null) {
state = WANDERING;
target = Dungeon.level.randomDestination();
target = Dungeon.level.randomDestination( Mob.this );
return true;
}
@ -835,7 +835,7 @@ public abstract class Mob extends Char {
if (!enemyInFOV) {
sprite.showLost();
state = WANDERING;
target = Dungeon.level.randomDestination();
target = Dungeon.level.randomDestination( Mob.this );
}
return true;
}

View File

@ -357,7 +357,7 @@ public class CursedWand {
GameScene.add( Blob.seed(i, 15, Regrowth.class));
}
do {
GameScene.add(Blob.seed(Dungeon.level.randomDestination(), 10, Fire.class));
GameScene.add(Blob.seed(Dungeon.level.randomDestination(null), 10, Fire.class));
} while (Random.Int(5) != 0);
new Flare(8, 32).color(0xFFFF66, true).show(user.sprite, 2f);
Sample.INSTANCE.play(Assets.SND_TELEPORT);

View File

@ -550,11 +550,12 @@ public abstract class Level implements Bundlable {
return cell;
}
public int randomDestination() {
public int randomDestination( Char ch ) {
int cell;
do {
cell = Random.Int( length() );
} while (!passable[cell]);
} while (!passable[cell]
|| (Char.hasProp(ch, Char.Property.LARGE) && !openSpace[cell]));
return cell;
}

View File

@ -250,7 +250,7 @@ public abstract class RegularLevel extends Level {
}
@Override
public int randomDestination() {
public int randomDestination( Char ch ) {
int count = 0;
int cell = -1;
@ -267,7 +267,7 @@ public abstract class RegularLevel extends Level {
}
cell = pointToCell(room.random());
if (passable[cell]) {
if (passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])) {
return cell;
}

View File

@ -66,7 +66,7 @@ public class FlashingTrap extends Trap {
if (c instanceof Mob) {
if (((Mob)c).state == ((Mob)c).HUNTING) ((Mob)c).state = ((Mob)c).WANDERING;
((Mob)c).beckon( Dungeon.level.randomDestination() );
((Mob)c).beckon( Dungeon.level.randomDestination( c ) );
}
}

View File

@ -53,7 +53,7 @@ public class Blindweed extends Plant {
Buff.prolong(ch, Cripple.class, len);
if (ch instanceof Mob) {
if (((Mob) ch).state == ((Mob) ch).HUNTING) ((Mob) ch).state = ((Mob) ch).WANDERING;
((Mob) ch).beckon(Dungeon.level.randomDestination());
((Mob) ch).beckon(Dungeon.level.randomDestination( ch ));
}
}
}