Guest User

zombie event

a guest
Dec 19th, 2012
1,949
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.77 KB | None | 1 0
  1. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5667)
  4. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  5. @@ -302,6 +313,96 @@
  6. */
  7. public final class L2PcInstance extends L2Playable
  8. {
  9. +
  10. + public boolean _zombie = false;
  11. + public void setZombie(boolean t)
  12. + {
  13. + _zombie = t;
  14. + }
  15. +
  16. + public boolean isZombie()
  17. + {
  18. + return _zombie;
  19. + }
  20. @@ -394,8 +494,19 @@
  21. @Override
  22. public void doAttack(L2Character target)
  23. {
  24. + Zombie z = new Zombie();
  25. super.doAttack(target);
  26. -
  27. + if (isZombie())
  28. + {
  29. +
  30. + L2PcInstance targeto = target.getActingPlayer();
  31. + z.infect(targeto);
  32. +
  33. + if (Zombie._notinfected.size() == 0)
  34. + {
  35. + z.end();
  36. + }
  37. + }
  38. // cancel the recent fake-death protection instantly if the player attacks or casts spells
  39. getPlayer().setRecentFakeDeath(false);
  40. }
  41. @@ -5389,6 +5576,15 @@
  42. @Override
  43. public synchronized void untransform()
  44. {
  45. + if (isZombie())
  46. + {
  47. + sendMessage("Fuck you noob cheater");
  48. + return;
  49. + }
  50. if (_transformation != null)
  51. {
  52. if (!fireTransformListeners(_transformation, false))
  53. \ No newline at end of file
  54. Index: java/com/l2jserver/gameserver/model/entity/Zombie.java
  55. ===================================================================
  56. --- java/com/l2jserver/gameserver/model/entity/Zombie.java (revision 0)
  57. +++ java/com/l2jserver/gameserver/model/entity/Zombie.java (revision 0)
  58. @@ -0,0 +1,298 @@
  59. +/* This program is free software; you can redistribute it and/or modify
  60. + * it under the terms of the GNU General Public License as published by
  61. + * the Free Software Foundation; either version 2, or (at your option)
  62. + * any later version.
  63. + *
  64. + * This program is distributed in the hope that it will be useful,
  65. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  66. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  67. + * GNU General Public License for more details.
  68. + *
  69. + * You should have received a copy of the GNU General Public License
  70. + * along with this program; if not, write to the Free Software
  71. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  72. + * 02111-1307, USA.
  73. + *
  74. + * http://www.gnu.org/copyleft/gpl.html
  75. + */
  76. +package com.l2jserver.gameserver.model.entity;
  77. +
  78. +import javolution.util.FastList;
  79. +
  80. +import com.l2jserver.gameserver.Announcements;
  81. +import com.l2jserver.gameserver.ThreadPoolManager;
  82. +import com.l2jserver.gameserver.datatables.DoorTable;
  83. +import com.l2jserver.gameserver.datatables.NpcTable;
  84. +import com.l2jserver.gameserver.datatables.SpawnTable;
  85. +import com.l2jserver.gameserver.instancemanager.TransformationManager;
  86. +import com.l2jserver.gameserver.model.L2Spawn;
  87. +import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  88. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  89. +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  90. +import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
  91. +import com.l2jserver.util.Rnd;
  92. +
  93. +/**
  94. + * @author Marwan
  95. + */
  96. +public class Zombie
  97. +{
  98. + public L2PcInstance zombie = null;
  99. + public static L2Spawn _npcSpawn;
  100. + public static FastList<L2PcInstance> all = new FastList<L2PcInstance>();
  101. + public static FastList<L2PcInstance> _infected = new FastList<L2PcInstance>();
  102. + public static FastList<L2PcInstance> _notinfected = new FastList<L2PcInstance>();
  103. + public int rounds = 3;
  104. +
  105. + public static enum State
  106. + {
  107. + INACTIVE,
  108. + ACTIVE
  109. + }
  110. +
  111. + public State state = State.INACTIVE;
  112. +
  113. + public class Start implements Runnable
  114. + {
  115. + @Override
  116. + public void run()
  117. + {
  118. + if (state == State.INACTIVE)
  119. + {
  120. + startEvent();
  121. + }
  122. + }
  123. + }
  124. +
  125. + public void startEvent()
  126. + {
  127. + state = State.ACTIVE;
  128. + all.addAll(_notinfected);
  129. + all.addAll(_infected);
  130. + Announcements.getInstance().announceToAll("Zombie event registrations will end in 10 minute(s).");
  131. + Announcements.getInstance().announceToAll("Registration npc in giran.");
  132. + spawnEventNpc();
  133. + waitSecs(10);
  134. + Announcements.getInstance().announceToAll("Zombie event registrations will end in 5 minute(s).");
  135. + waitSecs(10);
  136. + Announcements.getInstance().announceToAll("Zombie event registrations will end in 1 minute(s).");
  137. + waitSecs(10);
  138. +
  139. + if (_notinfected.size() >= 2)
  140. + {
  141. + closeDoor(24190002);
  142. + closeDoor(24190003);
  143. + closeDoor(24190001);
  144. + closeDoor(24190004);
  145. + pickZombie();
  146. + for (L2PcInstance players : _notinfected)
  147. + {
  148. + players.sendMessage("Zombie is " + zombie.getName());
  149. + players.teleToLocation(150108, 46736, -3407);
  150. + }
  151. + zombie.sendMessage("Infect others by hitting them");
  152. + zombie.teleToLocation(148498, 46752, -3413);
  153. + for (int i = 2; i <= rounds; i++)
  154. + {
  155. + i++;
  156. + waitSecs(110);
  157. + nextRound(i);
  158. + }
  159. + end();
  160. + }
  161. + else
  162. + {
  163. + Announcements.getInstance().announceToAll("Zombie event has been cancelled due to lack of participants");
  164. + state = State.INACTIVE;
  165. + }
  166. +
  167. + }
  168. +
  169. + public void nextRound(int round)
  170. + {
  171. + for (L2PcInstance pl : _notinfected)
  172. + {
  173. +
  174. + pl.teleToLocation(147771, 46712, -3411);
  175. + ExShowScreenMessage message1 = new ExShowScreenMessage("Round " + round + " will start in 30 seconds.", 8000);
  176. + pl.sendPacket(message1);
  177. + }
  178. + for (L2PcInstance pl : _infected)
  179. + {
  180. + pl.teleToLocation(151248, 46721, -3406);
  181. + ExShowScreenMessage message1 = new ExShowScreenMessage("Round " + round + " will start in 30 seconds.", 8000);
  182. + pl.sendPacket(message1);
  183. + }
  184. + waitSecs(30);
  185. + for (L2PcInstance pl : _notinfected)
  186. + {
  187. +
  188. + pl.teleToLocation(148515, 46660, -3413);
  189. + }
  190. + for (L2PcInstance pl : _infected)
  191. + {
  192. + pl.teleToLocation(150400, 46764, -3413);
  193. + }
  194. + }
  195. +
  196. + private static void spawnEventNpc()
  197. + {
  198. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(70012);
  199. +
  200. + try
  201. + {
  202. + _npcSpawn = new L2Spawn(tmpl);
  203. + _npcSpawn.setLocx(83450);
  204. + _npcSpawn.setLocy(148608);
  205. + _npcSpawn.setLocz(3405);
  206. + _npcSpawn.setAmount(1);
  207. + _npcSpawn.setHeading(1);
  208. + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  209. +
  210. + _npcSpawn.init();
  211. + _npcSpawn.getLastSpawn().setTitle("Zombie");
  212. + _npcSpawn.getLastSpawn().setName("Zombie Event");
  213. + }
  214. + catch (Exception e)
  215. + {
  216. + }
  217. + }
  218. +
  219. + public void pickZombie()
  220. + {
  221. + zombie = _notinfected.get(Rnd.get(0, _notinfected.size() - 1));
  222. + infect(zombie);
  223. + }
  224. +
  225. + public void infect(L2PcInstance z)
  226. + {
  227. + _infected.add(z);
  228. + _notinfected.remove(z);
  229. + z.getAppearance().setTitleColor(255, 0, 0);
  230. + z.setZombie(true);
  231. + TransformationManager.getInstance().transformPlayer(303, z);
  232. + }
  233. +
  234. + public void uninfectall()
  235. + {
  236. + for (L2PcInstance uninfect : _infected)
  237. + {
  238. + uninfect.untransform();
  239. + uninfect.setZombie(false);
  240. + }
  241. + }
  242. +
  243. + public void end()
  244. + {
  245. + openDoor(24190002);
  246. + openDoor(24190003);
  247. + openDoor(24190001);
  248. + openDoor(24190004);
  249. + uninfectall();
  250. + rewardWinner();
  251. + state = State.INACTIVE;
  252. + for (L2PcInstance p : all)
  253. + {
  254. + p.teleToLocation(83450, 148608, -3405);
  255. + }
  256. + if (_notinfected.size() >= 1)
  257. + {
  258. + Announcements.getInstance().announceToAll("Zombie event has end");
  259. + Announcements.getInstance().announceToAll("Players won");
  260. + _notinfected.removeAll(_notinfected);
  261. + }
  262. + else
  263. + {
  264. +
  265. + Announcements.getInstance().announceToAll("Zombie event has end");
  266. + Announcements.getInstance().announceToAll("Zombies won");
  267. + _infected.removeAll(_infected);
  268. + }
  269. +
  270. + }
  271. +
  272. + public void register(L2PcInstance p)
  273. + {
  274. + _notinfected.add(p);
  275. + p.sendMessage("You have succesfully registered");
  276. + }
  277. +
  278. + public void unregister(L2PcInstance p)
  279. + {
  280. + _notinfected.remove(p);
  281. + p.sendMessage("You have succesfully unregistered");
  282. + }
  283. +
  284. + public void rewardWinner()
  285. + {
  286. + if (_notinfected.size() == 0)
  287. + {
  288. + for (L2PcInstance n : _infected)
  289. + {
  290. + n.addItem("zombie", 57, 10000, n, false);
  291. + }
  292. + }
  293. + else
  294. + {
  295. + for (L2PcInstance n : _notinfected)
  296. + {
  297. + n.addItem("zombie", 57, 10000, n, false);
  298. + }
  299. + }
  300. + }
  301. +
  302. + public void waitSecs(int i)
  303. + {
  304. + try
  305. + {
  306. + Thread.sleep(i * 1000);
  307. + }
  308. + catch (InterruptedException ie)
  309. + {
  310. + ie.printStackTrace();
  311. + }
  312. + }
  313. +
  314. + public void wait(int i)
  315. + {
  316. + try
  317. + {
  318. + Thread.sleep(i * 60000);
  319. + }
  320. + catch (InterruptedException ie)
  321. + {
  322. + ie.printStackTrace();
  323. + }
  324. + }
  325. +
  326. + private static void closeDoor(int i)
  327. + {
  328. +
  329. + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(i);
  330. +
  331. + if (doorInstance != null)
  332. + {
  333. + doorInstance.closeMe();
  334. + }
  335. +
  336. + }
  337. +
  338. + private static void openDoor(int i)
  339. + {
  340. + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(i);
  341. +
  342. + if (doorInstance != null)
  343. + {
  344. + doorInstance.openMe();
  345. + }
  346. + }
  347. +
  348. + public Zombie()
  349. + {
  350. + ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Start(), 60000, 6000);
  351. +
  352. + }
  353. +
  354. + public static Zombie getInstance()
  355. + {
  356. + return SingletonHolder._instance;
  357. + }
  358. +
  359. + private static class SingletonHolder
  360. + {
  361. + protected static final Zombie _instance = new Zombie();
  362. + }
  363. +}
  364. Index: java/com/l2jserver/gameserver/instancemanager/ZombieNpc.java
  365. ===================================================================
  366. --- java/com/l2jserver/gameserver/instancemanager/ZombieNpc.java (revision 0)
  367. +++ java/com/l2jserver/gameserver/instancemanager/ZombieNpc.java (revision 0)
  368. @@ -0,0 +1,131 @@
  369. +/*
  370. + * This program is free software: you can redistribute it and/or modify it under
  371. + * the terms of the GNU General Public License as published by the Free Software
  372. + * Foundation, either version 3 of the License, or (at your option) any later
  373. + * version.
  374. + *
  375. + * This program is distributed in the hope that it will be useful, but WITHOUT
  376. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  377. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  378. + * details.
  379. + *
  380. + * You should have received a copy of the GNU General Public License along with
  381. + * this program. If not, see <http://www.gnu.org/licenses/>.
  382. + */
  383. +package com.l2jserver.gameserver.instancemanager;
  384. +
  385. +import com.l2jserver.Config;
  386. +import com.l2jserver.gameserver.model.actor.L2Npc;
  387. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  388. +import com.l2jserver.gameserver.model.entity.Zombie;
  389. +import com.l2jserver.gameserver.model.quest.Quest;
  390. +import com.l2jserver.gameserver.model.quest.QuestState;
  391. +
  392. +/**
  393. + * Zombie Npc
  394. + * @author Marwan
  395. + */
  396. +public final class ZombieNpc extends Quest
  397. +{
  398. +
  399. + private final int NpcId = 70012;
  400. +
  401. + private ZombieNpc(int questId, String name, String descr)
  402. + {
  403. +
  404. + super(questId, name, descr);
  405. + addStartNpc(NpcId);
  406. + addTalkId(NpcId);
  407. + }
  408. +
  409. + @Override
  410. + public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  411. + {
  412. + QuestState st = player.getQuestState("ZombieNpc");
  413. + if (st == null)
  414. + {
  415. + return "";
  416. + }
  417. + else if (event.equalsIgnoreCase("show"))
  418. + {
  419. + StringBuilder sb = new StringBuilder();
  420. + sb.append("<html><title>TvT Event</title>");
  421. + sb.append("<body>");
  422. + // sb.append("<br><font color=\"0066FF\">Current Event: 1vs1 </font>");
  423. + sb.append("<br><br><font color=\"00ff4d\">Hello " + player.getName() + ".<br> Here you can register for Zombie Event <br><br></font>");
  424. + sb.append("<hr>");
  425. + sb.append("<br><br><br><br>");
  426. + sb.append("<center><img src=\"L2UI.SquareWhite\" width=300 height=1>");
  427. + sb.append("<table bgcolor=333333 width=100>");
  428. + sb.append("<tr>");
  429. + sb.append("<td width=100 ALIGN=\"LEFT\"><button value=\"Register\" action=\"bypass -h Quest ZombieNpc register\" width=100 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td>");
  430. + sb.append("<td width=100 ALIGN=\"RIGHT\"><button value=\"Unregister\" action=\"bypass -h Quest ZombieNpc unregister\" width=100 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td></tr>");
  431. + sb.append("<br><tr><td width=150 ALIGN=\"CENTER\"><button value=\"Registered Players\" action=\"bypass -h Quest ZombieNpc players\" width=150 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td></tr>");
  432. +
  433. + sb.append("</tr>");
  434. + sb.append("</table>");
  435. + sb.append("<br><br></center>");
  436. + return sb.toString();
  437. + }
  438. +
  439. + else if (event.equalsIgnoreCase("register"))
  440. + {
  441. +
  442. + StringBuilder sb = new StringBuilder();
  443. + if (Zombie._notinfected.contains(player))
  444. + {
  445. + sb.append("<html><title>Zombie Event</title><body>");
  446. + sb.append("You are already registered</body></html>");
  447. + }
  448. + else
  449. + {
  450. + sb.append("<html><title>Zombie Event</title><body>");
  451. + sb.append("Registration succesful</body></html>");
  452. + Zombie z = new Zombie();
  453. + z.register(player);
  454. +
  455. + }
  456. + return sb.toString();
  457. +
  458. + }
  459. + else if (event.equalsIgnoreCase("unregister"))
  460. + {
  461. +
  462. + StringBuilder sb = new StringBuilder();
  463. + sb.append("<html><title>Zombie Event</title>");
  464. + sb.append("<body>You have succesfully unregistered</body></html>");
  465. + Zombie z = new Zombie();
  466. + z.unregister(player);
  467. + return sb.toString();
  468. + }
  469. + else if (event.equalsIgnoreCase("players"))
  470. + {
  471. + StringBuilder sb = new StringBuilder();
  472. + String noobs = null;
  473. + sb.append("<html><title>Zombie Event</title><body><center>");
  474. + sb.append("<br><br><table width=300><tr><td>Name</td><td width=80>Level</td></tr><br></font>");
  475. + for (L2PcInstance pls : Zombie._notinfected)
  476. + {
  477. + noobs += "<tr><td><font color=\"009900\">" + pls.getName() + "</td><td>" + pls.getLevel() + "</font></td></tr>";
  478. + }
  479. + sb.append("<table>" + noobs + "</table></body></html>");
  480. + return sb.toString();
  481. +
  482. + }
  483. +
  484. + return event;
  485. + }
  486. +
  487. + @SuppressWarnings("synthetic-access")
  488. + public static ZombieNpc getInstance()
  489. + {
  490. + return SingletonHolder._instance;
  491. + }
  492. +
  493. + private static class SingletonHolder
  494. + {
  495. + @SuppressWarnings("synthetic-access")
  496. + private static final ZombieNpc _instance = new ZombieNpc(-1, "ZombieNpc", "instances");
  497. + }
  498. +
  499. +}
Advertisement
Add Comment
Please, Sign In to add comment