Пример #1
0
  private void attackGrp(String command, L2PcInstance activeChar) {
    int groupId;
    int othGroupId;

    try {
      groupId = Integer.parseInt(command.split(" ")[1]);
      othGroupId = Integer.parseInt(command.split(" ")[2]);
    } catch (Exception e) {
      activeChar.sendMessage("Usage: //mobgroup_attackgrp <groupId> <TargetGroupId>");
      return;
    }

    final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);

    if (group == null) {
      activeChar.sendMessage("Invalid group specified.");
      return;
    }

    final MobGroup othGroup = MobGroupTable.getInstance().getGroup(othGroupId);

    if (othGroup == null) {
      activeChar.sendMessage("Incorrect target group.");
      return;
    }

    group.setAttackGroup(othGroup);
  }
Пример #2
0
  /**
   * Stops the TvTEvent fight<br>
   * 1. Set state EventState.INACTIVATING<br>
   * 2. Remove tvt npc from world<br>
   * 3. Open doors specified in configs<br>
   * 4. Teleport all participants back to participation npc location<br>
   * 5. Teams cleaning<br>
   * 6. Set state EventState.INACTIVE<br>
   */
  public static void stopFight() {
    // Set state INACTIVATING
    setState(EventState.INACTIVATING);
    // Unspawn event npc
    unSpawnNpc();
    // Opens all doors specified in configs for tvt
    openDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
    // Closes all doors specified in Configs for tvt
    closeDoors(Config.TVT_DOORS_IDS_TO_OPEN);

    // Iterate over all teams
    for (TvTEventTeam team : _teams) {
      for (L2PcInstance playerInstance : team.getParticipatedPlayers().values()) {
        // Check for nullpointer
        if (playerInstance != null) {
          // Enable player revival.
          playerInstance.setCanRevive(true);
          // Teleport back.
          new TvTEventTeleporter(
              playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
        }
      }
    }

    // Cleanup of teams
    _teams[0].cleanMe();
    _teams[1].cleanMe();
    // Set state INACTIVE
    setState(EventState.INACTIVE);
    AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
  }
Пример #3
0
  private void createGroup(String command, L2PcInstance activeChar) {
    int groupId;
    int templateId;
    int mobCount;

    try {
      final String[] cmdParams = command.split(" ");

      groupId = Integer.parseInt(cmdParams[1]);
      templateId = Integer.parseInt(cmdParams[2]);
      mobCount = Integer.parseInt(cmdParams[3]);
    } catch (Exception e) {
      activeChar.sendMessage("Usage: //mobgroup_create <group> <npcid> <count>");
      return;
    }

    if (MobGroupTable.getInstance().getGroup(groupId) != null) {
      activeChar.sendMessage("Mob group " + groupId + " already exists.");
      return;
    }

    final L2NpcTemplate template = NpcData.getInstance().getTemplate(templateId);

    if (template == null) {
      activeChar.sendMessage("Invalid NPC ID specified.");
      return;
    }

    final MobGroup group = new MobGroup(groupId, template, mobCount);
    MobGroupTable.getInstance().addGroup(groupId, group);

    activeChar.sendMessage("Mob group " + groupId + " created.");
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, true);
    String htmltext = getNoQuestMsg(player);
    if (qs.isCompleted()) {
      return getAlreadyCompletedMsg(player);
    }
    if (player.getRace() == Race.ERTHEIA) {
      return "31292-noErtheia.html";
    }
    if (player.isMageClass()) {
      return "31292-noMage.html";
    }

    switch (npc.getId()) {
      case ANDREI:
        {
          if (qs.isCreated()) {
            htmltext = "31292-01.htm";
          } else if (qs.isStarted()) {
            htmltext = "31292-03.html";
          }
          break;
        }
      case JANITT:
        {
          if (qs.isCond(1)) {
            htmltext = "33851-01.html";
          }
          break;
        }
    }
    return htmltext;
  }
Пример #5
0
  /**
   * Called on Appearing packet received (player finished teleporting)
   *
   * @param playerInstance
   */
  public static void onTeleported(L2PcInstance playerInstance) {
    if (!isStarted()
        || (playerInstance == null)
        || !isPlayerParticipant(playerInstance.getObjectId())) {
      return;
    }

    if (playerInstance.isMageClass()) {
      if ((Config.TVT_EVENT_MAGE_BUFFS != null) && !Config.TVT_EVENT_MAGE_BUFFS.isEmpty()) {
        for (Entry<Integer, Integer> e : Config.TVT_EVENT_MAGE_BUFFS.entrySet()) {
          final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
          if (skill != null) {
            skill.applyEffects(playerInstance, playerInstance);
          }
        }
      }
    } else {
      if ((Config.TVT_EVENT_FIGHTER_BUFFS != null) && !Config.TVT_EVENT_FIGHTER_BUFFS.isEmpty()) {
        for (Entry<Integer, Integer> e : Config.TVT_EVENT_FIGHTER_BUFFS.entrySet()) {
          final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
          if (skill != null) {
            skill.applyEffects(playerInstance, playerInstance);
          }
        }
      }
    }
  }
Пример #6
0
  /**
   * @param source
   * @param target
   * @param skill
   * @return true if player valid for skill
   */
  public static final boolean checkForTvTSkill(
      L2PcInstance source, L2PcInstance target, Skill skill) {
    if (!isStarted()) {
      return true;
    }
    // TvT is started
    final int sourcePlayerId = source.getObjectId();
    final int targetPlayerId = target.getObjectId();
    final boolean isSourceParticipant = isPlayerParticipant(sourcePlayerId);
    final boolean isTargetParticipant = isPlayerParticipant(targetPlayerId);

    // both players not participating
    if (!isSourceParticipant && !isTargetParticipant) {
      return true;
    }
    // one player not participating
    if (!(isSourceParticipant && isTargetParticipant)) {
      return false;
    }
    // players in the different teams ?
    if (getParticipantTeamId(sourcePlayerId) != getParticipantTeamId(targetPlayerId)) {
      if (!skill.isBad()) {
        return false;
      }
    }
    return true;
  }
Пример #7
0
  /**
   * Called on every onAction in L2PcIstance<br>
   * <br>
   *
   * @param playerInstance
   * @param targetedPlayerObjectId
   * @return boolean: true if player is allowed to target, otherwise false
   */
  public static boolean onAction(L2PcInstance playerInstance, int targetedPlayerObjectId) {
    if ((playerInstance == null) || !isStarted()) {
      return true;
    }

    if (playerInstance.isGM()) {
      return true;
    }

    final byte playerTeamId = getParticipantTeamId(playerInstance.getObjectId());
    final byte targetedPlayerTeamId = getParticipantTeamId(targetedPlayerObjectId);

    if (((playerTeamId != -1) && (targetedPlayerTeamId == -1))
        || ((playerTeamId == -1) && (targetedPlayerTeamId != -1))) {
      return false;
    }

    if ((playerTeamId != -1)
        && (targetedPlayerTeamId != -1)
        && (playerTeamId == targetedPlayerTeamId)
        && (playerInstance.getObjectId() != targetedPlayerObjectId)
        && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED) {
      return false;
    }

    return true;
  }
Пример #8
0
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   String htmltext = null;
   switch (event) {
     case "32972-1.html":
       {
         htmltext = event;
         break;
       }
     case "teleport_museum":
       {
         if (player.getLevel() >= MIN_LEVEL) {
           player.teleToLocation(MUSEUM);
           break;
         }
         htmltext = "32972-noteleport.html";
         break;
       }
     case "TEXT_SPAM":
       {
         if (npc != null) {
           broadcastNpcSay(
               npc,
               ChatType.NPC_GENERAL,
               NpcStringId.IS_IT_BETTER_TO_END_DESTINY_OR_START_DESTINY);
         }
         break;
       }
   }
   return htmltext;
 }
Пример #9
0
 public GMViewItemList(L2PcInstance cha) {
   _playerName = cha.getName();
   _limit = cha.getInventoryLimit();
   for (L2ItemInstance item : cha.getInventory().getItems()) {
     _items.add(item);
   }
 }
Пример #10
0
  private void invul(String command, L2PcInstance activeChar) {
    int groupId;
    String enabled;

    try {
      groupId = Integer.parseInt(command.split(" ")[1]);
      enabled = command.split(" ")[2];
    } catch (Exception e) {
      activeChar.sendMessage("Usage: //mobgroup_invul <groupId> <on|off>");
      return;
    }

    final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);

    if (group == null) {
      activeChar.sendMessage("Invalid group specified.");
      return;
    }

    if (enabled.equalsIgnoreCase("on") || enabled.equalsIgnoreCase("true")) {
      group.setInvul(true);
    } else if (enabled.equalsIgnoreCase("off") || enabled.equalsIgnoreCase("false")) {
      group.setInvul(false);
    } else {
      activeChar.sendMessage("Incorrect command arguments.");
    }
  }
Пример #11
0
  private void teleportGroup(String command, L2PcInstance activeChar) {
    int groupId;
    String targetPlayerStr = null;
    L2PcInstance targetPlayer = null;

    try {
      groupId = Integer.parseInt(command.split(" ")[1]);
      targetPlayerStr = command.split(" ")[2];

      if (targetPlayerStr != null) {
        targetPlayer = L2World.getInstance().getPlayer(targetPlayerStr);
      }

      if (targetPlayer == null) {
        targetPlayer = activeChar;
      }
    } catch (Exception e) {
      activeChar.sendMessage("Usage: //mobgroup_teleport <groupId> [playerName]");
      return;
    }

    final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);

    if (group == null) {
      activeChar.sendMessage("Invalid group specified.");
      return;
    }

    group.teleportGroup(activeChar);
  }
Пример #12
0
 private void exitInstance(L2PcInstance player) {
   final InstanceWorld inst = InstanceManager.getInstance().getWorld(player.getInstanceId());
   if (inst instanceof NornilsWorld) {
     final NornilsWorld world = ((NornilsWorld) inst);
     world.removeAllowed(player.getObjectId());
     teleportPlayer(player, EXIT_PPL, 0);
   }
 }
 private static QuestState getLeaderQuestState(L2PcInstance player, String quest) {
   if (player.getClan() != null) {
     final L2PcInstance leader = player.getClan().getLeader().getPlayerInstance();
     if (leader != null) {
       return leader.getQuestState(quest);
     }
   }
   return null;
 }
Пример #14
0
 /**
  * Called when a player logs out<br>
  * <br>
  *
  * @param playerInstance as L2PcInstance<br>
  */
 public static void onLogout(L2PcInstance playerInstance) {
   if ((playerInstance != null) && (isStarting() || isStarted() || isParticipating())) {
     if (removeParticipant(playerInstance.getObjectId())) {
       playerInstance.setXYZInvisible(
           (Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)) - 50,
           (Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)) - 50,
           Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
     }
   }
 }
Пример #15
0
 private static int highestLevelPcInstanceOf(Map<Integer, L2PcInstance> players) {
   int maxLevel = Integer.MIN_VALUE, maxLevelId = -1;
   for (L2PcInstance player : players.values()) {
     if (player.getLevel() >= maxLevel) {
       maxLevel = player.getLevel();
       maxLevelId = player.getObjectId();
     }
   }
   return maxLevelId;
 }
Пример #16
0
 @Override
 protected void runImpl() {
   final L2PcInstance activeChar = getClient().getActiveChar();
   if (activeChar == null) {
     return;
   }
   if (activeChar.inObserverMode()) {
     activeChar.leaveObserverMode();
     // activeChar.teleToLocation(activeChar.getObsX(), activeChar.getObsY(),
     // activeChar.getObsZ());
   }
 }
Пример #17
0
  /**
   * Send a SystemMessage to all participated players<br>
   * 1. Send the message to all players of team number one<br>
   * 2. Send the message to all players of team number two<br>
   * <br>
   *
   * @param message as String<br>
   */
  public static void sysMsgToAllParticipants(String message) {
    for (L2PcInstance playerInstance : _teams[0].getParticipatedPlayers().values()) {
      if (playerInstance != null) {
        playerInstance.sendMessage(message);
      }
    }

    for (L2PcInstance playerInstance : _teams[1].getParticipatedPlayers().values()) {
      if (playerInstance != null) {
        playerInstance.sendMessage(message);
      }
    }
  }
Пример #18
0
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState st = getQuestState(player, true);
   final QuestState st2 = player.getQuestState(Q00115_TheOtherSideOfTruth.class.getSimpleName());
   String htmltext = getNoQuestMsg(player);
   switch (npc.getId()) {
     case RAFFORTY:
       {
         if (st.isCreated()) {
           if (player.getLevel() < MIN_LVL) {
             htmltext = "32020-01.htm";
           } else {
             htmltext = ((st2 != null) && (st2.isCompleted())) ? "32020-02.htm" : "32020-03.htm";
           }
         } else if (st.isStarted()) {
           final long hasQuestItems =
               getQuestItemsCount(player, SILVER_ICE_CRYSTAL, BLACK_ICE_CRYSTAL);
           if ((st2 != null) && st2.isCompleted()) {
             htmltext = (hasQuestItems > 0) ? "32020-13.html" : "32020-11.html";
             if (st.isCond(1)) {
               st.setCond(2, true);
             }
           } else {
             htmltext = (hasQuestItems > 0) ? "32020-12.html" : "32020-10.html";
           }
         }
         break;
       }
     case ICE_SHELF:
       {
         // TODO: In High Five this quest have an updated reward system.
         if (st.isStarted()) {
           if (hasQuestItems(player, SILVER_ICE_CRYSTAL)) {
             final int val = st.getInt("ex") % 10;
             if (val == 0) {
               htmltext = "32023-03.html";
               st.set("ex", 0);
             } else {
               htmltext = "32023-09.html";
             }
           } else {
             htmltext = "32023-02.html";
           }
         } else {
           htmltext = "32023-01.html";
         }
         break;
       }
   }
   return htmltext;
 }
Пример #19
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    if ((_page > 10) || (_page < 0)) {
      return;
    }

    activeChar.deleteShortCut(_slot, _page);
    // client needs no confirmation. this packet is just to inform the server
  }
Пример #20
0
  /**
   * Is called when a player is killed<br>
   * <br>
   *
   * @param killerCharacter as L2Character<br>
   * @param killedPlayerInstance as L2PcInstance<br>
   */
  public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance) {
    if ((killedPlayerInstance == null) || !isStarted()) {
      return;
    }

    final byte killedTeamId = getParticipantTeamId(killedPlayerInstance.getObjectId());

    if (killedTeamId == -1) {
      return;
    }

    new TvTEventTeleporter(
        killedPlayerInstance, _teams[killedTeamId].getCoordinates(), false, false);

    if (killerCharacter == null) {
      return;
    }

    L2PcInstance killerPlayerInstance = null;

    if ((killerCharacter instanceof L2PetInstance)
        || (killerCharacter instanceof L2ServitorInstance)) {
      killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();

      if (killerPlayerInstance == null) {
        return;
      }
    } else if (killerCharacter instanceof L2PcInstance) {
      killerPlayerInstance = (L2PcInstance) killerCharacter;
    } else {
      return;
    }

    final byte killerTeamId = getParticipantTeamId(killerPlayerInstance.getObjectId());

    if ((killerTeamId != -1) && (killedTeamId != -1) && (killerTeamId != killedTeamId)) {
      final TvTEventTeam killerTeam = _teams[killerTeamId];

      killerTeam.increasePoints();

      final CreatureSay cs =
          new CreatureSay(
              killerPlayerInstance.getObjectId(),
              ChatType.WHISPER,
              killerPlayerInstance.getName(),
              "I have killed " + killedPlayerInstance.getName() + "!");

      for (L2PcInstance playerInstance : _teams[killerTeamId].getParticipatedPlayers().values()) {
        if (playerInstance != null) {
          playerInstance.sendPacket(cs);
        }
      }

      // Notify to scripts.
      EventDispatcher.getInstance()
          .notifyEventAsync(
              new OnTvTEventKill(killerPlayerInstance, killedPlayerInstance, killerTeam));
    }
  }
Пример #21
0
 private void setNormal(String command, L2PcInstance activeChar) {
   int groupId;
   try {
     groupId = Integer.parseInt(command.split(" ")[1]);
   } catch (Exception e) {
     activeChar.sendMessage("Incorrect command arguments.");
     return;
   }
   final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
   if (group == null) {
     activeChar.sendMessage("Invalid group specified.");
     return;
   }
   group.setAttackRandom();
 }
Пример #22
0
 private void follow(String command, L2PcInstance activeChar, L2Character target) {
   int groupId;
   try {
     groupId = Integer.parseInt(command.split(" ")[1]);
   } catch (Exception e) {
     activeChar.sendMessage("Incorrect command arguments.");
     return;
   }
   final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
   if (group == null) {
     activeChar.sendMessage("Invalid group specified.");
     return;
   }
   group.setFollowMode(target);
 }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, true);
    String htmltext = getNoQuestMsg(player);
    if (qs.isCompleted()) {
      return getAlreadyCompletedMsg(player);
    }
    if (player.getRace() == Race.ERTHEIA) {
      return "33864-noErtheia.html";
    }

    switch (npc.getId()) {
      case PATERSON:
        {
          if (qs.isCreated()) {
            htmltext = "33864-01.htm";
          } else if (qs.isStarted()) {
            htmltext = "33864-03.html";
          }
          break;
        }
      case SHUVANN:
        {
          if (qs.isCond(1)) {
            htmltext = "33867-01.html";
          }
          break;
        }
    }
    return htmltext;
  }
Пример #24
0
  @Override
  public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) {
    final QuestState st = getQuestState(player, false);
    if (st == null) {
      return null;
    }

    for (int _gk[] : _gatekeepers) {
      if (npc.getId() == _gk[0]) {
        // Drop key
        npc.dropItem(player, _gk[1], 1);

        // Check if gatekeeper should open bridge, and open it
        if (_gk[2] > 0) {
          final InstanceWorld tmpworld =
              InstanceManager.getInstance().getWorld(player.getInstanceId());
          if (tmpworld instanceof NornilsWorld) {
            openDoor(_gk[2], tmpworld.getInstanceId());
          }
        }
      }
      if (npc.getId() == 18355) {
        spawn2(npc);
      }
    }
    return super.onKill(npc, player, isSummon);
  }
Пример #25
0
 private void openDoor(QuestState st, L2PcInstance player, int doorId) {
   st.unset("correct");
   final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
   if (tmpworld instanceof NornilsWorld) {
     openDoor(doorId, tmpworld.getInstanceId());
   }
 }
Пример #26
0
 @Override
 public final void teleportPlayer(L2PcInstance player, Location loc, int instanceId) {
   giveBuffs(player);
   final L2Summon pet = player.getPet();
   if (pet != null) {
     giveBuffs(pet);
   }
   player
       .getServitors()
       .values()
       .forEach(
           s -> {
             giveBuffs(s);
           });
   super.teleportPlayer(player, loc, instanceId);
 }
Пример #27
0
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    final QuestState st = getQuestState(player, true);
    if (st == null) {
      return htmltext;
    }

    switch (npc.getId()) {
      case ANTON:
        switch (st.getState()) {
          case State.CREATED:
            htmltext = (player.getLevel() < 75) ? "31338-0a.htm" : "31338-0b.htm";
            break;
          case State.STARTED:
            htmltext = "31338-1a.html";
            break;
          case State.COMPLETED:
            htmltext = getAlreadyCompletedMsg(player);
            break;
        }
        break;
      case MARQUEZ:
        if (st.isCond(1)) {
          htmltext = "32113-1.html";
        }
        break;
    }
    return htmltext;
  }
Пример #28
0
 /**
  * @param player
  * @param target
  */
 public MyTargetSelected(L2PcInstance player, L2Character target) {
   _objectId =
       (target instanceof L2ControllableAirShipInstance)
           ? ((L2ControllableAirShipInstance) target).getHelmObjectId()
           : target.getObjectId();
   _color = target.isAutoAttackable(player) ? (player.getLevel() - target.getLevel()) : 0;
 }
Пример #29
0
 public static boolean payParticipationFee(L2PcInstance playerInstance) {
   return playerInstance.destroyItemByItemId(
       "TvT Participation Fee",
       Config.TVT_EVENT_PARTICIPATION_FEE[0],
       Config.TVT_EVENT_PARTICIPATION_FEE[1],
       _lastNpcSpawn,
       true);
 }
Пример #30
0
 @Override
 public boolean useAdminCommand(String command, L2PcInstance activeChar) {
   if (command.equals("admin_mobmenu")) {
     showMainPage(activeChar, command);
     return true;
   } else if (command.equals("admin_mobgroup_list")) {
     showGroupList(activeChar);
   } else if (command.startsWith("admin_mobgroup_create")) {
     createGroup(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_delete")
       || command.startsWith("admin_mobgroup_remove")) {
     removeGroup(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_spawn")) {
     spawnGroup(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_unspawn")) {
     unspawnGroup(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_kill")) {
     killGroup(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_attackgrp")) {
     attackGrp(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_attack")) {
     if (activeChar.getTarget() instanceof L2Character) {
       final L2Character target = (L2Character) activeChar.getTarget();
       attack(command, activeChar, target);
     }
   } else if (command.startsWith("admin_mobgroup_rnd")) {
     setNormal(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_idle")) {
     idle(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_return")) {
     returnToChar(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_follow")) {
     follow(command, activeChar, activeChar);
   } else if (command.startsWith("admin_mobgroup_casting")) {
     setCasting(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_nomove")) {
     noMove(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_invul")) {
     invul(command, activeChar);
   } else if (command.startsWith("admin_mobgroup_teleport")) {
     teleportGroup(command, activeChar);
   }
   showMainPage(activeChar, command);
   return true;
 }