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.tallocsHollow;
  
  import com.aionemu.gameserver.ai2.AIName;
  import com.aionemu.gameserver.model.gameobjects.Creature;
  import com.aionemu.gameserver.model.gameobjects.Npc;
  import com.aionemu.gameserver.model.gameobjects.Summon;
  import com.aionemu.gameserver.model.gameobjects.player.Player;
  import com.aionemu.gameserver.model.summons.SummonMode;
  import com.aionemu.gameserver.model.summons.UnsummonType;
  import com.aionemu.gameserver.model.templates.spawns.SpawnTemplate;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_PLAY_MOVIE;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
  import com.aionemu.gameserver.services.summons.SummonsService;
  import com.aionemu.gameserver.utils.PacketSendUtility;
  import com.aionemu.gameserver.world.WorldMapInstance;
  import com.aionemu.gameserver.world.knownlist.Visitor;
  
  import ai.SummonerAI2;
  
  /**
   * @author xTz
   */
  @AIName("queenmosqua")
  public class QueenMosquaAI2 extends SummonerAI2 {
  
  	private boolean isHome = true;
  
  	@Override
  	protected void handleCreatureAggro(Creature creature) {
  		super.handleCreatureAggro(creature);
  		if (isHome) {
  			isHome = false;
  			getPosition().getWorldMapInstance().getDoors().get(7).setOpen(false);
  		}
  	}
  
  	@Override
  	protected void handleBackHome() {
  		isHome = true;
  		getPosition().getWorldMapInstance().getDoors().get(7).setOpen(true);
  		super.handleBackHome();
  	}
  
  	@Override
  	protected void handleDied() {
  		super.handleDied();
  		WorldMapInstance instance = getPosition().getWorldMapInstance();
  		getPosition().getWorldMapInstance().getDoors().get(7).setOpen(true);
  
  		Npc npc = instance.getNpc(700738);
  		if (npc != null) {
  			SpawnTemplate template = npc.getSpawn();
  			spawn(700739, template.getX(), template.getY(), template.getZ(), template.getHeading(), 11);
  			npc.getKnownList().doOnAllPlayers(new Visitor<Player>() {
  
  				@Override
  				public void visit(Player player) {
  					PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1400476));
  					Summon summon = player.getSummon();
  					if (summon != null) {
  						if (summon.getNpcId() == 799500 || summon.getNpcId() == 799501) {
  							SummonsService.doMode(SummonMode.RELEASE, summon, UnsummonType.UNSPECIFIED);
  							PacketSendUtility.sendPacket(player, new SM_PLAY_MOVIE(0, 435));
  						}
  					}
  				}
  			});
  			npc.getController().onDelete();
  		}
  	}
  }
  