176 lines
4.4 KiB
Java
176 lines
4.4 KiB
Java
/*
|
|
* Pixel Dungeon
|
|
* Copyright (C) 2012-2015 Oleg Dolya
|
|
*
|
|
* Shattered Pixel Dungeon
|
|
* Copyright (C) 2014-2016 Evan Debenham
|
|
*
|
|
* 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;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
import com.shatteredpixel.shatteredpixeldungeon.Journal;
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon.Enchantment;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Grim;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Vampiric;
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.StatueSprite;
|
|
import com.watabou.utils.Bundle;
|
|
import com.watabou.utils.Random;
|
|
|
|
import java.util.HashSet;
|
|
|
|
public class Statue extends Mob {
|
|
|
|
{
|
|
spriteClass = StatueSprite.class;
|
|
|
|
EXP = 0;
|
|
state = PASSIVE;
|
|
}
|
|
|
|
protected Weapon weapon;
|
|
|
|
public Statue() {
|
|
super();
|
|
|
|
do {
|
|
weapon = (Weapon)Generator.random( Generator.Category.WEAPON );
|
|
} while (!(weapon instanceof MeleeWeapon) || weapon.cursed);
|
|
|
|
weapon.identify();
|
|
weapon.enchant( Enchantment.random() );
|
|
|
|
HP = HT = 15 + Dungeon.depth * 5;
|
|
defenseSkill = 4 + Dungeon.depth;
|
|
}
|
|
|
|
private static final String WEAPON = "weapon";
|
|
|
|
@Override
|
|
public void storeInBundle( Bundle bundle ) {
|
|
super.storeInBundle( bundle );
|
|
bundle.put( WEAPON, weapon );
|
|
}
|
|
|
|
@Override
|
|
public void restoreFromBundle( Bundle bundle ) {
|
|
super.restoreFromBundle( bundle );
|
|
weapon = (Weapon)bundle.get( WEAPON );
|
|
}
|
|
|
|
@Override
|
|
protected boolean act() {
|
|
if (Dungeon.visible[pos]) {
|
|
Journal.add( Journal.Feature.STATUE );
|
|
}
|
|
return super.act();
|
|
}
|
|
|
|
@Override
|
|
public int damageRoll() {
|
|
return Random.NormalIntRange( weapon.min(), weapon.max() );
|
|
}
|
|
|
|
@Override
|
|
public int attackSkill( Char target ) {
|
|
return (int)((9 + Dungeon.depth) * weapon.ACC);
|
|
}
|
|
|
|
@Override
|
|
protected float attackDelay() {
|
|
return weapon.DLY;
|
|
}
|
|
|
|
@Override
|
|
protected boolean canAttack(Char enemy) {
|
|
return Level.distance( pos, enemy.pos ) <= weapon.RCH;
|
|
}
|
|
|
|
@Override
|
|
public int drRoll() {
|
|
return Random.NormalIntRange(0, Dungeon.depth + weapon.defenseFactor(null));
|
|
}
|
|
|
|
@Override
|
|
public void damage( int dmg, Object src ) {
|
|
|
|
if (state == PASSIVE) {
|
|
state = HUNTING;
|
|
}
|
|
|
|
super.damage( dmg, src );
|
|
}
|
|
|
|
@Override
|
|
public int attackProc( Char enemy, int damage ) {
|
|
return weapon.proc( this, enemy, damage );
|
|
}
|
|
|
|
@Override
|
|
public void beckon( int cell ) {
|
|
// Do nothing
|
|
}
|
|
|
|
@Override
|
|
public void die( Object cause ) {
|
|
Dungeon.level.drop( weapon, pos ).sprite.drop();
|
|
super.die( cause );
|
|
}
|
|
|
|
@Override
|
|
public void destroy() {
|
|
Journal.remove( Journal.Feature.STATUE );
|
|
super.destroy();
|
|
}
|
|
|
|
@Override
|
|
public boolean reset() {
|
|
state = PASSIVE;
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public String description() {
|
|
return Messages.get(this, "desc", weapon.name());
|
|
}
|
|
|
|
private static final HashSet<Class<?>> RESISTANCES = new HashSet<>();
|
|
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<>();
|
|
static {
|
|
RESISTANCES.add( ToxicGas.class );
|
|
RESISTANCES.add( Poison.class );
|
|
RESISTANCES.add( Grim.class );
|
|
IMMUNITIES.add( Vampiric.class );
|
|
}
|
|
|
|
@Override
|
|
public HashSet<Class<?>> resistances() {
|
|
return RESISTANCES;
|
|
}
|
|
|
|
@Override
|
|
public HashSet<Class<?>> immunities() {
|
|
return IMMUNITIES;
|
|
}
|
|
}
|