コード例 #1
0
ファイル: Race.java プロジェクト: rukhavi/l2j-mobius
  @Override
  public boolean eventStart(L2PcInstance eventMaker) {
    // Don't start event if its active
    if (_isactive) {
      return false;
    }
    // Check Custom Table - we use custom NPC's
    if (!Config.CUSTOM_NPC_DATA) {
      _log.info(getName() + ": Event can't be started, because custom npc table is disabled!");
      eventMaker.sendMessage(
          "Event " + getName() + " can't be started because custom NPC table is disabled!");
      return false;
    }
    // Initialize list
    _npclist = new ArrayList<>();
    _players = new CopyOnWriteArrayList<>();
    // Set Event active
    _isactive = true;
    // Spawn Manager
    _npc = recordSpawn(_start_npc, 18429, 145861, -3090, 0, false, 0);

    // Announce event start
    Broadcast.toAllOnlinePlayers("* Race Event started! *");
    Broadcast.toAllOnlinePlayers(
        "Visit Event Manager in Dion village and signup, you have "
            + _time_register
            + " min before Race Start...");

    // Schedule Event end
    _eventTask =
        ThreadPoolManager.getInstance()
            .scheduleGeneral(() -> StartRace(), _time_register * 60 * 1000);

    return true;
  }
コード例 #2
0
  @Override
  protected void runImpl() {
    // Get the current L2PcInstance of the player
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    // Get the level of the used skill
    int level = activeChar.getSkillLevel(_skillId);
    if (level <= 0) {
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Get the L2Skill template corresponding to the skillID received from the client
    Skill skill = SkillData.getInstance().getSkill(_skillId, level);

    // Check the validity of the skill
    if (skill != null) {
      activeChar.setCurrentSkillWorldPosition(new Location(_x, _y, _z));

      // normally magicskilluse packet turns char client side but for these skills, it doesn't (even
      // with correct target)
      activeChar.setHeading(
          Util.calculateHeadingFrom(activeChar.getX(), activeChar.getY(), _x, _y));
      Broadcast.toKnownPlayers(activeChar, new ValidateLocation(activeChar));

      activeChar.useMagic(skill, _ctrlPressed, _shiftPressed);
    } else {
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      _log.warning("No skill found with id " + _skillId + " and level " + level + " !!");
    }
  }
コード例 #3
0
ファイル: Race.java プロジェクト: rukhavi/l2j-mobius
 protected void StartRace() {
   // Abort race if no players signup
   if (_players.isEmpty()) {
     Broadcast.toAllOnlinePlayers("Race aborted, nobody signup.");
     eventStop();
     return;
   }
   // Set state
   _isRaceStarted = true;
   // Announce
   Broadcast.toAllOnlinePlayers("Race started!");
   // Get random Finish
   int location = getRandom(0, _locations.length - 1);
   _randspawn = _coords[location];
   // And spawn NPC
   recordSpawn(_stop_npc, _randspawn[0], _randspawn[1], _randspawn[2], _randspawn[3], false, 0);
   // Transform players and send message
   for (L2PcInstance player : _players) {
     if ((player != null) && player.isOnline()) {
       if (player.isInsideRadius(_npc, 500, false, false)) {
         sendMessage(
             player,
             "Race started! Go find Finish NPC as fast as you can... He is located near "
                 + _locations[location]);
         transformPlayer(player);
         player.getRadar().addMarker(_randspawn[0], _randspawn[1], _randspawn[2]);
       } else {
         sendMessage(
             player,
             "I told you stay near me right? Distance was too high, you are excluded from race");
         _players.remove(player);
       }
     }
   }
   // Schedule timeup for Race
   _eventTask =
       ThreadPoolManager.getInstance().scheduleGeneral(() -> timeUp(), _time_race * 60 * 1000);
 }
コード例 #4
0
ファイル: Race.java プロジェクト: rukhavi/l2j-mobius
  @Override
  public boolean eventStop() {
    // Don't stop inactive event
    if (!_isactive) {
      return false;
    }

    // Set inactive
    _isactive = false;
    _isRaceStarted = false;

    // Cancel task if any
    if (_eventTask != null) {
      _eventTask.cancel(true);
      _eventTask = null;
    }
    // Untransform players
    // Teleport to event start point
    for (L2PcInstance player : _players) {
      if ((player != null) && player.isOnline()) {
        player.untransform();
        player.teleToLocation(_npc.getX(), _npc.getY(), _npc.getZ(), true);
      }
    }
    // Despawn NPCs
    for (L2Npc _npc : _npclist) {
      if (_npc != null) {
        _npc.deleteMe();
      }
    }
    _npclist.clear();
    _players.clear();
    // Announce event end
    Broadcast.toAllOnlinePlayers("* Race Event finished *");

    return true;
  }
コード例 #5
0
 @Override
 public boolean useAdminCommand(String command, L2PcInstance activeChar) {
   if (command.equals("admin_show_spawns")) {
     AdminHtml.showAdminHtml(activeChar, "spawns.htm");
   } else if (command.equalsIgnoreCase("admin_spawn_debug_menu")) {
     AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
   } else if (command.startsWith("admin_spawn_debug_print")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     L2Object target = activeChar.getTarget();
     if (target instanceof L2Npc) {
       try {
         st.nextToken();
         int type = Integer.parseInt(st.nextToken());
         printSpawn((L2Npc) target, type);
         if (command.contains("_menu")) {
           AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
         }
       } catch (Exception e) {
       }
     } else {
       activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
     }
   } else if (command.startsWith("admin_spawn_index")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       int level = Integer.parseInt(st.nextToken());
       int from = 0;
       try {
         from = Integer.parseInt(st.nextToken());
       } catch (NoSuchElementException nsee) {
       }
       showMonsters(activeChar, level, from);
     } catch (Exception e) {
       AdminHtml.showAdminHtml(activeChar, "spawns.htm");
     }
   } else if (command.equals("admin_show_npcs")) {
     AdminHtml.showAdminHtml(activeChar, "npcs.htm");
   } else if (command.startsWith("admin_npc_index")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       String letter = st.nextToken();
       int from = 0;
       try {
         from = Integer.parseInt(st.nextToken());
       } catch (NoSuchElementException nsee) {
       }
       showNpcs(activeChar, letter, from);
     } catch (Exception e) {
       AdminHtml.showAdminHtml(activeChar, "npcs.htm");
     }
   } else if (command.startsWith("admin_instance_spawns")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       int instance = Integer.parseInt(st.nextToken());
       if (instance >= 300000) {
         final StringBuilder html =
             StringUtil.startAppend(
                 500 + 1000,
                 "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>",
                 "<font color=\"LEVEL\">Spawns for " + String.valueOf(instance) + "</font>",
                 "</td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br>",
                 "<table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>");
         int counter = 0;
         int skiped = 0;
         Instance inst = InstanceManager.getInstance().getInstance(instance);
         if (inst != null) {
           for (L2Npc npc : inst.getNpcs()) {
             if (!npc.isDead()) {
               // Only 50 because of client html limitation
               if (counter < 50) {
                 StringUtil.append(
                     html,
                     "<tr><td>" + npc.getName() + "</td><td>",
                     "<a action=\"bypass -h admin_move_to "
                         + npc.getX()
                         + " "
                         + npc.getY()
                         + " "
                         + npc.getZ()
                         + "\">Go</a>",
                     "</td></tr>");
                 counter++;
               } else {
                 skiped++;
               }
             }
           }
           StringUtil.append(
               html,
               "<tr><td>Skipped:</td><td>"
                   + String.valueOf(skiped)
                   + "</td></tr></table></body></html>");
           final NpcHtmlMessage ms = new NpcHtmlMessage();
           ms.setHtml(html.toString());
           activeChar.sendPacket(ms);
         } else {
           activeChar.sendMessage("Cannot find instance " + instance);
         }
       } else {
         activeChar.sendMessage("Invalid instance number.");
       }
     } catch (Exception e) {
       activeChar.sendMessage("Usage //instance_spawns <instance_number>");
     }
   } else if (command.startsWith("admin_unspawnall")) {
     Broadcast.toAllOnlinePlayers(
         SystemMessage.getSystemMessage(SystemMessageId.NPC_SERVER_NOT_OPERATING));
     RaidBossSpawnManager.getInstance().cleanUp();
     DayNightSpawnManager.getInstance().cleanUp();
     L2World.getInstance().deleteVisibleNpcSpawns();
     AdminTable.getInstance().broadcastMessageToGMs("NPC Unspawn completed!");
   } else if (command.startsWith("admin_spawnday")) {
     DayNightSpawnManager.getInstance().spawnDayCreatures();
   } else if (command.startsWith("admin_spawnnight")) {
     DayNightSpawnManager.getInstance().spawnNightCreatures();
   } else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload")) {
     // make sure all spawns are deleted
     RaidBossSpawnManager.getInstance().cleanUp();
     DayNightSpawnManager.getInstance().cleanUp();
     L2World.getInstance().deleteVisibleNpcSpawns();
     // now respawn all
     NpcData.getInstance().load();
     SpawnTable.getInstance().load();
     RaidBossSpawnManager.getInstance().load();
     AutoSpawnHandler.getInstance().reload();
     SevenSigns.getInstance().spawnSevenSignsNPC();
     QuestManager.getInstance().reloadAllScripts();
     AdminTable.getInstance().broadcastMessageToGMs("NPC Respawn completed!");
   } else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       String cmd = st.nextToken();
       String id = st.nextToken();
       int respawnTime = 0;
       int mobCount = 1;
       if (st.hasMoreTokens()) {
         mobCount = Integer.parseInt(st.nextToken());
       }
       if (st.hasMoreTokens()) {
         respawnTime = Integer.parseInt(st.nextToken());
       }
       if (cmd.equalsIgnoreCase("admin_spawn_once")) {
         spawnMonster(activeChar, id, respawnTime, mobCount, false);
       } else {
         spawnMonster(activeChar, id, respawnTime, mobCount, true);
       }
     } catch (Exception e) { // Case of wrong or missing monster data
       AdminHtml.showAdminHtml(activeChar, "spawns.htm");
     }
   } else if (command.startsWith("admin_list_spawns")
       || command.startsWith("admin_list_positions")) {
     int npcId = 0;
     int teleportIndex = -1;
     try { // admin_list_spawns x[xxxx] x[xx]
       String[] params = command.split(" ");
       Pattern pattern = Pattern.compile("[0-9]*");
       Matcher regexp = pattern.matcher(params[1]);
       if (regexp.matches()) {
         npcId = Integer.parseInt(params[1]);
       } else {
         params[1] = params[1].replace('_', ' ');
         npcId = NpcData.getInstance().getTemplateByName(params[1]).getId();
       }
       if (params.length > 2) {
         teleportIndex = Integer.parseInt(params[2]);
       }
     } catch (Exception e) {
       activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]");
     }
     if (command.startsWith("admin_list_positions")) {
       findNPCInstances(activeChar, npcId, teleportIndex, true);
     } else {
       findNPCInstances(activeChar, npcId, teleportIndex, false);
     }
   }
   return true;
 }
コード例 #6
0
ファイル: Race.java プロジェクト: rukhavi/l2j-mobius
 private void winRace(L2PcInstance player) {
   int[] _reward = _rewards[getRandom(_rewards.length - 1)];
   player.addItem("eventModRace", _reward[0], _reward[1], _npc, true);
   Broadcast.toAllOnlinePlayers(player.getName() + " is a winner!");
   eventStop();
 }
コード例 #7
0
ファイル: Race.java プロジェクト: rukhavi/l2j-mobius
 protected void timeUp() {
   Broadcast.toAllOnlinePlayers("Time up, nobody wins!");
   eventStop();
 }