@Override
  protected void runImpl() {
    if (HandysBlockCheckerManager.getInstance().arenaIsBeingUsed(_arena)) return;
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null || activeChar.isDead()) return;

    switch (_team) {
      case 0:
      case 1:
        // Change Player Team
        HandysBlockCheckerManager.getInstance().changePlayerToTeam(activeChar, _arena, _team);
        break;
      case -1:
        {
          int team =
              HandysBlockCheckerManager.getInstance().getHolder(_arena).getPlayerTeam(activeChar);
          // client sends two times this packet if click on exit
          // client did not send this packet on restart
          if (team > -1)
            HandysBlockCheckerManager.getInstance().removePlayer(activeChar, _arena, team);
          break;
        }
      default:
        _log.warn("Wrong Team ID: " + _team);
        break;
    }
  }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    if (player.getEnchantScroll() != null) {
      Log.add(
          "Player "
              + player.getName()
              + " trying to use enchant exploit[Warehouse], ban this player!",
          "illegal-actions");
      player.setEnchantScroll(null);
      return;
    }

    if (command.startsWith("WithdrawP")) {
      int val = Integer.parseInt(command.substring(10));
      if (val == 99) {
        NpcHtmlMessage html = new NpcHtmlMessage(player, this);
        html.setFile("warehouse/personal.htm");
        html.replace("%npcname%", getName());
        player.sendPacket(html);
      } else WarehouseFunctions.showRetrieveWindow(player, val);
    } else if (command.equals("DepositP")) WarehouseFunctions.showDepositWindow(player);
    else if (command.startsWith("WithdrawC")) {
      int val = Integer.parseInt(command.substring(10));
      if (val == 99) {
        NpcHtmlMessage html = new NpcHtmlMessage(player, this);
        html.setFile("warehouse/clan.htm");
        html.replace("%npcname%", getName());
        player.sendPacket(html);
      } else WarehouseFunctions.showWithdrawWindowClan(player, val);
    } else if (command.equals("DepositC")) WarehouseFunctions.showDepositWindowClan(player);
    else super.onBypassFeedback(player, command);
  }
Example #3
0
  public void makeSubQuests() {
    Player player = getSelf();
    if (player == null) {
      return;
    }
    Quest q = QuestManager.getQuest(_234_FatesWhisper.class);
    QuestState qs = player.getQuestState(q.getClass());
    if (qs != null) {
      qs.exitCurrentQuest(true);
    }
    q.newQuestState(player, Quest.COMPLETED);

    if (player.getRace() == Race.kamael) {
      q = QuestManager.getQuest("_236_SeedsOfChaos");
      qs = player.getQuestState(q.getClass());
      if (qs != null) {
        qs.exitCurrentQuest(true);
      }
      q.newQuestState(player, Quest.COMPLETED);
    } else {
      q = QuestManager.getQuest("_235_MimirsElixir");
      qs = player.getQuestState(q.getClass());
      if (qs != null) {
        qs.exitCurrentQuest(true);
      }
      q.newQuestState(player, Quest.COMPLETED);
    }
  }
  @Override
  public String onEvent(String event, QuestState st, NpcInstance npc) {
    String htmltext = event;
    Castle castle = ResidenceHolder.getInstance().getResidence(ShuttgartCastle);
    if (castle.getOwner() == null) {
      return "Castle has no lord";
    }
    Player castleOwner = castle.getOwner().getLeader().getPlayer();

    if (event.equals("august_q714_03.htm")) {
      st.setState(STARTED);
      st.setCond(1);
      st.playSound(SOUND_ACCEPT);
    } else if (event.equals("august_q714_05.htm")) {
      st.setCond(2);
    } else if (event.equals("newyear_q714_03.htm")) {
      st.setCond(3);
    } else if (event.equals("yasheni_q714_02.htm")) {
      st.setCond(5);
    } else if (event.equals("august_q714_08.htm")) {
      Functions.npcSay(
          npc,
          NpcString.S1_HAS_BECOME_THE_LORD_OF_THE_TOWN_OF_SCHUTTGART,
          st.getPlayer().getName());
      castle.getDominion().changeOwner(castleOwner.getClan());
      st.playSound(SOUND_FINISH);
      st.exitCurrentQuest(true);
    }
    return htmltext;
  }
    public GuardiansSpawner(NpcInstance npc, QuestState st, int _count) {
      NpcTemplate template = NpcHolder.getInstance().getTemplate(Soul_of_Tree_Guardian);
      if (template == null) return;
      try {
        _spawn = new SimpleSpawner(template);
      } catch (Exception e) {
        e.printStackTrace();
      }
      for (int i = 0; i < _count; i++) {
        _spawn.setLoc(Location.findPointToStay(npc, 50, 200));
        _spawn.setHeading(Rnd.get(0, 0xFFFF));
        _spawn.setAmount(1);
        _spawn.doSpawn(true);

        agressor = st.getPlayer().getName();
        if (st.getPlayer().getSummonList().getPet() != null)
          agressors_pet = st.getPlayer().getSummonList().getPet().getName();
        if (st.getPlayer().getParty() != null) {
          agressors_party = new ArrayList<String>();
          for (Player _member : st.getPlayer().getParty().getPartyMembers())
            if (!_member.equals(st.getPlayer())) agressors_party.add(_member.getName());
        }
      }
      _spawn.stopRespawn();
      updateAgression();
    }
Example #6
0
  @SuppressWarnings("rawtypes")
  @Override
  public boolean useAdminCommand(
      Enum comm, String[] wordList, String fullString, Player activeChar) {
    Commands command = (Commands) comm;

    if (!activeChar.getPlayerAccess().CanEditCharAll) return false;

    switch (command) {
      case admin_quests:
        return ShowQuestList(getTargetChar(wordList, 1, activeChar), activeChar);

      case admin_quest:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //quest id|name [SHOW|STATE|VAR|CLEAR] ...");
          return true;
        }
        Quest _quest = QuestManager.getQuest2(wordList[1]);
        if (_quest == null) {
          activeChar.sendMessage("Quest " + wordList[1] + " undefined");
          return true;
        }
        if (wordList.length < 3 || wordList[2].equalsIgnoreCase("SHOW"))
          return cmd_Show(_quest, wordList, activeChar);
        if (wordList[2].equalsIgnoreCase("STATE")) return cmd_State(_quest, wordList, activeChar);
        if (wordList[2].equalsIgnoreCase("VAR")) return cmd_Var(_quest, wordList, activeChar);
        if (wordList[2].equalsIgnoreCase("CLEAR")) return cmd_Clear(_quest, wordList, activeChar);
        return cmd_Show(_quest, wordList, activeChar);
    }
    return true;
  }
Example #7
0
  public void giveItems(int itemId, long count, Element element, int power) {
    Player player = getPlayer();
    if (player == null) {
      return;
    }

    if (count <= 0) {
      count = 1;
    }

    // Get template of item
    ItemTemplate template = ItemHolder.getInstance().getTemplate(itemId);
    if (template == null) {
      return;
    }

    for (int i = 0; i < count; i++) {
      ItemInstance item = ItemFunctions.createItem(itemId);

      if (element != Element.NONE) {
        item.setAttributeElement(element, power);
      }

      // Add items to player's inventory
      player.getInventory().addItem(item);
    }

    player.sendPacket(SystemMessage2.obtainItems(template.getItemId(), count, 0));
    player.sendChanges();
  }
Example #8
0
 /** Используется для однодневных квестов */
 public void exitCurrentQuest(Quest quest) {
   Player player = getPlayer();
   exitCurrentQuest(true);
   quest.newQuestState(player, Quest.DELAYED);
   QuestState qs = player.getQuestState(quest.getClass());
   qs.setRestartTime();
 }
Example #9
0
  private void teleportToCharacter(Player activeChar, GameObject target) {
    if (target == null) return;

    activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
    activeChar.teleToLocation(target.getLoc(), target.getReflectionId());

    activeChar.sendMessage("You have teleported to " + target);
  }
Example #10
0
 /**
  * Add player to get notification of characters death
  *
  * @param player : L2Character of the character to get notification of death
  */
 public void addNotifyOfDeath(Player player, boolean withPet) {
   OnDeathListenerImpl listener = new OnDeathListenerImpl();
   player.addListener(listener);
   if (withPet) {
     for (Summon summon : player.getSummonList()) {
       summon.addListener(listener);
     }
   }
 }
Example #11
0
 private void recallNPC(Player activeChar) {
   GameObject obj = activeChar.getTarget();
   if (obj != null && obj.isNpc()) {
     obj.setLoc(activeChar.getLoc());
     ((NpcInstance) obj).broadcastCharInfo();
     activeChar.sendMessage(
         "You teleported npc " + obj.getName() + " to " + activeChar.getLoc().toString() + ".");
   } else activeChar.sendMessage("Target is't npc.");
 }
Example #12
0
 public String DialogAppend_30827(Integer val) {
   if (val == 0) {
     Player player = getSelf();
     return player.isLangRus()
         ? "<br>[scripts_services.RideHire:ride_prices|Взять на прокат ездовое животное.]"
         : "<br>[scripts_services.RideHire:ride_prices|Ride hire mountable pet.]";
   }
   return "";
 }
Example #13
0
 public void showTutorialHTML(String html, int type) {
   Player player = getPlayer();
   if (player == null) {
     return;
   }
   String text = html;
   if (type == 1) {
     text = HtmCache.getInstance().getNotNull("quests/_255_Tutorial/" + html, player);
   }
   player.sendPacket(new TutorialShowHtml(text, type));
 }
Example #14
0
    @Override
    public void onDeath(Creature actor, Creature killer) {
      Player player = actor.getPlayer();
      if (player == null) {
        return;
      }

      player.removeListener(this);

      _quest.notifyDeath(killer, actor, QuestState.this);
    }
Example #15
0
 public long getSumQuestItemsCount(int... itemIds) {
   Player player = getPlayer();
   if (player == null) {
     return 0;
   }
   long count = 0;
   for (int itemId : itemIds) {
     count += player.getInventory().getCountOf(itemId);
   }
   return count;
 }
Example #16
0
 private boolean cmd_Show(Quest _quest, String[] wordList, Player activeChar) {
   // quest id|name SHOW [target]
   Player targetChar = getTargetChar(wordList, 3, activeChar);
   QuestState qs = targetChar.getQuestState(_quest.getName());
   if (qs == null) {
     activeChar.sendMessage(
         "Player " + targetChar.getName() + " havn't Quest [" + _quest.getName() + "]");
     return false;
   }
   return ShowQuestState(qs, activeChar);
 }
Example #17
0
  public void rideOver() {
    Player player = getSelf();
    if (player == null) return;

    unRide(player);
    show(
        player.isLangRus()
            ? "Время проката закончилось. Приходите еще!"
            : "Ride time is over.<br><br>Welcome back again!",
        player);
  }
Example #18
0
  public void tele() {
    Player player = getSelf();
    NpcInstance npc = getNpc();

    if (player != null && npc != null)
      if (player.getLevel() < 75) show("teleporter/" + npc.getNpcId() + "-4.htm", player);
      else if (player.getAdena() >= 150000) {
        player.reduceAdena(150000, true);
        player.teleToLocation(-149406, 255247, -80);
      } else show("teleporter/" + npc.getNpcId() + "-2.htm", player);
  }
 private void updateAgression() {
   Player _player = World.getPlayer(agressor);
   if (_player != null) {
     if (agressors_pet != null
         && _player.getSummonList().getPet() != null
         && _player.getSummonList().getPet().getName().equalsIgnoreCase(agressors_pet))
       AddAgression(_player.getSummonList().getPet(), 10);
     AddAgression(_player, 2);
   }
   if (agressors_party != null)
     for (String _agressor : agressors_party) AddAgression(World.getPlayer(_agressor), 1);
 }
Example #20
0
 public boolean checkQuestItemsCount(int... itemIds) {
   Player player = getPlayer();
   if (player == null) {
     return false;
   }
   for (int itemId : itemIds) {
     if (player.getInventory().getCountOf(itemId) <= 0) {
       return false;
     }
   }
   return true;
 }
Example #21
0
 private boolean cmd_Clear(Quest _quest, String[] wordList, Player activeChar) {
   // quest id|name CLEAR [target]
   Player targetChar = getTargetChar(wordList, 3, activeChar);
   QuestState qs = targetChar.getQuestState(_quest.getName());
   if (qs == null) {
     activeChar.sendMessage(
         "Player " + targetChar.getName() + " havn't Quest [" + _quest.getName() + "]");
     return false;
   }
   qs.exitCurrentQuest(true);
   return ShowQuestList(targetChar, activeChar);
 }
Example #22
0
 private void teleportCharacter(Player activeChar, String Cords) {
   GameObject target = activeChar.getTarget();
   if (target == null || !target.isPlayer()) {
     activeChar.sendPacket(Msg.INVALID_TARGET);
     return;
   }
   if (target.getObjectId() == activeChar.getObjectId()) {
     activeChar.sendMessage("You cannot teleport yourself.");
     return;
   }
   teleportTo(activeChar, (Player) target, Cords, activeChar.getReflectionId());
 }
Example #23
0
 /**
  * Add XP and SP as quest reward <br>
  * <br>
  * Метод учитывает рейты! 3-ий параметр true/false показывает является ли квест на профессию и
  * рейты учитываются в завимисомти от параметра RateQuestsRewardOccupationChange
  */
 public void addExpAndSp(long exp, long sp) {
   Player player = getPlayer();
   if (player == null) {
     return;
   }
   if (exp > 0) {
     player.addExpAndSp((long) (exp * getRateQuestsReward()), 0);
   }
   if (sp > 0) {
     player.addExpAndSp(0, (long) (sp * getRateQuestsReward()));
   }
 }
Example #24
0
  public void startEvent() {
    Player player = getSelf();
    if (!player.getPlayerAccess().IsEventGm) return;

    if (SetActive("TVTArena5", true)) {
      spawnEventManagers();
      _log.info("Event: TVT Arena 5 started");
      Announcements.getInstance().announceToAll("Начался евент TVT Arena 5");
    } else player.sendMessage("Event: TVT Arena 5 already started");

    show("admin/events/custom/custom.htm", player);
  }
Example #25
0
 private boolean checkPartyMember(Player member, int state, int maxrange, GameObject rangefrom) {
   if (member == null) {
     return false;
   }
   if ((rangefrom != null) && (maxrange > 0) && !member.isInRange(rangefrom, maxrange)) {
     return false;
   }
   QuestState qs = member.getQuestState(getQuest().getName());
   if ((qs == null) || (qs.getState() != state)) {
     return false;
   }
   return true;
 }
Example #26
0
 private Player getTargetChar(String[] wordList, int wordListIndex, Player activeChar) {
   // цель задана аргументом
   if (wordListIndex >= 0 && wordList.length > wordListIndex) {
     Player player = World.getPlayer(wordList[wordListIndex]);
     if (player == null) activeChar.sendMessage("Can't find player: " + wordList[wordListIndex]);
     return player;
   }
   // цель задана текущим таргетом
   GameObject my_target = activeChar.getTarget();
   if (my_target != null && my_target.isPlayer()) return (Player) my_target;
   // в качестве цели сам админ
   return activeChar;
 }
Example #27
0
  public void stopEvent() {
    Player player = getSelf();
    if (!player.getPlayerAccess().IsEventGm) return;

    if (SetActive("TVTArena5", false)) {
      ServerVariables.unset("TVTArena5");
      unSpawnEventManagers();
      stop();
      _log.info("Event: TVT Arena 5 stopped");
      Announcements.getInstance().announceToAll("Окончен евент TVT Arena 5");
    } else player.sendMessage("Event: TVT Arena 5 not started");

    show("admin/events/custom/custom.htm", player);
  }
Example #28
0
  public void restore() {
    _listByIndex.clear();
    _listByClassId.clear();
    List<SubClass> subclasses = CharacterSubclassDAO.getInstance().restore(_owner);
    int lastFreeIndex = 2;
    for (SubClass sub : subclasses) {
      if (sub == null) // Невозможно, но хай будет.
      continue;

      if (size() >= MAX_SUB_COUNT) {
        _log.warn(
            "SubClassList:restore: Limit is subclass! Player: "
                + _owner.getName()
                + "("
                + _owner.getObjectId()
                + ")");
        break;
      }

      if (sub.isActive()) {
        _activeSubClass = sub;
      }

      if (sub.isBase()) {
        _baseSubClass = sub;
        sub.setIndex(1);
      } else {
        sub.setIndex(lastFreeIndex);
        lastFreeIndex++;
      }

      if (_listByIndex.containsKey(sub.getIndex()))
        _log.warn(
            "SubClassList:restore: Duplicate index in player subclasses! Player: "
                + _owner.getName()
                + "("
                + _owner.getObjectId()
                + ")");
      _listByIndex.put(sub.getIndex(), sub);

      if (_listByClassId.containsKey(sub.getClassId()))
        _log.warn(
            "SubClassList:restore: Duplicate class_id in player subclasses! Player: "
                + _owner.getName()
                + "("
                + _owner.getObjectId()
                + ")");
      _listByClassId.put(sub.getClassId(), sub);
    }

    _lastFreeIndex = lastFreeIndex;

    if (_listByIndex.size() != _listByClassId.size()) // Невозможно, но хай будет.
    _log.warn(
          "SubClassList:restore: The size of the lists do not match! Player: "
              + _owner.getName()
              + "("
              + _owner.getObjectId()
              + ")");
  }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    UndergroundColiseumEvent coliseumEvent =
        EventHolder.getInstance().getEvent(EventType.MAIN_EVENT, _coliseumId);

    if (command.equals("register")) {
      Party party = player.getParty();
      if (party == null) showChatWindow(player, "events/kerthang_manager008.htm");
      else if (party.getPartyLeader() != player)
        showChatWindow(player, "events/kerthang_manager004.htm");
      else
        for (Player $player : party)
          if ($player.getLevel() < coliseumEvent.getMinLevel()
              || $player.getLevel() > coliseumEvent.getMaxLevel()) {
            showChatWindow(player, "events/kerthang_manager011.htm", "%name%", $player.getName());
            return;
          }
    } else if (command.equals("viewTeams")) {

      List<Player> reg = coliseumEvent.getRegisteredPlayers();

      NpcHtmlMessage msg = new NpcHtmlMessage(player, this);
      msg.setFile("events/kerthang_manager003.htm");
      for (int i = 0; i < 5; i++) {
        Player $player = CollectionUtils.safeGet(reg, i);

        msg.replace("%team" + i + "%", $player == null ? StringUtils.EMPTY : $player.getName());
      }

      player.sendPacket(msg);
    } else super.onBypassFeedback(player, command);
  }
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (PetitionManager.getInstance().isPlayerInConsultation(activeChar)) {
      if (activeChar.isGM()) PetitionManager.getInstance().endActivePetition(activeChar);
      else activeChar.sendPacket(new SystemMessage(SystemMessage.PETITION_UNDER_PROCESS));
    } else if (PetitionManager.getInstance().isPlayerPetitionPending(activeChar)) {
      if (PetitionManager.getInstance().cancelActivePetition(activeChar)) {
        int numRemaining =
            Config.MAX_PETITIONS_PER_PLAYER
                - PetitionManager.getInstance().getPlayerTotalPetitionCount(activeChar);

        activeChar.sendPacket(
            new SystemMessage(
                    SystemMessage.THE_PETITION_WAS_CANCELED_YOU_MAY_SUBMIT_S1_MORE_PETITIONS_TODAY)
                .addString(String.valueOf(numRemaining)));

        // Notify all GMs that the player's pending petition has been cancelled.
        String msgContent = activeChar.getName() + " has canceled a pending petition.";
        GmListTable.broadcastToGMs(
            new Say2(activeChar.getObjectId(), ChatType.HERO_VOICE, "Petition System", msgContent));
      } else
        activeChar.sendPacket(
            new SystemMessage(SystemMessage.FAILED_TO_CANCEL_PETITION_PLEASE_TRY_AGAIN_LATER));
    } else
      activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_HAVE_NOT_SUBMITTED_A_PETITION));
  }