From 650669f7415cc447c5f53c9832434ea2831a3088 Mon Sep 17 00:00:00 2001
From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com>
Date: Wed, 28 Dec 2016 17:36:40 +0000
Subject: [PATCH] Gainak Siege. Contributed by gigilo1968.
---
.../dist/game/config/PVP.ini | 11 +-
.../mapregion/{gainak.xml => gainak_town.xml} | 4 +-
.../areas/GainakUnderground/GainakSiege.java | 184 ++++++++++++++++++
.../dist/game/data/zones/custom_script.xml | 19 ++
.../dist/game/data/zones/peace.xml | 23 ++-
.../java/com/l2jmobius/Config.java | 2 +
6 files changed, 239 insertions(+), 4 deletions(-)
rename L2J_Mobius_Underground/dist/game/data/mapregion/{gainak.xml => gainak_town.xml} (87%)
create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/GainakUnderground/GainakSiege.java
diff --git a/L2J_Mobius_Underground/dist/game/config/PVP.ini b/L2J_Mobius_Underground/dist/game/config/PVP.ini
index ed15ab8097..962b639e25 100644
--- a/L2J_Mobius_Underground/dist/game/config/PVP.ini
+++ b/L2J_Mobius_Underground/dist/game/config/PVP.ini
@@ -72,4 +72,13 @@ MaxReputation = 500
# Reputation increase for kill one PK
# Default: 100
-ReputationIncrease = 100
\ No newline at end of file
+ReputationIncrease = 100
+
+
+# ---------------------------------------------------------------------------
+# Gainak Siege
+# ---------------------------------------------------------------------------
+
+# Announce Gainak siege in all chat
+# Default: false
+AnnounceGainakSiege = false
diff --git a/L2J_Mobius_Underground/dist/game/data/mapregion/gainak.xml b/L2J_Mobius_Underground/dist/game/data/mapregion/gainak_town.xml
similarity index 87%
rename from L2J_Mobius_Underground/dist/game/data/mapregion/gainak.xml
rename to L2J_Mobius_Underground/dist/game/data/mapregion/gainak_town.xml
index 74064c8972..f338f2862e 100644
--- a/L2J_Mobius_Underground/dist/game/data/mapregion/gainak.xml
+++ b/L2J_Mobius_Underground/dist/game/data/mapregion/gainak_town.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/GainakUnderground/GainakSiege.java b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/GainakUnderground/GainakSiege.java
new file mode 100644
index 0000000000..c767185165
--- /dev/null
+++ b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/GainakUnderground/GainakSiege.java
@@ -0,0 +1,184 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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.areas.GainakUnderground;
+
+import com.l2jmobius.Config;
+import com.l2jmobius.gameserver.ThreadPoolManager;
+import com.l2jmobius.gameserver.instancemanager.ZoneManager;
+import com.l2jmobius.gameserver.model.Location;
+import com.l2jmobius.gameserver.model.actor.L2Character;
+import com.l2jmobius.gameserver.model.actor.L2Npc;
+import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jmobius.gameserver.model.events.EventType;
+import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
+import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
+import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
+import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureDeath;
+import com.l2jmobius.gameserver.model.zone.L2ZoneType;
+import com.l2jmobius.gameserver.model.zone.type.L2PeaceZone;
+import com.l2jmobius.gameserver.model.zone.type.L2SiegeZone;
+import com.l2jmobius.gameserver.network.NpcStringId;
+import com.l2jmobius.gameserver.network.SystemMessageId;
+import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
+import com.l2jmobius.gameserver.network.serverpackets.OnEventTrigger;
+import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
+import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
+import com.l2jmobius.gameserver.util.Broadcast;
+
+import ai.AbstractNpcAI;
+
+/**
+ * @author LasTravel, Gigi
+ * @URL http://l2wiki.com/Gainak
+ */
+public final class GainakSiege extends AbstractNpcAI
+{
+ private static final int SIEGE_EFFECT = 20140700;
+ private static final int SIEGE_DURATION = 30;
+ private static final L2PeaceZone GAINAK_PEACE_ZONE = ZoneManager.getInstance().getZoneById(60018, L2PeaceZone.class);
+ private static final L2SiegeZone GAINAK_SIEGE_ZONE = ZoneManager.getInstance().getZoneById(60019, L2SiegeZone.class);
+ private static final L2PeaceZone GAINAK_TOWN_ZONE = ZoneManager.getInstance().getZoneById(60020, L2PeaceZone.class);
+ protected static final int[] ASSASSIN_IDS =
+ {
+ 19471,
+ 19472,
+ 19473
+ };
+ private static final Location[] ASSASSIN_SPAWNS =
+ {
+ new Location(17085, -115385, -249, 41366),
+ new Location(15452, -114531, -243, 5464),
+ new Location(15862, -113121, -250, 53269)
+ };
+ private boolean _isInSiege = false;
+
+ public GainakSiege()
+ {
+ addEnterZoneId(GAINAK_SIEGE_ZONE.getId(), GAINAK_TOWN_ZONE.getId());
+ addKillId(ASSASSIN_IDS);
+ addSpawnId(ASSASSIN_IDS);
+ startQuestTimer("GAINAK_WAR", getTimeBetweenSieges() * 60000, null, null);
+ }
+
+ private final int getTimeBetweenSieges()
+ {
+ return getRandom(120, 180); // 2 to 3 hours.
+ }
+
+ @Override
+ public final String onEnterZone(L2Character character, L2ZoneType zone)
+ {
+ if (_isInSiege && character.isPlayer())
+ {
+ character.broadcastPacket(new OnEventTrigger(SIEGE_EFFECT, true));
+ }
+ return super.onEnterZone(character, zone);
+ }
+
+ @Override
+ public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+ {
+ if (event.equalsIgnoreCase("GAINAK_WAR"))
+ {
+ if (_isInSiege)
+ {
+ _isInSiege = false;
+ GAINAK_PEACE_ZONE.setEnabled(true);
+ GAINAK_SIEGE_ZONE.setIsActive(false);
+ GAINAK_SIEGE_ZONE.updateZoneStatusForCharactersInside();
+ GAINAK_TOWN_ZONE.broadcastPacket(new OnEventTrigger(SIEGE_EFFECT, false));
+ GAINAK_TOWN_ZONE.broadcastPacket(new ExShowScreenMessage(NpcStringId.GAINAK_IN_PEACE, ExShowScreenMessage.TOP_CENTER, 5000, true));
+ startQuestTimer("GAINAK_WAR", getTimeBetweenSieges() * 60000, null, null);
+ if (Config.ANNOUNCE_GAINAK_SIEGE)
+ {
+ SystemMessage s = SystemMessage.getSystemMessage(SystemMessageId.PROGRESS_EVENT_STAGE_S1);
+ s.addString("Gainak is now in peace.");
+ Broadcast.toAllOnlinePlayers(s);
+ }
+ }
+ else
+ {
+ for (Location loc : ASSASSIN_SPAWNS)
+ {
+ addSpawn(ASSASSIN_IDS[getRandom(ASSASSIN_IDS.length)], loc, true, 1800000);
+ }
+ _isInSiege = true;
+ GAINAK_PEACE_ZONE.setEnabled(false);
+ GAINAK_SIEGE_ZONE.setIsActive(true);
+ GAINAK_SIEGE_ZONE.updateZoneStatusForCharactersInside();
+ GAINAK_TOWN_ZONE.broadcastPacket(new OnEventTrigger(SIEGE_EFFECT, true));
+ GAINAK_TOWN_ZONE.broadcastPacket(new ExShowScreenMessage(NpcStringId.GAINAK_IN_WAR, ExShowScreenMessage.TOP_CENTER, 5000, true));
+ startQuestTimer("GAINAK_WAR", SIEGE_DURATION * 60000, null, null);
+ if (Config.ANNOUNCE_GAINAK_SIEGE)
+ {
+ SystemMessage s = SystemMessage.getSystemMessage(SystemMessageId.PROGRESS_EVENT_STAGE_S1);
+ s.addString("Gainak is now under siege.");
+ Broadcast.toAllOnlinePlayers(s);
+ }
+ ZoneManager.getInstance().getZoneById(GAINAK_TOWN_ZONE.getId(), L2PeaceZone.class).setEnabled(false);
+ }
+ }
+ return super.onAdvEvent(event, npc, player);
+ }
+
+ @Override
+ public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
+ {
+ final L2SiegeZone zone = ZoneManager.getInstance().getZone(npc, L2SiegeZone.class);
+ if ((zone != null) && (zone.getId() == 60019) && zone.isActive())
+ {
+ ThreadPoolManager.getInstance().scheduleAi(new RespawnNewAssassin(npc.getLocation()), 60000);
+ }
+ return super.onKill(npc, killer, isSummon);
+ }
+
+ private class RespawnNewAssassin implements Runnable
+ {
+ private final Location _loc;
+
+ public RespawnNewAssassin(Location loc)
+ {
+ _loc = loc;
+ }
+
+ @Override
+ public void run()
+ {
+ addSpawn(ASSASSIN_IDS[getRandom(ASSASSIN_IDS.length)], _loc, true, 1800000);
+ }
+ }
+
+ @RegisterEvent(EventType.ON_CREATURE_DEATH)
+ @RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
+ public void onPlayerDeath(OnCreatureDeath event)
+ {
+ if (_isInSiege && GAINAK_SIEGE_ZONE.getCharactersInside().contains(event.getTarget()))
+ {
+ if (event.getAttacker().isPlayer() && event.getTarget().isPlayer())
+ {
+ final L2PcInstance attackerPlayer = event.getAttacker().getActingPlayer();
+ attackerPlayer.setPvpKills(attackerPlayer.getPvpKills() + 1);
+ attackerPlayer.sendPacket(new UserInfo(attackerPlayer));
+ }
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ new GainakSiege();
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Underground/dist/game/data/zones/custom_script.xml b/L2J_Mobius_Underground/dist/game/data/zones/custom_script.xml
index b708797908..683ee92fde 100644
--- a/L2J_Mobius_Underground/dist/game/data/zones/custom_script.xml
+++ b/L2J_Mobius_Underground/dist/game/data/zones/custom_script.xml
@@ -734,4 +734,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L2J_Mobius_Underground/dist/game/data/zones/peace.xml b/L2J_Mobius_Underground/dist/game/data/zones/peace.xml
index 31890edd11..400727530d 100644
--- a/L2J_Mobius_Underground/dist/game/data/zones/peace.xml
+++ b/L2J_Mobius_Underground/dist/game/data/zones/peace.xml
@@ -714,5 +714,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L2J_Mobius_Underground/java/com/l2jmobius/Config.java b/L2J_Mobius_Underground/java/com/l2jmobius/Config.java
index a3ec200ca5..b68253fadd 100644
--- a/L2J_Mobius_Underground/java/com/l2jmobius/Config.java
+++ b/L2J_Mobius_Underground/java/com/l2jmobius/Config.java
@@ -768,6 +768,7 @@ public final class Config
public static boolean ANTIFEED_DUALBOX;
public static boolean ANTIFEED_DISCONNECTED_AS_DUALBOX;
public static int ANTIFEED_INTERVAL;
+ public static boolean ANNOUNCE_GAINAK_SIEGE;
// --------------------------------------------------
// Rate Settings
@@ -2268,6 +2269,7 @@ public final class Config
PVP_PVP_TIME = PVPSettings.getInt("PvPVsPvPTime", 60000);
MAX_REPUTATION = PVPSettings.getInt("MaxReputation", 500);
REPUTATION_INCREASE = PVPSettings.getInt("ReputationIncrease", 100);
+ ANNOUNCE_GAINAK_SIEGE = PVPSettings.getBoolean("AnnounceGainakSiege", false);
// Load Olympiad L2Properties file (if exists)
final PropertiesParser Olympiad = new PropertiesParser(OLYMPIAD_CONFIG_FILE);