Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: dist/game/data/scripts/handlers/voicedcommandhandlers/PvP.java
- ===================================================================
- --- dist/game/data/scripts/handlers/voicedcommandhandlers/PvP.java (revision 0)
- +++ dist/game/data/scripts/handlers/voicedcommandhandlers/PvP.java (revision 0)
- @@ -0,0 +1,67 @@
- +/* 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 handlers.voicedcommandhandlers;
- +
- +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
- +import com.l2jserver.gameserver.model.L2Object;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.Pvp;
- +import com.l2jserver.gameserver.model.entity.Pvp.State;
- +/**
- + *
- + * @author Marwan
- + */
- +public class PvP implements IVoicedCommandHandler
- +{
- + public final String[] VOICED_COMMANDS = {"pvp" ,"viewpvp"};
- +
- + @SuppressWarnings("static-access")
- + @Override
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
- + {
- + Pvp pvp = new Pvp();
- + if(command.startsWith("pvp")){
- + L2Object noobseverywhere = activeChar.getTarget();
- + L2PcInstance targett = noobseverywhere.getActingPlayer();
- + if(pvp.state == pvp.state.ACTIVE){
- + activeChar.sendMessage("There are already player the are making pvps");
- + return false;
- + }
- + if(targett instanceof L2Playable){
- + pvp.startPvPWith(activeChar, targett);
- +
- + }else{
- + activeChar.sendMessage("You can only pvp with players");
- + }
- + if(activeChar.getTarget() == null){
- + activeChar.sendMessage("You have to target someone");
- + }
- + if(command.startsWith("viewpvp")){
- + if(pvp.state == pvp.state.ACTIVE){
- + viewHTML();
- + }else{
- + activeChar.sendMessage("There is no pvps now");
- + }
- + }
- + return false;
- + }
- + public String viewHTML(){
- + StringBuilder sb = new StringBuilder();
- +sb.append("<html><title>Services</title><body>");
- +sb.append("<td align=center><button value=Observe PvP action=bypass -h npc_%objectId%_observe 80 149006 46758 -3413");
- +sb.append("</body></html>");
- + return sb.toString();
- +}
- + public String[] getVoicedCommandList()
- + {
- + return VOICED_COMMANDS;
- + }
- +}
- 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 +312,74 @@
- */
- public final class L2PcInstance extends L2Playable
- {
- +
- + public boolean _isinPvP = false;
- +
- + public void setInPvP(boolean omg)
- + {
- + _isinPvP = omg;
- + }
- +
- + public boolean isInPvP()
- + {
- + return _isinPvP;
- + }
- }
- + if (_inEventRaid && Raid._started)
- + {
- + getStatus().setCurrentHp(getMaxHp());
- + getStatus().setCurrentMp(getMaxMp());
- + getStatus().setCurrentCp(getMaxCp());
- + }
- }
- }
- }
- \ No newline at end of file
- Index: java/com/l2jserver/gameserver/model/entity/Pvp.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/Pvp.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/Pvp.java (revision 0)
- @@ -0,0 +1,128 @@
- +/* 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 com.l2jserver.gameserver.Announcements;
- +import com.l2jserver.gameserver.ThreadPoolManager;
- +import com.l2jserver.gameserver.model.Location;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * @author Marwan
- + */
- +public class Pvp
- +{
- + @SuppressWarnings("unused")
- + public static enum State
- + {
- + INACTIVE,
- + ACTIVE
- + }
- +
- + public static State state = State.INACTIVE;
- + public static L2PcInstance pl1, pl2 = null;
- + public static Location loc1, loc2;
- +
- + public void startPvPWith(L2PcInstance p1, L2PcInstance p2)
- + {
- +
- + pl1 = p1;
- + pl2 = p2;
- + loc1 = pl1.getLocation();
- + loc2 = pl2.getLocation();
- + pl1.setInPvP(true);
- + pl2.setInPvP(true);
- + state = state.ACTIVE;
- + Announcements.getInstance().announceToAll("PvP Started between " + p1 + " and " + p2);
- + Announcements.getInstance().announceToAll("To view the pvp press .viewpvp");
- + pl1.sendMessage("You will be teleported to the pvp arena in 30 secs");
- + pl2.sendMessage("You will be teleported to the pvp arena in 30 secs");
- + waitSecs(30);
- + pl1.teleToLocation(149936, 46751, -3413);
- + pl2.teleToLocation(149006, 46758, -3413);
- + if (state == State.ACTIVE)
- + {
- + pl1.sendMessage("Pvp will end in 5 minutes");
- + pl2.sendMessage("Pvp will end in 5 minutes");
- + wait(4);
- +
- + pl1.sendMessage("Pvp will end in 1 minute");
- + pl2.sendMessage("Pvp will end in 1 minute");
- + wait(1);
- + }
- +
- + }
- +
- + public void check()
- + {
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + if (pl1.isDead())
- + {
- + Announcements.getInstance().announceToAll("The winner is " + pl2.getName());
- + state = state.INACTIVE;
- + }
- + else
- + {
- + Announcements.getInstance().announceToAll("The winner is " + pl1.getName());
- + state = state.INACTIVE;
- + }
- + pl1.teleToLocation(loc1, true);
- + pl2.teleToLocation(loc2, true);
- + }
- + }, 10000);
- + }
- +
- + 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();
- + }
- + }
- +
- + /**
- + * @param activeChar
- + * @param targett
- + */
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment