private void spawnLightnings(FortunaWorld world) { Instance instance = InstanceManager.getInstance().getInstance(world.instanceId); if (instance != null) { for (L2Spawn spawn : instance.getGroupSpawn("lightning_sphere_1")) { L2Npc sphere = spawn.spawnOne(false); sphere.setIsNoRndWalk(true); } } }
protected EnterInstanceResult enterInstance(L2PcInstance player, String template) { InstanceManager.InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player); if (world != null) { if (!(world instanceof FortunaWorld)) { player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER); return EnterInstanceResult.ANOTHER_INSTANCE; } } world = new FortunaWorld(); int instanceTemplateId = InstanceZoneId.FORTUNA.getId(); EnterInstanceResult reason = checkConditions(player, instanceTemplateId); if (reason != EnterInstanceResult.OK) { return reason; } int instanceId = InstanceManager.getInstance().createDynamicInstance(template); world.instanceId = instanceId; world.templateId = instanceTemplateId; world.status = 0; InstanceManager.getInstance().addWorld(world); init((FortunaWorld) world); if ((player.isGM()) && (player.getParty() == null)) { player.teleToInstance(ENTRANCE, instanceId); world.allowed.add(Integer.valueOf(player.getObjectId())); ((FortunaWorld) world).playersInside.add(player); return EnterInstanceResult.OK; } if (player.getParty() != null) { for (L2PcInstance member : player.getParty().getMembers()) { member.teleToInstance(ENTRANCE, instanceId); world.allowed.add(Integer.valueOf(member.getObjectId())); ((FortunaWorld) world).playersInside.add(member); } return EnterInstanceResult.OK; } return EnterInstanceResult.NO_PARTY; }
public String onExitZone(L2Character character, L2ZoneType zone) { if ((character instanceof L2PcInstance)) { FortunaWorld world = (FortunaWorld) InstanceManager.getInstance().getInstanceWorld(character, FortunaWorld.class); if (world != null) { if (world.playersInside.contains(character)) world.playersInside.remove(character); } } return super.onExitZone(character, zone); }
public EnterInstanceResult reEnterInstance(L2PcInstance player) { InstanceManager.InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player); if (world != null) { if (!(world instanceof FortunaWorld)) { player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER); return EnterInstanceResult.ANOTHER_INSTANCE; } if (!((FortunaWorld) world).playersInside.contains(player)) { ((FortunaWorld) world).playersInside.add(player); world.allowed.add(Integer.valueOf(player.getObjectId())); } player.teleToInstance(LAIR_ENTRANCE, world.instanceId); return EnterInstanceResult.OK; } return EnterInstanceResult.CANNOT_REENTER; }
private EnterInstanceResult checkConditions(L2PcInstance player, int instanceTemplateId) { L2Party party = player.getParty(); if (player.isGM()) { Long reEnterTime = Long.valueOf( InstanceManager.getInstance() .getInstanceTime(player.getObjectId(), instanceTemplateId)); if (System.currentTimeMillis() < reEnterTime.longValue()) { player.sendPacket( SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET) .addPcName(player)); return EnterInstanceResult.LOCKED_DUE_TO_ENTER_TIME; } return EnterInstanceResult.OK; } if (player.getParty() == null) { player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER); return EnterInstanceResult.NO_PARTY; } int minPlayers = ConfigGrandBoss.MIN_FORTUNA_PLAYERS; int maxPlayers = ConfigGrandBoss.MAX_FORTUNA_PLAYERS; int minLevel = ConfigGrandBoss.MIN_LEVEL_FORTUNA_PLAYERS; if (party.getLeader() != player) { party.getCommandChannel().broadcastMessage(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER); return EnterInstanceResult.NOT_LEADER; } if (party.getMemberCount() > maxPlayers) { party.broadcastMessage(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER); return EnterInstanceResult.TOO_MANY_MEMBERS; } if (party.getMemberCount() < minPlayers) { party.broadcastPacket( SystemMessage.getSystemMessage( SystemMessageId.NOT_ENOUGH_PEOPLE_TO_ENTER_INSTANCE_ZONE_NEED_S1) .addNumber(minPlayers)); return EnterInstanceResult.TOO_LESS_MEMBERS; } for (L2PcInstance member : party.getMembers()) { if ((member == null) || (member.getLevel() < minLevel) || (!member.isAwakened())) { party.broadcastPacket( SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT) .addPcName(member)); return EnterInstanceResult.TOO_LOW_LEVEL; } if (!Util.checkIfInRange(1000, player, member, true)) { party.broadcastPacket( SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED) .addPcName(member)); return EnterInstanceResult.MEMBER_OUT_OF_RANGE; } Long reEnterTime = Long.valueOf( InstanceManager.getInstance() .getInstanceTime(member.getObjectId(), instanceTemplateId)); if (System.currentTimeMillis() < reEnterTime.longValue()) { party.broadcastPacket( SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET) .addPcName(member)); return EnterInstanceResult.LOCKED_DUE_TO_ENTER_TIME; } } return EnterInstanceResult.OK; }