Exemple #1
0
 private static final String checkConditions(L2Npc npc, L2PcInstance player) {
   final L2Party party = player.getParty();
   // player must be in party
   if (party == null) {
     player.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_IN_A_PARTY_SO_YOU_CANNOT_ENTER);
     return "32330-05.html";
   }
   // ...and be party leader
   if (party.getLeader() != player) {
     player.sendPacket(SystemMessageId.ONLY_A_PARTY_LEADER_CAN_MAKE_THE_REQUEST_TO_ENTER);
     return "32330-08.html";
   }
   boolean _kamael = false;
   // for each party member
   for (L2PcInstance partyMember : party.getMembers()) {
     // player level must be in range
     if (partyMember.getLevel() > INSTANCE_LVL_MAX) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-06.html";
     }
     if (partyMember.getLevel() < INSTANCE_LVL_MIN) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-07.html";
     }
     if (partyMember.getClassId().level() != 0) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-06.html";
     }
     // player must be near party leader
     if (!partyMember.isInsideRadius(player, 500, true, true)) {
       final SystemMessage sm =
           SystemMessage.getSystemMessage(
               SystemMessageId
                   .C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
       sm.addPcName(partyMember);
       player.sendPacket(sm);
       return "32330-08.html";
     }
     if (partyMember.getRace().ordinal() == 5) {
       _kamael = true;
     }
   }
   if (!_kamael) {
     return "32330-08.html";
   }
   return "ok";
 }
Exemple #2
0
  private final synchronized String enterInstance(L2Npc npc, L2PcInstance player) {
    InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
    if (world != null) {
      if (!(world instanceof NornilsWorld) || (world.getTemplateId() != TEMPLATE_ID)) {
        player.sendPacket(
            SystemMessageId
                .YOU_HAVE_ENTERED_ANOTHER_INSTANT_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
        return null;
      }
      // check for level difference again on reenter
      if ((player.getLevel() > INSTANCE_LVL_MAX) || (player.getLevel() < INSTANCE_LVL_MIN)) {
        final SystemMessage sm =
            SystemMessage.getSystemMessage(
                SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
        sm.addPcName(player);
        player.sendPacket(sm);
        return null;
      }
      // check what instance still exist
      final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
      if (inst != null) {
        teleportPlayer(player, SPAWN_PPL, world.getInstanceId());
      }
      return null;
    }
    // Creating new instance
    final String result = checkConditions(npc, player);
    if (!(result.equalsIgnoreCase("ok"))) {
      return result;
    }

    final int instanceId = InstanceManager.getInstance().createDynamicInstance("NornilsGarden.xml");
    final Instance inst = InstanceManager.getInstance().getInstance(instanceId);

    inst.setName(InstanceManager.getInstance().getInstanceIdName(TEMPLATE_ID));
    inst.setExitLoc(new Location(player));
    inst.setAllowSummon(false);
    inst.setDuration(DURATION_TIME * 60000);
    inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
    world = new NornilsWorld();
    world.setInstanceId(instanceId);
    world.setTemplateId(TEMPLATE_ID);
    InstanceManager.getInstance().addWorld(world);
    _log.info(
        "Nornils Garden: started, Instance: "
            + instanceId
            + " created by player: "
            + player.getName());

    prepareInstance((NornilsWorld) world);

    // and finally teleport party into instance
    final L2Party party = player.getParty();
    if (party != null) {
      for (L2PcInstance partyMember : party.getMembers()) {
        world.addAllowed(partyMember.getObjectId());
        teleportPlayer(partyMember, SPAWN_PPL, instanceId);
      }
    }
    return null;
  }