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.instance.steelRake;
  
  import java.util.concurrent.atomic.AtomicBoolean;
  
  import com.aionemu.commons.network.util.ThreadPoolManager;
  import com.aionemu.gameserver.ai2.AI2Actions;
  import com.aionemu.gameserver.ai2.AIName;
  import com.aionemu.gameserver.ai2.manager.WalkManager;
  import com.aionemu.gameserver.model.EmotionType;
  import com.aionemu.gameserver.model.gameobjects.Creature;
  import com.aionemu.gameserver.model.gameobjects.player.Player;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_EMOTION;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_QUEST_ACTION;
  import com.aionemu.gameserver.services.NpcShoutsService;
  import com.aionemu.gameserver.skillengine.SkillEngine;
  import com.aionemu.gameserver.utils.PacketSendUtility;
  
  import ai.GeneralNpcAI2;
  
  /**
   * @author xTz
   */
  @AIName("tamer_anikiki")
  public class TamerAnikikiAI2 extends GeneralNpcAI2 {
  
  	private AtomicBoolean isStartedWalkEvent = new AtomicBoolean(false);
  
  	@Override
  	public boolean canThink() {
  		return false;
  	}
  
  	@Override
  	protected void handleCreatureMoved(Creature creature) {
  		super.handleCreatureMoved(creature);
  		if (getNpcId() == 219040 && isInRange(creature, 10) && creature instanceof Player) {
  			if (isStartedWalkEvent.compareAndSet(false, true)) {
  				getSpawnTemplate().setWalkerId("3004600001");
  				WalkManager.startWalking(this);
  				getOwner().setState(1);
  				PacketSendUtility.broadcastPacket(getOwner(), new SM_EMOTION(getOwner(), EmotionType.START_EMOTE2, 0, getObjectId()));
  				// Key Box
  				spawn(700553, 611, 481, 936, (byte) 90);
  				spawn(700553, 657, 482, 936, (byte) 60);
  				spawn(700553, 626, 540, 936, (byte) 1);
  				spawn(700553, 645, 534, 936, (byte) 75);
  				PacketSendUtility.sendPacket((Player) creature, new SM_QUEST_ACTION(0, 180));
  				NpcShoutsService.getInstance().sendMsg(getOwner(), 1400262);
  				NpcShoutsService.getInstance().sendMsg(getOwner(), 1400262, getObjectId(), 0, 0);
  			}
  		}
  	}
  
  	@Override
  	protected void handleMoveArrived() {
  		int point = getOwner().getMoveController().getCurrentPoint();
  		super.handleMoveArrived();
  		if (getNpcId() == 219040) {
  			if (point == 8) {
  				getOwner().setState(64);
  				PacketSendUtility.broadcastPacket(getOwner(), new SM_EMOTION(getOwner(), EmotionType.START_EMOTE2, 0, getObjectId()));
  			}
  			if (point == 12) {
  				getSpawnTemplate().setWalkerId(null);
  				WalkManager.stopWalking(this);
  				AI2Actions.deleteOwner(this);
  			}
  		}
  	}
  
  	@Override
  	protected void handleSpawned() {
  		super.handleSpawned();
  		if (getNpcId() != 219040) {
  			ThreadPoolManager.getInstance().schedule(new Runnable() {
  
  				@Override
  				public void run() {
  					SkillEngine.getInstance().getSkill(getOwner(), 18189, 20, getOwner()).useNoAnimationSkill();
  				}
  			}, 5000);
  		}
  	}
  
  	@Override
  	public int modifyDamage(int damage) {
  		if (getNpcId() == 219037) {
  			return damage;
  		}
  		else {
  			return 1;
  		}
  	}
  }
  