Guest User

OneInTheChamber

a guest
Aug 19th, 2013
620
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.39 KB | None | 1 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_DataPack_BETA
  3. Index: dist/game/data/scripts/handlers/MasterHandler.java
  4. ===================================================================
  5. --- dist/game/data/scripts/handlers/MasterHandler.java (revision 9910)
  6. +++ dist/game/data/scripts/handlers/MasterHandler.java (working copy)
  7. @@ -274,6 +274,7 @@
  8. import handlers.usercommandhandlers.Time;
  9. import handlers.usercommandhandlers.Unstuck;
  10. import handlers.voicedcommandhandlers.Banking;
  11. +import handlers.voicedcommandhandlers.Chamber;
  12. import handlers.voicedcommandhandlers.ChangePassword;
  13. import handlers.voicedcommandhandlers.ChatAdmin;
  14. import handlers.voicedcommandhandlers.Debug;
  15. @@ -540,6 +541,7 @@
  16. // TODO: Add configuration options for this voiced commands:
  17. // CastleVCmd.class,
  18. // SetVCmd.class,
  19. + Chamber.class,
  20. (Config.L2JMOD_ALLOW_WEDDING ? Wedding.class : null),
  21. (Config.BANKING_SYSTEM_ENABLED ? Banking.class : null),
  22. (Config.TVT_ALLOW_VOICED_COMMAND ? TvTVoicedInfo.class : null),
  23. Index: dist/game/data/scripts/handlers/voicedcommandhandlers/Chamber.java
  24. ===================================================================
  25. --- dist/game/data/scripts/handlers/voicedcommandhandlers/Chamber.java (revision 0)
  26. +++ dist/game/data/scripts/handlers/voicedcommandhandlers/Chamber.java (revision 0)
  27. @@ -0,0 +1,57 @@
  28. +/*
  29. + * Copyright (C) 2004-2013 L2J DataPack
  30. + *
  31. + * This file is part of L2J DataPack.
  32. + *
  33. + * L2J DataPack is free software: you can redistribute it and/or modify
  34. + * it under the terms of the GNU General Public License as published by
  35. + * the Free Software Foundation, either version 3 of the License, or
  36. + * (at your option) any later version.
  37. + *
  38. + * L2J DataPack is distributed in the hope that it will be useful,
  39. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  41. + * General Public License for more details.
  42. + *
  43. + * You should have received a copy of the GNU General Public License
  44. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  45. + */
  46. +package handlers.voicedcommandhandlers;
  47. +
  48. +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  49. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  50. +import com.l2jserver.gameserver.model.entity.OneInTheChamber;
  51. +
  52. +/**
  53. + * @author Zoey76
  54. + */
  55. +public class Chamber implements IVoicedCommandHandler
  56. +{
  57. + private static final String[] VOICED_COMMANDS =
  58. + {
  59. + "register",
  60. + "unregister"
  61. +
  62. + };
  63. +
  64. + @Override
  65. + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  66. + {
  67. + if (command.equalsIgnoreCase(VOICED_COMMANDS[0]))
  68. + {
  69. + OneInTheChamber.getInstance().register(activeChar);
  70. + }
  71. + else if (command.equalsIgnoreCase(VOICED_COMMANDS[1]))
  72. + {
  73. + OneInTheChamber.getInstance().unregister(activeChar);
  74. + }
  75. +
  76. + return true;
  77. + }
  78. +
  79. + @Override
  80. + public String[] getVoicedCommandList()
  81. + {
  82. + return VOICED_COMMANDS;
  83. + }
  84. +}
  85. #P L2J_Server_BETA
  86. Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java
  87. ===================================================================
  88. --- java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (revision 6166)
  89. +++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
  90. @@ -33,6 +33,7 @@
  91. import com.l2jserver.gameserver.model.entity.Castle;
  92. import com.l2jserver.gameserver.model.entity.ClanHall;
  93. import com.l2jserver.gameserver.model.entity.Fort;
  94. +import com.l2jserver.gameserver.model.entity.OneInTheChamber;
  95. import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
  96.  
  97. /**
  98. @@ -264,7 +265,14 @@
  99. }
  100. default:
  101. {
  102. - loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
  103. + if (activeChar.inChamber)
  104. + {
  105. + loc = new Location(OneInTheChamber.getInstance().getX(), OneInTheChamber.getInstance().getY(), OneInTheChamber.getInstance().getZ());
  106. + }
  107. + else
  108. + {
  109. + loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
  110. + }
  111. break;
  112. }
  113. }
  114. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  115. ===================================================================
  116. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 6166)
  117. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  118. @@ -196,6 +196,7 @@
  119. import com.l2jserver.gameserver.model.entity.Hero;
  120. import com.l2jserver.gameserver.model.entity.Instance;
  121. import com.l2jserver.gameserver.model.entity.L2Event;
  122. +import com.l2jserver.gameserver.model.entity.OneInTheChamber;
  123. import com.l2jserver.gameserver.model.entity.Siege;
  124. import com.l2jserver.gameserver.model.entity.TvTEvent;
  125. import com.l2jserver.gameserver.model.fishing.L2Fish;
  126. @@ -336,6 +337,10 @@
  127. */
  128. public final class L2PcInstance extends L2Playable
  129. {
  130. +
  131. + public int chamberKills = 0;
  132. + public boolean inChamber = false;
  133. + public int arrowCount = 0;
  134. // Character Skill SQL String Definitions:
  135. private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE charId=? AND class_index=?";
  136. private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (charId,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
  137. @@ -427,7 +432,13 @@
  138. public void doAttack(L2Character target)
  139. {
  140. super.doAttack(target);
  141. -
  142. + L2PcInstance targett = target.getActingPlayer();
  143. + if (inChamber)
  144. + {
  145. + targett.doDie(target);
  146. + chamberKills += 1;
  147. + OneInTheChamber.getInstance().addArrow(this.getPlayer());
  148. + }
  149. // cancel the recent fake-death protection instantly if the player attacks or casts spells
  150. getPlayer().setRecentFakeDeath(false);
  151. }
  152. @@ -5448,6 +5459,10 @@
  153. return false;
  154. }
  155.  
  156. + if (inChamber)
  157. + {
  158. + OneInTheChamber.addArrow(this.getActingPlayer());
  159. + }
  160. if (isMounted())
  161. {
  162. stopFeed();
  163. @@ -5810,7 +5825,6 @@
  164. {
  165. // Add karma to attacker and increase its PK counter
  166. setPvpKills(getPvpKills() + 1);
  167. -
  168. // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  169. sendPacket(new UserInfo(this));
  170. sendPacket(new ExBrExtraUserInfo(this));
  171. Index: java/com/l2jserver/gameserver/model/entity/OneInTheChamber.java
  172. ===================================================================
  173. --- java/com/l2jserver/gameserver/model/entity/OneInTheChamber.java (revision 0)
  174. +++ java/com/l2jserver/gameserver/model/entity/OneInTheChamber.java (revision 0)
  175. @@ -0,0 +1,215 @@
  176. +/*
  177. + * Copyright (C) 2004-2013 L2J Server
  178. + *
  179. + * This file is part of L2J Server.
  180. + *
  181. + * L2J Server is free software: you can redistribute it and/or modify
  182. + * it under the terms of the GNU General Public License as published by
  183. + * the Free Software Foundation, either version 3 of the License, or
  184. + * (at your option) any later version.
  185. + *
  186. + * L2J Server is distributed in the hope that it will be useful,
  187. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  188. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  189. + * General Public License for more details.
  190. + *
  191. + * You should have received a copy of the GNU General Public License
  192. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  193. + */
  194. +package com.l2jserver.gameserver.model.entity;
  195. +
  196. +import javolution.util.FastList;
  197. +
  198. +import com.l2jserver.gameserver.Announcements;
  199. +import com.l2jserver.gameserver.ThreadPoolManager;
  200. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  201. +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  202. +import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  203. +
  204. +/**
  205. + * @author Marwan
  206. + */
  207. +public class OneInTheChamber
  208. +{
  209. + int regTime = 1;
  210. + int eventTime = 10;
  211. + int LocationX = 1;
  212. + int LocationY = 1;
  213. + int LocationZ = 1;
  214. + int itemId = 57;
  215. + int itemCount = 100;
  216. + FastList<L2PcInstance> players = new FastList<L2PcInstance>();
  217. + L2PcInstance pls = null;
  218. +
  219. + public OneInTheChamber()
  220. + {
  221. + ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Run(), 600000, 600000);
  222. +
  223. + }
  224. +
  225. + public class Run implements Runnable
  226. + {
  227. +
  228. + @Override
  229. + public void run()
  230. + {
  231. + start();
  232. + }
  233. + }
  234. +
  235. + public void start()
  236. + {
  237. + announce("One in The Chamber event will start in " + regTime, true);
  238. + sleep(regTime);
  239. + if (players.size() >= 2)
  240. + {
  241. + announce("One in The Chamber event has started", true);
  242. + telePlayers(LocationX, LocationY, LocationZ);
  243. + giveBow();
  244. + announce("You have been teleported to event area", false);
  245. + sleep(eventTime);
  246. + reward();
  247. + clean();
  248. + }
  249. + else
  250. + {
  251. + announce("One in The Chamber event has ended due to lack of participants", true);
  252. +
  253. + }
  254. + }
  255. +
  256. + public void register(L2PcInstance i)
  257. + {
  258. + players.add(i);
  259. + i.inChamber = true;
  260. + }
  261. +
  262. + public void unregister(L2PcInstance i)
  263. + {
  264. + players.remove(i);
  265. + i.inChamber = false;
  266. + }
  267. +
  268. + public void telePlayers(int x, int y, int z)
  269. + {
  270. + for (L2PcInstance pls : players)
  271. + {
  272. + pls.teleToLocation(x, y, z);
  273. + }
  274. + }
  275. +
  276. + public void announce(String message, boolean all)
  277. + {
  278. + if (all)
  279. + {
  280. + Announcements.getInstance().announceToAll(message);
  281. + }
  282. + else
  283. + {
  284. + for (L2PcInstance pls : players)
  285. + {
  286. + CreatureSay cs = new CreatureSay(1, 2, "OneInTheChamber", message);
  287. + pls.sendPacket(cs);
  288. +
  289. + }
  290. + }
  291. + }
  292. +
  293. + public void sleep(int mints)
  294. + {
  295. + try
  296. + {
  297. + Thread.sleep(mints * 1000);
  298. + }
  299. + catch (InterruptedException e)
  300. + {
  301. + e.printStackTrace();
  302. + }
  303. + }
  304. +
  305. + public int getX()
  306. + {
  307. + return LocationX;
  308. + }
  309. +
  310. + public int getY()
  311. + {
  312. + return LocationY;
  313. + }
  314. +
  315. + public int getZ()
  316. + {
  317. + return LocationZ;
  318. + }
  319. +
  320. + public void giveBow()
  321. + {
  322. + for (L2PcInstance pls : players)
  323. + {
  324. +
  325. + pls.getInventory().addItem("bow", 14, 1, pls, this);
  326. + announce("You have recieved a bow and one arrow", false);
  327. + }
  328. + }
  329. +
  330. + public void removeArrows()
  331. + {
  332. + for (L2PcInstance pls : players)
  333. + {
  334. + L2ItemInstance item;
  335. + item = pls.getInventory().getItemByItemId(17);
  336. + if (item != null)
  337. + {
  338. + pls.getInventory().destroyItemByItemId("arrow", item.getId(), item.getCount(), pls, item);
  339. + }
  340. + pls.arrowCount = (int) item.getCount();
  341. + }
  342. + }
  343. +
  344. + public void addArrowsBack()
  345. + {
  346. + for (L2PcInstance pls : players)
  347. + {
  348. +
  349. + pls.getInventory().addItem("arrow", 17, pls.arrowCount, pls, this);
  350. + }
  351. + }
  352. +
  353. + public static void addArrow(L2PcInstance player)
  354. + {
  355. + player.getInventory().addItem("arrow", 17, 1, player, null);
  356. + }
  357. +
  358. + public void reward()
  359. + {
  360. + int topkills = 0;
  361. + for (L2PcInstance playas : players)
  362. + {
  363. + if (topkills < playas.chamberKills)
  364. + {
  365. + topkills = playas.chamberKills;
  366. + pls = playas;
  367. + }
  368. + }
  369. + pls.addItem("chamber", itemId, itemCount, pls, false);
  370. + announce(pls.getName() + " has won OneInTheChamber event", true);
  371. +
  372. + }
  373. +
  374. + public void clean()
  375. + {
  376. + players.removeAll(players);
  377. + addArrowsBack();
  378. + }
  379. +
  380. + public static OneInTheChamber getInstance()
  381. + {
  382. + return SingletonHolder._instance;
  383. + }
  384. +
  385. + private static class SingletonHolder
  386. + {
  387. + @SuppressWarnings("synthetic-access")
  388. + protected static final OneInTheChamber _instance = new OneInTheChamber();
  389. + }
  390. +}
Advertisement
Add Comment
Please, Sign In to add comment