Files
shattered-pixel-dungeon-web…/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Shaman.java
T
2016-02-22 16:22:44 -05:00

135 lines
3.5 KiB
Java

/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2015 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 java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.Camera;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.LightningTrap;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ShamanSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public class Shaman extends Mob implements Callback {
private static final float TIME_TO_ZAP = 1f;
{
spriteClass = ShamanSprite.class;
HP = HT = 18;
defenseSkill = 8;
EXP = 6;
maxLvl = 14;
loot = Generator.Category.SCROLL;
lootChance = 0.33f;
}
@Override
public int damageRoll() {
return Random.NormalIntRange( 2, 6 );
}
@Override
public int attackSkill( Char target ) {
return 11;
}
@Override
public int dr() {
return 4;
}
@Override
protected boolean canAttack( Char enemy ) {
return new Ballistica( pos, enemy.pos, Ballistica.MAGIC_BOLT).collisionPos == enemy.pos;
}
@Override
protected boolean doAttack( Char enemy ) {
if (Level.distance( pos, enemy.pos ) <= 1) {
return super.doAttack( enemy );
} else {
boolean visible = Level.fieldOfView[pos] || Level.fieldOfView[enemy.pos];
if (visible) {
sprite.zap( enemy.pos );
}
spend( TIME_TO_ZAP );
if (hit( this, enemy, true )) {
int dmg = (int)(damageRoll()*1.5f);
if (Level.water[enemy.pos] && !enemy.flying) {
dmg *= 1.5f;
}
enemy.damage( dmg, LightningTrap.LIGHTNING );
enemy.sprite.centerEmitter().burst( SparkParticle.FACTORY, 3 );
enemy.sprite.flash();
if (enemy == Dungeon.hero) {
Camera.main.shake( 2, 0.3f );
if (!enemy.isAlive()) {
Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "zap_kill") );
}
}
} else {
enemy.sprite.showStatus( CharSprite.NEUTRAL, enemy.defenseVerb() );
}
return !visible;
}
}
@Override
public void call() {
next();
}
private static final HashSet<Class<?>> RESISTANCES = new HashSet<>();
static {
RESISTANCES.add( LightningTrap.Electricity.class );
}
@Override
public HashSet<Class<?>> resistances() {
return RESISTANCES;
}
}