content: /**
   * This file is part of Aion-Lightning <aion-lightning.org>.
   *
   *  Aion-Lightning 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.
   *
   *  Aion-Lightning 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 Aion-Lightning.
   *  If not, see <http://www.gnu.org/licenses/>.
   */
  package ai;
  
  import com.aionemu.gameserver.ai2.AI2Actions;
  import com.aionemu.gameserver.ai2.AIName;
  import com.aionemu.gameserver.ai2.poll.AIAnswer;
  import com.aionemu.gameserver.ai2.poll.AIAnswers;
  import com.aionemu.gameserver.ai2.poll.AIQuestion;
  import com.aionemu.gameserver.dataholders.DataManager;
  import com.aionemu.gameserver.model.ai.BombTemplate;
  import com.aionemu.gameserver.utils.ThreadPoolManager;
  
  /**
   * @author xTz
   */
  @AIName("bomb")
  public class BombAi2 extends AggressiveNpcAI2 {
  
  	private BombTemplate template;
  
  	@Override
  	protected void handleSpawned() {
  		template = DataManager.AI_DATA.getAiTemplate().get(getNpcId()).getBombs().getBombTemplate();
  		ThreadPoolManager.getInstance().schedule(new Runnable() {
  
  			@Override
  			public void run() {
  				doUseSkill();
  			}
  		}, 2000);
  	}
  
  	private void doUseSkill() {
  		ThreadPoolManager.getInstance().schedule(new Runnable() {
  
  			@Override
  			public void run() {
  				useSkill(template.getSkillId());
  			}
  		}, template.getCd());
  	}
  
  	@Override
  	protected AIAnswer pollInstance(AIQuestion question) {
  		switch (question) {
  			case SHOULD_DECAY:
  				return AIAnswers.NEGATIVE;
  			case SHOULD_RESPAWN:
  				return AIAnswers.NEGATIVE;
  			case SHOULD_REWARD:
  				return AIAnswers.NEGATIVE;
  			default:
  				return null;
  		}
  	}
  
  	private void useSkill(int skill) {
  		AI2Actions.targetSelf(this);
  		AI2Actions.useSkill(this, skill);
  		int duration = DataManager.SKILL_DATA.getSkillTemplate(skill).getDuration();
  		ThreadPoolManager.getInstance().schedule(new Runnable() {
  
  			@Override
  			public void run() {
  				AI2Actions.deleteOwner(BombAi2.this);
  			}
  		}, duration != 0 ? duration + 4000 : 0);
  	}
  }
  