Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P HideAndSeek
- Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (revision 952)
- +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -27,6 +27,7 @@
- import com.l2jfrozen.gameserver.model.Inventory;
- import com.l2jfrozen.gameserver.model.L2Party;
- import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
- import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
- import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
- import com.l2jfrozen.gameserver.network.L2GameClient;
- @@ -85,6 +86,13 @@
- return;
- }
- + if(player == HiddenBastard.bastard)
- + {
- + player.sendMessage("You cannot restart while being the hidden bastard");
- + sendPacket(RestartResponse.valueOf(false));
- + return;
- + }
- +
- // Check if player is in combat
- if(AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !(player.isGM() && Config.GM_RESTART_FIGHTING))
- {
- Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java (revision 952)
- +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java (working copy)
- @@ -36,6 +36,7 @@
- import com.l2jfrozen.gameserver.model.L2World;
- import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance.PunishLevel;
- +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
- import com.l2jfrozen.gameserver.network.SystemChatChannelId;
- import com.l2jfrozen.gameserver.network.SystemMessageId;
- import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
- @@ -131,6 +132,11 @@
- return;
- }
- + if(activeChar == HiddenBastard.bastard)
- + {
- + activeChar.sendMessage("You are the hidden bastard. You are not supposed to talk");
- + return;
- + }
- if(activeChar == null)
- {
- _log.warning("[Say2.java] Active Character is null.");
- Index: head-src/com/l2jfrozen/gameserver/model/entity/event/HiddenBastard.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/model/entity/event/HiddenBastard.java (revision 0)
- +++ head-src/com/l2jfrozen/gameserver/model/entity/event/HiddenBastard.java (working copy)
- @@ -0,0 +1,166 @@
- +/* 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.l2jfrozen.gameserver.model.entity.event;
- +
- +import java.util.Collection;
- +
- +import com.l2jfrozen.gameserver.managers.TownManager;
- +import com.l2jfrozen.gameserver.model.L2Character;
- +import com.l2jfrozen.gameserver.model.L2World;
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
- +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
- +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
- +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
- +import com.l2jfrozen.util.random.Rnd;
- +
- +import javolution.util.FastList;
- +
- +
- +/**
- + *
- + * @author Elfocrash
- + */
- +
- +public class HiddenBastard
- +{
- + public static FastList<L2PcInstance> _players = new FastList<L2PcInstance>();
- + public static State state = State.INACTIVE;
- + public static L2PcInstance bastard = null;
- + public static enum State { INACTIVE,
- + PICKING,
- + SEARCHING
- + }
- +
- + public class Task implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + if (state != State.INACTIVE)
- + {
- + return;
- + }
- + Runner();
- + }
- + }
- +
- + public void Runner()
- + {
- + Announce("Hide And Seek Event Started. In 20 seconds a random player from Giran will be picked to become the hidden bastard.");
- + state = State.PICKING;
- + waitSecs(20);
- + Announce("The event started! Someone in Giran is the Hidden Bastard. Use .bastard command while targeting a player to check if he is the bastard!");
- + Announce("You have 5 minutes to search for him.");
- + pickBastard();
- + wait(4);
- + while(state == State.SEARCHING)
- + {
- + Announce("One minute left! Still searching for him!");
- + wait(1);
- + Announce("No one found the hidden bastard. And that's just sad. " + bastard + "was the bastard.");
- + bastard.setIsBastard(false);
- + bastard.setIsImobilised(false);
- + clear();
- + }
- + }
- + public static void Announce(String msg)
- + {
- + Collection<L2PcInstance> plrs = L2World.getInstance().getAllPlayers();
- + CreatureSay cs = new CreatureSay(1, Say2.ANNOUNCEMENT, "", msg);
- +
- + for (L2PcInstance pls : plrs)
- + {
- + pls.sendPacket(cs);
- + }
- + }
- +
- +
- + public static void pickBastard()
- + {
- + state = State.SEARCHING;
- +
- + L2ZoneType zone = TownManager.getInstance().getTown(9);
- +
- + for (L2Character character : zone.getCharactersInside().values())
- + if (character instanceof L2PcInstance)
- + _players.add((L2PcInstance) character);
- +
- + bastard = _players.get(Rnd.get(0, _players.size() - 1));
- + bastard.setIsBastard(true);
- + bastard.sendMessage("You are the secret bastard. You are not allowed to move or talk.");
- + bastard.setIsImobilised(true);
- + }
- +
- +
- +
- + public static void endAndReward()
- + {
- + //reward with the way you want to
- + //bastard.blabla
- + }
- +
- + public static void clear()
- + {
- + _players.clear();
- + bastard = null;
- + state = State.INACTIVE;
- +
- + }
- +
- + private HiddenBastard()
- + {
- + ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Task(), 100000, 600000);
- + }
- +
- + 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();
- + }
- + }
- +
- + public static HiddenBastard getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + @SuppressWarnings("synthetic-access")
- + protected static final HiddenBastard _instance = new HiddenBastard();
- + }
- +}
- \ No newline at end of file
- Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (revision 952)
- +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -21,6 +21,7 @@
- import com.l2jfrozen.gameserver.datatables.SkillTable;
- import com.l2jfrozen.gameserver.model.L2Party;
- import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
- import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
- import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
- import com.l2jfrozen.gameserver.network.SystemMessageId;
- @@ -77,6 +78,12 @@
- return;
- }
- + if(player == HiddenBastard.bastard)
- + {
- + player.sendMessage("You cannot logout while being the hidden bastard.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- // Dont allow leaving if player is teleporting
- if (player.isTeleporting() && !player.isGM())
- {
- Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (revision 952)
- +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -290,6 +290,8 @@
- /** The _last teleport action. */
- private long _lastTeleportAction = 0;
- +
- +
- /**
- * Gets the actual status.
- *
- @@ -19132,7 +19134,17 @@
- _isLocked = a;
- }
- -
- + private boolean bastard = false;
- +
- + public void setIsBastard(boolean bastardaki)
- + {
- + bastardaki = this.bastard;
- + }
- +
- + public boolean isBastard()
- + {
- + return bastard;
- + }
- /** The _punish level. */
- private PunishLevel _punishLevel = PunishLevel.NONE;
- Index: head-src/com/l2jfrozen/gameserver/model/L2Character.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/model/L2Character.java (revision 952)
- +++ head-src/com/l2jfrozen/gameserver/model/L2Character.java (working copy)
- @@ -2760,6 +2760,8 @@
- _isImobilised = value;
- }
- +
- +
- /**
- * Checks if is block buff.
- *
- Index: head-src/com/l2jfrozen/gameserver/GameServer.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/GameServer.java (revision 952)
- +++ head-src/com/l2jfrozen/gameserver/GameServer.java (working copy)
- @@ -118,6 +118,7 @@
- import com.l2jfrozen.gameserver.model.entity.Announcements;
- import com.l2jfrozen.gameserver.model.entity.Hero;
- import com.l2jfrozen.gameserver.model.entity.MonsterRace;
- +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
- import com.l2jfrozen.gameserver.model.entity.event.manager.EventManager;
- import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
- import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSigns;
- @@ -410,6 +411,8 @@
- AdminCommandHandler.getInstance();
- UserCommandHandler.getInstance();
- VoicedCommandHandler.getInstance();
- +
- + HiddenBastard.getInstance();
- _log.info("AutoChatHandler : Loaded " + AutoChatHandler.getInstance().size() + " handlers in total.");
- Index: head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java (revision 952)
- +++ head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java (working copy)
- @@ -30,6 +30,7 @@
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.CTFCmd;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.DMCmd;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.FarmPvpCmd;
- +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.HiddenBastardCmd;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Online;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.StatsCmd;
- import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.TvTCmd;
- @@ -71,6 +72,8 @@
- registerVoicedCommandHandler(new BankingCmd());
- }
- + registerVoicedCommandHandler(new HiddenBastardCmd());
- +
- if(Config.CTF_COMMAND)
- {
- registerVoicedCommandHandler(new CTFCmd());
- Index: head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/HiddenBastardCmd.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/HiddenBastardCmd.java (revision 0)
- +++ head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/HiddenBastardCmd.java (working copy)
- @@ -0,0 +1,74 @@
- +/*
- + * 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.l2jfrozen.gameserver.handler.voicedcommandhandlers;
- +
- +import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
- +
- +/**
- + *
- + * @author Elfocrash
- + */
- +
- +public class HiddenBastardCmd implements IVoicedCommandHandler
- +{
- + private static String[] _voicedCommands =
- + {
- + "bastard"
- + };
- +
- + @Override
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
- + {
- + if(command.equalsIgnoreCase(_voicedCommands[0]))
- + {
- + if(!(activeChar.getTarget() instanceof L2PcInstance))
- + {
- + activeChar.sendMessage("Only players can be bastards.");
- + return false;
- + }
- +
- + if(activeChar.getTarget() == activeChar)
- + {
- + activeChar.sendMessage("You are too good to be the bastard.");
- + return false;
- + }
- +
- + if(activeChar.getTarget() == null)
- + {
- + activeChar.sendMessage("You have to target someone.");
- + return false;
- + }
- +
- + if(((L2PcInstance) activeChar.getTarget()) == HiddenBastard.bastard)
- + {
- + activeChar.sendMessage("You found him!" + activeChar.getTarget().getName() + " is the bastard.");
- + HiddenBastard.Announce(activeChar.getName() + " found the hidden bastard who was " + HiddenBastard.bastard);
- + HiddenBastard.endAndReward();
- + HiddenBastard.bastard.setIsBastard(false);
- + HiddenBastard.bastard.setIsImobilised(false);
- + HiddenBastard.clear();
- + }
- + else
- + {
- + activeChar.sendMessage("No! " + activeChar.getTarget().getName() + " is not the bastard.");
- + return false;
- + }
- + }
- + return true;
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- + return _voicedCommands;
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment