v0.8.0: added large character logic to randomDestination
This commit is contained in:
parent
87012ef1de
commit
8919b068c8
|
@ -176,7 +176,7 @@ public class Ghoul extends Mob {
|
||||||
target = enemy.pos;
|
target = enemy.pos;
|
||||||
} else if (enemy == null) {
|
} else if (enemy == null) {
|
||||||
state = WANDERING;
|
state = WANDERING;
|
||||||
target = Dungeon.level.randomDestination();
|
target = Dungeon.level.randomDestination( Ghoul.this );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public class Ghoul extends Mob {
|
||||||
spend( TICK );
|
spend( TICK );
|
||||||
sprite.showLost();
|
sprite.showLost();
|
||||||
state = WANDERING;
|
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
|
//try to move closer to partner if they can't move to hero
|
||||||
} else if (partner != null && getCloser(partner.pos)) {
|
} else if (partner != null && getCloser(partner.pos)) {
|
||||||
|
|
|
@ -794,7 +794,7 @@ public abstract class Mob extends Char {
|
||||||
spend( 1 / speed() );
|
spend( 1 / speed() );
|
||||||
return moveSprite( oldPos, pos );
|
return moveSprite( oldPos, pos );
|
||||||
} else {
|
} else {
|
||||||
target = Dungeon.level.randomDestination();
|
target = Dungeon.level.randomDestination( Mob.this );
|
||||||
spend( TICK );
|
spend( TICK );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +820,7 @@ public abstract class Mob extends Char {
|
||||||
target = enemy.pos;
|
target = enemy.pos;
|
||||||
} else if (enemy == null) {
|
} else if (enemy == null) {
|
||||||
state = WANDERING;
|
state = WANDERING;
|
||||||
target = Dungeon.level.randomDestination();
|
target = Dungeon.level.randomDestination( Mob.this );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,7 +835,7 @@ public abstract class Mob extends Char {
|
||||||
if (!enemyInFOV) {
|
if (!enemyInFOV) {
|
||||||
sprite.showLost();
|
sprite.showLost();
|
||||||
state = WANDERING;
|
state = WANDERING;
|
||||||
target = Dungeon.level.randomDestination();
|
target = Dungeon.level.randomDestination( Mob.this );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,7 +357,7 @@ public class CursedWand {
|
||||||
GameScene.add( Blob.seed(i, 15, Regrowth.class));
|
GameScene.add( Blob.seed(i, 15, Regrowth.class));
|
||||||
}
|
}
|
||||||
do {
|
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);
|
} while (Random.Int(5) != 0);
|
||||||
new Flare(8, 32).color(0xFFFF66, true).show(user.sprite, 2f);
|
new Flare(8, 32).color(0xFFFF66, true).show(user.sprite, 2f);
|
||||||
Sample.INSTANCE.play(Assets.SND_TELEPORT);
|
Sample.INSTANCE.play(Assets.SND_TELEPORT);
|
||||||
|
|
|
@ -550,11 +550,12 @@ public abstract class Level implements Bundlable {
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int randomDestination() {
|
public int randomDestination( Char ch ) {
|
||||||
int cell;
|
int cell;
|
||||||
do {
|
do {
|
||||||
cell = Random.Int( length() );
|
cell = Random.Int( length() );
|
||||||
} while (!passable[cell]);
|
} while (!passable[cell]
|
||||||
|
|| (Char.hasProp(ch, Char.Property.LARGE) && !openSpace[cell]));
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ public abstract class RegularLevel extends Level {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int randomDestination() {
|
public int randomDestination( Char ch ) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int cell = -1;
|
int cell = -1;
|
||||||
|
@ -267,7 +267,7 @@ public abstract class RegularLevel extends Level {
|
||||||
}
|
}
|
||||||
|
|
||||||
cell = pointToCell(room.random());
|
cell = pointToCell(room.random());
|
||||||
if (passable[cell]) {
|
if (passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])) {
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class FlashingTrap extends Trap {
|
||||||
|
|
||||||
if (c instanceof Mob) {
|
if (c instanceof Mob) {
|
||||||
if (((Mob)c).state == ((Mob)c).HUNTING) ((Mob)c).state = ((Mob)c).WANDERING;
|
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 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class Blindweed extends Plant {
|
||||||
Buff.prolong(ch, Cripple.class, len);
|
Buff.prolong(ch, Cripple.class, len);
|
||||||
if (ch instanceof Mob) {
|
if (ch instanceof Mob) {
|
||||||
if (((Mob) ch).state == ((Mob) ch).HUNTING) ((Mob) ch).state = ((Mob) ch).WANDERING;
|
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 ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user