package ai.instance.tiamatStrongHold;
import com.aionemu.gameserver.ai.AIActions;
import com.aionemu.gameserver.ai.AIName;
import com.aionemu.gameserver.ai.NpcAI;
import com.aionemu.gameserver.ai.poll.AIQuestion;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.utils.PositionUtil;
import com.aionemu.gameserver.utils.ThreadPoolManager;
/**
* @author Cheatkiller
*/
@AIName("earthquake")
public class EarthQuakeAI extends NpcAI {
public EarthQuakeAI(Npc owner) {
super(owner);
}
@Override
protected void handleCreatureSee(Creature creature) {
checkDistance(creature);
}
@Override
protected void handleCreatureMoved(Creature creature) {
checkDistance(creature);
}
private void checkDistance(Creature creature) {
if (creature instanceof Player) {
if (PositionUtil.isInRange(getOwner(), creature, 5) && !creature.getEffectController().hasAbnormalEffect(20718)) {
AIActions.useSkill(this, 20718);
}
}
}
@Override
protected void handleSpawned() {
super.handleSpawned();
despawn();
}
private void despawn() {
ThreadPoolManager.getInstance().schedule(() -> getOwner().getController().delete(), 9000);
}
@Override
public boolean ask(AIQuestion question) {
return switch (question) {
case ALLOW_DECAY, ALLOW_RESPAWN, REWARD_AP_XP_DP_LOOT -> false;
default -> super.ask(question);
};
}
}