Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Intancias PvP Aleatorias

Iniciado por Swarlog, Ago 03, 2025, 01:06 AM

Tema anterior - Siguiente tema

Swarlog

Comparto este codigo son 4 zonas pvps (se pueden agregar mas o quitar) que rotan automaticamente cada x tiempo (se configura el tiempo). Tiene autoflag. Si quieren pueden agregar mas cosas o pedirmelas que las implemento en el codigo como autonobles, respawn aleatorio, gatekeepers, etc.

DATAPACK

--- /dev/null
+++ b/L2J_DataPack/dist/game/data/scripts/custom/randompvpzone/RandomPvpZone.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2004-2015 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package custom.randompvpzone;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.zone.L2ZoneType;
+import com.l2jserver.util.Rnd;
+
+/**
+ * @author Ezequiel
+ */
+public class RandomPvpZone extends AbstractNpcAI
+{
+	// zonas id
+	private final int zoneid1 = 100000;
+	private final int zoneid2 = 100001;
+	private final int zoneid3 = 100002;
+	private final int zoneid4 = 100003;
+	
+	// tiempo de cada zone 30 min
+	private final int tiempocadazona = 1800000;
+	private int zonechoose;
+	private long time;
+	
+	public RandomPvpZone()
+	{
+		super(RandomPvpZone.class.getSimpleName(), "custom");
+		
+		// agregamos las zonas
+		addEnterZoneId(zoneid1, zoneid2, zoneid3, zoneid4);
+		addExitZoneId(zoneid1, zoneid2, zoneid3, zoneid4);
+		
+		time = System.currentTimeMillis();
+		
+		zonechoose = zoneid1;
+	}
+	
+	@Override
+	public String onEnterZone(L2Character character, L2ZoneType zone)
+	{
+		
+		if (zone.getId() == luckyzone())
+		{
+			character.sendMessage("Estas en una zona pvp");
+			character.updatePvPFlag(1);
+			
+		}
+		
+		return super.onEnterZone(character, zone);
+	}
+	
+	@Override
+	public String onExitZone(L2Character character, L2ZoneType zone)
+	{
+		if (zone.getId() == luckyzone())
+		{
+			character.sendMessage("Has salido de la zona Pvp");
+			character.updatePvPFlag(0);
+		}
+		
+		return super.onExitZone(character, zone);
+		
+	}
+	
+	private int luckyzone()
+	{
+		if (System.currentTimeMillis() > (time + tiempocadazona))
+		{
+			// elije una zona random
+			zonechoose = Rnd.get(zoneid1, zoneid4);
+			time = System.currentTimeMillis();
+		}
+		return zonechoose;
+	}
+	
+	public static void main(String[] args)
+	{
+		new RandomPvpZone();
+	}
+}
\ No newline at end of file


en el xml donde dice "editar" deben agregar las coordenadas de cada zona pvp y su radio.

--- /dev/null
+++ b/L2J_DataPack/dist/game/data/zones/randompvpzone.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/zones.xsd">
+	<!-- Custom Script Zones -->
+	<zone name="RandomPvpZone1" id="100000" type="ScriptZone" shape="Cylinder" minZ="editar" maxZ="editar" rad="editar">
+		<node X="editar" Y="editar" />
+	</zone>
+	<zone name="RandomPvpZone2" id="100001" type="ScriptZone" shape="Cylinder" minZ="editar" maxZ="editar" rad="editar">
+		<node X="editar" Y="editar" />
+	</zone>
+	<zone name="RandomPvpZone3" id="100002" type="ScriptZone" shape="Cylinder" minZ="editar" maxZ="editar" rad="editar">
+		<node X="editar" Y="editar" />
+	</zone>
+	<zone name="RandomPvpZone4" id="100003" type="ScriptZone" shape="Cylinder" minZ="editar" maxZ="editar" rad="editar">
+		<node X="editar" Y="editar" />
+	</zone>
+</list>
\ No newline at end of file

Creditos: execanciani