Noticias:

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

Menú Principal

Evento Zombie

Iniciado por Swarlog, Ago 06, 2022, 01:57 AM

Tema anterior - Siguiente tema

Swarlog

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



    Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
    ===================================================================
    --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java        (revision 5667)
    +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java        (working copy)
     @@ -302,6 +313,96 @@
      */
     public final class L2PcInstance extends L2Playable
     {
    +     
    +       public boolean _zombie = false;
    +       public void setZombie(boolean t)
    +       {
    +               _zombie = t;
    +       }
    +     
    +       public boolean isZombie()
    +       {
    +               return _zombie;
    +       }
    @@ -394,8 +494,19 @@
                    @Override
                    public void doAttack(L2Character target)
                    {
    +                       Zombie z = new Zombie();
                            super.doAttack(target);
    -                     
    +                       if (isZombie())
    +                       {
    +                             
    +                               L2PcInstance targeto = target.getActingPlayer();
    +                               z.infect(targeto);
    +                             
    +                               if (Zombie._notinfected.size() == 0)
    +                               {
    +                                       z.end();
    +                               }
    +                       }
                            // cancel the recent fake-death protection instantly if the player attacks or casts spells
                            getPlayer().setRecentFakeDeath(false);
                    }
    @@ -5389,6 +5576,15 @@
            @Override
            public synchronized void untransform()
            {
    +               if (isZombie())
    +               {
    +                       sendMessage("Fuck you noob cheater");
    +                       return;
    +               }
                    if (_transformation != null)
                    {
                            if (!fireTransformListeners(_transformation, false))
    \ No newline at end of file
    Index: java/com/l2jserver/gameserver/model/entity/Zombie.java
    ===================================================================
    --- java/com/l2jserver/gameserver/model/entity/Zombie.java      (revision 0)
    +++ java/com/l2jserver/gameserver/model/entity/Zombie.java      (revision 0)
    @@ -0,0 +1,298 @@
    +/* 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 2, 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, write to the Free Software
    + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    + * 02111-1307, USA.
    + *
    + * http://www.gnu.org/copyleft/gpl.html
    + */
    +package com.l2jserver.gameserver.model.entity;
    +
    +import javolution.util.FastList;
    +
    +import com.l2jserver.gameserver.Announcements;
    +import com.l2jserver.gameserver.ThreadPoolManager;
    +import com.l2jserver.gameserver.datatables.DoorTable;
    +import com.l2jserver.gameserver.datatables.NpcTable;
    +import com.l2jserver.gameserver.datatables.SpawnTable;
    +import com.l2jserver.gameserver.instancemanager.TransformationManager;
    +import com.l2jserver.gameserver.model.L2Spawn;
    +import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
    +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
    +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
    +import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
    +import com.l2jserver.util.Rnd;
    +
    +/**
    + * @author Marwan
    + */
    +public class Zombie
    +{
    +       public L2PcInstance zombie = null;
    +       public static L2Spawn _npcSpawn;
    +       public static FastList<L2PcInstance> all = new FastList<L2PcInstance>();
    +       public static FastList<L2PcInstance> _infected = new FastList<L2PcInstance>();
    +       public static FastList<L2PcInstance> _notinfected = new FastList<L2PcInstance>();
    +       public int rounds = 3;
    +     
    +       public static enum State
    +       {
    +               INACTIVE,
    +               ACTIVE
    +       }
    +     
    +       public State state = State.INACTIVE;
    +     
    +       public class Start implements Runnable
    +       {
    +               @Override
    +               public void run()
    +               {
    +                       if (state == State.INACTIVE)
    +                       {
    +                               startEvent();
    +                       }
    +               }
    +       }
    +     
    +       public void startEvent()
    +       {
    +               state = State.ACTIVE;
    +               all.addAll(_notinfected);
    +               all.addAll(_infected);
    +               Announcements.getInstance().announceToAll("Zombie event registrations will end in 10 minute(s).");
    +               Announcements.getInstance().announceToAll("Registration npc in giran.");
    +               spawnEventNpc();
    +               waitSecs(10);
    +               Announcements.getInstance().announceToAll("Zombie event registrations will end in 5 minute(s).");
    +               waitSecs(10);
    +               Announcements.getInstance().announceToAll("Zombie event registrations will end in 1 minute(s).");
    +               waitSecs(10);
    +             
    +               if (_notinfected.size() >= 2)
    +               {
    +                       closeDoor(24190002);
    +                       closeDoor(24190003);
    +                       closeDoor(24190001);
    +                       closeDoor(24190004);
    +                       pickZombie();
    +                       for (L2PcInstance players : _notinfected)
    +                       {
    +                               players.sendMessage("Zombie is " + zombie.getName());
    +                               players.teleToLocation(150108, 46736, -3407);
    +                       }
    +                       zombie.sendMessage("Infect others by hitting them");
    +                       zombie.teleToLocation(148498, 46752, -3413);
    +                       for (int i = 2; i <= rounds; i++)
    +                       {
    +                               i++;
    +                               waitSecs(110);
    +                               nextRound(i);
    +                       }
    +                       end();
    +               }
    +               else
    +               {
    +                       Announcements.getInstance().announceToAll("Zombie event has been cancelled due to lack of participants");
    +                       state = State.INACTIVE;
    +               }
    +             
    +       }
    +     
    +       public void nextRound(int round)
    +       {
    +               for (L2PcInstance pl : _notinfected)
    +               {
    +                     
    +                       pl.teleToLocation(147771, 46712, -3411);
    +                       ExShowScreenMessage message1 = new ExShowScreenMessage("Round " + round + " will start in 30 seconds.", 8000);
    +                       pl.sendPacket(message1);
    +               }
    +               for (L2PcInstance pl : _infected)
    +               {
    +                       pl.teleToLocation(151248, 46721, -3406);
    +                       ExShowScreenMessage message1 = new ExShowScreenMessage("Round " + round + " will start in 30 seconds.", 8000);
    +                       pl.sendPacket(message1);
    +               }
    +               waitSecs(30);
    +               for (L2PcInstance pl : _notinfected)
    +               {
    +                     
    +                       pl.teleToLocation(148515, 46660, -3413);
    +               }
    +               for (L2PcInstance pl : _infected)
    +               {
    +                       pl.teleToLocation(150400, 46764, -3413);
    +               }
    +       }
    +     
    +       private static void spawnEventNpc()
    +       {
    +               L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(70012);
    +             
    +               try
    +               {
    +                       _npcSpawn = new L2Spawn(tmpl);
    +                       _npcSpawn.setLocx(83450);
    +                       _npcSpawn.setLocy(148608);
    +                       _npcSpawn.setLocz(3405);
    +                       _npcSpawn.setAmount(1);
    +                       _npcSpawn.setHeading(1);
    +                       SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
    +                     
    +                       _npcSpawn.init();
    +                       _npcSpawn.getLastSpawn().setTitle("Zombie");
    +                       _npcSpawn.getLastSpawn().setName("Zombie Event");
    +               }
    +               catch (Exception e)
    +               {
    +               }
    +       }
    +     
    +       public void pickZombie()
    +       {
    +               zombie = _notinfected.get(Rnd.get(0, _notinfected.size() - 1));
    +               infect(zombie);
    +       }
    +     
    +       public void infect(L2PcInstance z)
    +       {
    +               _infected.add(z);
    +               _notinfected.remove(z);
    +               z.getAppearance().setTitleColor(255, 0, 0);
    +               z.setZombie(true);
    +               TransformationManager.getInstance().transformPlayer(303, z);
    +       }
    +     
    +       public void uninfectall()
    +       {
    +               for (L2PcInstance uninfect : _infected)
    +               {
    +                       uninfect.untransform();
    +                       uninfect.setZombie(false);
    +               }
    +       }
    +     
    +       public void end()
    +       {
    +                       openDoor(24190002);
    +                       openDoor(24190003);
    +                       openDoor(24190001);
    +                       openDoor(24190004);
    +                       uninfectall();
    +               rewardWinner();
    +               state = State.INACTIVE;
    +               for (L2PcInstance p : all)
    +               {
    +                       p.teleToLocation(83450, 148608, -3405);
    +               }
    +               if (_notinfected.size() >= 1)
    +               {
    +                       Announcements.getInstance().announceToAll("Zombie event has end");
    +                       Announcements.getInstance().announceToAll("Players won");
    +                       _notinfected.removeAll(_notinfected);
    +               }
    +               else
    +               {
    +                     
    +                       Announcements.getInstance().announceToAll("Zombie event has end");
    +                       Announcements.getInstance().announceToAll("Zombies won");
    +                       _infected.removeAll(_infected);
    +               }
    +             
    +       }
    +     
    +       public void register(L2PcInstance p)
    +       {
    +               _notinfected.add(p);
    +               p.sendMessage("You have succesfully registered");
    +       }
    +     
    +       public void unregister(L2PcInstance p)
    +       {
    +               _notinfected.remove(p);
    +               p.sendMessage("You have succesfully unregistered");
    +       }
    +     
    +       public void rewardWinner()
    +       {
    +               if (_notinfected.size() == 0)
    +               {
    +                       for (L2PcInstance n : _infected)
    +                       {
    +                               n.addItem("zombie", 57, 10000, n, false);
    +                       }
    +               }
    +               else
    +               {
    +                       for (L2PcInstance n : _notinfected)
    +                       {
    +                               n.addItem("zombie", 57, 10000, n, false);
    +                       }
    +               }
    +       }
    +     
    +       public void waitSecs(int i)
    +       {
    +               try
    +               {
    +                       Thread.sleep(i * 1000);
    +               }
    +               catch (InterruptedException ie)
    +               {
    +                       ie.printStackTrace();
    +               }
    +       }
    +     
    +       public void wait(int i)
    +       {
    +               try
    +               {
    +                       Thread.sleep(i * 60000);
    +               }
    +               catch (InterruptedException ie)
    +               {
    +                       ie.printStackTrace();
    +               }
    +       }
    +     
    +       private static void closeDoor(int i)
    +       {
    +             
    +               L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(i);
    +             
    +               if (doorInstance != null)
    +               {
    +                       doorInstance.closeMe();
    +               }
    +             
    +       }
    +     
    +       private static void openDoor(int i)
    +       {
    +               L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(i);
    +             
    +               if (doorInstance != null)
    +               {
    +                       doorInstance.openMe();
    +               }
    +       }
    +     
    +       public Zombie()
    +       {
    +               ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Start(), 60000, 6000);
    +             
    +       }
    +     
    +       public static Zombie getInstance()
    +       {
    +               return SingletonHolder._instance;
    +       }
    +     
    +       private static class SingletonHolder
    +       {
    +               protected static final Zombie _instance = new Zombie();
    +       }
    +}
    Index: java/com/l2jserver/gameserver/instancemanager/ZombieNpc.java
    ===================================================================
    --- java/com/l2jserver/gameserver/instancemanager/ZombieNpc.java        (revision 0)
    +++ java/com/l2jserver/gameserver/instancemanager/ZombieNpc.java        (revision 0)
    @@ -0,0 +1,131 @@
    +/*
    + * 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.l2jserver.gameserver.instancemanager;
    +
    +import com.l2jserver.Config;
    +import com.l2jserver.gameserver.model.actor.L2Npc;
    +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
    +import com.l2jserver.gameserver.model.entity.Zombie;
    +import com.l2jserver.gameserver.model.quest.Quest;
    +import com.l2jserver.gameserver.model.quest.QuestState;
    +
    +/**
    + * Zombie Npc
    + * @author Marwan
    + */
    +public final class ZombieNpc extends Quest
    +{
    +     
    +       private final int NpcId = 70012;
    +     
    +       private ZombieNpc(int questId, String name, String descr)
    +       {
    +             
    +               super(questId, name, descr);
    +               addStartNpc(NpcId);
    +               addTalkId(NpcId);
    +       }
    +     
    +       @Override
    +       public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
    +       {
    +               QuestState st = player.getQuestState("ZombieNpc");
    +               if (st == null)
    +               {
    +                       return "";
    +               }
    +               else if (event.equalsIgnoreCase("show"))
    +               {
    +                       StringBuilder sb = new StringBuilder();
    +                       sb.append("<html><title>TvT Event</title>");
    +                       sb.append("<body>");
    +                       // sb.append("<br><font color=\"0066FF\">Current Event: 1vs1 </font>");
    +                       sb.append("<br><br><font color=\"00ff4d\">Hello " + player.getName() + ".<br> Here you can register for Zombie Event <br><br></font>");
    +                       sb.append("<hr>");
    +                       sb.append("<br><br><br><br>");
    +                       sb.append("<center><img src=\"L2UI.SquareWhite\" width=300 height=1>");
    +                       sb.append("<table bgcolor=333333 width=100>");
    +                       sb.append("<tr>");
    +                       sb.append("<td width=100 ALIGN=\"LEFT\"><button value=\"Register\" action=\"bypass -h Quest ZombieNpc register\" width=100 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td>");
    +                       sb.append("<td width=100 ALIGN=\"RIGHT\"><button value=\"Unregister\" action=\"bypass -h Quest ZombieNpc unregister\" width=100 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td></tr>");
    +                       sb.append("<br><tr><td width=150 ALIGN=\"CENTER\"><button value=\"Registered Players\" action=\"bypass -h Quest ZombieNpc players\" width=150 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td></tr>");
    +                     
    +                       sb.append("</tr>");
    +                       sb.append("</table>");
    +                       sb.append("<br><br></center>");
    +                       return sb.toString();
    +               }
    +             
    +               else if (event.equalsIgnoreCase("register"))
    +               {
    +                     
    +                       StringBuilder sb = new StringBuilder();
    +                       if (Zombie._notinfected.contains(player))
    +                       {
    +                               sb.append("<html><title>Zombie Event</title><body>");
    +                               sb.append("You are already registered</body></html>");
    +                       }
    +                       else
    +                       {
    +                               sb.append("<html><title>Zombie Event</title><body>");
    +                               sb.append("Registration succesful</body></html>");
    +                               Zombie z = new Zombie();
    +                               z.register(player);
    +                             
    +                       }
    +                       return sb.toString();
    +                     
    +               }
    +               else if (event.equalsIgnoreCase("unregister"))
    +               {
    +                     
    +                       StringBuilder sb = new StringBuilder();
    +                       sb.append("<html><title>Zombie Event</title>");
    +                       sb.append("<body>You have succesfully unregistered</body></html>");
    +                       Zombie z = new Zombie();
    +                       z.unregister(player);
    +                       return sb.toString();
    +               }
    +               else if (event.equalsIgnoreCase("players"))
    +               {
    +                       StringBuilder sb = new StringBuilder();
    +                       String noobs = null;
    +                       sb.append("<html><title>Zombie Event</title><body><center>");
    +                       sb.append("<br><br><table width=300><tr><td>Name</td><td width=80>Level</td></tr><br></font>");
    +                       for (L2PcInstance pls : Zombie._notinfected)
    +                       {
    +                               noobs += "<tr><td><font color=\"009900\">" + pls.getName() + "</td><td>" + pls.getLevel() + "</font></td></tr>";
    +                       }
    +                       sb.append("<table>" + noobs + "</table></body></html>");
    +                       return sb.toString();
    +                     
    +               }
    +             
    +               return event;
    +       }
    +     
    +       @SuppressWarnings("synthetic-access")
    +       public static ZombieNpc getInstance()
    +       {
    +               return SingletonHolder._instance;
    +       }
    +     
    +       private static class SingletonHolder
    +       {
    +               @SuppressWarnings("synthetic-access")
    +               private static final ZombieNpc _instance = new ZombieNpc(-1, "ZombieNpc", "instances");
    +       }
    +     
    +}


CitarNPC: ID 70012 Type: L2Npc

<button value="Event" action="bypass -h Quest Zombie show" width=90 height=25

Para cambiar el nº de rondas: public int rounds = 3;