Merging Source v1.7.2: actor changes

This commit is contained in:
Evan Debenham
2014-10-20 23:51:15 -04:00
parent 724338b57f
commit 4a49763309
30 changed files with 980 additions and 682 deletions
@@ -246,7 +246,7 @@ public class King extends Mob {
EXP = 0;
state = State.WANDERING;
state = WANDERING;
}
@Override
@@ -20,6 +20,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
@@ -31,7 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.Wound;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfAccuracy;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
@@ -48,15 +48,13 @@ public abstract class Mob extends Char {
protected static final String TXT_NOTICE1 = "?!";
protected static final String TXT_RAGE = "#$%^";
protected static final String TXT_EXP = "%+dEXP";
public enum State {
SLEEPING,
HUNTING,
WANDERING,
FLEEING,
PASSIVE
}
public State state = State.SLEEPING;
public AiState SLEEPEING = new Sleeping();
public AiState HUNTING = new Hunting();
public AiState WANDERING = new Wandering();
public AiState FLEEING = new Fleeing();
public AiState PASSIVE = new Passive();
public AiState state = SLEEPEING;
public Class<? extends CharSprite> spriteClass;
@@ -90,25 +88,41 @@ public abstract class Mob extends Char {
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( STATE, state.toString() );
bundle.put( SEEN, enemySeen);
if (state != State.SLEEPING) {
bundle.put( TARGET, target );
}
if (state == SLEEPEING) {
bundle.put( STATE, Sleeping.TAG );
} else if (state == WANDERING) {
bundle.put( STATE, Wandering.TAG );
} else if (state == HUNTING) {
bundle.put( STATE, Hunting.TAG );
} else if (state == FLEEING) {
bundle.put( STATE, Fleeing.TAG );
} else if (state == PASSIVE) {
bundle.put( STATE, Passive.TAG );
}
bundle.put( TARGET, target );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
state = State.valueOf( bundle.getString( STATE ) );
enemySeen = bundle.getBoolean( SEEN );
if (state != State.SLEEPING) {
target = bundle.getInt( TARGET );
}
}
String state = bundle.getString( STATE );
if (state.equals( Sleeping.TAG )) {
this.state = SLEEPEING;
} else if (state.equals( Wandering.TAG )) {
this.state = WANDERING;
} else if (state.equals( Hunting.TAG )) {
this.state = HUNTING;
} else if (state.equals( Fleeing.TAG )) {
this.state = FLEEING;
} else if (state.equals( Passive.TAG )) {
this.state = PASSIVE;
}
target = bundle.getInt( TARGET );
}
public CharSprite sprite() {
CharSprite sprite = null;
@@ -124,7 +138,7 @@ public abstract class Mob extends Char {
super.act();
boolean alertedNow = alerted;
boolean justAlerted = alerted;
alerted = false;
sprite.hideAlert();
@@ -138,110 +152,8 @@ public abstract class Mob extends Char {
enemy = chooseEnemy();
boolean enemyInFOV = enemy.isAlive() && Level.fieldOfView[enemy.pos] && enemy.invisible <= 0;
int oldPos = pos;
switch (state) {
case SLEEPING:
if (enemyInFOV &&
Random.Int( distance( enemy ) + enemy.stealth() + (enemy.flying ? 2 : 0) ) == 0) {
enemySeen = true;
notice();
state = State.HUNTING;
target = enemy.pos;
spend( TIME_TO_WAKE_UP );
} else {
enemySeen = false;
spend( TICK );
}
return true;
case WANDERING:
if (enemyInFOV && (alertedNow || Random.Int( distance( enemy ) / 2 + enemy.stealth() ) == 0)) {
enemySeen = true;
notice();
state = State.HUNTING;
target = enemy.pos;
} else {
enemySeen = false;
if (target != -1 && getCloser( target )) {
spend( 1 / speed() );
return moveSprite( oldPos, pos );
} else {
target = Dungeon.level.randomDestination();
spend( TICK );
}
}
return true;
case HUNTING:
enemySeen = enemyInFOV;
if (enemyInFOV && canAttack( enemy )) {
return doAttack( enemy );
} else {
if (enemyInFOV) {
target = enemy.pos;
}
if (target != -1 && getCloser( target )) {
spend( 1 / speed() );
return moveSprite( oldPos, pos );
} else {
spend( TICK );
state = State.WANDERING;
target = Dungeon.level.randomDestination(); // <--------
return true;
}
}
case FLEEING:
enemySeen = enemyInFOV;
if (enemyInFOV) {
target = enemy.pos;
}
if (target != -1 && getFurther( target )) {
spend( 1 / speed() );
return moveSprite( oldPos, pos );
} else {
spend( TICK );
nowhereToRun();
return true;
}
case PASSIVE:
enemySeen = false;
spend( TICK );
return true;
}
return true;
return state.act( enemyInFOV, justAlerted );
}
protected Char chooseEnemy() {
@@ -271,15 +183,12 @@ public abstract class Mob extends Char {
return Dungeon.hero;
}
protected void nowhereToRun() {
}
protected boolean moveSprite( int from, int to ) {
if (sprite.isVisible() && (Dungeon.visible[from] || Dungeon.visible[to])) {
sprite.move( from, to );
return false;
return true;
} else {
sprite.place( to );
return true;
@@ -293,11 +202,11 @@ public abstract class Mob extends Char {
if (sprite != null) {
sprite.showStatus( CharSprite.NEGATIVE, TXT_RAGE );
}
state = State.HUNTING;
state = HUNTING;
} else if (buff instanceof Terror) {
state = State.FLEEING;
state = FLEEING;
} else if (buff instanceof Sleep) {
state = State.SLEEPING;
state = SLEEPEING;
this.sprite().showSleep();
postpone( Sleep.SWS );
}
@@ -308,7 +217,7 @@ public abstract class Mob extends Char {
super.remove( buff );
if (buff instanceof Terror) {
sprite.showStatus( CharSprite.NEGATIVE, TXT_RAGE );
state = State.HUNTING;
state = HUNTING;
}
}
@@ -408,10 +317,10 @@ public abstract class Mob extends Char {
public void damage( int dmg, Object src ) {
Terror.recover( this );
if (state == State.SLEEPING) {
state = State.WANDERING;
}
if (state == SLEEPEING) {
state = WANDERING;
}
alerted = true;
super.damage( dmg, src );
@@ -501,8 +410,8 @@ public abstract class Mob extends Char {
notice();
if (state != State.HUNTING) {
state = State.WANDERING;
if (state != HUNTING) {
state = WANDERING;
}
target = cell;
}
@@ -518,32 +427,178 @@ public abstract class Mob extends Char {
public void yell( String str ) {
GLog.n( "%s: \"%s\" ", name, str );
}
public static abstract class NPC extends Mob {
{
HP = HT = 1;
EXP = 0;
hostile = false;
state = State.PASSIVE;
}
protected void throwItem() {
Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) {
int n;
do {
n = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[n] && !Level.avoid[n]);
Dungeon.level.drop( heap.pickUp(), n ).sprite.drop( pos );
}
}
@Override
public void beckon( int cell ) {
}
abstract public void interact();
}
public interface AiState {
public boolean act( boolean enemyInFOV, boolean justAlerted );
public String status();
}
private class Sleeping implements AiState {
public static final String TAG = "SLEEPING";
@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if (enemyInFOV && Random.Int( distance( enemy ) + enemy.stealth() + (enemy.flying ? 2 : 0) ) == 0) {
enemySeen = true;
notice();
state = HUNTING;
target = enemy.pos;
if (Dungeon.isChallenged( Challenges.SWARM_INTELLIGENCE )) {
for (Mob mob : Dungeon.level.mobs) {
if (mob != Mob.this) {
mob.beckon( target );
}
}
}
spend( TIME_TO_WAKE_UP );
} else {
enemySeen = false;
spend( TICK );
}
return true;
}
@Override
public String status() {
return String.format( "This %s is sleeping", name );
}
}
private class Wandering implements AiState {
public static final String TAG = "WANDERING";
@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if (enemyInFOV && (justAlerted || Random.Int( distance( enemy ) / 2 + enemy.stealth() ) == 0)) {
enemySeen = true;
notice();
state = HUNTING;
target = enemy.pos;
} else {
enemySeen = false;
int oldPos = pos;
if (target != -1 && getCloser( target )) {
spend( 1 / speed() );
return moveSprite( oldPos, pos );
} else {
target = Dungeon.level.randomDestination();
spend( TICK );
}
}
return true;
}
@Override
public String status() {
return String.format( "This %s is wandering", name );
}
}
private class Hunting implements AiState {
public static final String TAG = "HUNTING";
@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
enemySeen = enemyInFOV;
if (enemyInFOV && canAttack( enemy )) {
return doAttack( enemy );
} else {
if (enemyInFOV) {
target = enemy.pos;
}
int oldPos = pos;
if (target != -1 && getCloser( target )) {
spend( 1 / speed() );
return moveSprite( oldPos, pos );
} else {
spend( TICK );
state = WANDERING;
target = Dungeon.level.randomDestination();
return true;
}
}
}
@Override
public String status() {
return String.format( "This %s is hunting", name );
}
}
protected class Fleeing implements AiState {
public static final String TAG = "FLEEING";
@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
enemySeen = enemyInFOV;
if (enemyInFOV) {
target = enemy.pos;
}
int oldPos = pos;
if (target != -1 && getFurther( target )) {
spend( 1 / speed() );
return moveSprite( oldPos, pos );
} else {
spend( TICK );
nowhereToRun();
return true;
}
}
protected void nowhereToRun() {
}
@Override
public String status() {
return String.format( "This %s is fleeing", name );
}
}
private class Passive implements AiState {
public static final String TAG = "PASSIVE";
@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
enemySeen = false;
spend( TICK );
return true;
}
@Override
public String status() {
return String.format( "This %s is passive", name );
}
}
}
@@ -81,7 +81,7 @@ public class Scorpio extends Mob {
@Override
protected boolean getCloser( int target ) {
if (state == State.HUNTING) {
if (state == HUNTING) {
return enemySeen && getFurther( target );
} else {
return super.getCloser( target );
@@ -32,99 +32,105 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.SpinnerSprite;
import com.watabou.utils.Random;
public class Spinner extends Mob {
{
name = "cave spinner";
spriteClass = SpinnerSprite.class;
HP = HT = 50;
defenseSkill = 14;
EXP = 9;
maxLvl = 16;
loot = new MysteryMeat();
lootChance = 0.125f;
}
@Override
public int damageRoll() {
return Random.NormalIntRange( 12, 16 );
}
@Override
protected void nowhereToRun() {
if (buff( Terror.class ) == null) {
state = State.HUNTING;
} else {
super.nowhereToRun();
}
}
@Override
public int attackSkill( Char target ) {
return 20;
}
@Override
public int dr() {
return 6;
}
@Override
protected boolean act() {
boolean result = super.act();
if (state == State.FLEEING && buff( Terror.class ) == null &&
enemySeen && enemy.buff( Poison.class ) == null) {
state = State.HUNTING;
}
return result;
}
@Override
public int attackProc( Char enemy, int damage ) {
if (Random.Int( 2 ) == 0) {
Buff.affect( enemy, Poison.class ).set( Random.Int( 5, 7 ) * Poison.durationFactor( enemy ) );
state = State.FLEEING;
}
return damage;
}
@Override
public void move( int step ) {
if (state == State.FLEEING) {
GameScene.add( Blob.seed( pos, Random.Int( 5, 7 ), Web.class ) );
}
super.move( step );
}
@Override
public String description() {
return
"These greenish furry cave spiders try to avoid direct combat, preferring to wait in the distance " +
"while their victim, entangled in the spinner's excreted cobweb, slowly dies from their poisonous bite.";
}
private static final HashSet<Class<?>> RESISTANCES = new HashSet<Class<?>>();
static {
RESISTANCES.add( Poison.class );
}
@Override
public HashSet<Class<?>> resistances() {
return RESISTANCES;
}
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static {
IMMUNITIES.add( Roots.class );
}
@Override
public HashSet<Class<?>> immunities() {
return IMMUNITIES;
}
{
name = "cave spinner";
spriteClass = SpinnerSprite.class;
HP = HT = 50;
defenseSkill = 14;
EXP = 9;
maxLvl = 16;
loot = new MysteryMeat();
lootChance = 0.125f;
FLEEING = new Fleeing();
}
@Override
public int damageRoll() {
return Random.NormalIntRange(12, 16);
}
@Override
public int attackSkill(Char target) {
return 20;
}
@Override
public int dr() {
return 6;
}
@Override
protected boolean act() {
boolean result = super.act();
if (state == FLEEING && buff(Terror.class) == null &&
enemySeen && enemy.buff(Poison.class) == null) {
state = HUNTING;
}
return result;
}
@Override
public int attackProc(Char enemy, int damage) {
if (Random.Int(2) == 0) {
Buff.affect(enemy, Poison.class).set(Random.Int(7, 9) * Poison.durationFactor(enemy));
state = FLEEING;
}
return damage;
}
@Override
public void move(int step) {
if (state == FLEEING) {
GameScene.add(Blob.seed(pos, Random.Int(5, 7), Web.class));
}
super.move(step);
}
@Override
public String description() {
return
"These greenish furry cave spiders try to avoid direct combat, preferring to wait in the distance " +
"while their victim, entangled in the spinner's excreted cobweb, slowly dies from their poisonous bite.";
}
private static final HashSet<Class<?>> RESISTANCES = new HashSet<Class<?>>();
static {
RESISTANCES.add(Poison.class);
}
@Override
public HashSet<Class<?>> resistances() {
return RESISTANCES;
}
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static {
IMMUNITIES.add(Roots.class);
}
@Override
public HashSet<Class<?>> immunities() {
return IMMUNITIES;
}
private class Fleeing extends Mob.Fleeing {
@Override
protected void nowhereToRun() {
if (buff(Terror.class) == null) {
state = HUNTING;
} else {
super.nowhereToRun();
}
}
}
}
@@ -42,7 +42,7 @@ public class Statue extends Mob {
spriteClass = StatueSprite.class;
EXP = 0;
state = State.PASSIVE;
state = PASSIVE;
}
private Weapon weapon;
@@ -106,8 +106,8 @@ public class Statue extends Mob {
@Override
public void damage( int dmg, Object src ) {
if (state == State.PASSIVE) {
state = State.HUNTING;
if (state == PASSIVE) {
state = HUNTING;
}
super.damage( dmg, src );
@@ -137,7 +137,7 @@ public class Statue extends Mob {
@Override
public boolean reset() {
state = State.PASSIVE;
state = PASSIVE;
return true;
}
@@ -91,7 +91,7 @@ public class Swarm extends Mob {
Swarm clone = split();
clone.HP = (HP - damage) / 2;
clone.pos = Random.element( candidates );
clone.state = State.HUNTING;
clone.state = clone.HUNTING;
if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
Door.enter( clone.pos );
@@ -49,108 +49,112 @@ public class Thief extends Mob {
maxLvl = 10;
loot = MasterThievesArmband.class;
lootChance = 0.01f;
}
private static final String ITEM = "item";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( ITEM, item );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
item = (Item)bundle.get( ITEM );
}
@Override
public int damageRoll() {
return Random.NormalIntRange( 1, 7 );
}
@Override
protected float attackDelay() {
return 0.5f;
}
@Override
protected void nowhereToRun() {
if (buff( Terror.class ) == null) {
sprite.showStatus( CharSprite.NEGATIVE, TXT_RAGE );
state = State.HUNTING;
} else {
super.nowhereToRun();
}
}
@Override
public void die( Object cause ) {
lootChance = 0.01f;
super.die( cause );
if (item != null) {
Dungeon.level.drop( item, pos ).sprite.drop();
}
}
@Override
public int attackSkill( Char target ) {
return 12;
}
@Override
public int dr() {
return 3;
}
@Override
public int attackProc( Char enemy, int damage ) {
if (item == null && enemy instanceof Hero && steal( (Hero)enemy )) {
state = State.FLEEING;
}
return damage;
}
@Override
public int defenseProc(Char enemy, int damage) {
if (state == State.FLEEING) {
Dungeon.level.drop( new Gold(), pos ).sprite.drop();
}
return damage;
}
protected boolean steal( Hero hero ) {
Item item = hero.belongings.randomUnequipped();
if (item != null) {
GLog.w( TXT_STOLE, this.name, item.name() );
item.detachAll( hero.belongings.backpack );
this.item = item;
return true;
} else {
return false;
}
}
@Override
public String description() {
String desc =
"Deeper levels of the dungeon have always been a hiding place for all kinds of criminals. " +
"Not all of them could keep a clear mind during their extended periods so far from daylight. Long ago, " +
"these crazy thieves and bandits have forgotten who they are and why they steal.";
if (item != null) {
desc += String.format( TXT_CARRIES, Utils.capitalize( this.name ), item.name() );
}
return desc;
}
FLEEING = new Fleeing();
}
private static final String ITEM = "item";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( ITEM, item );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
item = (Item)bundle.get( ITEM );
}
@Override
public int damageRoll() {
return Random.NormalIntRange( 1, 7 );
}
@Override
protected float attackDelay() {
return 0.5f;
}
@Override
public void die( Object cause ) {
super.die( cause );
if (item != null) {
Dungeon.level.drop( item, pos ).sprite.drop();
}
}
@Override
public int attackSkill( Char target ) {
return 12;
}
@Override
public int dr() {
return 3;
}
@Override
public int attackProc( Char enemy, int damage ) {
if (item == null && enemy instanceof Hero && steal( (Hero)enemy )) {
state = FLEEING;
}
return damage;
}
@Override
public int defenseProc(Char enemy, int damage) {
if (state == FLEEING) {
Dungeon.level.drop( new Gold(), pos ).sprite.drop();
}
return damage;
}
protected boolean steal( Hero hero ) {
Item item = hero.belongings.randomUnequipped();
if (item != null) {
GLog.w( TXT_STOLE, this.name, item.name() );
item.detachAll( hero.belongings.backpack );
this.item = item;
return true;
} else {
return false;
}
}
@Override
public String description() {
String desc =
"Deeper levels of the dungeon have always been a hiding place for all kinds of criminals. " +
"Not all of them could keep a clear mind during their extended periods so far from daylight. Long ago, " +
"these crazy thieves and bandits have forgotten who they are and why they steal.";
if (item != null) {
desc += String.format( TXT_CARRIES, Utils.capitalize( this.name ), item.name() );
}
return desc;
}
private class Fleeing extends Mob.Fleeing {
@Override
protected void nowhereToRun() {
if (buff( Terror.class ) == null) {
sprite.showStatus( CharSprite.NEGATIVE, TXT_RAGE );
state = HUNTING;
} else {
super.nowhereToRun();
}
}
}
}
@@ -86,7 +86,7 @@ public class Wraith extends Mob {
@Override
public boolean reset() {
state = State.WANDERING;
state = WANDERING;
return true;
}
@@ -112,7 +112,7 @@ public class Wraith extends Mob {
Wraith w = new Wraith();
w.adjustStats( Dungeon.depth );
w.pos = pos;
w.state = State.HUNTING;
w.state = w.HUNTING;
GameScene.add( w, SPAWN_DELAY );
w.sprite.alpha( 0 );
@@ -62,7 +62,7 @@ public class Yog extends Mob {
EXP = 50;
state = State.PASSIVE;
state = PASSIVE;
}
private static final String TXT_DESC =
@@ -193,7 +193,7 @@ public class Yog extends Mob {
EXP = 0;
state = State.WANDERING;
state = WANDERING;
}
public RottingFist() {
@@ -286,7 +286,7 @@ public class Yog extends Mob {
EXP = 0;
state = State.WANDERING;
state = WANDERING;
}
public BurningFist() {
@@ -404,7 +404,7 @@ public class Yog extends Mob {
EXP = 0;
state = State.HUNTING;
state = HUNTING;
}
@Override
@@ -43,7 +43,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Blacksmith extends Mob.NPC {
public class Blacksmith extends NPC {
private static final String TXT_GOLD_1 =
"Hey human! Wanna be useful, eh? Take dis pickaxe and mine me some _dark gold ore_, _15 pieces_ should be enough. " +
@@ -167,8 +167,8 @@ public class Blacksmith extends Mob.NPC {
if (item1 == item2) {
return "Select 2 different items, not the same item twice!";
}
if (!item1.isSimilar( item2 )) {
if (item1.getClass() != item2.getClass()) {
return "Select 2 items of the same type!";
}
@@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
import java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.StenchGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
@@ -27,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Crab;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Gnoll;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Rat;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.RatSkull;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
@@ -61,7 +63,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndSadGhost;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Ghost extends Mob.NPC {
public class Ghost extends NPC {
{
name = "sad ghost";
@@ -69,7 +71,7 @@ public class Ghost extends Mob.NPC {
flying = true;
state = State.WANDERING;
state = WANDERING;
}
private static final String TXT_RAT1 =
@@ -195,7 +197,6 @@ public class Ghost extends Mob.NPC {
txt_quest = TXT_CRAB1; break;
}
questBoss.state = Mob.State.WANDERING;
questBoss.pos = Dungeon.level.randomRespawnCell();
if (questBoss.pos != -1) {
@@ -353,6 +354,10 @@ public class Ghost extends Mob.NPC {
}
}
//TODO this is silly, why trap the player with bad armour? Just remove the button from the window.
if (Dungeon.isChallenged( Challenges.NO_ARMOR ))
armor = (Armor)new ClothArmor().degrade();
weapon.identify();
armor.identify();
}
@@ -386,6 +391,8 @@ public class Ghost extends Mob.NPC {
defenseSkill = 4;
EXP = 4;
state = WANDERING;
}
@Override
@@ -445,6 +452,8 @@ public class Ghost extends Mob.NPC {
EXP = 5;
state = WANDERING;
loot = Generator.random(CurareDart.class);
lootChance = 1f;
}
@@ -489,7 +498,7 @@ public class Ghost extends Mob.NPC {
@Override
protected boolean getCloser( int target ) {
combo = 0; //if he's moving, he isn't attacking, reset combo.
if (state == State.HUNTING) {
if (state == HUNTING) {
return enemySeen && getFurther( target );
} else {
return super.getCloser( target );
@@ -573,6 +582,7 @@ public class Ghost extends Mob.NPC {
EXP = 6;
state = WANDERING;
}
private boolean moving = true;
@@ -38,7 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Imp extends Mob.NPC {
public class Imp extends NPC {
{
name = "ambitious imp";
@@ -21,6 +21,8 @@ import java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
@@ -29,13 +31,13 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.MirrorSprite;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class MirrorImage extends Mob.NPC {
public class MirrorImage extends NPC {
{
name = "mirror image";
spriteClass = MirrorSprite.class;
state = State.HUNTING;
state = HUNTING;
enemy = DUMMY;
}
@@ -134,5 +136,16 @@ public class MirrorImage extends Mob.NPC {
Dungeon.hero.spend( 1 / Dungeon.hero.speed() );
Dungeon.hero.busy();
}
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static {
IMMUNITIES.add( ToxicGas.class );
IMMUNITIES.add( Burning.class );
}
@Override
public HashSet<Class<?>> immunities() {
return IMMUNITIES;
}
}
@@ -0,0 +1,52 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.watabou.utils.Random;
public abstract class NPC extends Mob {
{
HP = HT = 1;
EXP = 0;
hostile = false;
state = PASSIVE;
}
protected void throwItem() {
Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) {
int n;
do {
n = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[n] && !Level.avoid[n]);
Dungeon.level.drop( heap.pickUp(), n ).sprite.drop( pos );
}
}
@Override
public void beckon( int cell ) {
}
abstract public void interact();
}
@@ -24,13 +24,13 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.sprites.RatKingSprite;
public class RatKing extends Mob.NPC {
public class RatKing extends NPC {
{
name = "rat king";
spriteClass = RatKingSprite.class;
state = State.SLEEPING;
state = SLEEPEING;
}
@Override
@@ -64,10 +64,10 @@ public class RatKing extends Mob.NPC {
@Override
public void interact() {
sprite.turnTo( pos, Dungeon.hero.pos );
if (state == State.SLEEPING) {
if (state == SLEEPEING) {
notice();
yell( "I'm not sleeping!" );
state = State.WANDERING;
state = WANDERING;
} else {
yell( "What is it? I have no time for this nonsense. My kingdom won't rule itself!" );
}
@@ -29,7 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ShopkeeperSprite;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem;
public class Shopkeeper extends Mob.NPC {
public class Shopkeeper extends NPC {
public static final String TXT_THIEF = "Thief, Thief!";
@@ -63,7 +63,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndWandmaker;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Wandmaker extends Mob.NPC {
public class Wandmaker extends NPC {
{
name = "old wandmaker";