Autor Tema: RandomZone, aCis  (Leído 1513 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Huesitos

  • Grado A
  • *
  • Topic Author
  • Mensajes: 443
  • ve
  • Agradecimientos: 171
  • Cronica: : C6
  • Revision: 382
  • S.O: Windows 7
  • Serverpack : aCis
A SixJokers, execanciani, chuchuqui, agustinxkpo48, Homer Simpson y cesar, les gusta este post.

RandomZone, aCis
« en: Enero 11, 2017, 03:17:12 pm »
gracias
Este post tiene 6 agradecimientos
  • Añade a tus favoritos
  • Hola, les comparto un código que tengo en mi server, es algo parecido a este: http://l2devsadmins.net/l2devsAdmins2-0-11/index.php?topic=4345.0

    Breve explicación: Zonas aleatorias que cambian en un rango de tiempo, da la opción de "flag" al entrar a la zona, se agrego un "bypass" en teleport para que puedan ir directamente en la zona random actual...

    Core: 374 (Sin probar solo update)


    Código: [Seleccionar]
    Index: java/net/sf/l2j/gameserver/GameServer.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/GameServer.java (revision 0)
    +++ java/net/sf/l2j/gameserver/GameServer.java (revision 0)
    @@ -81,6 +81,7 @@
     import net.sf.l2j.gameserver.instancemanager.SevenSigns;
     import net.sf.l2j.gameserver.instancemanager.SevenSignsFestival;
     import net.sf.l2j.gameserver.instancemanager.ZoneManager;
    +import net.sf.l2j.gameserver.instancemanager.ZoneRandom;
     import net.sf.l2j.gameserver.instancemanager.games.MonsterRace;
     import net.sf.l2j.gameserver.model.World;
     import net.sf.l2j.gameserver.model.entity.Hero;
    @@ -202,6 +203,7 @@
     
      StringUtil.printSection("Zones");
      ZoneManager.getInstance();
    + ZoneRandom.getInstance();
     
      StringUtil.printSection("Task Managers");
      AttackStanceTaskManager.getInstance();
    Index: java/net/sf/l2j/gameserver/instancemanager/ZoneRandom.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/instancemanager/ZoneRandom.java (revision 0)
    +++ java/net/sf/l2j/gameserver/instancemanager/ZoneRandom.java (revision 0)
    @@ -0,0 +1,66 @@
    +package net.sf.l2j.gameserver.instancemanager;
    +
    +import java.util.logging.Logger;
    +
    +import net.sf.l2j.commons.concurrent.ThreadPool;
    +import net.sf.l2j.commons.random.Rnd;
    +
    +import net.sf.l2j.gameserver.model.World;
    +import net.sf.l2j.gameserver.model.actor.instance.Player;
    +import net.sf.l2j.gameserver.model.location.Location;
    +import net.sf.l2j.gameserver.model.location.SpawnLocation;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
    +import net.sf.l2j.gameserver.util.Broadcast;
    +
    +public class ZoneRandom implements Runnable
    +{
    + private static final Logger _log = Logger.getLogger(ZoneRandom.class.getName());
    +
    + public int REFRESH = 35;
    + public int RANDOM_RANGE = 100;
    + public int RANDOM;
    +
    + private static final SpawnLocation[] ZONES =
    + {
    + new SpawnLocation(10468, -24569, -3650, 0), // Primeval Isle Wharf.    
    + new SpawnLocation(106024, 114968, -1560, 0), // Hardin's Academy.
    + new SpawnLocation(29205, 74948, -3775, 0) //Elven Fortress.
    + };
    +
    + public ZoneRandom()
    + {
    + _log.info("ZoneRandom: Loading zones...");
    +
    + ThreadPool.scheduleAtFixedRate(this, 0, REFRESH * 1000 * 60);
    + }
    +
    + @Override
    + public void run()
    + {
    + RANDOM = Rnd.get(ZONES.length-1);
    +
    + for (Player player : World.getInstance().getPlayers())
    + {
    + if (player.isInsideZone(ZoneId.RANDOM_ZONE))
    + player.teleToLocation(getRandomZone().getX() + Rnd.get(-RANDOM_RANGE,RANDOM_RANGE), getRandomZone().getY() + Rnd.get(-RANDOM_RANGE,RANDOM_RANGE), getRandomZone().getZ(), 20); 
    + }
    +
    + Broadcast.announceToOnlinePlayers("The pvp area was changed to a random.", true);
    + Broadcast.announceToOnlinePlayers("Next random pvp area will be change after " + REFRESH + " minute(s).", true);
    + }
    +
    + public Location getRandomZone()
    + {
    + return ZONES[RANDOM];
    + }
    +
    + public static ZoneRandom getInstance()
    + {
    + return SingletonHolder._instance;
    + }
    +
    + private static class SingletonHolder
    + {
    + protected static final ZoneRandom _instance = new ZoneRandom();
    + }
    +}
    \ No newline at end of file
    Index: java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java (revision 0)
    +++ java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java (revision 0)
    @@ -7,6 +7,7 @@
     import net.sf.l2j.gameserver.data.cache.HtmCache;
     import net.sf.l2j.gameserver.data.manager.CastleManager;
     import net.sf.l2j.gameserver.data.xml.TeleportLocationData;
    +import net.sf.l2j.gameserver.instancemanager.ZoneRandom;
     import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
     import net.sf.l2j.gameserver.model.location.TeleportLocation;
     import net.sf.l2j.gameserver.network.SystemMessageId;
    @@ -135,6 +136,11 @@
      }
      showChatWindow(player, val);
      }
    + else if (command.startsWith("random"))
    + {
    + if (ZoneRandom.getInstance().getRandomZone() != null)
    + player.teleToLocation(ZoneRandom.getInstance().getRandomZone(), 20);
    + }
      else
      super.onBypassFeedback(player, command);
      }
    Index: java/net/sf/l2j/gameserver/model/zone/type/RandomZone.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/zone/type/RandomZone.java (revision 0)
    +++ java/net/sf/l2j/gameserver/model/zone/type/RandomZone.java (revision 0)
    @@ -0,0 +1,75 @@
    +package net.sf.l2j.gameserver.model.zone.type;
    +
    +import net.sf.l2j.gameserver.data.SkillTable;
    +import net.sf.l2j.gameserver.model.L2Skill;
    +import net.sf.l2j.gameserver.model.actor.Creature;
    +import net.sf.l2j.gameserver.model.actor.instance.Player;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
    +import net.sf.l2j.gameserver.model.zone.ZoneType;
    +import net.sf.l2j.gameserver.network.SystemMessageId;
    +import net.sf.l2j.gameserver.taskmanager.PvpFlagTaskManager;
    +
    +public class RandomZone extends ZoneType
    +{
    + L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1); // Noblesse Blessing.
    +
    + public RandomZone(int id)
    + {
    + super(id);
    + }
    +
    + @Override
    + protected void onEnter(Creature character)
    + {
    + if (character instanceof Player)
    + {
    + if (!character.isInsideZone(ZoneId.RANDOM_ZONE))
    + ((Player) character).sendPacket(SystemMessageId.ENTERED_COMBAT_ZONE);
    +
    + Player player = character.getActingPlayer();
    + PvpFlagTaskManager.getInstance().remove(player);
    +
    + noblesse.getEffects(player, player);
    + player.updatePvPFlag(1);
    + player.broadcastUserInfo();
    + }
    +
    + character.setInsideZone(ZoneId.RANDOM_ZONE, true);
    + }
    +
    + @Override
    + protected void onExit(Creature character)
    + {
    + character.setInsideZone(ZoneId.RANDOM_ZONE, false);
    +
    + if (character instanceof Player)
    + {
    + if (!character.isInsideZone(ZoneId.RANDOM_ZONE))
    + ((Player) character).sendPacket(SystemMessageId.LEFT_COMBAT_ZONE);
    +
    + Player player = character.getActingPlayer();
    + PvpFlagTaskManager.getInstance().remove(player);
    +
    + player.updatePvPFlag(0);
    + player.broadcastUserInfo();
    + }
    + }
    +
    + @Override
    + public void onDieInside(Creature character)
    + {
    + }
    +
    + @Override
    + public void onReviveInside(Creature character)
    + {
    + if (character instanceof Player)
    + {
    + final Player player = (Player) character;
    +
    + noblesse.getEffects(player, player);
    + player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
    + player.setCurrentCp(player.getMaxCp());
    + }
    + }
    +}
    \ No newline at end of file
    Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 0)
    +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 0)
    @@ -1,12 +1,14 @@
     package net.sf.l2j.gameserver.network.clientpackets;
     
     import net.sf.l2j.commons.concurrent.ThreadPool;
    +import net.sf.l2j.commons.random.Rnd;
     
     import net.sf.l2j.Config;
     import net.sf.l2j.gameserver.data.manager.CastleManager;
     import net.sf.l2j.gameserver.data.xml.MapRegionData;
     import net.sf.l2j.gameserver.data.xml.MapRegionData.TeleportType;
     import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
    +import net.sf.l2j.gameserver.instancemanager.ZoneRandom;
     import net.sf.l2j.gameserver.model.actor.instance.Player;
     import net.sf.l2j.gameserver.model.entity.ClanHall;
     import net.sf.l2j.gameserver.model.entity.ClanHall.ClanHallFunction;
    @@ -14,6 +16,7 @@
     import net.sf.l2j.gameserver.model.entity.Siege.SiegeSide;
     import net.sf.l2j.gameserver.model.location.Location;
     import net.sf.l2j.gameserver.model.pledge.Clan;
    +import net.sf.l2j.gameserver.model.zone.ZoneId;
     
     public final class RequestRestartPoint extends L2GameClientPacket
     {
    @@ -21,6 +24,8 @@
     
      protected int _requestType;
     
    + public int RANDOM_RANGE = 500;
    +
      @Override
      protected void readImpl()
      {
    @@ -130,6 +135,14 @@
     
      loc = JAIL_LOCATION;
      }
    + else if (player.isInsideZone(ZoneId.RANDOM_ZONE) && player.isDead())
    + {
    + Location location = ZoneRandom.getInstance().getRandomZone();
    +
    + player.doRevive();
    + player.teleToLocation(location.getX() + Rnd.get(-RANDOM_RANGE,RANDOM_RANGE), location.getY() + Rnd.get(-RANDOM_RANGE,RANDOM_RANGE), location.getZ(), 20);
    + return;
    + }
      // Nothing has been found, use regular "To town" behavior.
      else
      loc = MapRegionData.getInstance().getLocationToTeleport(player, TeleportType.TOWN);
    Index: java/net/sf/l2j/gameserver/model/zone/ZoneId.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/zone/ZoneId.java (revision 6)
    +++ java/net/sf/l2j/gameserver/model/zone/ZoneId.java (working copy)
    @@ -21,7 +21,8 @@
      CAST_ON_ARTIFACT(16),
      NO_RESTART(17),
      SCRIPT(18),
    - BOSS(19);
    + BOSS(19),
    + RANDOM_ZONE(20);
     
      private final int _id;
     

    Datapack:


    Código: [Seleccionar]
    <?xml version="1.0" encoding="UTF-8"?>
    <list>
    <zone type="RandomZone" shape="NPoly" minZ="-4290" maxZ="-1290"> <!-- 20_17 -->
    <node X="10408" Y="-27395" />
    <node X="12065" Y="-25334" />
    <node X="15834" Y="-19850" />
    <node X="8791" Y="-10223" />
    <node X="3487" Y="-12137" />
    <node X="4110" Y="-34245" />
    </zone>
    <zone type="RandomZone" shape="NPoly" minZ="-1560" maxZ="-1560"> <!-- 23_21 -->
    <node X="98304" Y="98560" />
    <node X="131056" Y="98560" />
    <node X="130032" Y="131056" />
    <node X="98304" Y="131056" />
    <spawn X="106024" Y="114968" Z="-1560" />
    </zone>
    </list>

    NOTA: los map que sale en RandomZone.xml pertenecen a "Primeval Isle Wharf" / "Hardin's Academy"
    NOTA: En "SpawnLocation[] ZONES" deben colocar el spawn iniciar de sus zona.
    NOTA: Después de a ver hecho el paso de arriba crean su zona normal en el RandomZone.xml..
    « Última modificación: ſeptiembre 02, 2018, 06:32:44 pm por ¡Huesitos! »
    No me duelen los actos de la gente MALA, me duele la indiferencia de la gente BUENA.

    - Martin Luther King.

    Desconectado Kain

    • Grado D
    • *
    • Mensajes: 75
    • 00
    • Agradecimientos: 8
      • L2jbrasil
    • Cronica: : Interlude
    • Revision: L2jacis 350
    • S.O: otro
    • Serverpack : L2jacis
    Re:RandomZone, aCis
    « Respuesta #1 en: Enero 11, 2017, 07:03:22 pm »
    gracias
    Este post tiene 0 agradecimientos
  • Añade a tus favoritos
  • Nice work more could leave the default xml not to need to change in the core

    Desconectado TigVec

    • No Grade
    • *
    • Mensajes: 11
    • Agradecimientos: 2
    • Revision: 373
    • Serverpack : L2J aCis
    Re:RandomZone, aCis
    « Respuesta #2 en: Marzo 12, 2018, 04:38:50 pm »
    gracias
    Este post tiene 0 agradecimientos
  • Añade a tus favoritos
    Hola! Una pregunta, cuando una zona no esta en uso, deja de ser flag zone y vuelve a ser normal?