Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hitman.getInstance();
- oh forgot ,add in gameserver.java
- ### Eclipse Workspace Patch 1.0
- #P L2J_Server
- 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 _hitman = false;
- + public void setHitman(boolean h)
- + {
- +
- + _hitman = h;
- + }
- +
- + public boolean isHitman()
- + {
- + return _hitman;
- + }
- +
- @@ -5814,6 +6019,17 @@
- public boolean doDie(L2Character killer)
- {
- // Kill the L2PcInstance
- + if (isHitman())
- + {
- + L2PcInstance killer1 = killer.getActingPlayer();
- + Hitman event = new Hitman();
- + event.rewardWinner(killer1);
- + event.annoucneWinner(killer1);
- + setHitman(false);
- +
- + event.state = event.state.INACTIVE;
- + event.clear();
- + }
- if (!super.doDie(killer))
- {
- return false;
- Index: java/com/l2jserver/gameserver/model/entity/Hitman.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/Hitman.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/Hitman.java (revision 0)
- @@ -0,0 +1,159 @@
- +/* 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.model.actor.instance.L2PcInstance;
- +import com.l2jserver.util.Rnd;
- +
- +/**
- + * @author Marwan
- + */
- +public class Hitman
- +{
- + @SuppressWarnings("unused")
- + public static FastList<L2PcInstance> _players = new FastList<L2PcInstance>();
- + public static L2PcInstance chossenPlayer = null;
- +
- + public static enum State
- + {
- + INACTIVE,
- + ACTIVE
- + }
- +
- + public static State state = State.INACTIVE;
- +
- + public class Start implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + startEvent();
- + }
- + }
- +
- + public void startEvent()
- + {
- + Announcements.getInstance().announceToAll("Hitman event started.");
- + Announcements.getInstance().announceToAll("Player will be chossen in 30 seconds to be the hitman.");
- + pickplayer();
- + waitSecs(30);
- + announce();
- + chosse(chossenPlayer);
- +
- + if (state == State.ACTIVE)
- + {
- + Announcements.getInstance().announceToAll("Hitman Event will end in 5 minutes.");
- + wait(4);
- +
- + Announcements.getInstance().announceToAll("Hitman Event will end in 1 minutes.");
- + wait(1);
- + end();
- + }
- +
- + }
- +
- + public void pickplayer()
- + {
- + state = State.ACTIVE;
- + chossenPlayer = _players.get(Rnd.get(0, _players.size() - 1));
- + }
- +
- + public void end()
- + {
- + Announcements.getInstance().announceToAll("No one killed the Hitman");
- + Announcements.getInstance().announceToAll("Hitman event has end");
- + _players.clear();
- +
- + }
- +
- + public void announce()
- + {
- + Announcements.getInstance().announceToAll("Player :" + chossenPlayer.getName() + " has been chossen");
- + Announcements.getInstance().announceToAll("The first who kills him wil be rewarded");
- + Announcements.getInstance().announceToAll("Event will end in 10 minutes.");
- + }
- +
- + public void chosse(L2PcInstance pl)
- + {
- + pl.setHitman(true);
- + pl.setTitle("HitMan Target");
- + pl.getAppearance().setTitleColor(255, 0, 0);
- + }
- +
- + public void rewardWinner(L2PcInstance a)
- + {
- +
- + a.addItem("hitman", 57, 10000, a, false);
- +
- + }
- +
- + public void annoucneWinner(L2PcInstance a)
- + {
- +
- + Announcements.getInstance().announceToAll(a.getName() + " has won Hitman Event");
- +
- + }
- +
- + public void clear()
- + {
- + _players.clear();
- + }
- +
- + 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 Hitman()
- + {
- + // ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Start(), 600000, 600000);
- + }
- +
- + public static Hitman getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + @SuppressWarnings("synthetic-access")
- + protected static final Hitman _instance = new Hitman();
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement