Spoiler
/*
* This program 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.
*
* This program 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 .
*/
package ai.RandomPvpZone;
import ai.AbstractNpcAI;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.zone.L2ZoneType;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.util.Rnd;
/**
* @author Ezequiel Adaptacion CaFi
*/
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(String name, String descr)
{
super(name, descr);
// agregamos las zonas
addEnterZoneId(zoneid1, zoneid2, zoneid3, zoneid4);
addExitZoneId(zoneid1, zoneid2, zoneid3, zoneid4);
time = System.currentTimeMillis();
zonechoose = zoneid1;
}
public String onEnterZone(L2PcInstance character, L2ZoneType zone)
{
if (zone.getId() == luckyzone())
{
character.sendPacket(SystemMessageId.ENTERED_COMBAT_ZONE);
character.broadcastUserInfo();
character.updatePvPFlag(1);
}
return super.onEnterZone(character, zone);
}
public String onExitZone(L2PcInstance character, L2ZoneType zone)
{
if (zone.getId() == luckyzone())
{
character.sendPacket(SystemMessageId.LEFT_COMBAT_ZONE);
character.broadcastUserInfo();
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(RandomPvpZone.class.getSimpleName(), "ai/RandomPvpZone");
}
}
--- /dev/null
+++ b/L2J_DataPack/dist/game/data/zones/randompvpzone.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
* This program 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.
*
* This program 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 .
*/
package ai.RandomPvpZone;
import ai.AbstractNpcAI;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.zone.L2ZoneType;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.util.Rnd;
/**
* @author Ezequiel Adaptacion CaFi
*/
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(String name, String descr)
{
super(name, descr);
// agregamos las zonas
addEnterZoneId(zoneid1, zoneid2, zoneid3, zoneid4);
addExitZoneId(zoneid1, zoneid2, zoneid3, zoneid4);
time = System.currentTimeMillis();
zonechoose = zoneid1;
}
public String onEnterZone(L2PcInstance character, L2ZoneType zone)
{
if (zone.getId() == luckyzone())
{
character.sendPacket(SystemMessageId.ENTERED_COMBAT_ZONE);
character.broadcastUserInfo();
character.updatePvPFlag(1);
}
return super.onEnterZone(character, zone);
}
public String onExitZone(L2PcInstance character, L2ZoneType zone)
{
if (zone.getId() == luckyzone())
{
character.sendPacket(SystemMessageId.LEFT_COMBAT_ZONE);
character.broadcastUserInfo();
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(RandomPvpZone.class.getSimpleName(), "ai/RandomPvpZone");
}
}
--- /dev/null
+++ b/L2J_DataPack/dist/game/data/zones/randompvpzone.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file