warc222

.pvp

Dec 24th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.08 KB | None | 0 0
  1. Index: dist/game/data/scripts/handlers/voicedcommandhandlers/PvP.java
  2. ===================================================================
  3. --- dist/game/data/scripts/handlers/voicedcommandhandlers/PvP.java (revision 0)
  4. +++ dist/game/data/scripts/handlers/voicedcommandhandlers/PvP.java (revision 0)
  5. @@ -0,0 +1,67 @@
  6. +/* This program is free software; you can redistribute it and/or modify
  7. + * it under the terms of the GNU General Public License as published by
  8. + * the Free Software Foundation; either version 2, or (at your option)
  9. + * any later version.
  10. + *
  11. + * This program is distributed in the hope that it will be useful,
  12. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. + * GNU General Public License for more details.
  15. + *
  16. + * You should have received a copy of the GNU General Public License
  17. + * along with this program; if not, write to the Free Software
  18. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. + * 02111-1307, USA.
  20. + *
  21. + * http://www.gnu.org/copyleft/gpl.html
  22. + */
  23. +package handlers.voicedcommandhandlers;
  24. +
  25. +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  26. +import com.l2jserver.gameserver.model.L2Object;
  27. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. +import com.l2jserver.gameserver.model.entity.Pvp;
  29. +import com.l2jserver.gameserver.model.entity.Pvp.State;
  30. +/**
  31. + *
  32. + * @author Marwan
  33. + */
  34. +public class PvP implements IVoicedCommandHandler
  35. +{
  36. + public final String[] VOICED_COMMANDS = {"pvp" ,"viewpvp"};
  37. +
  38. + @SuppressWarnings("static-access")
  39. + @Override
  40. + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  41. + {
  42. + Pvp pvp = new Pvp();
  43. + if(command.startsWith("pvp")){
  44. + L2Object noobseverywhere = activeChar.getTarget();
  45. + L2PcInstance targett = noobseverywhere.getActingPlayer();
  46. + if(pvp.state == pvp.state.ACTIVE){
  47. + activeChar.sendMessage("There are already player the are making pvps");
  48. + return false;
  49. + }
  50. + if(targett instanceof L2Playable){
  51. + pvp.startPvPWith(activeChar, targett);
  52. +
  53. + }else{
  54. + activeChar.sendMessage("You can only pvp with players");
  55. + }
  56. + if(activeChar.getTarget() == null){
  57. + activeChar.sendMessage("You have to target someone");
  58. + }
  59. + if(command.startsWith("viewpvp")){
  60. + if(pvp.state == pvp.state.ACTIVE){
  61. + viewHTML();
  62. + }else{
  63. + activeChar.sendMessage("There is no pvps now");
  64. + }
  65. + }
  66. + return false;
  67. + }
  68. + public String viewHTML(){
  69. + StringBuilder sb = new StringBuilder();
  70. +sb.append("<html><title>Services</title><body>");
  71. +sb.append("<td align=center><button value=Observe PvP action=bypass -h npc_%objectId%_observe 80 149006 46758 -3413");
  72. +sb.append("</body></html>");
  73. + return sb.toString();
  74. +}
  75. + public String[] getVoicedCommandList()
  76. + {
  77. + return VOICED_COMMANDS;
  78. + }
  79. +}
  80. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  81. ===================================================================
  82. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5667)
  83. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  84. @@ -302,6 +312,74 @@
  85. */
  86. public final class L2PcInstance extends L2Playable
  87. {
  88. +
  89. + public boolean _isinPvP = false;
  90. +
  91. + public void setInPvP(boolean omg)
  92. + {
  93. + _isinPvP = omg;
  94. + }
  95. +
  96. + public boolean isInPvP()
  97. + {
  98. + return _isinPvP;
  99. + }
  100.  
  101. }
  102. + if (_inEventRaid && Raid._started)
  103. + {
  104. + getStatus().setCurrentHp(getMaxHp());
  105. + getStatus().setCurrentMp(getMaxMp());
  106. + getStatus().setCurrentCp(getMaxCp());
  107. + }
  108. }
  109. }
  110. }
  111. \ No newline at end of file
  112. Index: java/com/l2jserver/gameserver/model/entity/Pvp.java
  113. ===================================================================
  114. --- java/com/l2jserver/gameserver/model/entity/Pvp.java (revision 0)
  115. +++ java/com/l2jserver/gameserver/model/entity/Pvp.java (revision 0)
  116. @@ -0,0 +1,128 @@
  117. +/* This program is free software; you can redistribute it and/or modify
  118. + * it under the terms of the GNU General Public License as published by
  119. + * the Free Software Foundation; either version 2, or (at your option)
  120. + * any later version.
  121. + *
  122. + * This program is distributed in the hope that it will be useful,
  123. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  124. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  125. + * GNU General Public License for more details.
  126. + *
  127. + * You should have received a copy of the GNU General Public License
  128. + * along with this program; if not, write to the Free Software
  129. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  130. + * 02111-1307, USA.
  131. + *
  132. + * http://www.gnu.org/copyleft/gpl.html
  133. + */
  134. +package com.l2jserver.gameserver.model.entity;
  135. +
  136. +import com.l2jserver.gameserver.Announcements;
  137. +import com.l2jserver.gameserver.ThreadPoolManager;
  138. +import com.l2jserver.gameserver.model.Location;
  139. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  140. +
  141. +/**
  142. + * @author Marwan
  143. + */
  144. +public class Pvp
  145. +{
  146. + @SuppressWarnings("unused")
  147. + public static enum State
  148. + {
  149. + INACTIVE,
  150. + ACTIVE
  151. + }
  152. +
  153. + public static State state = State.INACTIVE;
  154. + public static L2PcInstance pl1, pl2 = null;
  155. + public static Location loc1, loc2;
  156. +
  157. + public void startPvPWith(L2PcInstance p1, L2PcInstance p2)
  158. + {
  159. +
  160. + pl1 = p1;
  161. + pl2 = p2;
  162. + loc1 = pl1.getLocation();
  163. + loc2 = pl2.getLocation();
  164. + pl1.setInPvP(true);
  165. + pl2.setInPvP(true);
  166. + state = state.ACTIVE;
  167. + Announcements.getInstance().announceToAll("PvP Started between " + p1 + " and " + p2);
  168. + Announcements.getInstance().announceToAll("To view the pvp press .viewpvp");
  169. + pl1.sendMessage("You will be teleported to the pvp arena in 30 secs");
  170. + pl2.sendMessage("You will be teleported to the pvp arena in 30 secs");
  171. + waitSecs(30);
  172. + pl1.teleToLocation(149936, 46751, -3413);
  173. + pl2.teleToLocation(149006, 46758, -3413);
  174. + if (state == State.ACTIVE)
  175. + {
  176. + pl1.sendMessage("Pvp will end in 5 minutes");
  177. + pl2.sendMessage("Pvp will end in 5 minutes");
  178. + wait(4);
  179. +
  180. + pl1.sendMessage("Pvp will end in 1 minute");
  181. + pl2.sendMessage("Pvp will end in 1 minute");
  182. + wait(1);
  183. + }
  184. +
  185. + }
  186. +
  187. + public void check()
  188. + {
  189. +
  190. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  191. + {
  192. + @Override
  193. + public void run()
  194. + {
  195. + if (pl1.isDead())
  196. + {
  197. + Announcements.getInstance().announceToAll("The winner is " + pl2.getName());
  198. + state = state.INACTIVE;
  199. + }
  200. + else
  201. + {
  202. + Announcements.getInstance().announceToAll("The winner is " + pl1.getName());
  203. + state = state.INACTIVE;
  204. + }
  205. + pl1.teleToLocation(loc1, true);
  206. + pl2.teleToLocation(loc2, true);
  207. + }
  208. + }, 10000);
  209. + }
  210. +
  211. + public void waitSecs(int i)
  212. + {
  213. + try
  214. + {
  215. + Thread.sleep(i * 1000);
  216. + }
  217. + catch (InterruptedException ie)
  218. + {
  219. + ie.printStackTrace();
  220. + }
  221. + }
  222. +
  223. + public void wait(int i)
  224. + {
  225. + try
  226. + {
  227. + Thread.sleep(i * 60000);
  228. + }
  229. + catch (InterruptedException ie)
  230. + {
  231. + ie.printStackTrace();
  232. + }
  233. + }
  234. +
  235. + /**
  236. + * @param activeChar
  237. + * @param targett
  238. + */
  239. + {
  240. + // TODO Auto-generated method stub
  241. +
  242. + }
  243. +
  244. +}
  245. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment