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 quest.sanctum;
  
  import com.aionemu.gameserver.model.DialogAction;
  import com.aionemu.gameserver.model.TeleportAnimation;
  import com.aionemu.gameserver.model.gameobjects.player.Player;
  import com.aionemu.gameserver.questEngine.handlers.QuestHandler;
  import com.aionemu.gameserver.questEngine.model.QuestEnv;
  import com.aionemu.gameserver.questEngine.model.QuestState;
  import com.aionemu.gameserver.questEngine.model.QuestStatus;
  import com.aionemu.gameserver.services.teleport.TeleportService2;
  import com.aionemu.gameserver.world.zone.ZoneName;
  
  /**
   * @author FrozenKiller
   */
  public class _60101TheOngoingSearchForOdium extends QuestHandler {
  
  	private final static int questId = 60101;
  
  	public _60101TheOngoingSearchForOdium() {
  		super(questId);
  	}
  
  	@Override
  	public void register() {
  		qe.registerOnLevelUp(questId);
  		qe.registerQuestNpc(798600).addOnTalkEvent(questId); // Eremitia
  		qe.registerQuestNpc(805362).addOnTalkEvent(questId); // Kaisinel
  		qe.registerQuestNpc(203726).addOnTalkEvent(questId); // Polyidus
  		qe.registerQuestNpc(820016).addOnTalkEvent(questId); // Royer 2
  		qe.registerOnEnterZone(ZoneName.get("NEW_HEIRON_GATE_210040000"), questId);
          qe.registerOnLogOut(questId);
  	}
  
  	@Override
  	public boolean onLvlUpEvent(QuestEnv env) {
  		return defaultOnLvlUpEvent(env, 60100, false);
  	}
  	
  	@Override
  	public boolean onEnterZoneEvent(QuestEnv env, ZoneName zoneName) {
  		Player player = env.getPlayer();
  		if (player == null) {
  			return false;
  		}
  
  		QuestState qs = player.getQuestStateList().getQuestState(questId);
  		if (qs != null && qs.getStatus() == QuestStatus.START) {
  			int var = qs.getQuestVarById(0);
  			if (var == 3 && zoneName == ZoneName.get("NEW_HEIRON_GATE_210040000")) {
  				changeQuestStep(env, 3, 4, true);
  				return true;
  			}
  		}
  		return false;
  	}
  
      @Override
      public boolean onLogOutEvent(QuestEnv env) {
          final Player player = env.getPlayer();
          final QuestState qs = player.getQuestStateList().getQuestState(questId);
          if (qs == null){
              return false;
          }
          int var = qs.getQuestVarById(0);
          if (var <= 2) {
              qs.setQuestVar(0);
              updateQuestStatus(env);
              return true;
          }
          return false;
      }
  
      @Override
      public boolean onDialogEvent(QuestEnv env) {
          Player player = env.getPlayer();
          QuestState qs = player.getQuestStateList().getQuestState(questId);
          DialogAction dialog = env.getDialog();
          int targetId = env.getTargetId();
  
          if (qs == null) {
              return false;
          }
  
          if (qs.getStatus() == QuestStatus.START) {
              switch (targetId) {
                  case 798600: {
                      switch (dialog) {
                          case QUEST_SELECT:
                              return sendQuestDialog(env, 1011);
                          case SETPRO1:
                              qs.setQuestVar(1);
                              updateQuestStatus(env);
                              TeleportService2.teleportTo(player, 110020000, 483f, 497f, 499f, (byte) 69, TeleportAnimation.BEAM_ANIMATION);
                              return closeDialogWindow(env);
                          default:
                              break;
                      }
                      break;
                  }
                  case 805362: {
                      switch (dialog) {
                          case QUEST_SELECT:
                              return sendQuestDialog(env, 1352);
                          case SETPRO2:
                              qs.setQuestVar(2);
                              updateQuestStatus(env);
                              TeleportService2.teleportTo(player, 110010000, 1334.7222F, 1511.4169f, 569.03876f, (byte) 0, TeleportAnimation.BEAM_ANIMATION);
                              return closeDialogWindow(env);
                          default:
                              break;
                      }
                      break;
                  }
                  case 203726: {
                      switch (dialog) {
                          case QUEST_SELECT:
                              return sendQuestDialog(env, 1693);
                          case SETPRO3:
                              qs.setQuestVar(3);
                              updateQuestStatus(env);
                              return closeDialogWindow(env);
                          default:
                              break;
                      }
                      break;
                  }
                  default:
                      break;
              }
          } else if (qs.getStatus() == QuestStatus.REWARD) {
              if (targetId == 820016) {
                  switch (dialog) {
                      case USE_OBJECT:
                          return sendQuestDialog(env, 10002);
                      case SELECT_QUEST_REWARD:
                          return sendQuestDialog(env, 5);
                      case SELECTED_QUEST_NOREWARD:
                          return sendQuestEndDialog(env);
  				default:
  					break;
                  }
              }
          }
  
          return false;
      }
  }
  