Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Evento Castle Wars Flags

Iniciado por Swarlog, Ago 06, 2022, 02:43 AM

Tema anterior - Siguiente tema

Swarlog


Poco he de decir de este evento, es simple.

Se crean dos bandos, uno ataca y otro defiende un castillo. El bando atacante ha de capturar las tres banderas situadas en el castillo, de no ser así el equipo defensor será el ganador. Creado por Boorinio para la crónica interlude.


Index: L2jHellasC/java/com/l2jhellas/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- L2jHellasC/java/com/l2jhellas/gameserver/handler/VoicedCommandHandler.java    (revision 192)
+++ L2jHellasC/java/com/l2jhellas/gameserver/handler/VoicedCommandHandler.java    (working copy)
@@ -22,6 +22,7 @@
 import com.l2jhellas.ExternalConfig;
 import com.l2jhellas.gameserver.handler.voicedcommandhandlers.Away;
 import com.l2jhellas.gameserver.handler.voicedcommandhandlers.Banking;
+import com.l2jhellas.gameserver.handler.voicedcommandhandlers.CastleWarsRegi;
 import com.l2jhellas.gameserver.handler.voicedcommandhandlers.ChaosCmd;
 import com.l2jhellas.gameserver.handler.voicedcommandhandlers.Cl;
 import com.l2jhellas.gameserver.handler.voicedcommandhandlers.MailCmd;
@@ -95,6 +96,7 @@
             registerVoicedCommandHandler(new ChaosCmd());
         registerVoicedCommandHandler(new Premium());
         registerVoicedCommandHandler(new QuizCmd());
+        registerVoicedCommandHandler(new CastleWarsRegi());
        
         _log.config("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers in total.");
     }
Index: L2jHellasC/java/com/l2jhellas/gameserver/handler/voicedcommandhandlers/CastleWarsRegi.java
===================================================================
--- L2jHellasC/java/com/l2jhellas/gameserver/handler/voicedcommandhandlers/CastleWarsRegi.java    (revision 0)
+++ L2jHellasC/java/com/l2jhellas/gameserver/handler/voicedcommandhandlers/CastleWarsRegi.java    (revision 0)
@@ -0,0 +1,95 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package com.l2jhellas.gameserver.handler.voicedcommandhandlers;
+
+import java.io.File;
+
+import com.l2jhellas.Config;
+import com.l2jhellas.gameserver.handler.IVoicedCommandHandler;
+import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jhellas.gameserver.model.entity.engines.CastleWars;
+import com.l2jhellas.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author Boorinio
+ */
+public class CastleWarsRegi implements IVoicedCommandHandler
+{
+    private static final String[] VOICED_COMMANDS =
+    {
+    "join", "leave"
+    };
+   
+    @Override
+public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+    {
+        if(CastleWars.CastleRegi)
+        {
+            if (command.startsWith(VOICED_COMMANDS[0])&& isEligible(activeChar))
+            {
+                activeChar.isinCastleWars =  true;
+                activeChar.sendMessage("You are now registered to CastleWars event!");
+                String CastleWars_Path = "data/html/CastleTutorial.htm";
+                File mainText = new File(Config.DATAPACK_ROOT, CastleWars_Path);
+                NpcHtmlMessage html = new NpcHtmlMessage(1);
+                html.setFile(CastleWars_Path);
+                activeChar.sendPacket(html);
+            }
+            if(command.startsWith(VOICED_COMMANDS[1])&&activeChar.isinCastleWars)
+            {
+                activeChar.isinCastleWars =  false;
+                activeChar.sendMessage("You are now unregistered.");
+            }
+        }
+        else
+        {
+            if (command.startsWith(VOICED_COMMANDS[0])||(command.startsWith(VOICED_COMMANDS[1])))
+                {
+                  activeChar.sendMessage("CastleWars registrations are inactive.");
+                }
+        }
+        return true;
+    }
+    public boolean isEligible(L2PcInstance player)
+    {
+        if(player.isinCastleWars)
+    {
+            player.sendMessage("You are already Registered");
+            return false;
+        }
+        if(player.getLevel()<76)
+        {
+            player.sendMessage("You are low level");
+            return false;
+        }
+        if(player.isInJail())
+        {
+            player.sendMessage("You are in jail...daah");
+            return false;
+        }
+        if(player.isInOlympiadMode())
+        {
+            player.sendMessage("You are in olympiad mode");
+            return false;
+        }
+        return true;
+    }
+   
+    @Override
+    public String[] getVoicedCommandList()
+    {
+        return VOICED_COMMANDS;
+    }
+}
\ No newline at end of file
Index: L2jHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2NpcInstance.java
===================================================================
--- L2jHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2NpcInstance.java    (revision 192)
+++ L2jHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2NpcInstance.java    (working copy)
@@ -64,6 +64,7 @@
 import com.l2jhellas.gameserver.model.entity.L2Event;
 import com.l2jhellas.gameserver.model.entity.Olympiad;
 import com.l2jhellas.gameserver.model.entity.engines.CTF;
+import com.l2jhellas.gameserver.model.entity.engines.CastleWars;
 import com.l2jhellas.gameserver.model.entity.engines.DM;
 import com.l2jhellas.gameserver.model.entity.engines.TvT;
 import com.l2jhellas.gameserver.model.entity.engines.VIP;
@@ -2248,6 +2249,15 @@
     {
         if (!super.doDie(killer))
             return false;
+                if (getNpcId() == 36006)
+                    {
+                        if(!CastleWars.isFinished)
+                        {
+                            CastleWars.flagskilled++;
+                            CastleWars.attackersWin();
+                        }
+                       
+                    }
        
         // normally this wouldn't really be needed, but for those few exceptions,
         // we do need to reset the weapons back to the initial templated weapon.
Index: L2jHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- L2jHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (revision 192)
+++ L2jHellasC/java/com/l2jhellas/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
@@ -142,6 +142,7 @@
 import com.l2jhellas.gameserver.model.entity.Olympiad;
 import com.l2jhellas.gameserver.model.entity.Siege;
 import com.l2jhellas.gameserver.model.entity.engines.CTF;
+import com.l2jhellas.gameserver.model.entity.engines.CastleWars;
 import com.l2jhellas.gameserver.model.entity.engines.DM;
 import com.l2jhellas.gameserver.model.entity.engines.TvT;
 import com.l2jhellas.gameserver.model.entity.engines.VIP;
@@ -230,7 +231,9 @@
     // Chaos Event.
     public int _chaosKills;
     public boolean _inChaosEvent = false;
-
+    public boolean isinCastleWars=false;
+    public boolean isAttacker=false;
+    public boolean isDefender=false;
     // Character Skills
     private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
     private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=?";
@@ -5076,6 +5079,12 @@
                 RankPvpSystem cps = new RankPvpSystem(killer, this);
                 cps.doPvp();
             }
+                        if (CastleWars.isRunning && (isinCastleWars && pk.isinCastleWars))
+                            {
+                                sendMessage("You will be revived in your spot");
+                               
+                            }
+                
             if (pk != null && pk._inEventTvT && _inEventTvT)
             {
                 if (TvT._teleport || TvT._started)
@@ -11023,7 +11032,21 @@
         sendPacket(new EtcStatusUpdate(this));
         _reviveRequested = 0;
         _revivePower = 0;
+                if (CastleWars.isRunning)
+                    {
+                    if (isAttacker)
+                        {
+                           
+                            teleToLocation(CastleWars.attackersx, CastleWars.attackersy, CastleWars.attackersz);
+                        }
+                        if (isDefender)
+                        {
+                           
+                            teleToLocation(CastleWars.defendersx, CastleWars.defendersy, CastleWars.defendersz);
+                        }
+                    }
 
+       
         if (isInParty() && getParty().isInDimensionalRift())
         {
             if (!DimensionalRiftManager.getInstance().checkIfInPeaceZone(getX(), getY(), getZ()))
Index: L2jHellasC/java/com/l2jhellas/gameserver/model/entity/engines/CastleWars.java
===================================================================
--- L2jHellasC/java/com/l2jhellas/gameserver/model/entity/engines/CastleWars.java    (revision 0)
+++ L2jHellasC/java/com/l2jhellas/gameserver/model/entity/engines/CastleWars.java    (revision 0)
@@ -0,0 +1,261 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+/**
+ * @author Boorinio
+ */
+package com.l2jhellas.gameserver.model.entity.engines;
+
+import java.util.List;
+
+import com.l2jhellas.gameserver.Announcements;
+import com.l2jhellas.gameserver.datatables.DoorTable;
+import com.l2jhellas.gameserver.datatables.NpcTable;
+import com.l2jhellas.gameserver.model.L2Spawn;
+import com.l2jhellas.gameserver.model.L2World;
+import com.l2jhellas.gameserver.model.actor.instance.L2NpcInstance;
+import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jhellas.gameserver.templates.L2NpcTemplate;
+
+import javolution.util.FastList;
+import javolution.util.FastSet;
+
+public class CastleWars
+{
+    private static List<L2PcInstance> _defenders = new FastList<L2PcInstance>();
+    private static List<L2PcInstance> _attackers = new FastList<L2PcInstance>();
+    private static FastSet<L2NpcInstance> _flags = new FastSet<L2NpcInstance>();
+    public static boolean isFinished;
+    public static boolean CastleRegi;
+    public static boolean isRunning;
+    private static boolean alaksokolies = false;
+    private static int i;
+    public static int flagskilled = 0;
+    public static int defendersx = 77566;
+    public static int defendersy = -152128;
+    public static int defendersz = -545;
+    public static int attackersx = 84303;
+    public static int attackersy = -140727;
+    public static int attackersz = -1568;
+    public static int[] flagslocx =
+    {
+    77545, 76663, 78446,
+    };
+    private static int[] flagslocy =
+    {
+    -149937, -154522, -154524,
+    };
+    private static int[] flagslocz =
+    {
+    345, 128, 235,
+    };
+   
+    public static void openRegi()
+    {
+        Announcements.getInstance().announceToAll("Castle Wars Event has Started!");
+        Announcements.getInstance().announceToAll("Type .join to enter or .leave to leave!");
+        Announcements.getInstance().announceToAll("You have 5 minutes to register!");
+        isRunning = true;
+        isFinished = false;
+        CastleRegi = true;
+        waitSecs(300);
+        stopRegi();
+        preparecastle();
+        shufflePlayers();
+        teleportThem();
+        Announcements.getInstance().announceToAll("You have 10 minutes till the event is finished!");
+        waitSecs(600);
+        if (!isFinished)
+        {
+            defendersWin();
+           
+        }
+       
+    }
+   
+    public static void preparecastle()
+    {
+        DoorTable.getInstance().getDoor(22130001).openMe();
+        DoorTable.getInstance().getDoor(22130002).openMe();
+        DoorTable.getInstance().getDoor(22130003).openMe();
+        DoorTable.getInstance().getDoor(22130004).openMe();
+        DoorTable.getInstance().getDoor(22130005).openMe();
+        DoorTable.getInstance().getDoor(22130010).openMe();
+        DoorTable.getInstance().getDoor(22130007).openMe();
+        DoorTable.getInstance().getDoor(22130011).openMe();
+        DoorTable.getInstance().getDoor(22130009).openMe();
+        DoorTable.getInstance().getDoor(22130008).openMe();
+        DoorTable.getInstance().getDoor(22130010).openMe();
+        DoorTable.getInstance().getDoor(22130006).openMe();
+        L2NpcInstance flags = null;
+        for (i = 0; i < 3; i++)
+        {
+            flags = addSpawn(36006, flagslocx[i], flagslocy[i], flagslocz[i]);
+            _flags.add(flags);
+        }
+    }
+   
+    public static void cleanevent()
+    {
+        for (L2PcInstance defender : _defenders)
+        {
+            defender.getAppearance().setNameColor(0xFFFFFF);
+            defender.setTitle("");
+            defender.broadcastUserInfo();
+            defender.teleToLocation(82724, 148307, -3469);
+            defender.isinCastleWars = false;
+            defender.isDefender=false;
+        }
+        for (L2PcInstance attacker : _attackers)
+        {
+            attacker.getAppearance().setNameColor(0xFFFFFF);
+            attacker.setTitle("");
+            attacker.broadcastUserInfo();
+            attacker.teleToLocation(82724, 148307, -3469);
+            attacker.isinCastleWars = false;
+            attacker.isAttacker=false;
+        }
+        for (L2NpcInstance flags : _flags)
+        {
+            flags.deleteMe();
+           
+        }
+        flagskilled = 0;
+        _flags.clear();
+        _defenders.clear();
+        _attackers.clear();
+        DoorTable.getInstance().getDoor(22130001).closeMe();
+        DoorTable.getInstance().getDoor(22130002).closeMe();
+        DoorTable.getInstance().getDoor(22130003).closeMe();
+        DoorTable.getInstance().getDoor(22130004).closeMe();
+        DoorTable.getInstance().getDoor(22130005).closeMe();
+        DoorTable.getInstance().getDoor(22130010).closeMe();
+        DoorTable.getInstance().getDoor(22130007).closeMe();
+        DoorTable.getInstance().getDoor(22130011).closeMe();
+        DoorTable.getInstance().getDoor(22130009).closeMe();
+        DoorTable.getInstance().getDoor(22130008).closeMe();
+        DoorTable.getInstance().getDoor(22130010).closeMe();
+        DoorTable.getInstance().getDoor(22130006).closeMe();
+    }
+   
+    public static void defendersWin()
+    {
+        Announcements.getInstance().announceToAll("Defenders Won the event they protected the flags!");
+        for (L2PcInstance defender : _defenders)
+        {
+            defender.sendMessage("Congratulations! Here is a reward for your effort!");
+            defender.addItem("Reward", 3470, 1, defender, true);
+        }
+        isFinished = true;
+        cleanevent();
+    }
+   
+    public static void attackersWin()
+    {
+        if (flagskilled == 3)
+        {
+            Announcements.getInstance().announceToAll("Attackers Won the event they killed all the flags!");
+            for (L2PcInstance attacker : _attackers)
+            {
+                attacker.sendMessage("Congratulations! Here is a reward for your effort!");
+                attacker.addItem("Reward", 3470, 1, attacker, true);
+            }
+            isFinished = true;
+            cleanevent();
+        }
+    }
+   
+    public static void teleportThem()
+    {
+        for (L2PcInstance defender : _defenders)
+        {
+            defender.teleToLocation(defendersx, defendersy, defendersz);
+        }
+        for (L2PcInstance attacker : _attackers)
+        {
+            attacker.teleToLocation(attackersx, attackersy, attackersz);
+        }
+    }
+   
+    public static void stopRegi()
+    {
+        Announcements.getInstance().announceToAll("Registrations are now over!");
+        CastleRegi = false;
+    }
+   
+    public static void shufflePlayers()
+    {
+        for (L2PcInstance player : L2World.getInstance().getAllPlayers())
+        {
+            if (player.isinCastleWars)
+            {
+                if (alaksokolies)
+                {
+                    _defenders.add(player);
+                    player.getAppearance().setNameColor(0xFF0000);
+                    player.setTitle("Defender");
+                    player.broadcastUserInfo();
+                    player.isDefender=true;
+                    alaksokolies = false;
+                }
+                else
+                {
+                    _attackers.add(player);
+                    player.getAppearance().setNameColor(0x0000FF);
+                    player.setTitle("Attacker");
+                    player.broadcastUserInfo();
+                    player.isAttacker=true;
+                    alaksokolies = true;
+                }
+            }
+        }
+    }
+   
+    public static void waitSecs(int i)
+    {
+        try
+        {
+            Thread.sleep(i * 1000);
+        }
+        catch (InterruptedException ie)
+        {
+            ie.printStackTrace();
+        }
+    }
+   
+    private static L2NpcInstance addSpawn(int npcId, int x, int y, int z)
+    {
+        L2NpcInstance result = null;
+        try
+        {
+            L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
+            if (template != null)
+            {
+                L2Spawn spawn = new L2Spawn(template);
+                spawn.setInstanceId(0);
+                spawn.setHeading(1);
+                spawn.setLocx(x);
+                spawn.setLocy(y);
+                spawn.setLocz(z);
+                spawn.stopRespawn();
+                result = spawn.spawnOne();
+                return result;
+            }
+        }
+        catch (Exception e1)
+        {
+        }
+        return null;
+    }
+}
\ No newline at end of file
Index: L2JHellasD/data/html/CastleTutorial.htm
===================================================================
--- L2JHellasD/data/html/CastleTutorial.htm    (revision 0)
+++ L2JHellasD/data/html/CastleTutorial.htm    (revision 0)
@@ -0,0 +1,14 @@
+<html><title>CastleWars Tutorial</title><body>Jail:<br>
+Once the Event starts:<br>
+-If you are a defender:<br>
+You need to defend all of the castle's flags<br>
+2 in the artifact's rooms<br>
+1 on the roof top<br>
+If you succeed for 10 minutes you win the event<br>
+<br>
+-If you are an attacker:
+You need to kill all the flags in the castle<br>
+2 in the artifact's rooms<br>
+1 on the roof top<br>
+If you kill all 3 flags the event ends!<br>
+</body></html>
\ No newline at end of file
Index: L2JHellasD/sql/game/npc.sql
===================================================================
--- L2JHellasD/sql/game/npc.sql    (revision 189)
+++ L2JHellasD/sql/game/npc.sql    (working copy)
@@ -6608,7 +6608,8 @@
     (36002,29022,'Zaken',0,'',0,'Monster.zaken',16.00,32.00,60,'male','L2GrandBoss',40,858518,1975,799.68,2.45,60,57,73,76,70,80,4879745,423589,7273,2951,19762,1197,333,0,3819,0,0,0,68,275,NULL,0,1,12,'FULL_PARTY'),
     (36003,29019,'Antharas',0,'',0,'Monster.antaras',300.00,300.00,79,'male','L2GrandBoss',40,13090000,22197,2380.00,265.32,60,57,73,76,70,80,262720918,29116376,13308,8064,28099,1641,333,0,3819,0,0,0,81,301,NULL,0,0,13,'FULL_PARTY'),
     (36004,29028,'Valakas',0,'',0,'Monster2.valakas',190.00,335.00,85,'male','L2GrandBoss',40,16660000,22197,2856.00,265.32,60,57,73,76,70,80,284286178,27215401,14375,7999,36620,1999,333,0,3819,0,0,0,194,486,'valakas_clan',300,0,13,'FULL_PARTY'),
-    (36005,29001,'Queen Ant',0,'',0,'Monster.queen_ant',45.00,53.00,40,'female','L2GrandBoss',40,229898,667,495.04,2.14,60,57,73,76,70,80,2179535,140740,329,1615,77,655,278,0,3819,0,0,0,129,372,'queen_ant_clan',1000,0,0,'LAST_HIT');
+    (36005,29001,'Queen Ant',0,'',0,'Monster.queen_ant',45.00,53.00,40,'female','L2GrandBoss',40,229898,667,495.04,2.14,60,57,73,76,70,80,2179535,140740,329,1615,77,655,278,0,3819,0,0,0,129,372,'queen_ant_clan',1000,0,0,'LAST_HIT'),
+    (36006,35062,'CaptureFlag',0,'',0,'Deco.flag_a',21.00,82.00,1,'etc','L2Monster',80,700000,989,3.16,0.91,40,43,30,21,20,10,0,0,652,753,358,295,423,0,333,0,0,0,55,132,NULL,0,1,0,'LAST_HIT');
    
     -- DO Check in this nightwolf
 UPDATE `npc` SET `type` = 'L2NpcWalker' WHERE `id` IN (31358,31359,31360,31361,31362,31363,31357,31356,31364,31365,32070,32072);