SHOW:
|
|
- or go back to the newest paste.
| 1 | ### Eclipse Workspace Patch 1.0 | |
| 2 | #P L2jFrozen_GameServer | |
| 3 | Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java | |
| 4 | =================================================================== | |
| 5 | --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java (revision 936) | |
| 6 | +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java (working copy) | |
| 7 | @@ -27,6 +27,8 @@ | |
| 8 | ||
| 9 | import com.l2jfrozen.Config; | |
| 10 | import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable; | |
| 11 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 12 | +import com.l2jfrozen.gameserver.event.LMS; | |
| 13 | import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler; | |
| 14 | import com.l2jfrozen.gameserver.handler.VoicedCommandHandler; | |
| 15 | import com.l2jfrozen.gameserver.managers.PetitionManager; | |
| 16 | @@ -64,6 +66,8 @@ | |
| 17 | public final static int PARTYROOM_ALL = 16; //(Red) | |
| 18 | public final static int PARTYROOM_COMMANDER = 15; //(Yellow) | |
| 19 | public final static int HERO_VOICE = 17; //% | |
| 20 | + | |
| 21 | + private boolean _isInLMS; | |
| 22 | ||
| 23 | private final static String[] CHAT_NAMES = | |
| 24 | {
| |
| 25 | @@ -277,6 +281,18 @@ | |
| 26 | } | |
| 27 | ||
| 28 | CreatureSay cs = new CreatureSay(activeChar.getObjectId(), _type, activeChar.getName(), _text); | |
| 29 | + | |
| 30 | + if(EventManager.getInstance().isRegistered(activeChar)) | |
| 31 | + EventManager.getInstance().getCurrentEvent().onSay(_type, activeChar, _text); | |
| 32 | + | |
| 33 | + _isInLMS = EventManager.getInstance().isRegistered(activeChar) && EventManager.getInstance().getCurrentEvent() instanceof LMS; | |
| 34 | + | |
| 35 | + if(_isInLMS) | |
| 36 | + {
| |
| 37 | + activeChar.sendMessage("You cannot talk while in LMS");
| |
| 38 | + return; | |
| 39 | + } | |
| 40 | + | |
| 41 | switch(_type) | |
| 42 | {
| |
| 43 | case TELL: | |
| 44 | Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java | |
| 45 | =================================================================== | |
| 46 | --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (revision 936) | |
| 47 | +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (working copy) | |
| 48 | @@ -24,6 +24,7 @@ | |
| 49 | import com.l2jfrozen.gameserver.GameServer; | |
| 50 | import com.l2jfrozen.gameserver.communitybbs.Manager.RegionBBSManager; | |
| 51 | import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 52 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 53 | import com.l2jfrozen.gameserver.model.Inventory; | |
| 54 | import com.l2jfrozen.gameserver.model.L2Party; | |
| 55 | import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 56 | @@ -111,6 +112,13 @@ | |
| 57 | sendPacket(RestartResponse.valueOf(false)); | |
| 58 | return; | |
| 59 | } | |
| 60 | + | |
| 61 | + if(EventManager.getInstance().isRegistered(player) && !EventManager.getInstance().getBoolean("restartAllowed"))
| |
| 62 | + {
| |
| 63 | + player.sendMessage("You cannot restart while you are a participant in an event.");
| |
| 64 | + sendPacket(new ActionFailed()); | |
| 65 | + return; | |
| 66 | + } | |
| 67 | ||
| 68 | // Prevent player from restarting if they are a festival participant | |
| 69 | // and it is in progress, otherwise notify party members that the player | |
| 70 | Index: head-src/com/l2jfrozen/gameserver/event/CTF.java | |
| 71 | =================================================================== | |
| 72 | --- head-src/com/l2jfrozen/gameserver/event/CTF.java (revision 0) | |
| 73 | +++ head-src/com/l2jfrozen/gameserver/event/CTF.java (revision 0) | |
| 74 | @@ -0,0 +1,401 @@ | |
| 75 | +package com.l2jfrozen.gameserver.event; | |
| 76 | + | |
| 77 | +import javolution.text.TextBuilder; | |
| 78 | + | |
| 79 | +import com.l2jfrozen.gameserver.datatables.sql.ItemTable; | |
| 80 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 81 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 82 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 83 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 84 | +import com.l2jfrozen.gameserver.model.Inventory; | |
| 85 | +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay; | |
| 86 | +import com.l2jfrozen.gameserver.network.serverpackets.InventoryUpdate; | |
| 87 | +import com.l2jfrozen.gameserver.network.serverpackets.ItemList; | |
| 88 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 89 | +import com.l2jfrozen.gameserver.network.serverpackets.SocialAction; | |
| 90 | +import com.l2jfrozen.gameserver.templates.L2EtcItemType; | |
| 91 | + | |
| 92 | +public class CTF extends Event | |
| 93 | +{
| |
| 94 | + private class Core implements Runnable | |
| 95 | + {
| |
| 96 | + | |
| 97 | + public void run() | |
| 98 | + {
| |
| 99 | + try | |
| 100 | + {
| |
| 101 | + switch (eventState) | |
| 102 | + {
| |
| 103 | + case START: | |
| 104 | + divideIntoTeams(2); | |
| 105 | + preparePlayers(); | |
| 106 | + teleportToTeamPos(); | |
| 107 | + createPartyOfTeam(1); | |
| 108 | + createPartyOfTeam(2); | |
| 109 | + forceSitAll(); | |
| 110 | + spawnFlagsAndHolders(); | |
| 111 | + setStatus(EventState.FIGHT); | |
| 112 | + debug("The event started with " + players.size() + " players");
| |
| 113 | + schedule(20000); | |
| 114 | + break; | |
| 115 | + | |
| 116 | + case FIGHT: | |
| 117 | + forceStandAll(); | |
| 118 | + setStatus(EventState.END); | |
| 119 | + debug("The fight started");
| |
| 120 | + clock.startClock(getInt("matchTime"));
| |
| 121 | + break; | |
| 122 | + | |
| 123 | + case END: | |
| 124 | + clock.setTime(0); | |
| 125 | + if (winnerTeam == 0) | |
| 126 | + winnerTeam = getWinnerTeam(); | |
| 127 | + | |
| 128 | + unspawnFlagsAndHolders(); | |
| 129 | + debug("The flags unspawned");
| |
| 130 | + if (playerWithRedFlag != null) | |
| 131 | + unequipFlag(playerWithRedFlag); | |
| 132 | + if (playerWithBlueFlag != null) | |
| 133 | + unequipFlag(playerWithBlueFlag); | |
| 134 | + giveReward(getPlayersOfTeam(winnerTeam), getInt("rewardId"), getInt("rewardAmmount"));
| |
| 135 | + setStatus(EventState.INACTIVE); | |
| 136 | + debug("The event ended. Winner: " + winnerTeam);
| |
| 137 | + EventManager.getInstance().end("Congratulation! The " + teams.get(winnerTeam).getName() + " team won the event with " + teams.get(winnerTeam).getScore() + " Flags taken!");
| |
| 138 | + break; | |
| 139 | + } | |
| 140 | + } | |
| 141 | + catch (Throwable e) | |
| 142 | + {
| |
| 143 | + e.printStackTrace(); | |
| 144 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 145 | + } | |
| 146 | + } | |
| 147 | + } | |
| 148 | + | |
| 149 | + private enum EventState | |
| 150 | + {
| |
| 151 | + START, FIGHT, END, TELEPORT, INACTIVE | |
| 152 | + } | |
| 153 | + | |
| 154 | + private EventState eventState; | |
| 155 | + | |
| 156 | + private Core task; | |
| 157 | + | |
| 158 | + private L2Spawn redFlagNpc; | |
| 159 | + private L2Spawn blueFlagNpc; | |
| 160 | + private L2Spawn redHolderNpc; | |
| 161 | + private L2Spawn blueHolderNpc; | |
| 162 | + private int redFlagStatus; | |
| 163 | + private int blueFlagStatus; | |
| 164 | + private L2PcInstance playerWithRedFlag; | |
| 165 | + private L2PcInstance playerWithBlueFlag; | |
| 166 | + | |
| 167 | + public CTF() | |
| 168 | + {
| |
| 169 | + super(); | |
| 170 | + eventId = 10; | |
| 171 | + createNewTeam(1, "Blue", getColor("Blue"), getPosition("Blue", 1));
| |
| 172 | + createNewTeam(2, "Red", getColor("Red"), getPosition("Red", 1));
| |
| 173 | + task = new Core(); | |
| 174 | + winnerTeam = 0; | |
| 175 | + playerWithRedFlag = null; | |
| 176 | + playerWithBlueFlag = null; | |
| 177 | + blueFlagStatus = 0; | |
| 178 | + redFlagStatus = 0; | |
| 179 | + | |
| 180 | + } | |
| 181 | + | |
| 182 | + @Override | |
| 183 | + protected void endEvent() | |
| 184 | + {
| |
| 185 | + winnerTeam = players.head().getNext().getValue()[0]; | |
| 186 | + | |
| 187 | + setStatus(EventState.END); | |
| 188 | + clock.setTime(0); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + private void equipFlag(L2PcInstance player, int flag) | |
| 193 | + {
| |
| 194 | + L2ItemInstance wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND); | |
| 195 | + if (wpn != null) | |
| 196 | + player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND); | |
| 197 | + | |
| 198 | + wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND); | |
| 199 | + if (wpn != null) | |
| 200 | + player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_LHAND); | |
| 201 | + | |
| 202 | + player.getInventory().equipItem(ItemTable.getInstance().createItem("", 6718, 1, player, null));
| |
| 203 | + player.broadcastPacket(new SocialAction(player.getObjectId(), 16)); | |
| 204 | + switch (flag) | |
| 205 | + {
| |
| 206 | + case 1: | |
| 207 | + playerWithBlueFlag = player; | |
| 208 | + announce(getPlayerList(), player.getName() + " took the Blue flag!"); | |
| 209 | + unspawnNPC(blueFlagNpc); | |
| 210 | + break; | |
| 211 | + case 2: | |
| 212 | + playerWithRedFlag = player; | |
| 213 | + announce(getPlayerList(), player.getName() + " took the Red flag!"); | |
| 214 | + unspawnNPC(redFlagNpc); | |
| 215 | + break; | |
| 216 | + default: | |
| 217 | + break; | |
| 218 | + } | |
| 219 | + player.broadcastUserInfo(); | |
| 220 | + CreatureSay cs = new CreatureSay(player.getObjectId(), 15, ":", "You got it! Run back! ::"); // 8D | |
| 221 | + player.sendPacket(cs); | |
| 222 | + } | |
| 223 | + | |
| 224 | + @Override | |
| 225 | + protected String getScorebar() | |
| 226 | + {
| |
| 227 | + return "" + teams.get(1).getName() + ": " + teams.get(1).getScore() + " " + teams.get(2).getName() + ": " + teams.get(2).getScore() + " Time: " + clock.getTime(); | |
| 228 | + } | |
| 229 | + | |
| 230 | + @Override | |
| 231 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 232 | + {
| |
| 233 | + super.onDie(victim, killer); | |
| 234 | + if (playerWithRedFlag == victim) | |
| 235 | + {
| |
| 236 | + announce(getPlayerList(), victim.getName() + " dropped the Red flag!"); | |
| 237 | + redFlagStatus = 2; | |
| 238 | + unequipFlag(victim); | |
| 239 | + redFlagNpc = spawnNPC(victim.getX(), victim.getY(), victim.getZ(), getInt("redFlagId"));
| |
| 240 | + } | |
| 241 | + if (playerWithBlueFlag == victim) | |
| 242 | + {
| |
| 243 | + announce(getPlayerList(), victim.getName() + " dropped the Blue flag!"); | |
| 244 | + blueFlagStatus = 2; | |
| 245 | + unequipFlag(victim); | |
| 246 | + blueFlagNpc = spawnNPC(victim.getX(), victim.getY(), victim.getZ(), getInt("blueFlagId"));
| |
| 247 | + } | |
| 248 | + | |
| 249 | + addToResurrector(victim); | |
| 250 | + } | |
| 251 | + | |
| 252 | + @Override | |
| 253 | + public void onLogout(L2PcInstance player) | |
| 254 | + {
| |
| 255 | + super.onLogout(player); | |
| 256 | + | |
| 257 | + if (playerWithRedFlag == player) | |
| 258 | + {
| |
| 259 | + announce(getPlayerList(), player.getName() + " dropped the Red flag!"); | |
| 260 | + redFlagStatus = 2; | |
| 261 | + unequipFlag(player); | |
| 262 | + redFlagNpc = spawnNPC(player.getX(), player.getY(), player.getZ(), getInt("redFlagId"));
| |
| 263 | + } | |
| 264 | + if (playerWithBlueFlag == player) | |
| 265 | + {
| |
| 266 | + announce(getPlayerList(), player.getName() + " dropped the Blue flag!"); | |
| 267 | + blueFlagStatus = 2; | |
| 268 | + unequipFlag(player); | |
| 269 | + blueFlagNpc = spawnNPC(player.getX(), player.getY(), player.getZ(), getInt("blueFlagId"));
| |
| 270 | + } | |
| 271 | + | |
| 272 | + } | |
| 273 | + | |
| 274 | + @Override | |
| 275 | + public boolean onTalkNpc(L2NpcInstance npc, L2PcInstance player) | |
| 276 | + {
| |
| 277 | + if (!(npc.getNpcId() == getInt("blueFlagId") || npc.getNpcId() == getInt("blueFlagHolderId") || npc.getNpcId() == getInt("redFlagId") || npc.getNpcId() == getInt("redFlagHolderId")))
| |
| 278 | + return false; | |
| 279 | + | |
| 280 | + //Blue holder | |
| 281 | + if (npc.getNpcId() == getInt("blueFlagHolderId"))
| |
| 282 | + if (player == playerWithRedFlag && blueFlagStatus == 0) | |
| 283 | + {
| |
| 284 | + announce(getPlayerList(), "The Blue team scored!"); | |
| 285 | + teams.get(getTeam(player)).increaseScore(); | |
| 286 | + increasePlayersScore(player); | |
| 287 | + player.addItem("Event", 6392, 4, player, true);
| |
| 288 | + returnFlag(2); | |
| 289 | + } | |
| 290 | + | |
| 291 | + //Red holder | |
| 292 | + if (npc.getNpcId() == getInt("redFlagHolderId"))
| |
| 293 | + if (player == playerWithBlueFlag && redFlagStatus == 0) | |
| 294 | + {
| |
| 295 | + announce(getPlayerList(), "The Red team scored!"); | |
| 296 | + teams.get(getTeam(player)).increaseScore(); | |
| 297 | + increasePlayersScore(player); | |
| 298 | + player.addItem("Event", 6392, 4, player, true);
| |
| 299 | + returnFlag(1); | |
| 300 | + } | |
| 301 | + | |
| 302 | + //Blue flag | |
| 303 | + if (npc.getNpcId() == getInt("blueFlagId"))
| |
| 304 | + {
| |
| 305 | + if (blueFlagStatus == 2) | |
| 306 | + {
| |
| 307 | + //blue player | |
| 308 | + if (getTeam(player) == 1) | |
| 309 | + returnFlag(1); | |
| 310 | + | |
| 311 | + //red player | |
| 312 | + if (getTeam(player) == 2) | |
| 313 | + equipFlag(player, 1); | |
| 314 | + } | |
| 315 | + if (blueFlagStatus == 0) | |
| 316 | + if (getTeam(player) == 2) | |
| 317 | + {
| |
| 318 | + equipFlag(player, 1); | |
| 319 | + unspawnNPC(blueFlagNpc); | |
| 320 | + blueFlagStatus = 1; | |
| 321 | + } | |
| 322 | + | |
| 323 | + } | |
| 324 | + | |
| 325 | + //Red flag | |
| 326 | + if (npc.getNpcId() == getInt("redFlagId"))
| |
| 327 | + {
| |
| 328 | + if (redFlagStatus == 2) | |
| 329 | + {
| |
| 330 | + //red player | |
| 331 | + if (getTeam(player) == 2) | |
| 332 | + returnFlag(2); | |
| 333 | + | |
| 334 | + //blue player | |
| 335 | + if (getTeam(player) == 1) | |
| 336 | + equipFlag(player, 2); | |
| 337 | + } | |
| 338 | + if (redFlagStatus == 0) | |
| 339 | + if (getTeam(player) == 1) | |
| 340 | + {
| |
| 341 | + equipFlag(player, 2); | |
| 342 | + unspawnNPC(redFlagNpc); | |
| 343 | + redFlagStatus = 1; | |
| 344 | + } | |
| 345 | + } | |
| 346 | + return true; | |
| 347 | + } | |
| 348 | + | |
| 349 | + @Override | |
| 350 | + public boolean onUseItem(L2PcInstance player, L2ItemInstance item) | |
| 351 | + {
| |
| 352 | + if (playerWithRedFlag == player || playerWithBlueFlag == player) | |
| 353 | + return false; | |
| 354 | + | |
| 355 | + if (item.getItemType() == L2EtcItemType.POTION) | |
| 356 | + return false; | |
| 357 | + | |
| 358 | + return true; | |
| 359 | + } | |
| 360 | + | |
| 361 | + private void returnFlag(int flag) | |
| 362 | + {
| |
| 363 | + int[] pos; | |
| 364 | + switch (flag) | |
| 365 | + {
| |
| 366 | + case 1: | |
| 367 | + if (playerWithBlueFlag != null) | |
| 368 | + unequipFlag(playerWithBlueFlag); | |
| 369 | + if (blueFlagStatus == 2) | |
| 370 | + unspawnNPC(blueFlagNpc); | |
| 371 | + | |
| 372 | + pos = getPosition("BlueFlag", 1);
| |
| 373 | + blueFlagNpc = spawnNPC(pos[0], pos[1], pos[2], getInt("blueFlagId"));
| |
| 374 | + blueFlagStatus = 0; | |
| 375 | + announce(getPlayerList(), "The Blue flag returned!"); | |
| 376 | + break; | |
| 377 | + | |
| 378 | + case 2: | |
| 379 | + if (playerWithRedFlag != null) | |
| 380 | + unequipFlag(playerWithRedFlag); | |
| 381 | + if (redFlagStatus == 2) | |
| 382 | + unspawnNPC(redFlagNpc); | |
| 383 | + | |
| 384 | + pos = getPosition("RedFlag", 1);
| |
| 385 | + redFlagNpc = spawnNPC(pos[0], pos[1], pos[2], getInt("redFlagId"));
| |
| 386 | + redFlagStatus = 0; | |
| 387 | + announce(getPlayerList(), "The Red flag returned!"); | |
| 388 | + break; | |
| 389 | + } | |
| 390 | + } | |
| 391 | + | |
| 392 | + @Override | |
| 393 | + protected void schedule(int time) | |
| 394 | + {
| |
| 395 | + tpm.scheduleGeneral(task, time); | |
| 396 | + } | |
| 397 | + | |
| 398 | + private void setStatus(EventState s) | |
| 399 | + {
| |
| 400 | + eventState = s; | |
| 401 | + } | |
| 402 | + | |
| 403 | + @Override | |
| 404 | + protected void showHtml(L2PcInstance player, int obj) | |
| 405 | + {
| |
| 406 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 407 | + TextBuilder sb = new TextBuilder(); | |
| 408 | + | |
| 409 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 410 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 411 | + sb.append("<center><table width=270><tr><td><center><font color=" + teams.get(1).getHexaColor() + ">" + teams.get(1).getScore() + "</font> - " + "<font color=" + teams.get(2).getHexaColor() + ">" + teams.get(2).getScore() + "</font></td></tr></table>");
| |
| 412 | + sb.append("<br><table width=270>");
| |
| 413 | + int i = 0; | |
| 414 | + for (EventTeam team : teams.values()) | |
| 415 | + {
| |
| 416 | + i++; | |
| 417 | + sb.append("<tr><td><font color=" + team.getHexaColor() + ">" + team.getName() + "</font> team</td><td></td><td></td><td></td></tr>");
| |
| 418 | + for (L2PcInstance p : getPlayersOfTeam(i)) | |
| 419 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 420 | + } | |
| 421 | + | |
| 422 | + sb.append("</table></body></html>");
| |
| 423 | + html.setHtml(sb.toString()); | |
| 424 | + player.sendPacket(html); | |
| 425 | + | |
| 426 | + } | |
| 427 | + | |
| 428 | + private void spawnFlagsAndHolders() | |
| 429 | + {
| |
| 430 | + int[] pos = getPosition("BlueFlag", 1);
| |
| 431 | + blueFlagNpc = spawnNPC(pos[0], pos[1], pos[2], getInt("blueFlagId"));
| |
| 432 | + blueHolderNpc = spawnNPC(pos[0]+50, pos[1], pos[2], getInt("blueFlagHolderId"));
| |
| 433 | + | |
| 434 | + pos = getPosition("RedFlag", 1);
| |
| 435 | + redFlagNpc = spawnNPC(pos[0], pos[1], pos[2], getInt("redFlagId"));
| |
| 436 | + redHolderNpc = spawnNPC(pos[0]+50, pos[1], pos[2], getInt("redFlagHolderId"));
| |
| 437 | + debug("The flags spawned.");
| |
| 438 | + } | |
| 439 | + | |
| 440 | + @Override | |
| 441 | + protected void start() | |
| 442 | + {
| |
| 443 | + setStatus(EventState.START); | |
| 444 | + schedule(1); | |
| 445 | + } | |
| 446 | + | |
| 447 | + private void unequipFlag(L2PcInstance player) | |
| 448 | + {
| |
| 449 | + L2ItemInstance wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND); | |
| 450 | + if (wpn != null) | |
| 451 | + {
| |
| 452 | + L2ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()); | |
| 453 | + player.getInventory().destroyItemByItemId("", 6718, 1, player, null);
| |
| 454 | + InventoryUpdate iu = new InventoryUpdate(); | |
| 455 | + for (L2ItemInstance element : unequiped) | |
| 456 | + iu.addModifiedItem(element); | |
| 457 | + player.sendPacket(iu); | |
| 458 | + player.sendPacket(new ItemList(player, true)); | |
| 459 | + player.broadcastUserInfo(); | |
| 460 | + } | |
| 461 | + | |
| 462 | + if (player == playerWithRedFlag) | |
| 463 | + playerWithRedFlag = null; | |
| 464 | + if (player == playerWithBlueFlag) | |
| 465 | + playerWithBlueFlag = null; | |
| 466 | + } | |
| 467 | + | |
| 468 | + private void unspawnFlagsAndHolders() | |
| 469 | + {
| |
| 470 | + unspawnNPC(blueFlagNpc); | |
| 471 | + unspawnNPC(blueHolderNpc); | |
| 472 | + unspawnNPC(redFlagNpc); | |
| 473 | + unspawnNPC(redHolderNpc); | |
| 474 | + } | |
| 475 | +} | |
| 476 | \ No newline at end of file | |
| 477 | Index: head-src/com/l2jfrozen/gameserver/network/serverpackets/CharInfo.java | |
| 478 | =================================================================== | |
| 479 | --- head-src/com/l2jfrozen/gameserver/network/serverpackets/CharInfo.java (revision 936) | |
| 480 | +++ head-src/com/l2jfrozen/gameserver/network/serverpackets/CharInfo.java (working copy) | |
| 481 | @@ -22,12 +22,15 @@ | |
| 482 | import java.util.logging.Logger; | |
| 483 | ||
| 484 | import com.l2jfrozen.Config; | |
| 485 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 486 | import com.l2jfrozen.gameserver.datatables.sql.NpcTable; | |
| 487 | import com.l2jfrozen.gameserver.managers.CursedWeaponsManager; | |
| 488 | import com.l2jfrozen.gameserver.model.Inventory; | |
| 489 | import com.l2jfrozen.gameserver.model.L2Character; | |
| 490 | import com.l2jfrozen.gameserver.model.actor.instance.L2CubicInstance; | |
| 491 | import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 492 | +import com.l2jfrozen.gameserver.event.LMS; | |
| 493 | +import com.l2jfrozen.gameserver.event.dm; | |
| 494 | import com.l2jfrozen.gameserver.templates.L2NpcTemplate; | |
| 495 | ||
| 496 | /** | |
| 497 | @@ -80,6 +83,8 @@ | |
| 498 | private int _runSpd, _walkSpd, _swimRunSpd, _swimWalkSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd; | |
| 499 | private float _moveMultiplier, _attackSpeedMultiplier; | |
| 500 | private int _maxCp; | |
| 501 | + private boolean _isInLMS; | |
| 502 | + private boolean _isInDM; | |
| 503 | ||
| 504 | /** | |
| 505 | * @param cha | |
| 506 | @@ -101,6 +106,8 @@ | |
| 507 | _swimRunSpd = _flRunSpd = _flyRunSpd = _runSpd; | |
| 508 | _swimWalkSpd = _flWalkSpd = _flyWalkSpd = _walkSpd; | |
| 509 | _maxCp = _activeChar.getMaxCp(); | |
| 510 | + _isInLMS = EventManager.getInstance().isRegistered(_activeChar) && EventManager.getInstance().getCurrentEvent() instanceof LMS; | |
| 511 | + _isInDM = EventManager.getInstance().isRegistered(_activeChar) && EventManager.getInstance().getCurrentEvent() instanceof dm; | |
| 512 | } | |
| 513 | ||
| 514 | @Override | |
| 515 | @@ -163,7 +170,15 @@ | |
| 516 | // writeC(_activeChar.getAppearance().getInvisible() ? 1 : 0); // invisible ?? 0=false 1=true 2=summoned (only works if model has a summon animation) | |
| 517 | //} | |
| 518 | ||
| 519 | - writeS(_activeChar.getName()); | |
| 520 | + if(_isInLMS || _isInDM) | |
| 521 | + {
| |
| 522 | + writeS("Player");
| |
| 523 | + } | |
| 524 | + else | |
| 525 | + {
| |
| 526 | + writeS(_activeChar.getName()); | |
| 527 | + } | |
| 528 | + //->writeS(_activeChar.getName()); | |
| 529 | ||
| 530 | if(_activeChar.getAppearance().getInvisible()) | |
| 531 | //if(gmSeeInvis) | |
| 532 | @@ -208,7 +223,14 @@ | |
| 533 | writeD(_z); | |
| 534 | writeD(_heading); | |
| 535 | writeD(_activeChar.getObjectId()); | |
| 536 | - writeS(_activeChar.getName()); | |
| 537 | + if(_isInLMS || _isInDM) | |
| 538 | + {
| |
| 539 | + writeS("Player");
| |
| 540 | + } | |
| 541 | + else | |
| 542 | + {
| |
| 543 | + writeS(_activeChar.getName()); | |
| 544 | + } | |
| 545 | writeD(_activeChar.getRace().ordinal()); | |
| 546 | writeD(_activeChar.getAppearance().getSex() ? 1 : 0); | |
| 547 | ||
| 548 | @@ -221,18 +243,36 @@ | |
| 549 | writeD(_activeChar.getBaseClass()); | |
| 550 | } | |
| 551 | ||
| 552 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DHAIR)); | |
| 553 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD)); | |
| 554 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND)); | |
| 555 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND)); | |
| 556 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES)); | |
| 557 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST)); | |
| 558 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS)); | |
| 559 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET)); | |
| 560 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_BACK)); | |
| 561 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND)); | |
| 562 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR)); | |
| 563 | - writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FACE)); | |
| 564 | + if(_isInLMS || _isInDM) | |
| 565 | + {
| |
| 566 | + writeD(0); | |
| 567 | + writeD(0); | |
| 568 | + writeD(0); | |
| 569 | + writeD(0); | |
| 570 | + writeD(0); | |
| 571 | + writeD(6408); | |
| 572 | + writeD(0); | |
| 573 | + writeD(0); | |
| 574 | + writeD(0); | |
| 575 | + writeD(0); | |
| 576 | + writeD(0); | |
| 577 | + writeD(0); | |
| 578 | + } | |
| 579 | + else | |
| 580 | + {
| |
| 581 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DHAIR)); | |
| 582 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD)); | |
| 583 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND)); | |
| 584 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND)); | |
| 585 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES)); | |
| 586 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST)); | |
| 587 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS)); | |
| 588 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET)); | |
| 589 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_BACK)); | |
| 590 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND)); | |
| 591 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR)); | |
| 592 | + writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FACE)); | |
| 593 | + } | |
| 594 | ||
| 595 | // c6 new h's | |
| 596 | writeH(0x00); | |
| 597 | @@ -294,10 +334,20 @@ | |
| 598 | writeS(_activeChar.getTitle()); | |
| 599 | } | |
| 600 | ||
| 601 | - writeD(_activeChar.getClanId()); | |
| 602 | - writeD(_activeChar.getClanCrestId()); | |
| 603 | - writeD(_activeChar.getAllyId()); | |
| 604 | - writeD(_activeChar.getAllyCrestId()); | |
| 605 | + if(_isInLMS || _isInDM) | |
| 606 | + {
| |
| 607 | + writeD(0); | |
| 608 | + writeD(0); | |
| 609 | + writeD(0); | |
| 610 | + writeD(0); | |
| 611 | + } | |
| 612 | + else | |
| 613 | + {
| |
| 614 | + writeD(_activeChar.getClanId()); | |
| 615 | + writeD(_activeChar.getClanCrestId()); | |
| 616 | + writeD(_activeChar.getAllyId()); | |
| 617 | + writeD(_activeChar.getAllyCrestId()); | |
| 618 | + } | |
| 619 | // In UserInfo leader rights and siege flags, but here found nothing?? | |
| 620 | // Therefore RelationChanged packet with that info is required | |
| 621 | writeD(0); | |
| 622 | Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java | |
| 623 | =================================================================== | |
| 624 | --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (revision 936) | |
| 625 | +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (working copy) | |
| 626 | @@ -19,6 +19,7 @@ | |
| 627 | import com.l2jfrozen.Config; | |
| 628 | import com.l2jfrozen.gameserver.communitybbs.Manager.RegionBBSManager; | |
| 629 | import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 630 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 631 | import com.l2jfrozen.gameserver.model.L2Party; | |
| 632 | import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 633 | import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad; | |
| 634 | @@ -90,6 +91,13 @@ | |
| 635 | player.sendPacket(SystemMessage.sendString("A superior power doesn't allow you to leave the event."));
| |
| 636 | return; | |
| 637 | } | |
| 638 | + | |
| 639 | + if(EventManager.getInstance().isRegistered(player) && !EventManager.getInstance().getBoolean("restartAllowed"))
| |
| 640 | + {
| |
| 641 | + player.sendMessage("You cannot logout while you are a participant in an event.");
| |
| 642 | + sendPacket(new ActionFailed()); | |
| 643 | + return; | |
| 644 | + } | |
| 645 | ||
| 646 | if(player.isInOlympiadMode() || Olympiad.getInstance().isRegistered(player)) | |
| 647 | {
| |
| 648 | Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java | |
| 649 | =================================================================== | |
| 650 | --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (revision 936) | |
| 651 | +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (working copy) | |
| 652 | @@ -138,7 +138,7 @@ | |
| 653 | import com.l2jfrozen.gameserver.model.entity.Duel; | |
| 654 | import com.l2jfrozen.gameserver.model.entity.event.CTF; | |
| 655 | import com.l2jfrozen.gameserver.model.entity.event.DM; | |
| 656 | -import com.l2jfrozen.gameserver.model.entity.event.L2Event; | |
| 657 | +//import com.l2jfrozen.gameserver.model.entity.event.L2Event; | |
| 658 | import com.l2jfrozen.gameserver.model.entity.event.TvT; | |
| 659 | import com.l2jfrozen.gameserver.model.entity.event.VIP; | |
| 660 | import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad; | |
| 661 | @@ -233,7 +233,7 @@ | |
| 662 | import com.l2jfrozen.util.Point3D; | |
| 663 | import com.l2jfrozen.util.database.L2DatabaseFactory; | |
| 664 | import com.l2jfrozen.util.random.Rnd; | |
| 665 | - | |
| 666 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 667 | ||
| 668 | /** | |
| 669 | * This class represents all player characters in the world. There is always a client-thread connected to this (except | |
| 670 | @@ -4545,7 +4545,7 @@ | |
| 671 | return; | |
| 672 | } | |
| 673 | ||
| 674 | - if(L2Event.active && eventSitForced) | |
| 675 | + if (EventManager.getInstance().isRunning() && eventSitForced) | |
| 676 | {
| |
| 677 | sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ...");
| |
| 678 | } | |
| 679 | @@ -5883,6 +5883,11 @@ | |
| 680 | return; | |
| 681 | } | |
| 682 | } | |
| 683 | + if(!EventManager.getInstance().canTargetPlayer(this, player)) | |
| 684 | + {
| |
| 685 | + player.sendPacket(new ActionFailed()); | |
| 686 | + return; | |
| 687 | + } | |
| 688 | // Check if the L2PcInstance is confused | |
| 689 | if(player.isOutOfControl()) | |
| 690 | {
| |
| 691 | @@ -7296,6 +7301,19 @@ | |
| 692 | doPkInfo(pk); | |
| 693 | } | |
| 694 | } | |
| 695 | + | |
| 696 | + L2PcInstance ek = null; | |
| 697 | + | |
| 698 | + if (killer instanceof L2PcInstance) | |
| 699 | + ek = (L2PcInstance) killer; | |
| 700 | + if(killer instanceof L2Summon) | |
| 701 | + ek = ((L2Summon) killer).getOwner(); | |
| 702 | + | |
| 703 | + if(ek != null && EventManager.getInstance().isRunning() && EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRegistered(ek)) | |
| 704 | + {
| |
| 705 | + EventManager.getInstance().getCurrentEvent().onKill(this,ek); | |
| 706 | + EventManager.getInstance().getCurrentEvent().onDie(this,ek); | |
| 707 | + } | |
| 708 | ||
| 709 | if(atEvent && pk != null) | |
| 710 | {
| |
| 711 | @@ -7754,6 +7772,9 @@ | |
| 712 | // If in duel and you kill (only can kill l2summon), do nothing | |
| 713 | if(isInDuel() && targetPlayer.isInDuel()) | |
| 714 | return; | |
| 715 | + | |
| 716 | + if (EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRegistered(targetPlayer)) | |
| 717 | + return; | |
| 718 | ||
| 719 | // If in Arena, do nothing | |
| 720 | if(isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP)) | |
| 721 | @@ -8432,6 +8453,9 @@ | |
| 722 | ||
| 723 | if(isInsideZone(ZONE_PVP)) | |
| 724 | return; | |
| 725 | + | |
| 726 | + if(EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRunning()) | |
| 727 | + return; | |
| 728 | ||
| 729 | setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_NORMAL_TIME); | |
| 730 | ||
| 731 | @@ -8461,6 +8485,9 @@ | |
| 732 | ||
| 733 | if(player_target == null) | |
| 734 | return; | |
| 735 | + | |
| 736 | + if(EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRunning()) | |
| 737 | + return; | |
| 738 | ||
| 739 | if((TvT.is_started() && _inEventTvT && player_target._inEventTvT) || (DM.is_started() && _inEventDM && player_target._inEventDM) || (CTF.is_started() && _inEventCTF && player_target._inEventCTF) || (VIP._started && _inEventVIP && player_target._inEventVIP)) | |
| 740 | return; | |
| 741 | @@ -8579,6 +8606,9 @@ | |
| 742 | {
| |
| 743 | _log.fine(getName() + " died and lost " + lostExp + " experience."); | |
| 744 | } | |
| 745 | + | |
| 746 | + if(EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRunning()) | |
| 747 | + lostExp = 0; | |
| 748 | ||
| 749 | // Set the new Experience value of the L2PcInstance | |
| 750 | getStat().addExp(-lostExp); | |
| 751 | @@ -11818,6 +11848,9 @@ | |
| 752 | // Check if the L2PcInstance is in an arena or a siege area | |
| 753 | if(isInsideZone(ZONE_PVP) && ((L2PcInstance) attacker).isInsideZone(ZONE_PVP)) | |
| 754 | return true; | |
| 755 | + | |
| 756 | + if(EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRegistered((L2PcInstance)attacker) && EventManager.getInstance().isRunning()) | |
| 757 | + return true; | |
| 758 | ||
| 759 | if(getClan() != null) | |
| 760 | {
| |
| 761 | @@ -11907,6 +11940,17 @@ | |
| 762 | */ | |
| 763 | public void useMagic(L2Skill skill, boolean forceUse, boolean dontMove) | |
| 764 | {
| |
| 765 | + if(EventManager.getInstance().isRegistered(this)) | |
| 766 | + if(!EventManager.getInstance().getCurrentEvent().getBoolean("allowUseMagic"))
| |
| 767 | + {
| |
| 768 | + sendPacket(new ActionFailed()); | |
| 769 | + return; | |
| 770 | + } | |
| 771 | + | |
| 772 | + if(EventManager.getInstance().isRunning() && EventManager.getInstance().isRegistered(this)) | |
| 773 | + if(!EventManager.getInstance().getCurrentEvent().onUseMagic(skill)) | |
| 774 | + return; | |
| 775 | + | |
| 776 | if(isDead()) | |
| 777 | {
| |
| 778 | abortCast(); | |
| 779 | @@ -12617,6 +12661,9 @@ | |
| 780 | //SkillDat skilldatpet = getCurrentPetSkill(); | |
| 781 | if(skill.isPvpSkill()) // pvp skill | |
| 782 | {
| |
| 783 | + if(EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRegistered((L2PcInstance)target) && EventManager.getInstance().isRunning()) | |
| 784 | + return true; | |
| 785 | + | |
| 786 | if(getClan() != null && ((L2PcInstance)target).getClan() != null) | |
| 787 | {
| |
| 788 | if(getClan().isAtWarWith(((L2PcInstance)target).getClan().getClanId()) && ((L2PcInstance)target).getClan().isAtWarWith(getClan().getClanId())) | |
| 789 | @@ -12631,6 +12678,9 @@ | |
| 790 | else if ((skilldat != null && !skilldat.isCtrlPressed() && skill.isOffensive() && !srcIsSummon) | |
| 791 | /*|| (skilldatpet != null && !skilldatpet.isCtrlPressed() && skill.isOffensive() && srcIsSummon)*/) | |
| 792 | {
| |
| 793 | + if(EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRegistered((L2PcInstance)target) && EventManager.getInstance().isRunning()) | |
| 794 | + return true; | |
| 795 | + | |
| 796 | if(getClan() != null && ((L2PcInstance)target).getClan() != null) | |
| 797 | {
| |
| 798 | if(getClan().isAtWarWith(((L2PcInstance)target).getClan().getClanId()) && ((L2PcInstance)target).getClan().isAtWarWith(getClan().getClanId())) | |
| 799 | @@ -14855,6 +14905,9 @@ | |
| 800 | */ | |
| 801 | public synchronized boolean setActiveClass(int classIndex) | |
| 802 | {
| |
| 803 | + if(EventManager.getInstance().players.contains(this)) | |
| 804 | + return false; | |
| 805 | + | |
| 806 | if(isInCombat() || this.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK){
| |
| 807 | sendMessage("Impossible switch class if in combat");
| |
| 808 | sendPacket( ActionFailed.STATIC_PACKET ); | |
| 809 | @@ -16378,6 +16431,10 @@ | |
| 810 | setXYZ(_obsX, _obsY, _obsZ); | |
| 811 | } | |
| 812 | ||
| 813 | + EventManager.getInstance().onLogout(this); | |
| 814 | + if(EventManager.getInstance().isRegistered(this)) | |
| 815 | + EventManager.getInstance().getCurrentEvent().onLogout(this); | |
| 816 | + | |
| 817 | if(isTeleporting()) | |
| 818 | {
| |
| 819 | try | |
| 820 | @@ -17641,6 +17698,9 @@ | |
| 821 | {
| |
| 822 | if(getDeathPenaltyBuffLevel() >= 15) //maximum level reached | |
| 823 | return; | |
| 824 | + | |
| 825 | + if(EventManager.getInstance().isRegistered(this) && EventManager.getInstance().isRunning()) | |
| 826 | + return; | |
| 827 | ||
| 828 | if(getDeathPenaltyBuffLevel() != 0) | |
| 829 | {
| |
| 830 | Index: head-src/com/l2jfrozen/gameserver/event/Domination.java | |
| 831 | =================================================================== | |
| 832 | --- head-src/com/l2jfrozen/gameserver/event/Domination.java (revision 0) | |
| 833 | +++ head-src/com/l2jfrozen/gameserver/event/Domination.java (revision 0) | |
| 834 | @@ -0,0 +1,197 @@ | |
| 835 | +package com.l2jfrozen.gameserver.event; | |
| 836 | + | |
| 837 | +import javolution.text.TextBuilder; | |
| 838 | +import javolution.util.FastList; | |
| 839 | + | |
| 840 | +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable; | |
| 841 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 842 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 843 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 844 | + | |
| 845 | +public class Domination extends Event | |
| 846 | +{
| |
| 847 | + private class Core implements Runnable | |
| 848 | + {
| |
| 849 | + public void run() | |
| 850 | + {
| |
| 851 | + try | |
| 852 | + {
| |
| 853 | + switch (eventState) | |
| 854 | + {
| |
| 855 | + case START: | |
| 856 | + divideIntoTeams(2); | |
| 857 | + preparePlayers(); | |
| 858 | + teleportToTeamPos(); | |
| 859 | + createPartyOfTeam(1); | |
| 860 | + createPartyOfTeam(2); | |
| 861 | + forceSitAll(); | |
| 862 | + debug("The event started with " + players.size() + " player");
| |
| 863 | + setStatus(EventState.FIGHT); | |
| 864 | + schedule(20000); | |
| 865 | + break; | |
| 866 | + | |
| 867 | + case FIGHT: | |
| 868 | + forceStandAll(); | |
| 869 | + setStatus(EventState.END); | |
| 870 | + debug("The event started");
| |
| 871 | + clock.startClock(getInt("matchTime"));
| |
| 872 | + break; | |
| 873 | + | |
| 874 | + case END: | |
| 875 | + clock.setTime(0); | |
| 876 | + if (winnerTeam == 0) | |
| 877 | + winnerTeam = getWinnerTeam(); | |
| 878 | + | |
| 879 | + giveReward(getPlayersOfTeam(winnerTeam), getInt("rewardId"), getInt("rewardAmmount"));
| |
| 880 | + unSpawnZones(); | |
| 881 | + setStatus(EventState.INACTIVE); | |
| 882 | + debug("The event ended. Winner: " + winnerTeam);
| |
| 883 | + EventManager.getInstance().end("Congratulation! The " + teams.get(winnerTeam).getName() + " team won the event with " + teams.get(winnerTeam).getScore() + " Domination points!");
| |
| 884 | + break; | |
| 885 | + } | |
| 886 | + } | |
| 887 | + catch (Throwable e) | |
| 888 | + {
| |
| 889 | + e.printStackTrace(); | |
| 890 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 891 | + } | |
| 892 | + } | |
| 893 | + } | |
| 894 | + | |
| 895 | + private enum EventState | |
| 896 | + {
| |
| 897 | + START, FIGHT, END, INACTIVE | |
| 898 | + } | |
| 899 | + | |
| 900 | + private EventState eventState; | |
| 901 | + | |
| 902 | + private Core task; | |
| 903 | + | |
| 904 | + private FastList<L2Spawn> zones; | |
| 905 | + | |
| 906 | + public Domination() | |
| 907 | + {
| |
| 908 | + super(); | |
| 909 | + eventId = 2; | |
| 910 | + createNewTeam(1, "Blue", getColor("Blue"), getPosition("Blue", 1));
| |
| 911 | + createNewTeam(2, "Red", getColor("Red"), getPosition("Red", 1));
| |
| 912 | + task = new Core(); | |
| 913 | + zones = new FastList<L2Spawn>(); | |
| 914 | + winnerTeam = 0; | |
| 915 | + } | |
| 916 | + | |
| 917 | + @Override | |
| 918 | + protected void clockTick() | |
| 919 | + {
| |
| 920 | + int team1 = 0; | |
| 921 | + int team2 = 0; | |
| 922 | + | |
| 923 | + for (L2PcInstance player : getPlayerList()) | |
| 924 | + switch (getTeam(player)) | |
| 925 | + {
| |
| 926 | + case 1: | |
| 927 | + if (Math.sqrt(player.getPlanDistanceSq(zones.getFirst().getLastSpawn())) <= getInt("zoneRadius"))
| |
| 928 | + team1++; | |
| 929 | + break; | |
| 930 | + | |
| 931 | + case 2: | |
| 932 | + if (Math.sqrt(player.getPlanDistanceSq(zones.getFirst().getLastSpawn())) <= getInt("zoneRadius"))
| |
| 933 | + team2++; | |
| 934 | + break; | |
| 935 | + } | |
| 936 | + | |
| 937 | + if (team1 > team2) | |
| 938 | + {
| |
| 939 | + for (L2PcInstance player : getPlayersOfTeam(1)) | |
| 940 | + increasePlayersScore(player); | |
| 941 | + teams.get(1).increaseScore(); | |
| 942 | + } | |
| 943 | + | |
| 944 | + if (team2 > team1) | |
| 945 | + {
| |
| 946 | + for (L2PcInstance player : getPlayersOfTeam(2)) | |
| 947 | + increasePlayersScore(player); | |
| 948 | + teams.get(2).increaseScore(); | |
| 949 | + } | |
| 950 | + | |
| 951 | + } | |
| 952 | + | |
| 953 | + @Override | |
| 954 | + protected void endEvent() | |
| 955 | + {
| |
| 956 | + setStatus(EventState.END); | |
| 957 | + clock.setTime(0); | |
| 958 | + | |
| 959 | + } | |
| 960 | + | |
| 961 | + @Override | |
| 962 | + protected String getScorebar() | |
| 963 | + {
| |
| 964 | + return "" + teams.get(1).getName() + ": " + teams.get(1).getScore() + " " + teams.get(2).getName() + ": " + teams.get(2).getScore() + " Time: " + clock.getTime(); | |
| 965 | + } | |
| 966 | + | |
| 967 | + @Override | |
| 968 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 969 | + {
| |
| 970 | + super.onDie(victim, killer); | |
| 971 | + killer.addItem("Event", 6392, 1, killer, true);
| |
| 972 | + addToResurrector(victim); | |
| 973 | + } | |
| 974 | + | |
| 975 | + @Override | |
| 976 | + protected void schedule(int time) | |
| 977 | + {
| |
| 978 | + tpm.scheduleGeneral(task, time); | |
| 979 | + } | |
| 980 | + | |
| 981 | + private void setStatus(EventState s) | |
| 982 | + {
| |
| 983 | + eventState = s; | |
| 984 | + } | |
| 985 | + | |
| 986 | + @Override | |
| 987 | + protected void showHtml(L2PcInstance player, int obj) | |
| 988 | + {
| |
| 989 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 990 | + TextBuilder sb = new TextBuilder(); | |
| 991 | + | |
| 992 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 993 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 994 | + sb.append("<table width=270><tr><td><center><font color=" + teams.get(1).getHexaColor() + ">" + teams.get(1).getScore() + "</font> - " + "<font color=" + teams.get(2).getHexaColor() + ">" + teams.get(2).getScore() + "</font></td></tr></table>");
| |
| 995 | + sb.append("<br><table width=270>");
| |
| 996 | + int i = 0; | |
| 997 | + for (EventTeam team : teams.values()) | |
| 998 | + {
| |
| 999 | + i++; | |
| 1000 | + sb.append("<tr><td><font color=" + team.getHexaColor() + ">" + team.getName() + "</font> team</td><td></td><td></td><td></td></tr>");
| |
| 1001 | + for (L2PcInstance p : getPlayersOfTeam(i)) | |
| 1002 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 1003 | + } | |
| 1004 | + | |
| 1005 | + sb.append("</table></body></html>");
| |
| 1006 | + html.setHtml(sb.toString()); | |
| 1007 | + player.sendPacket(html); | |
| 1008 | + | |
| 1009 | + } | |
| 1010 | + | |
| 1011 | + @Override | |
| 1012 | + protected void start() | |
| 1013 | + {
| |
| 1014 | + int[] npcpos = getPosition("Zone", 1);
| |
| 1015 | + zones.add(spawnNPC(npcpos[0], npcpos[1], npcpos[2], getInt("zoneNpcId")));
| |
| 1016 | + setStatus(EventState.START); | |
| 1017 | + schedule(1); | |
| 1018 | + } | |
| 1019 | + | |
| 1020 | + private void unSpawnZones() | |
| 1021 | + {
| |
| 1022 | + for (L2Spawn s : zones) | |
| 1023 | + {
| |
| 1024 | + s.getLastSpawn().deleteMe(); | |
| 1025 | + s.stopRespawn(); | |
| 1026 | + SpawnTable.getInstance().deleteSpawn(s, true); | |
| 1027 | + zones.remove(s); | |
| 1028 | + } | |
| 1029 | + } | |
| 1030 | + | |
| 1031 | +} | |
| 1032 | \ No newline at end of file | |
| 1033 | Index: head-src/com/l2jfrozen/gameserver/GameServer.java | |
| 1034 | =================================================================== | |
| 1035 | --- head-src/com/l2jfrozen/gameserver/GameServer.java (revision 936) | |
| 1036 | +++ head-src/com/l2jfrozen/gameserver/GameServer.java (working copy) | |
| 1037 | @@ -74,6 +74,9 @@ | |
| 1038 | import com.l2jfrozen.gameserver.datatables.xml.AugmentationData; | |
| 1039 | import com.l2jfrozen.gameserver.datatables.xml.ExperienceData; | |
| 1040 | import com.l2jfrozen.gameserver.datatables.xml.ZoneData; | |
| 1041 | +import com.l2jfrozen.gameserver.event.EventBuffer; | |
| 1042 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 1043 | +import com.l2jfrozen.gameserver.event.EventStats; | |
| 1044 | import com.l2jfrozen.gameserver.geo.GeoData; | |
| 1045 | import com.l2jfrozen.gameserver.geo.geoeditorcon.GeoEditorListener; | |
| 1046 | import com.l2jfrozen.gameserver.geo.pathfinding.PathFinding; | |
| 1047 | @@ -118,7 +121,7 @@ | |
| 1048 | import com.l2jfrozen.gameserver.model.entity.Announcements; | |
| 1049 | import com.l2jfrozen.gameserver.model.entity.Hero; | |
| 1050 | import com.l2jfrozen.gameserver.model.entity.MonsterRace; | |
| 1051 | -import com.l2jfrozen.gameserver.model.entity.event.manager.EventManager; | |
| 1052 | +//import com.l2jfrozen.gameserver.model.entity.event.manager.EventManager; | |
| 1053 | import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad; | |
| 1054 | import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSigns; | |
| 1055 | import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival; | |
| 1056 | @@ -531,7 +534,7 @@ | |
| 1057 | else | |
| 1058 | _log.info("All custom mods are Disabled.");
| |
| 1059 | ||
| 1060 | - Util.printSection("EventManager");
| |
| 1061 | + /*Util.printSection("EventManager");
| |
| 1062 | EventManager.getInstance().startEventRegistration(); | |
| 1063 | ||
| 1064 | if(EventManager.TVT_EVENT_ENABLED || EventManager.CTF_EVENT_ENABLED || EventManager.DM_EVENT_ENABLED) | |
| 1065 | @@ -544,7 +547,7 @@ | |
| 1066 | _log.info("DM Event is Enabled.");
| |
| 1067 | } | |
| 1068 | else | |
| 1069 | - _log.info("All events are Disabled.");
| |
| 1070 | + _log.info("All events are Disabled.");*/
| |
| 1071 | ||
| 1072 | if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) | |
| 1073 | OfflineTradeTable.restoreOfflineTraders(); | |
| 1074 | @@ -555,6 +558,11 @@ | |
| 1075 | _log.info("Maximum Numbers of Connected Players: " + Config.MAXIMUM_ONLINE_USERS);
| |
| 1076 | _log.info("GameServer Started, free memory " + Memory.getFreeMemory() + " Mb of " + Memory.getTotalMemory() + " Mb");
| |
| 1077 | _log.info("Used memory: " + Memory.getUsedMemory() + " MB");
| |
| 1078 | + | |
| 1079 | + EventManager.getInstance(); | |
| 1080 | + EventStats.getInstance(); | |
| 1081 | + if(EventManager.getInstance().getBoolean("eventBufferEnabled"))
| |
| 1082 | + EventBuffer.getInstance(); | |
| 1083 | ||
| 1084 | Util.printSection("Status");
| |
| 1085 | System.gc(); | |
| 1086 | Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2EventManagerInstance.java | |
| 1087 | =================================================================== | |
| 1088 | --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2EventManagerInstance.java (revision 0) | |
| 1089 | +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2EventManagerInstance.java (revision 0) | |
| 1090 | @@ -0,0 +1,50 @@ | |
| 1091 | +package com.l2jfrozen.gameserver.model.actor.instance; | |
| 1092 | + | |
| 1093 | +import com.l2jfrozen.gameserver.templates.L2NpcTemplate; | |
| 1094 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 1095 | +import javolution.text.TextBuilder; | |
| 1096 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 1097 | + | |
| 1098 | +public class L2EventManagerInstance extends L2FolkInstance | |
| 1099 | +{
| |
| 1100 | +private int objectId; | |
| 1101 | + | |
| 1102 | + public L2EventManagerInstance(int objectId, L2NpcTemplate template) | |
| 1103 | + {
| |
| 1104 | + super(objectId, template); | |
| 1105 | + this.objectId = objectId; | |
| 1106 | + } | |
| 1107 | + | |
| 1108 | + @Override | |
| 1109 | + public void onBypassFeedback(L2PcInstance player, String command) | |
| 1110 | + {
| |
| 1111 | + if (command.startsWith("reg"))
| |
| 1112 | + {
| |
| 1113 | + EventManager.getInstance().registerPlayer(player); | |
| 1114 | + } | |
| 1115 | + if (command.startsWith("unreg"))
| |
| 1116 | + {
| |
| 1117 | + EventManager.getInstance().unregisterPlayer(player); | |
| 1118 | + } | |
| 1119 | + if (command.startsWith("list"))
| |
| 1120 | + {
| |
| 1121 | + NpcHtmlMessage html = new NpcHtmlMessage(getObjectId()); | |
| 1122 | + TextBuilder sb = new TextBuilder(); | |
| 1123 | + sb.append("<html><body><center>Select an event to vote for it:<br>");
| |
| 1124 | + | |
| 1125 | + int i = 0; | |
| 1126 | + for(String name: EventManager.getInstance().getEventNames()) | |
| 1127 | + {
| |
| 1128 | + i++; | |
| 1129 | + sb.append (" <a action=\"bypass -h npc_"+objectId+"_"+i+"\">- "+name+" -</a> <br>");
| |
| 1130 | + } | |
| 1131 | + sb.append("</center></body></html>");
| |
| 1132 | + html.setHtml(sb.toString()); | |
| 1133 | + player.sendPacket(html); | |
| 1134 | + } | |
| 1135 | + else | |
| 1136 | + {
| |
| 1137 | + EventManager.getInstance().addVote(player,Integer.parseInt(command)); | |
| 1138 | + } | |
| 1139 | + } | |
| 1140 | +} | |
| 1141 | \ No newline at end of file | |
| 1142 | Index: head-src/com/l2jfrozen/gameserver/event/EventConfig.java | |
| 1143 | =================================================================== | |
| 1144 | --- head-src/com/l2jfrozen/gameserver/event/EventConfig.java (revision 0) | |
| 1145 | +++ head-src/com/l2jfrozen/gameserver/event/EventConfig.java (revision 0) | |
| 1146 | @@ -0,0 +1,270 @@ | |
| 1147 | +package com.l2jfrozen.gameserver.event; | |
| 1148 | + | |
| 1149 | +import java.io.File; | |
| 1150 | +import java.util.StringTokenizer; | |
| 1151 | +import java.util.logging.Logger; | |
| 1152 | + | |
| 1153 | +import javax.xml.parsers.DocumentBuilder; | |
| 1154 | +import javax.xml.parsers.DocumentBuilderFactory; | |
| 1155 | + | |
| 1156 | +import javolution.util.FastList; | |
| 1157 | +import javolution.util.FastMap; | |
| 1158 | + | |
| 1159 | +import org.w3c.dom.Document; | |
| 1160 | +import org.w3c.dom.NamedNodeMap; | |
| 1161 | +import org.w3c.dom.Node; | |
| 1162 | + | |
| 1163 | +import com.l2jfrozen.util.random.Rnd; | |
| 1164 | + | |
| 1165 | +public class EventConfig | |
| 1166 | +{
| |
| 1167 | + | |
| 1168 | + @SuppressWarnings("synthetic-access")
| |
| 1169 | + private static class SingletonHolder | |
| 1170 | + {
| |
| 1171 | + protected static final EventConfig _instance = new EventConfig(); | |
| 1172 | + } | |
| 1173 | + | |
| 1174 | + public static EventConfig getInstance() | |
| 1175 | + {
| |
| 1176 | + return SingletonHolder._instance; | |
| 1177 | + } | |
| 1178 | + | |
| 1179 | + private Logger _log = Logger.getLogger(EventConfig.class.getName()); | |
| 1180 | + public FastMap<Integer, FastMap<String, String>> config; | |
| 1181 | + | |
| 1182 | + public FastMap<Integer, FastMap<String, FastMap<Integer, int[]>>> positions; | |
| 1183 | + | |
| 1184 | + public FastMap<Integer, FastMap<String, int[]>> colors; | |
| 1185 | + | |
| 1186 | + public FastMap<Integer, FastMap<String, FastList<Integer>>> restrictions; | |
| 1187 | + | |
| 1188 | + public EventConfig() | |
| 1189 | + {
| |
| 1190 | + config = new FastMap<Integer, FastMap<String, String>>(); | |
| 1191 | + positions = new FastMap<Integer, FastMap<String, FastMap<Integer, int[]>>>(); | |
| 1192 | + colors = new FastMap<Integer, FastMap<String, int[]>>(); | |
| 1193 | + restrictions = new FastMap<Integer, FastMap<String, FastList<Integer>>>(); | |
| 1194 | + loadConfigs(); | |
| 1195 | + } | |
| 1196 | + | |
| 1197 | + private void addColor(int id, String owner, int[] color) | |
| 1198 | + {
| |
| 1199 | + if (!colors.containsKey(id)) | |
| 1200 | + colors.put(id, new FastMap<String, int[]>()); | |
| 1201 | + | |
| 1202 | + colors.get(id).put(owner, color); | |
| 1203 | + } | |
| 1204 | + | |
| 1205 | + private void addPosition(int id, String owner, int x, int y, int z, int radius) | |
| 1206 | + {
| |
| 1207 | + | |
| 1208 | + if (!positions.containsKey(id)) | |
| 1209 | + positions.put(id, new FastMap<String, FastMap<Integer, int[]>>()); | |
| 1210 | + if (!positions.get(id).containsKey(owner)) | |
| 1211 | + positions.get(id).put(owner, new FastMap<Integer, int[]>()); | |
| 1212 | + | |
| 1213 | + positions.get(id).get(owner).put(positions.get(id).get(owner).size() + 1, new int[] { x, y, z, radius });
| |
| 1214 | + } | |
| 1215 | + | |
| 1216 | + private void addProperty(int id, String propName, String value) | |
| 1217 | + {
| |
| 1218 | + if (!config.containsKey(id)) | |
| 1219 | + config.put(id, new FastMap<String, String>()); | |
| 1220 | + | |
| 1221 | + config.get(id).put(propName, value); | |
| 1222 | + } | |
| 1223 | + | |
| 1224 | + private void addRestriction(int id, String type, String ids) | |
| 1225 | + {
| |
| 1226 | + if (!restrictions.containsKey(id)) | |
| 1227 | + restrictions.put(id, new FastMap<String, FastList<Integer>>()); | |
| 1228 | + | |
| 1229 | + FastList<Integer> idlist = new FastList<Integer>(); | |
| 1230 | + StringTokenizer st = new StringTokenizer(ids, ","); | |
| 1231 | + while (st.hasMoreTokens()) | |
| 1232 | + idlist.add(Integer.parseInt(st.nextToken())); | |
| 1233 | + | |
| 1234 | + restrictions.get(id).put(type, idlist); | |
| 1235 | + } | |
| 1236 | + | |
| 1237 | + public boolean getBoolean(int event, String propName) | |
| 1238 | + {
| |
| 1239 | + if (!(config.containsKey(event))) | |
| 1240 | + {
| |
| 1241 | + _log.warning("Event: Try to get a property of a non existing event: ID: " + event);
| |
| 1242 | + return false; | |
| 1243 | + } | |
| 1244 | + | |
| 1245 | + if (config.get(event).containsKey(propName)) | |
| 1246 | + return Boolean.parseBoolean(config.get(event).get(propName)); | |
| 1247 | + else | |
| 1248 | + {
| |
| 1249 | + _log.warning("Event: Try to get a non existing property: " + propName);
| |
| 1250 | + return false; | |
| 1251 | + } | |
| 1252 | + | |
| 1253 | + } | |
| 1254 | + | |
| 1255 | + public int[] getColor(int event, String owner) | |
| 1256 | + {
| |
| 1257 | + if (!(colors.containsKey(event))) | |
| 1258 | + {
| |
| 1259 | + _log.warning("Event: Try to get a color of a non existing event: ID: " + event);
| |
| 1260 | + return new int[] { 255, 255, 255 };
| |
| 1261 | + } | |
| 1262 | + | |
| 1263 | + if (colors.get(event).containsKey(owner)) | |
| 1264 | + return colors.get(event).get(owner); | |
| 1265 | + else | |
| 1266 | + {
| |
| 1267 | + _log.warning("Event: Try to get a non existing color: " + owner);
| |
| 1268 | + return new int[] { 255, 255, 255 };
| |
| 1269 | + } | |
| 1270 | + } | |
| 1271 | + | |
| 1272 | + public int getInt(int event, String propName) | |
| 1273 | + {
| |
| 1274 | + if (!(config.containsKey(event))) | |
| 1275 | + {
| |
| 1276 | + _log.warning("Event: Try to get a property of a non existing event: ID: " + event);
| |
| 1277 | + return -1; | |
| 1278 | + } | |
| 1279 | + | |
| 1280 | + if (config.get(event).containsKey(propName)) | |
| 1281 | + return Integer.parseInt(config.get(event).get(propName)); | |
| 1282 | + else | |
| 1283 | + {
| |
| 1284 | + _log.warning("Event: Try to get a non existing property: " + propName);
| |
| 1285 | + return -1; | |
| 1286 | + } | |
| 1287 | + } | |
| 1288 | + | |
| 1289 | + public int[] getPosition(int event, String owner, int num) | |
| 1290 | + {
| |
| 1291 | + if (!positions.containsKey(event)) | |
| 1292 | + {
| |
| 1293 | + _log.warning("Event: Try to get a position of a non existing event: ID: " + event);
| |
| 1294 | + return new int[] {};
| |
| 1295 | + } | |
| 1296 | + if (!positions.get(event).containsKey(owner)) | |
| 1297 | + {
| |
| 1298 | + _log.warning("Event: Try to get a position of a non existing owner: " + owner);
| |
| 1299 | + return new int[] {};
| |
| 1300 | + } | |
| 1301 | + if (!positions.get(event).get(owner).containsKey(num) && num != 0) | |
| 1302 | + {
| |
| 1303 | + _log.warning("Event: Try to get a non existing position: " + num);
| |
| 1304 | + return new int[] {};
| |
| 1305 | + } | |
| 1306 | + | |
| 1307 | + if (num == 0) | |
| 1308 | + return positions.get(event).get(owner).get(Rnd.get(positions.get(event).get(owner).size()) + 1); | |
| 1309 | + else | |
| 1310 | + return positions.get(event).get(owner).get(num); | |
| 1311 | + } | |
| 1312 | + | |
| 1313 | + public FastList<Integer> getRestriction(int event, String type) | |
| 1314 | + {
| |
| 1315 | + if (!(restrictions.containsKey(event))) | |
| 1316 | + {
| |
| 1317 | + _log.warning("Event: Try to get a restriction of a non existing event: ID: " + event);
| |
| 1318 | + return null; | |
| 1319 | + } | |
| 1320 | + if (restrictions.get(event).containsKey(type)) | |
| 1321 | + return restrictions.get(event).get(type); | |
| 1322 | + else | |
| 1323 | + {
| |
| 1324 | + _log.warning("Event: Try to get a non existing restriction: " + type);
| |
| 1325 | + return null; | |
| 1326 | + } | |
| 1327 | + } | |
| 1328 | + | |
| 1329 | + public String getString(int event, String propName) | |
| 1330 | + {
| |
| 1331 | + if (!(config.containsKey(event))) | |
| 1332 | + {
| |
| 1333 | + _log.warning("Event: Try to get a property of a non existing event: ID: " + event);
| |
| 1334 | + return null; | |
| 1335 | + } | |
| 1336 | + | |
| 1337 | + if (config.get(event).containsKey(propName)) | |
| 1338 | + return config.get(event).get(propName); | |
| 1339 | + else | |
| 1340 | + {
| |
| 1341 | + _log.warning("Event: Try to get a non existing property: " + propName);
| |
| 1342 | + return null; | |
| 1343 | + } | |
| 1344 | + | |
| 1345 | + } | |
| 1346 | + | |
| 1347 | + private void loadConfigs() | |
| 1348 | + {
| |
| 1349 | + File configFile = new File("./config/Events.xml");
| |
| 1350 | + Document doc = null; | |
| 1351 | + try | |
| 1352 | + {
| |
| 1353 | + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | |
| 1354 | + dbf.setIgnoringComments(true); | |
| 1355 | + dbf.setValidating(false); | |
| 1356 | + DocumentBuilder db = dbf.newDocumentBuilder(); | |
| 1357 | + doc = db.parse(configFile); | |
| 1358 | + | |
| 1359 | + for (Node root = doc.getFirstChild(); root != null; root = root.getNextSibling()) | |
| 1360 | + if ("events".equalsIgnoreCase(root.getNodeName()))
| |
| 1361 | + for (Node event = root.getFirstChild(); event != null; event = event.getNextSibling()) | |
| 1362 | + if ("event".equalsIgnoreCase(event.getNodeName()))
| |
| 1363 | + {
| |
| 1364 | + NamedNodeMap eventAttrs = event.getAttributes(); | |
| 1365 | + int eventId = Integer.parseInt(eventAttrs.getNamedItem("id").getNodeValue());
| |
| 1366 | + | |
| 1367 | + for (Node property = event.getFirstChild(); property != null; property = property.getNextSibling()) | |
| 1368 | + {
| |
| 1369 | + | |
| 1370 | + if ("property".equalsIgnoreCase(property.getNodeName()))
| |
| 1371 | + {
| |
| 1372 | + NamedNodeMap propAttrs = property.getAttributes(); | |
| 1373 | + String name = propAttrs.getNamedItem("name").getNodeValue();
| |
| 1374 | + String value = propAttrs.getNamedItem("value").getNodeValue();
| |
| 1375 | + addProperty(eventId, name, value); | |
| 1376 | + } | |
| 1377 | + | |
| 1378 | + if ("position".equalsIgnoreCase(property.getNodeName()))
| |
| 1379 | + {
| |
| 1380 | + NamedNodeMap propAttrs = property.getAttributes(); | |
| 1381 | + String owner = propAttrs.getNamedItem("owner").getNodeValue();
| |
| 1382 | + String x = propAttrs.getNamedItem("x").getNodeValue();
| |
| 1383 | + String y = propAttrs.getNamedItem("y").getNodeValue();
| |
| 1384 | + String z = propAttrs.getNamedItem("z").getNodeValue();
| |
| 1385 | + String radius = propAttrs.getNamedItem("radius").getNodeValue();
| |
| 1386 | + addPosition(eventId, owner, Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z), Integer.parseInt(radius)); | |
| 1387 | + | |
| 1388 | + } | |
| 1389 | + | |
| 1390 | + if ("color".equalsIgnoreCase(property.getNodeName()))
| |
| 1391 | + {
| |
| 1392 | + NamedNodeMap propAttrs = property.getAttributes(); | |
| 1393 | + String owner = propAttrs.getNamedItem("owner").getNodeValue();
| |
| 1394 | + int r = Integer.parseInt(propAttrs.getNamedItem("r").getNodeValue());
| |
| 1395 | + int g = Integer.parseInt(propAttrs.getNamedItem("g").getNodeValue());
| |
| 1396 | + int b = Integer.parseInt(propAttrs.getNamedItem("b").getNodeValue());
| |
| 1397 | + addColor(eventId, owner, new int[] { r, g, b });
| |
| 1398 | + } | |
| 1399 | + | |
| 1400 | + if ("restriction".equalsIgnoreCase(property.getNodeName()))
| |
| 1401 | + {
| |
| 1402 | + NamedNodeMap propAttrs = property.getAttributes(); | |
| 1403 | + String type = propAttrs.getNamedItem("type").getNodeValue();
| |
| 1404 | + String ids = propAttrs.getNamedItem("ids").getNodeValue();
| |
| 1405 | + addRestriction(eventId, type, ids); | |
| 1406 | + } | |
| 1407 | + } | |
| 1408 | + } | |
| 1409 | + } | |
| 1410 | + catch (Exception e) | |
| 1411 | + {
| |
| 1412 | + | |
| 1413 | + } | |
| 1414 | + | |
| 1415 | + } | |
| 1416 | +} | |
| 1417 | \ No newline at end of file | |
| 1418 | Index: head-src/com/l2jfrozen/gameserver/event/Event.java | |
| 1419 | =================================================================== | |
| 1420 | --- head-src/com/l2jfrozen/gameserver/event/Event.java (revision 0) | |
| 1421 | +++ head-src/com/l2jfrozen/gameserver/event/Event.java (revision 0) | |
| 1422 | @@ -0,0 +1,696 @@ | |
| 1423 | +package com.l2jfrozen.gameserver.event; | |
| 1424 | + | |
| 1425 | +import java.util.Set; | |
| 1426 | + | |
| 1427 | +import javolution.util.FastList; | |
| 1428 | +import javolution.util.FastMap; | |
| 1429 | + | |
| 1430 | +import com.l2jfrozen.gameserver.thread.ThreadPoolManager; | |
| 1431 | +import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 1432 | +import com.l2jfrozen.gameserver.datatables.sql.NpcTable; | |
| 1433 | +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable; | |
| 1434 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 1435 | +import com.l2jfrozen.gameserver.model.L2Object; | |
| 1436 | +import com.l2jfrozen.gameserver.model.L2Party; | |
| 1437 | +import com.l2jfrozen.gameserver.model.L2Skill; | |
| 1438 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 1439 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 1440 | +import com.l2jfrozen.gameserver.model.L2Summon; | |
| 1441 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 1442 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance; | |
| 1443 | +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay; | |
| 1444 | +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage; | |
| 1445 | +import com.l2jfrozen.gameserver.network.serverpackets.Ride; | |
| 1446 | +import com.l2jfrozen.gameserver.templates.L2NpcTemplate; | |
| 1447 | +import com.l2jfrozen.gameserver.templates.L2EtcItemType; | |
| 1448 | +import com.l2jfrozen.gameserver.util.Broadcast; | |
| 1449 | +import com.l2jfrozen.util.random.Rnd; | |
| 1450 | + | |
| 1451 | +/** | |
| 1452 | + * @author Rizel | |
| 1453 | + * | |
| 1454 | + */ | |
| 1455 | +public abstract class Event | |
| 1456 | +{
| |
| 1457 | + protected class Clock implements Runnable | |
| 1458 | + {
| |
| 1459 | + protected String getTime() | |
| 1460 | + {
| |
| 1461 | + String mins = "" + time / 60; | |
| 1462 | + String secs = (time % 60 < 10 ? "0" + time % 60 : "" + time % 60); | |
| 1463 | + return "" + mins + ":" + secs + ""; | |
| 1464 | + } | |
| 1465 | + | |
| 1466 | + public void run() | |
| 1467 | + {
| |
| 1468 | + clockTick(); | |
| 1469 | + scorebartext = getScorebar(); | |
| 1470 | + for (L2PcInstance player : getPlayerList()) | |
| 1471 | + player.sendPacket(new ExShowScreenMessage(1, -1, 2, false, 1, 0, 0, false, 2000, false, scorebartext)); | |
| 1472 | + | |
| 1473 | + if (time <= 0) | |
| 1474 | + schedule(1); | |
| 1475 | + else | |
| 1476 | + {
| |
| 1477 | + time--; | |
| 1478 | + tpm.scheduleGeneral(clock, 1000); | |
| 1479 | + } | |
| 1480 | + } | |
| 1481 | + | |
| 1482 | + protected void setTime(int t) | |
| 1483 | + {
| |
| 1484 | + time = t; | |
| 1485 | + } | |
| 1486 | + | |
| 1487 | + protected void startClock(int mt) | |
| 1488 | + {
| |
| 1489 | + time = mt; | |
| 1490 | + tpm.scheduleGeneral(clock, 1); | |
| 1491 | + } | |
| 1492 | + } | |
| 1493 | + | |
| 1494 | + protected class ResurrectorTask implements Runnable | |
| 1495 | + {
| |
| 1496 | + private L2PcInstance player; | |
| 1497 | + | |
| 1498 | + public ResurrectorTask(L2PcInstance p) | |
| 1499 | + {
| |
| 1500 | + player = p; | |
| 1501 | + ThreadPoolManager.getInstance().scheduleGeneral(this, 7000); | |
| 1502 | + debug("Resurrector task created: " + player.getName());
| |
| 1503 | + } | |
| 1504 | + | |
| 1505 | + public void run() | |
| 1506 | + {
| |
| 1507 | + if (EventManager.getInstance().isRegistered(player)) | |
| 1508 | + {
| |
| 1509 | + debug("Resurrector task executed: " + player.getName());
| |
| 1510 | + player.doRevive(); | |
| 1511 | + | |
| 1512 | + if(EventManager.getInstance().getBoolean("eventBufferEnabled"))
| |
| 1513 | + EventBuffer.getInstance().buffPlayer(player); | |
| 1514 | + | |
| 1515 | + player.setCurrentCp(player.getMaxCp()); | |
| 1516 | + player.setCurrentHp(player.getMaxHp()); | |
| 1517 | + player.setCurrentMp(player.getMaxMp()); | |
| 1518 | + teleportToTeamPos(player); | |
| 1519 | + } | |
| 1520 | + | |
| 1521 | + } | |
| 1522 | + } | |
| 1523 | + | |
| 1524 | + protected int eventId; | |
| 1525 | + | |
| 1526 | + //Config | |
| 1527 | + protected EventConfig config = EventConfig.getInstance(); | |
| 1528 | + | |
| 1529 | + protected static int[] startpos = EventManager.npcPos; | |
| 1530 | + | |
| 1531 | + protected FastMap<Integer, EventTeam> teams; | |
| 1532 | + | |
| 1533 | + //TEAM-STATUS-SCORE | |
| 1534 | + protected FastMap<L2PcInstance, int[]> players; | |
| 1535 | + | |
| 1536 | + protected ThreadPoolManager tpm; | |
| 1537 | + | |
| 1538 | + protected ResurrectorTask resurrectorTask; | |
| 1539 | + | |
| 1540 | + private String scorebartext; | |
| 1541 | + | |
| 1542 | + protected Clock clock; | |
| 1543 | + | |
| 1544 | + protected int time; | |
| 1545 | + | |
| 1546 | + protected int winnerTeam; | |
| 1547 | + | |
| 1548 | + protected int loserTeam; | |
| 1549 | + | |
| 1550 | + public Event() | |
| 1551 | + {
| |
| 1552 | + teams = new FastMap<Integer, EventTeam>(); | |
| 1553 | + clock = new Clock(); | |
| 1554 | + tpm = ThreadPoolManager.getInstance(); | |
| 1555 | + players = new FastMap<L2PcInstance, int[]>(); | |
| 1556 | + time = 0; | |
| 1557 | + } | |
| 1558 | + | |
| 1559 | + protected void addToResurrector(L2PcInstance player) | |
| 1560 | + {
| |
| 1561 | + new ResurrectorTask(player); | |
| 1562 | + } | |
| 1563 | + | |
| 1564 | + protected void announce(Set<L2PcInstance> list, String text) | |
| 1565 | + {
| |
| 1566 | + for (L2PcInstance player : list) | |
| 1567 | + player.sendPacket(new CreatureSay(0, 18, "", "[Event] " + text)); | |
| 1568 | + } | |
| 1569 | + | |
| 1570 | + public boolean canAttack(L2PcInstance player, L2Object target) | |
| 1571 | + {
| |
| 1572 | + return true; | |
| 1573 | + } | |
| 1574 | + | |
| 1575 | + protected void clockTick() | |
| 1576 | + {
| |
| 1577 | + | |
| 1578 | + } | |
| 1579 | + | |
| 1580 | + protected int countOfPositiveStatus() | |
| 1581 | + {
| |
| 1582 | + int count = 0; | |
| 1583 | + for (L2PcInstance player : getPlayerList()) | |
| 1584 | + if (getStatus(player) >= 0) | |
| 1585 | + count++; | |
| 1586 | + | |
| 1587 | + return count; | |
| 1588 | + } | |
| 1589 | + | |
| 1590 | + protected void createNewTeam(int id, String name, int[] color, int[] startPos) | |
| 1591 | + {
| |
| 1592 | + teams.put(id, new EventTeam(id, name, color, startPos)); | |
| 1593 | + } | |
| 1594 | + | |
| 1595 | + protected void createPartyOfTeam(int teamId) | |
| 1596 | + {
| |
| 1597 | + int count = 0; | |
| 1598 | + L2Party party = null; | |
| 1599 | + | |
| 1600 | + FastList<L2PcInstance> list = new FastList<L2PcInstance>(); | |
| 1601 | + | |
| 1602 | + for (L2PcInstance p : players.keySet()) | |
| 1603 | + if (getTeam(p) == teamId) | |
| 1604 | + list.add(p); | |
| 1605 | + | |
| 1606 | + for (L2PcInstance player : list) | |
| 1607 | + {
| |
| 1608 | + if (count % 9 == 0 && list.size() - count != 1) | |
| 1609 | + party = new L2Party(player, 1); | |
| 1610 | + if (count % 9 < 9) | |
| 1611 | + player.joinParty(party); | |
| 1612 | + count++; | |
| 1613 | + } | |
| 1614 | + } | |
| 1615 | + | |
| 1616 | + protected void debug(String text) | |
| 1617 | + {
| |
| 1618 | + EventManager.getInstance().debug(text); | |
| 1619 | + } | |
| 1620 | + | |
| 1621 | + protected void divideIntoTeams(int number) | |
| 1622 | + {
| |
| 1623 | + int i = 0; | |
| 1624 | + while (EventManager.getInstance().players.size() != 0) | |
| 1625 | + {
| |
| 1626 | + i++; | |
| 1627 | + L2PcInstance player = EventManager.getInstance().players.get(Rnd.get(EventManager.getInstance().players.size())); | |
| 1628 | + players.put(player, new int[] { i, 0, 0 });
| |
| 1629 | + EventManager.getInstance().players.remove(player); | |
| 1630 | + if (i == number) | |
| 1631 | + i = 0; | |
| 1632 | + } | |
| 1633 | + } | |
| 1634 | + | |
| 1635 | + public void dropBomb(L2PcInstance player) | |
| 1636 | + {
| |
| 1637 | + | |
| 1638 | + } | |
| 1639 | + | |
| 1640 | + protected abstract void endEvent(); | |
| 1641 | + | |
| 1642 | + protected void forceSitAll() | |
| 1643 | + {
| |
| 1644 | + for (L2PcInstance player : players.keySet()) | |
| 1645 | + {
| |
| 1646 | + if (player.isCastingNow()) | |
| 1647 | + player.abortCast(); | |
| 1648 | + if (player.isAttackingNow()) | |
| 1649 | + player.abortAttack(); | |
| 1650 | + player.sitDown(); | |
| 1651 | + player.eventSitForced = true; | |
| 1652 | + } | |
| 1653 | + } | |
| 1654 | + | |
| 1655 | + protected void forceStandAll() | |
| 1656 | + {
| |
| 1657 | + for (L2PcInstance player : players.keySet()) | |
| 1658 | + {
| |
| 1659 | + player.eventSitForced = false; | |
| 1660 | + player.standUp(); | |
| 1661 | + } | |
| 1662 | + | |
| 1663 | + } | |
| 1664 | + | |
| 1665 | + public boolean getBoolean(String propName) | |
| 1666 | + {
| |
| 1667 | + return config.getBoolean(eventId, propName); | |
| 1668 | + } | |
| 1669 | + | |
| 1670 | + public int[] getColor(String owner) | |
| 1671 | + {
| |
| 1672 | + return config.getColor(eventId, owner); | |
| 1673 | + } | |
| 1674 | + | |
| 1675 | + public int getInt(String propName) | |
| 1676 | + {
| |
| 1677 | + return config.getInt(eventId, propName); | |
| 1678 | + } | |
| 1679 | + | |
| 1680 | + protected Set<L2PcInstance> getPlayerList() | |
| 1681 | + {
| |
| 1682 | + return players.keySet(); | |
| 1683 | + } | |
| 1684 | + | |
| 1685 | + protected FastList<L2PcInstance> getPlayersOfTeam(int team) | |
| 1686 | + {
| |
| 1687 | + FastList<L2PcInstance> list = new FastList<L2PcInstance>(); | |
| 1688 | + | |
| 1689 | + for (L2PcInstance player : getPlayerList()) | |
| 1690 | + if (getTeam(player) == team) | |
| 1691 | + list.add(player); | |
| 1692 | + | |
| 1693 | + return list; | |
| 1694 | + } | |
| 1695 | + | |
| 1696 | + protected EventTeam getPlayersTeam(L2PcInstance player) | |
| 1697 | + {
| |
| 1698 | + return teams.get(players.get(player)[0]); | |
| 1699 | + } | |
| 1700 | + | |
| 1701 | + protected FastList<L2PcInstance> getPlayersWithStatus(int status) | |
| 1702 | + {
| |
| 1703 | + FastList<L2PcInstance> list = new FastList<L2PcInstance>(); | |
| 1704 | + | |
| 1705 | + for (L2PcInstance player : getPlayerList()) | |
| 1706 | + if (getStatus(player) == status) | |
| 1707 | + list.add(player); | |
| 1708 | + | |
| 1709 | + return list; | |
| 1710 | + } | |
| 1711 | + | |
| 1712 | + protected L2PcInstance getPlayerWithMaxScore() | |
| 1713 | + {
| |
| 1714 | + L2PcInstance max; | |
| 1715 | + max = players.head().getNext().getKey(); | |
| 1716 | + for (L2PcInstance player : players.keySet()) | |
| 1717 | + if (players.get(player)[2] > players.get(max)[2]) | |
| 1718 | + max = player; | |
| 1719 | + | |
| 1720 | + return max; | |
| 1721 | + } | |
| 1722 | + | |
| 1723 | + protected void unequip(){
| |
| 1724 | + for (L2PcInstance player : players.keySet()) | |
| 1725 | + {
| |
| 1726 | + player.getInventory().unEquipItemInSlot(7); | |
| 1727 | + player.getInventory().unEquipItemInSlot(8); | |
| 1728 | + player.getInventory().unEquipItemInSlot(14); | |
| 1729 | + } | |
| 1730 | + } | |
| 1731 | + | |
| 1732 | + public int[] getPosition(String owner, int num) | |
| 1733 | + {
| |
| 1734 | + return config.getPosition(eventId, owner, num); | |
| 1735 | + } | |
| 1736 | + | |
| 1737 | + protected L2PcInstance getRandomPlayer() | |
| 1738 | + {
| |
| 1739 | + FastList<L2PcInstance> temp = new FastList<L2PcInstance>(); | |
| 1740 | + for (L2PcInstance player : players.keySet()) | |
| 1741 | + temp.add(player); | |
| 1742 | + | |
| 1743 | + return temp.get(Rnd.get(temp.size())); | |
| 1744 | + } | |
| 1745 | + | |
| 1746 | + protected L2PcInstance getRandomPlayerFromTeam(int team) | |
| 1747 | + {
| |
| 1748 | + FastList<L2PcInstance> temp = new FastList<L2PcInstance>(); | |
| 1749 | + for (L2PcInstance player : players.keySet()) | |
| 1750 | + if (getTeam(player) == team) | |
| 1751 | + temp.add(player); | |
| 1752 | + | |
| 1753 | + return temp.get(Rnd.get(temp.size())); | |
| 1754 | + } | |
| 1755 | + | |
| 1756 | + public FastList<Integer> getRestriction(String type) | |
| 1757 | + {
| |
| 1758 | + return config.getRestriction(eventId, type); | |
| 1759 | + } | |
| 1760 | + | |
| 1761 | + protected int getScore(L2PcInstance player) | |
| 1762 | + {
| |
| 1763 | + return players.get(player)[2]; | |
| 1764 | + } | |
| 1765 | + | |
| 1766 | + protected abstract String getScorebar(); | |
| 1767 | + | |
| 1768 | + protected int getStatus(L2PcInstance player) | |
| 1769 | + {
| |
| 1770 | + return players.get(player)[1]; | |
| 1771 | + } | |
| 1772 | + | |
| 1773 | + public String getString(String propName) | |
| 1774 | + {
| |
| 1775 | + return config.getString(eventId, propName); | |
| 1776 | + } | |
| 1777 | + | |
| 1778 | + public int getTeam(L2PcInstance player) | |
| 1779 | + {
| |
| 1780 | + return players.get(player)[0]; | |
| 1781 | + } | |
| 1782 | + | |
| 1783 | + protected int getWinnerTeam() | |
| 1784 | + {
| |
| 1785 | + FastList<EventTeam> t = new FastList<EventTeam>(); | |
| 1786 | + | |
| 1787 | + for (EventTeam team : teams.values()) | |
| 1788 | + {
| |
| 1789 | + if (t.size() == 0) | |
| 1790 | + {
| |
| 1791 | + t.add(team); | |
| 1792 | + continue; | |
| 1793 | + } | |
| 1794 | + | |
| 1795 | + if (team.getScore() > t.getFirst().getScore()) | |
| 1796 | + {
| |
| 1797 | + t.clear(); | |
| 1798 | + t.add(team); | |
| 1799 | + continue; | |
| 1800 | + } | |
| 1801 | + if (team.getScore() == t.getFirst().getScore()) | |
| 1802 | + t.add(team); | |
| 1803 | + | |
| 1804 | + } | |
| 1805 | + | |
| 1806 | + if (t.size() > 1) | |
| 1807 | + return t.get(Rnd.get(t.size())).getId(); | |
| 1808 | + else | |
| 1809 | + return t.getFirst().getId(); | |
| 1810 | + | |
| 1811 | + } | |
| 1812 | + | |
| 1813 | + protected void giveReward(FastList<L2PcInstance> players, int id, int ammount) | |
| 1814 | + {
| |
| 1815 | + for (L2PcInstance player : players) | |
| 1816 | + {
| |
| 1817 | + if(player == null) | |
| 1818 | + continue; | |
| 1819 | + | |
| 1820 | + player.addItem("Event", id, ammount, player, true);
| |
| 1821 | + EventStats.getInstance().tempTable.get(player.getObjectId())[0] = 1; | |
| 1822 | + } | |
| 1823 | + | |
| 1824 | + } | |
| 1825 | + | |
| 1826 | + protected void giveReward(L2PcInstance player, int id, int ammount) | |
| 1827 | + {
| |
| 1828 | + EventStats.getInstance().tempTable.get(player.getObjectId())[0] = 1; | |
| 1829 | + | |
| 1830 | + player.addItem("Event", id, ammount, player, true);
| |
| 1831 | + } | |
| 1832 | + | |
| 1833 | + protected void increasePlayersScore(L2PcInstance player) | |
| 1834 | + {
| |
| 1835 | + int old = getScore(player); | |
| 1836 | + setScore(player, old + 1); | |
| 1837 | + EventStats.getInstance().tempTable.get(player.getObjectId())[3] = EventStats.getInstance().tempTable.get(player.getObjectId())[3] + 1; | |
| 1838 | + } | |
| 1839 | + | |
| 1840 | + protected void msgToAll(String text) | |
| 1841 | + {
| |
| 1842 | + for (L2PcInstance player : players.keySet()) | |
| 1843 | + player.sendMessage(text); | |
| 1844 | + } | |
| 1845 | + | |
| 1846 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 1847 | + {
| |
| 1848 | + EventStats.getInstance().tempTable.get(victim.getObjectId())[2] = EventStats.getInstance().tempTable.get(victim.getObjectId())[2] + 1; | |
| 1849 | + return; | |
| 1850 | + } | |
| 1851 | + | |
| 1852 | + public void onHit(L2PcInstance actor, L2PcInstance target) | |
| 1853 | + {
| |
| 1854 | + } | |
| 1855 | + | |
| 1856 | + public void onKill(L2PcInstance victim, L2PcInstance killer) | |
| 1857 | + {
| |
| 1858 | + EventStats.getInstance().tempTable.get(killer.getObjectId())[1] = EventStats.getInstance().tempTable.get(killer.getObjectId())[1] + 1; | |
| 1859 | + return; | |
| 1860 | + } | |
| 1861 | + | |
| 1862 | + public void onLogout(L2PcInstance player) | |
| 1863 | + {
| |
| 1864 | + if (players.containsKey(player)) | |
| 1865 | + removePlayer(player); | |
| 1866 | + | |
| 1867 | + player.setXYZ(EventManager.getInstance().positions.get(player)[0], EventManager.getInstance().positions.get(player)[1], EventManager.getInstance().positions.get(player)[2]); | |
| 1868 | + player.setTitle(EventManager.getInstance().titles.get(player)); | |
| 1869 | + | |
| 1870 | + if (teams.size() == 1) | |
| 1871 | + if (getPlayerList().size() == 1) | |
| 1872 | + {
| |
| 1873 | + endEvent(); | |
| 1874 | + return; | |
| 1875 | + } | |
| 1876 | + | |
| 1877 | + if (teams.size() > 1) | |
| 1878 | + {
| |
| 1879 | + int t = players.head().getNext().getValue()[0]; | |
| 1880 | + for (L2PcInstance p : getPlayerList()) | |
| 1881 | + if (getTeam(p) != t) | |
| 1882 | + return; | |
| 1883 | + | |
| 1884 | + endEvent(); | |
| 1885 | + return; | |
| 1886 | + | |
| 1887 | + } | |
| 1888 | + } | |
| 1889 | + | |
| 1890 | + public void onSay(int type, L2PcInstance player, String text) | |
| 1891 | + {
| |
| 1892 | + return; | |
| 1893 | + } | |
| 1894 | + | |
| 1895 | + public boolean onTalkNpc(L2NpcInstance npc, L2PcInstance player) | |
| 1896 | + {
| |
| 1897 | + return false; | |
| 1898 | + } | |
| 1899 | + | |
| 1900 | + public boolean onUseItem(L2PcInstance player, L2ItemInstance item) | |
| 1901 | + {
| |
| 1902 | + if (EventManager.getInstance().getRestriction("item").contains(item.getItemId()) || getRestriction("item").contains(item.getItemId()))
| |
| 1903 | + return false; | |
| 1904 | + | |
| 1905 | + if (item.getItemType() == L2EtcItemType.POTION && !getBoolean("allowPotions"))
| |
| 1906 | + return false; | |
| 1907 | + | |
| 1908 | + if (item.getItemType() == L2EtcItemType.SCROLL) | |
| 1909 | + return false; | |
| 1910 | + | |
| 1911 | + return true; | |
| 1912 | + } | |
| 1913 | + | |
| 1914 | + public boolean onUseMagic(L2Skill skill) | |
| 1915 | + {
| |
| 1916 | + if (EventManager.getInstance().getRestriction("skill").contains(skill.getId()) || getRestriction("skill").contains(skill.getId()))
| |
| 1917 | + return false; | |
| 1918 | + | |
| 1919 | + if (skill.getSkillType() == L2Skill.SkillType.RESURRECT) | |
| 1920 | + return false; | |
| 1921 | + | |
| 1922 | + if (skill.getSkillType() == L2Skill.SkillType.SUMMON_FRIEND) | |
| 1923 | + return false; | |
| 1924 | + | |
| 1925 | + if (skill.getSkillType() == L2Skill.SkillType.RECALL) | |
| 1926 | + return false; | |
| 1927 | + | |
| 1928 | + if (skill.getSkillType() == L2Skill.SkillType.FAKE_DEATH) | |
| 1929 | + return false; | |
| 1930 | + | |
| 1931 | + return true; | |
| 1932 | + } | |
| 1933 | + | |
| 1934 | + protected void prepare(L2PcInstance player) | |
| 1935 | + {
| |
| 1936 | + if (player.isCastingNow()) | |
| 1937 | + player.abortCast(); | |
| 1938 | + player.getAppearance().setVisible(); | |
| 1939 | + | |
| 1940 | + if (player.getPet() != null) | |
| 1941 | + {
| |
| 1942 | + L2Summon summon = player.getPet(); | |
| 1943 | + if (summon instanceof L2PetInstance) | |
| 1944 | + summon.unSummon(player); | |
| 1945 | + } | |
| 1946 | + | |
| 1947 | + if(player.isMounted()) | |
| 1948 | + {
| |
| 1949 | + if(player.setMountType(0)) | |
| 1950 | + {
| |
| 1951 | + if(player.isFlying()) | |
| 1952 | + {
| |
| 1953 | + player.removeSkill(SkillTable.getInstance().getInfo(4289, 1)); | |
| 1954 | + } | |
| 1955 | + Ride dismount = new Ride(player.getObjectId(), Ride.ACTION_DISMOUNT, 0); | |
| 1956 | + Broadcast.toSelfAndKnownPlayers(player, dismount); | |
| 1957 | + player.setMountObjectID(0); | |
| 1958 | + dismount = null; | |
| 1959 | + } | |
| 1960 | + } | |
| 1961 | + | |
| 1962 | + if (getBoolean("removeBuffs"))
| |
| 1963 | + {
| |
| 1964 | + player.stopAllEffects(); | |
| 1965 | + if (player.getPet() != null) | |
| 1966 | + {
| |
| 1967 | + L2Summon summon = player.getPet(); | |
| 1968 | + if (summon instanceof L2Summon) | |
| 1969 | + summon.unSummon(player); | |
| 1970 | + } | |
| 1971 | + } | |
| 1972 | + | |
| 1973 | + if (player.getParty() != null) | |
| 1974 | + {
| |
| 1975 | + L2Party party = player.getParty(); | |
| 1976 | + party.removePartyMember(player); | |
| 1977 | + } | |
| 1978 | + int[] nameColor = getPlayersTeam(player).getTeamColor(); | |
| 1979 | + player.getAppearance().setNameColor(nameColor[0], nameColor[1], nameColor[2]); | |
| 1980 | + player.setTitle("<- 0 ->");
| |
| 1981 | + | |
| 1982 | + if(EventManager.getInstance().getBoolean("eventBufferEnabled"))
| |
| 1983 | + EventBuffer.getInstance().buffPlayer(player); | |
| 1984 | + | |
| 1985 | + player.broadcastUserInfo(); | |
| 1986 | + } | |
| 1987 | + | |
| 1988 | + protected void preparePlayers() | |
| 1989 | + {
| |
| 1990 | + for (L2PcInstance player : players.keySet()) | |
| 1991 | + prepare(player); | |
| 1992 | + } | |
| 1993 | + | |
| 1994 | + protected void removePlayer(L2PcInstance player) | |
| 1995 | + {
| |
| 1996 | + players.remove(player); | |
| 1997 | + } | |
| 1998 | + | |
| 1999 | + public void reset() | |
| 2000 | + {
| |
| 2001 | + players.clear(); | |
| 2002 | + tpm.purge(); | |
| 2003 | + winnerTeam = 0; | |
| 2004 | + | |
| 2005 | + for (EventTeam team : teams.values()) | |
| 2006 | + team.setScore(0); | |
| 2007 | + | |
| 2008 | + debug("Event reseted");
| |
| 2009 | + } | |
| 2010 | + | |
| 2011 | + protected abstract void schedule(int time); | |
| 2012 | + | |
| 2013 | + protected void selectPlayers(int teamId, int playerCount) | |
| 2014 | + {
| |
| 2015 | + for (int i = 0; i < playerCount; i++) | |
| 2016 | + {
| |
| 2017 | + L2PcInstance player = EventManager.getInstance().players.get(Rnd.get(EventManager.getInstance().players.size())); | |
| 2018 | + players.put(player, new int[] { teamId, 0, 0 });
| |
| 2019 | + EventManager.getInstance().players.remove(player); | |
| 2020 | + } | |
| 2021 | + | |
| 2022 | + } | |
| 2023 | + | |
| 2024 | + protected void setScore(L2PcInstance player, int score) | |
| 2025 | + {
| |
| 2026 | + players.get(player)[2] = score; | |
| 2027 | + player.setTitle("<- " + score + " ->");
| |
| 2028 | + player.broadcastUserInfo(); | |
| 2029 | + } | |
| 2030 | + | |
| 2031 | + protected void setStatus(L2PcInstance player, int status) | |
| 2032 | + {
| |
| 2033 | + if (players.containsKey(player)) | |
| 2034 | + players.get(player)[1] = status; | |
| 2035 | + } | |
| 2036 | + | |
| 2037 | + protected void setTeam(L2PcInstance player, int team) | |
| 2038 | + {
| |
| 2039 | + players.get(player)[0] = team; | |
| 2040 | + } | |
| 2041 | + | |
| 2042 | + protected abstract void showHtml(L2PcInstance player, int obj); | |
| 2043 | + | |
| 2044 | + protected L2Spawn spawnNPC(int xPos, int yPos, int zPos, int npcId) | |
| 2045 | + {
| |
| 2046 | + final L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId); | |
| 2047 | + try | |
| 2048 | + {
| |
| 2049 | + final L2Spawn spawn = new L2Spawn(template); | |
| 2050 | + spawn.setLocx(xPos); | |
| 2051 | + spawn.setLocy(yPos); | |
| 2052 | + spawn.setLocz(zPos); | |
| 2053 | + spawn.setAmount(1); | |
| 2054 | + spawn.setHeading(0); | |
| 2055 | + spawn.setRespawnDelay(1); | |
| 2056 | + SpawnTable.getInstance().addNewSpawn(spawn, false); | |
| 2057 | + spawn.init(); | |
| 2058 | + return spawn; | |
| 2059 | + } | |
| 2060 | + catch (Exception e) | |
| 2061 | + {
| |
| 2062 | + return null; | |
| 2063 | + } | |
| 2064 | + } | |
| 2065 | + | |
| 2066 | + protected abstract void start(); | |
| 2067 | + | |
| 2068 | + protected void teleportPlayer(L2PcInstance player, int[] coordinates) | |
| 2069 | + {
| |
| 2070 | + player.teleToLocation(coordinates[0] + (Rnd.get(coordinates[3] * 2) - coordinates[3]), coordinates[1] + (Rnd.get(coordinates[3] * 2) - coordinates[3]), coordinates[2]); | |
| 2071 | + } | |
| 2072 | + | |
| 2073 | + protected void teleportToTeamPos() | |
| 2074 | + {
| |
| 2075 | + for (L2PcInstance player : players.keySet()) | |
| 2076 | + {
| |
| 2077 | + teleportToTeamPos(player); | |
| 2078 | + } | |
| 2079 | + | |
| 2080 | + } | |
| 2081 | + | |
| 2082 | + protected void teleportToTeamPos(L2PcInstance player) | |
| 2083 | + {
| |
| 2084 | + int[] pos = getPosition(teams.get(getTeam(player)).getName(), 0); | |
| 2085 | + teleportPlayer(player, pos); | |
| 2086 | + } | |
| 2087 | + | |
| 2088 | + protected void unspawnNPC(L2Spawn npcSpawn) | |
| 2089 | + {
| |
| 2090 | + if (npcSpawn == null) | |
| 2091 | + return; | |
| 2092 | + | |
| 2093 | + npcSpawn.getLastSpawn().deleteMe(); | |
| 2094 | + npcSpawn.stopRespawn(); | |
| 2095 | + SpawnTable.getInstance().deleteSpawn(npcSpawn, true); | |
| 2096 | + } | |
| 2097 | + | |
| 2098 | + public int numberOfTeams() | |
| 2099 | + {
| |
| 2100 | + return teams.size(); | |
| 2101 | + } | |
| 2102 | + | |
| 2103 | + public void useCapture(L2PcInstance player, L2NpcInstance base){}
| |
| 2104 | + | |
| 2105 | + protected void polymorph(L2PcInstance player, int id) | |
| 2106 | + {
| |
| 2107 | + player.getPoly().setPolyInfo("", String.valueOf(id));
| |
| 2108 | + player.decayMe(); | |
| 2109 | + player.spawnMe(player.getX(),player.getY(),player.getZ()); | |
| 2110 | + } | |
| 2111 | + | |
| 2112 | + protected void unpolymorph(L2PcInstance player) | |
| 2113 | + {
| |
| 2114 | + player.getPoly().setPolyInfo(null, "1"); | |
| 2115 | + player.decayMe(); | |
| 2116 | + player.spawnMe(player.getX(),player.getY(),player.getZ()); | |
| 2117 | + } | |
| 2118 | +} | |
| 2119 | \ No newline at end of file | |
| 2120 | Index: head-src/com/l2jfrozen/gameserver/event/EventBuffer.java | |
| 2121 | =================================================================== | |
| 2122 | --- head-src/com/l2jfrozen/gameserver/event/EventBuffer.java (revision 0) | |
| 2123 | +++ head-src/com/l2jfrozen/gameserver/event/EventBuffer.java (revision 0) | |
| 2124 | @@ -0,0 +1,315 @@ | |
| 2125 | +/* | |
| 2126 | + * This program is free software: you can redistribute it and/or modify it under | |
| 2127 | + * the terms of the GNU General Public License as published by the Free Software | |
| 2128 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 2129 | + * version. | |
| 2130 | + * | |
| 2131 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 2132 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 2133 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 2134 | + * details. | |
| 2135 | + * | |
| 2136 | + * You should have received a copy of the GNU General Public License along with | |
| 2137 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 2138 | + */ | |
| 2139 | +package com.l2jfrozen.gameserver.event; | |
| 2140 | + | |
| 2141 | +import java.sql.Connection; | |
| 2142 | +import java.sql.PreparedStatement; | |
| 2143 | +import java.sql.ResultSet; | |
| 2144 | +import java.util.Map; | |
| 2145 | +import java.util.StringTokenizer; | |
| 2146 | + | |
| 2147 | +import javolution.text.TextBuilder; | |
| 2148 | +import javolution.util.FastList; | |
| 2149 | +import javolution.util.FastMap; | |
| 2150 | + | |
| 2151 | +import com.l2jfrozen.util.database.L2DatabaseFactory; | |
| 2152 | +import com.l2jfrozen.gameserver.thread.ThreadPoolManager; | |
| 2153 | +import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 2154 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 2155 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 2156 | + | |
| 2157 | +/** | |
| 2158 | + * @author Rizel | |
| 2159 | + * | |
| 2160 | + */ | |
| 2161 | +public class EventBuffer | |
| 2162 | +{
| |
| 2163 | + private static class SingletonHolder | |
| 2164 | + {
| |
| 2165 | + protected static final EventBuffer _instance = new EventBuffer(); | |
| 2166 | + } | |
| 2167 | + private class UpdateTask implements Runnable | |
| 2168 | + {
| |
| 2169 | + public void run() | |
| 2170 | + {
| |
| 2171 | + updateSQL(); | |
| 2172 | + } | |
| 2173 | + } | |
| 2174 | + public static EventBuffer getInstance() | |
| 2175 | + {
| |
| 2176 | + return SingletonHolder._instance; | |
| 2177 | + } | |
| 2178 | + | |
| 2179 | + private FastMap<String, FastList<Integer>> buffTemplates; | |
| 2180 | + | |
| 2181 | + private FastMap<String, Boolean> changes; | |
| 2182 | + | |
| 2183 | + private UpdateTask updateTask; | |
| 2184 | + | |
| 2185 | + public EventBuffer() | |
| 2186 | + {
| |
| 2187 | + updateTask = new UpdateTask(); | |
| 2188 | + changes = new FastMap<String, Boolean>(); | |
| 2189 | + buffTemplates = new FastMap<String, FastList<Integer>>(); | |
| 2190 | + loadSQL(); | |
| 2191 | + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(updateTask, 600000, 600000); | |
| 2192 | + } | |
| 2193 | + | |
| 2194 | + protected void buffPlayer(L2PcInstance player) | |
| 2195 | + {
| |
| 2196 | + boolean bss = player.checkBss(); | |
| 2197 | + boolean sps = player.checkSps(); | |
| 2198 | + boolean ss = player.checkSs(); | |
| 2199 | + | |
| 2200 | + String playerId = "" + player.getObjectId() + player.getClassIndex(); | |
| 2201 | + | |
| 2202 | + if(!buffTemplates.containsKey(playerId)) | |
| 2203 | + {
| |
| 2204 | + EventManager.getInstance().debug("The player : "+player.getName()+" ("+playerId+") without template");
| |
| 2205 | + return; | |
| 2206 | + } | |
| 2207 | + | |
| 2208 | + for (int skillId : buffTemplates.get(playerId)) | |
| 2209 | + SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId,1)).getEffects(player, player, ss, sps, bss); | |
| 2210 | + } | |
| 2211 | + | |
| 2212 | + public void changeList(L2PcInstance player, int buff, boolean action) | |
| 2213 | + {
| |
| 2214 | + String playerId = "" + player.getObjectId() + player.getClassIndex(); | |
| 2215 | + | |
| 2216 | + if (!buffTemplates.containsKey(playerId)) | |
| 2217 | + {
| |
| 2218 | + buffTemplates.put(playerId, new FastList<Integer>()); | |
| 2219 | + changes.put(playerId, true); | |
| 2220 | + } | |
| 2221 | + else | |
| 2222 | + {
| |
| 2223 | + if (!changes.containsKey(playerId)) | |
| 2224 | + changes.put(playerId, false); | |
| 2225 | + | |
| 2226 | + if (action) | |
| 2227 | + buffTemplates.get(playerId).add(buff); | |
| 2228 | + else | |
| 2229 | + buffTemplates.get(playerId).remove(buffTemplates.get(playerId).indexOf(buff)); | |
| 2230 | + | |
| 2231 | + } | |
| 2232 | + | |
| 2233 | + } | |
| 2234 | + | |
| 2235 | + private void loadSQL() | |
| 2236 | + {
| |
| 2237 | + if (!EventManager.getInstance().getBoolean("eventBufferEnabled"))
| |
| 2238 | + return; | |
| 2239 | + | |
| 2240 | + Connection con = null; | |
| 2241 | + PreparedStatement statement = null; | |
| 2242 | + try | |
| 2243 | + {
| |
| 2244 | + con = L2DatabaseFactory.getInstance().getConnection(); | |
| 2245 | + statement = con.prepareStatement("SELECT * FROM event_buffs");
| |
| 2246 | + ResultSet rset = statement.executeQuery(); | |
| 2247 | + int count = 0; | |
| 2248 | + while (rset.next()) | |
| 2249 | + {
| |
| 2250 | + count++; | |
| 2251 | + | |
| 2252 | + buffTemplates.put(rset.getString("player"), new FastList<Integer>());
| |
| 2253 | + | |
| 2254 | + StringTokenizer st = new StringTokenizer(rset.getString("buffs"), ",");
| |
| 2255 | + | |
| 2256 | + FastList<Integer> templist = new FastList<Integer>(); | |
| 2257 | + | |
| 2258 | + while (st.hasMoreTokens()) | |
| 2259 | + templist.add(Integer.parseInt(st.nextToken())); | |
| 2260 | + | |
| 2261 | + buffTemplates.getEntry(rset.getString("player")).setValue(templist);
| |
| 2262 | + } | |
| 2263 | + rset.close(); | |
| 2264 | + statement.close(); | |
| 2265 | + | |
| 2266 | + EventManager.getInstance().debug("Buffer loaded: " + count + " players template.");
| |
| 2267 | + } | |
| 2268 | + catch (Exception e) | |
| 2269 | + {
| |
| 2270 | + System.out.println("EventBuffs SQL catch");
| |
| 2271 | + } | |
| 2272 | + finally | |
| 2273 | + {
| |
| 2274 | + try { con.close(); } catch (Exception e) {}
| |
| 2275 | + } | |
| 2276 | + } | |
| 2277 | + | |
| 2278 | + protected boolean playerHaveTemplate(L2PcInstance player) | |
| 2279 | + {
| |
| 2280 | + String playerId = "" + player.getObjectId() + player.getClassIndex(); | |
| 2281 | + | |
| 2282 | + if (buffTemplates.containsKey(playerId)) | |
| 2283 | + return true; | |
| 2284 | + else | |
| 2285 | + return false; | |
| 2286 | + } | |
| 2287 | + | |
| 2288 | + public void showHtml(L2PcInstance player) | |
| 2289 | + {
| |
| 2290 | + try{
| |
| 2291 | + String playerId = "" + player.getObjectId() + player.getClassIndex(); | |
| 2292 | + | |
| 2293 | + if (!buffTemplates.containsKey(playerId)) | |
| 2294 | + {
| |
| 2295 | + buffTemplates.put(playerId, new FastList<Integer>()); | |
| 2296 | + changes.put(playerId, true); | |
| 2297 | + } | |
| 2298 | + | |
| 2299 | + StringTokenizer st = new StringTokenizer(EventManager.getInstance().getString("allowedBuffsList"), ",");
| |
| 2300 | + | |
| 2301 | + FastList<Integer> skillList = new FastList<Integer>(); | |
| 2302 | + | |
| 2303 | + while (st.hasMoreTokens()) | |
| 2304 | + skillList.add(Integer.parseInt(st.nextToken())); | |
| 2305 | + | |
| 2306 | + NpcHtmlMessage html = new NpcHtmlMessage(0); | |
| 2307 | + TextBuilder sb = new TextBuilder(); | |
| 2308 | + | |
| 2309 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 2310 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Edit Buffs</td><td width=80></td><td width=120>Remaining slots: " + (EventManager.getInstance().getInt("maxBuffNum") - buffTemplates.get(playerId).size()) + "</td></tr></table><br><br>");
| |
| 2311 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td>Added buffs:</td></tr></table><br>");
| |
| 2312 | + sb.append("<center><table width=270>");
| |
| 2313 | + | |
| 2314 | + int c = 0; | |
| 2315 | + for (int skillId : buffTemplates.get(playerId)) | |
| 2316 | + {
| |
| 2317 | + c++; | |
| 2318 | + String skillStr = "0000"; | |
| 2319 | + if (skillId < 100) | |
| 2320 | + skillStr = "00" + skillId; | |
| 2321 | + else if (skillId > 99 && skillId < 1000) | |
| 2322 | + skillStr = "0" + skillId; | |
| 2323 | + else if (skillId > 4698 && skillId < 4701) | |
| 2324 | + skillStr = "1331"; | |
| 2325 | + else if (skillId > 4701 && skillId < 4704) | |
| 2326 | + skillStr = "1332"; | |
| 2327 | + else | |
| 2328 | + skillStr = "" + skillId; | |
| 2329 | + | |
| 2330 | + if (c % 2 == 1) | |
| 2331 | + sb.append("<tr><td width=33><img src=\"Icon.skill" + skillStr + "\" width=32 height=32></td><td width=100><a action=\"bypass -h eventbuffer " + skillId + " 0\">" + SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId,1)).getName() + "</a></td>");
| |
| 2332 | + if (c % 2 == 0) | |
| 2333 | + sb.append("<td width=33><img src=\"Icon.skill" + skillStr + "\" width=32 height=32></td><td width=100><a action=\"bypass -h eventbuffer " + skillId + " 0\">" + SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId,1)).getName() + "</a></td></tr>");
| |
| 2334 | + } | |
| 2335 | + | |
| 2336 | + if (c % 2 == 1) | |
| 2337 | + sb.append("<td width=33></td><td width=100></td></tr>");
| |
| 2338 | + | |
| 2339 | + sb.append("</table><br>");
| |
| 2340 | + | |
| 2341 | + sb.append("<br><br><center><table width=270 bgcolor=5A5A5A><tr><td>Available buffs:</td></tr></table><br>");
| |
| 2342 | + sb.append("<center><table width=270>");
| |
| 2343 | + | |
| 2344 | + c = 0; | |
| 2345 | + for (int skillId : skillList) | |
| 2346 | + {
| |
| 2347 | + String skillStr = "0000"; | |
| 2348 | + if (skillId < 100) | |
| 2349 | + skillStr = "00" + skillId; | |
| 2350 | + else if (skillId > 99 && skillId < 1000) | |
| 2351 | + skillStr = "0" + skillId; | |
| 2352 | + else if (skillId > 4698 && skillId < 4701) | |
| 2353 | + skillStr = "1331"; | |
| 2354 | + else if (skillId > 4701 && skillId < 4704) | |
| 2355 | + skillStr = "1332"; | |
| 2356 | + else | |
| 2357 | + skillStr = "" + skillId; | |
| 2358 | + | |
| 2359 | + if (!buffTemplates.get(playerId).contains(skillId)) | |
| 2360 | + {
| |
| 2361 | + c++; | |
| 2362 | + if (c % 2 == 1) | |
| 2363 | + sb.append("<tr><td width=32><img src=\"Icon.skill" + skillStr + "\" width=32 height=32></td><td width=100>" + ((EventManager.getInstance().getInt("maxBuffNum") - buffTemplates.get(playerId).size()) != 0 ? "<a action=\"bypass -h eventbuffer " + skillId + " 1\">" : "") + SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId,1)).getName() + ((EventManager.getInstance().getInt("maxBuffNum") - buffTemplates.get(playerId).size()) != 0 ? "</a>" : "") + "</td>");
| |
| 2364 | + if (c % 2 == 0) | |
| 2365 | + sb.append("<td width=32><img src=\"Icon.skill" + skillStr + "\" width=32 height=32></td><td width=100>" + ((EventManager.getInstance().getInt("maxBuffNum") - buffTemplates.get(playerId).size()) != 0 ? "<a action=\"bypass -h eventbuffer " + skillId + " 1\">" : "") + SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId,1)).getName() + ((EventManager.getInstance().getInt("maxBuffNum") - buffTemplates.get(playerId).size()) != 0 ? "</a>" : "") + "</td></tr>");
| |
| 2366 | + } | |
| 2367 | + } | |
| 2368 | + | |
| 2369 | + if (c % 2 == 1) | |
| 2370 | + sb.append("<td width=33></td><td width=100></td></tr>");
| |
| 2371 | + | |
| 2372 | + sb.append("</table>");
| |
| 2373 | + | |
| 2374 | + sb.append("</body></html>");
| |
| 2375 | + html.setHtml(sb.toString()); | |
| 2376 | + player.sendPacket(html); | |
| 2377 | + } | |
| 2378 | + catch(Throwable e) | |
| 2379 | + {
| |
| 2380 | + e.printStackTrace(); | |
| 2381 | + } | |
| 2382 | + } | |
| 2383 | + | |
| 2384 | + public void updateSQL() | |
| 2385 | + {
| |
| 2386 | + Connection con = null; | |
| 2387 | + PreparedStatement statement = null; | |
| 2388 | + | |
| 2389 | + try | |
| 2390 | + {
| |
| 2391 | + con = L2DatabaseFactory.getInstance().getConnection(); | |
| 2392 | + | |
| 2393 | + for (Map.Entry<String, Boolean> player : changes.entrySet()) | |
| 2394 | + {
| |
| 2395 | + | |
| 2396 | + TextBuilder sb = new TextBuilder(); | |
| 2397 | + | |
| 2398 | + int c = 0; | |
| 2399 | + for (int buffid : buffTemplates.get(player.getKey())) | |
| 2400 | + if (c == 0) | |
| 2401 | + {
| |
| 2402 | + sb.append(buffid); | |
| 2403 | + c++; | |
| 2404 | + } | |
| 2405 | + else | |
| 2406 | + sb.append("," + buffid);
| |
| 2407 | + | |
| 2408 | + if (player.getValue()) | |
| 2409 | + {
| |
| 2410 | + statement = con.prepareStatement("INSERT INTO event_buffs(player,buffs) VALUES (?,?)");
| |
| 2411 | + statement.setString(1, player.getKey()); | |
| 2412 | + statement.setString(2, sb.toString()); | |
| 2413 | + | |
| 2414 | + statement.executeUpdate(); | |
| 2415 | + statement.close(); | |
| 2416 | + } | |
| 2417 | + else | |
| 2418 | + {
| |
| 2419 | + statement = con.prepareStatement("UPDATE event_buffs SET buffs=? WHERE player=?");
| |
| 2420 | + statement.setString(1, sb.toString()); | |
| 2421 | + statement.setString(2, player.getKey()); | |
| 2422 | + | |
| 2423 | + statement.executeUpdate(); | |
| 2424 | + statement.close(); | |
| 2425 | + } | |
| 2426 | + } | |
| 2427 | + } | |
| 2428 | + catch (Exception e) | |
| 2429 | + {
| |
| 2430 | + System.out.println("EventBuffs SQL catch");
| |
| 2431 | + } | |
| 2432 | + finally | |
| 2433 | + {
| |
| 2434 | + try { con.close(); } catch (Exception e) {}
| |
| 2435 | + } | |
| 2436 | + | |
| 2437 | + changes.clear(); | |
| 2438 | + } | |
| 2439 | +} | |
| 2440 | \ No newline at end of file | |
| 2441 | Index: head-src/com/l2jfrozen/gameserver/event/VIPTvT.java | |
| 2442 | =================================================================== | |
| 2443 | --- head-src/com/l2jfrozen/gameserver/event/VIPTvT.java (revision 0) | |
| 2444 | +++ head-src/com/l2jfrozen/gameserver/event/VIPTvT.java (revision 0) | |
| 2445 | @@ -0,0 +1,207 @@ | |
| 2446 | +package com.l2jfrozen.gameserver.event; | |
| 2447 | + | |
| 2448 | +import javolution.text.TextBuilder; | |
| 2449 | +import javolution.util.FastMap; | |
| 2450 | + | |
| 2451 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 2452 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 2453 | + | |
| 2454 | +public class VIPTvT extends Event | |
| 2455 | +{
| |
| 2456 | + private class Core implements Runnable | |
| 2457 | + {
| |
| 2458 | + public void run() | |
| 2459 | + {
| |
| 2460 | + try | |
| 2461 | + {
| |
| 2462 | + switch (eventState) | |
| 2463 | + {
| |
| 2464 | + case START: | |
| 2465 | + divideIntoTeams(2); | |
| 2466 | + preparePlayers(); | |
| 2467 | + teleportToTeamPos(); | |
| 2468 | + createPartyOfTeam(1); | |
| 2469 | + createPartyOfTeam(2); | |
| 2470 | + selectNewVipOfTeam(1); | |
| 2471 | + selectNewVipOfTeam(2); | |
| 2472 | + forceSitAll(); | |
| 2473 | + setStatus(EventState.FIGHT); | |
| 2474 | + schedule(20000); | |
| 2475 | + break; | |
| 2476 | + | |
| 2477 | + case FIGHT: | |
| 2478 | + forceStandAll(); | |
| 2479 | + setStatus(EventState.END); | |
| 2480 | + clock.startClock(getInt("matchTime"));
| |
| 2481 | + break; | |
| 2482 | + | |
| 2483 | + case END: | |
| 2484 | + clock.setTime(0); | |
| 2485 | + if (winnerTeam == 0) | |
| 2486 | + winnerTeam = getWinnerTeam(); | |
| 2487 | + | |
| 2488 | + giveReward(getPlayersOfTeam(winnerTeam), getInt("rewardId"), getInt("rewardAmmount"));
| |
| 2489 | + setStatus(EventState.INACTIVE); | |
| 2490 | + EventManager.getInstance().end("Congratulation! The " + teams.get(winnerTeam).getName() + " team won the event with " + teams.get(winnerTeam).getScore() + " VIP kills!");
| |
| 2491 | + break; | |
| 2492 | + } | |
| 2493 | + } | |
| 2494 | + catch (Throwable e) | |
| 2495 | + {
| |
| 2496 | + e.printStackTrace(); | |
| 2497 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 2498 | + } | |
| 2499 | + | |
| 2500 | + } | |
| 2501 | + } | |
| 2502 | + | |
| 2503 | + private enum EventState | |
| 2504 | + {
| |
| 2505 | + START, FIGHT, END, TELEPORT, INACTIVE | |
| 2506 | + } | |
| 2507 | + | |
| 2508 | + private EventState eventState; | |
| 2509 | + | |
| 2510 | + private Core task; | |
| 2511 | + | |
| 2512 | + private FastMap<Integer, L2PcInstance> vips; | |
| 2513 | + | |
| 2514 | + public VIPTvT() | |
| 2515 | + {
| |
| 2516 | + super(); | |
| 2517 | + eventId = 8; | |
| 2518 | + createNewTeam(1, "Blue", getColor("Blue"), getPosition("Blue", 1));
| |
| 2519 | + createNewTeam(2, "Red", getColor("Red"), getPosition("Red", 1));
| |
| 2520 | + task = new Core(); | |
| 2521 | + vips = new FastMap<Integer, L2PcInstance>(); | |
| 2522 | + winnerTeam = 0; | |
| 2523 | + } | |
| 2524 | + | |
| 2525 | + @Override | |
| 2526 | + protected void endEvent() | |
| 2527 | + {
| |
| 2528 | + winnerTeam = players.head().getNext().getValue()[0]; | |
| 2529 | + | |
| 2530 | + setStatus(EventState.END); | |
| 2531 | + clock.setTime(0); | |
| 2532 | + | |
| 2533 | + } | |
| 2534 | + | |
| 2535 | + @Override | |
| 2536 | + protected String getScorebar() | |
| 2537 | + {
| |
| 2538 | + return "" + teams.get(1).getName() + ": " + teams.get(1).getScore() + " " + teams.get(2).getName() + ": " + teams.get(2).getScore() + " Time: " + clock.getTime(); | |
| 2539 | + } | |
| 2540 | + | |
| 2541 | + @Override | |
| 2542 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 2543 | + {
| |
| 2544 | + super.onDie(victim, killer); | |
| 2545 | + if (vips.get(1) == victim) | |
| 2546 | + {
| |
| 2547 | + teams.get(2).increaseScore(); | |
| 2548 | + increasePlayersScore(killer); | |
| 2549 | + killer.addItem("Event", 6392, 3, killer, true);
| |
| 2550 | + selectNewVipOfTeam(1); | |
| 2551 | + } | |
| 2552 | + if (vips.get(2) == victim) | |
| 2553 | + {
| |
| 2554 | + teams.get(1).increaseScore(); | |
| 2555 | + increasePlayersScore(killer); | |
| 2556 | + killer.addItem("Event", 6392, 3, killer, true);
| |
| 2557 | + selectNewVipOfTeam(2); | |
| 2558 | + } | |
| 2559 | + | |
| 2560 | + addToResurrector(victim); | |
| 2561 | + } | |
| 2562 | + | |
| 2563 | + @Override | |
| 2564 | + protected void schedule(int time) | |
| 2565 | + {
| |
| 2566 | + tpm.scheduleGeneral(task, time); | |
| 2567 | + } | |
| 2568 | + | |
| 2569 | + private void selectNewVipOfTeam(int team) | |
| 2570 | + {
| |
| 2571 | + if (vips.get(team) != null) | |
| 2572 | + {
| |
| 2573 | + int[] nameColor = teams.get(getTeam(vips.get(team))).getTeamColor(); | |
| 2574 | + vips.get(team).getAppearance().setNameColor(nameColor[0], nameColor[1], nameColor[2]); | |
| 2575 | + } | |
| 2576 | + | |
| 2577 | + L2PcInstance newvip = getRandomPlayerFromTeam(team); | |
| 2578 | + vips.getEntry(team).setValue(newvip); | |
| 2579 | + if (team == 1) | |
| 2580 | + {
| |
| 2581 | + int[] c = getColor("BlueVIP");
| |
| 2582 | + newvip.getAppearance().setNameColor(c[0], c[1], c[2]); | |
| 2583 | + } | |
| 2584 | + | |
| 2585 | + if (team == 2) | |
| 2586 | + {
| |
| 2587 | + int[] c = getColor("RedVIP");
| |
| 2588 | + newvip.getAppearance().setNameColor(c[0], c[1], c[2]); | |
| 2589 | + } | |
| 2590 | + | |
| 2591 | + if (!newvip.isDead()) | |
| 2592 | + {
| |
| 2593 | + newvip.setCurrentCp(newvip.getMaxCp()); | |
| 2594 | + newvip.setCurrentMp(newvip.getMaxMp()); | |
| 2595 | + newvip.setCurrentHp(newvip.getMaxHp()); | |
| 2596 | + } | |
| 2597 | + | |
| 2598 | + newvip.broadcastUserInfo(); | |
| 2599 | + | |
| 2600 | + } | |
| 2601 | + | |
| 2602 | + private void setStatus(EventState s) | |
| 2603 | + {
| |
| 2604 | + eventState = s; | |
| 2605 | + } | |
| 2606 | + | |
| 2607 | + @Override | |
| 2608 | + protected void showHtml(L2PcInstance player, int obj) | |
| 2609 | + {
| |
| 2610 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 2611 | + TextBuilder sb = new TextBuilder(); | |
| 2612 | + | |
| 2613 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 2614 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 2615 | + sb.append("<table width=270><tr><td><center><font color=" + teams.get(1).getHexaColor() + ">" + teams.get(1).getScore() + "</font> - " + "<font color=" + teams.get(2).getHexaColor() + ">" + teams.get(2).getScore() + "</font></td></tr></table>");
| |
| 2616 | + sb.append("<br><table width=270>");
| |
| 2617 | + int i = 0; | |
| 2618 | + for (EventTeam team : teams.values()) | |
| 2619 | + {
| |
| 2620 | + i++; | |
| 2621 | + sb.append("<tr><td><font color=" + team.getHexaColor() + ">" + team.getName() + "</font> team</td><td></td><td></td><td></td></tr>");
| |
| 2622 | + for (L2PcInstance p : getPlayersOfTeam(i)) | |
| 2623 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 2624 | + } | |
| 2625 | + | |
| 2626 | + sb.append("</table></body></html>");
| |
| 2627 | + html.setHtml(sb.toString()); | |
| 2628 | + player.sendPacket(html); | |
| 2629 | + | |
| 2630 | + } | |
| 2631 | + | |
| 2632 | + @Override | |
| 2633 | + protected void start() | |
| 2634 | + {
| |
| 2635 | + vips.put(1, null); | |
| 2636 | + vips.put(2, null); | |
| 2637 | + setStatus(EventState.START); | |
| 2638 | + schedule(1); | |
| 2639 | + } | |
| 2640 | + | |
| 2641 | + @Override | |
| 2642 | + public void onLogout(L2PcInstance player) | |
| 2643 | + {
| |
| 2644 | + super.onLogout(player); | |
| 2645 | + | |
| 2646 | + if(vips.get(1) == player) | |
| 2647 | + selectNewVipOfTeam(1); | |
| 2648 | + if(vips.get(2) == player) | |
| 2649 | + selectNewVipOfTeam(2); | |
| 2650 | + | |
| 2651 | + } | |
| 2652 | +} | |
| 2653 | \ No newline at end of file | |
| 2654 | Index: head-src/com/l2jfrozen/gameserver/event/EventTeam.java | |
| 2655 | =================================================================== | |
| 2656 | --- head-src/com/l2jfrozen/gameserver/event/EventTeam.java (revision 0) | |
| 2657 | +++ head-src/com/l2jfrozen/gameserver/event/EventTeam.java (revision 0) | |
| 2658 | @@ -0,0 +1,109 @@ | |
| 2659 | +/* | |
| 2660 | + * This program is free software: you can redistribute it and/or modify it under | |
| 2661 | + * the terms of the GNU General Public License as published by the Free Software | |
| 2662 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 2663 | + * version. | |
| 2664 | + * | |
| 2665 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 2666 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 2667 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 2668 | + * details. | |
| 2669 | + * | |
| 2670 | + * You should have received a copy of the GNU General Public License along with | |
| 2671 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 2672 | + */ | |
| 2673 | +package com.l2jfrozen.gameserver.event; | |
| 2674 | + | |
| 2675 | +/** | |
| 2676 | + * @author Rizel | |
| 2677 | + * | |
| 2678 | + */ | |
| 2679 | +public class EventTeam implements Comparable<EventTeam> | |
| 2680 | +{
| |
| 2681 | + private int score; | |
| 2682 | + | |
| 2683 | + private String name; | |
| 2684 | + | |
| 2685 | + private int[] nameColor; | |
| 2686 | + | |
| 2687 | + private int[] startPos; | |
| 2688 | + | |
| 2689 | + private int id; | |
| 2690 | + | |
| 2691 | + public EventTeam(int id, String name, int[] color, int[] startPos) | |
| 2692 | + {
| |
| 2693 | + this.id = id; | |
| 2694 | + score = 0; | |
| 2695 | + this.name = name; | |
| 2696 | + nameColor = color; | |
| 2697 | + this.startPos = startPos; | |
| 2698 | + } | |
| 2699 | + | |
| 2700 | + public int compareTo(EventTeam second) | |
| 2701 | + {
| |
| 2702 | + | |
| 2703 | + if (getScore() > second.getScore()) | |
| 2704 | + return 1; | |
| 2705 | + if (getScore() < second.getScore()) | |
| 2706 | + return -1; | |
| 2707 | + if (getScore() == second.getScore()) | |
| 2708 | + return 0; | |
| 2709 | + | |
| 2710 | + return 0; | |
| 2711 | + | |
| 2712 | + } | |
| 2713 | + | |
| 2714 | + protected String getHexaColor() | |
| 2715 | + {
| |
| 2716 | + String hexa; | |
| 2717 | + Integer i1 = nameColor[0]; | |
| 2718 | + Integer i2 = nameColor[1]; | |
| 2719 | + Integer i3 = nameColor[2]; | |
| 2720 | + hexa = "" + (i1 > 15 ? Integer.toHexString(i1) : "0" + Integer.toHexString(i1)) + (i2 > 15 ? Integer.toHexString(i2) : "0" + Integer.toHexString(i2)) + (i3 > 15 ? Integer.toHexString(i3) : "0" + Integer.toHexString(i3)); | |
| 2721 | + return hexa; | |
| 2722 | + } | |
| 2723 | + | |
| 2724 | + protected int getId() | |
| 2725 | + {
| |
| 2726 | + return id; | |
| 2727 | + } | |
| 2728 | + | |
| 2729 | + protected String getName() | |
| 2730 | + {
| |
| 2731 | + return name; | |
| 2732 | + } | |
| 2733 | + | |
| 2734 | + protected int getScore() | |
| 2735 | + {
| |
| 2736 | + return score; | |
| 2737 | + } | |
| 2738 | + | |
| 2739 | + protected int[] getTeamColor() | |
| 2740 | + {
| |
| 2741 | + return nameColor; | |
| 2742 | + } | |
| 2743 | + | |
| 2744 | + protected int[] getTeamPos() | |
| 2745 | + {
| |
| 2746 | + return startPos; | |
| 2747 | + } | |
| 2748 | + | |
| 2749 | + protected void increaseScore() | |
| 2750 | + {
| |
| 2751 | + score++; | |
| 2752 | + } | |
| 2753 | + | |
| 2754 | + /* (non-Javadoc) | |
| 2755 | + * @see java.lang.Comparable#compareTo(java.lang.Object) | |
| 2756 | + */ | |
| 2757 | + | |
| 2758 | + protected void increaseScore(int ammount) | |
| 2759 | + {
| |
| 2760 | + score += ammount; | |
| 2761 | + } | |
| 2762 | + | |
| 2763 | + protected void setScore(int ammount) | |
| 2764 | + {
| |
| 2765 | + score = ammount; | |
| 2766 | + } | |
| 2767 | +} | |
| 2768 | \ No newline at end of file | |
| 2769 | Index: head-src/com/l2jfrozen/gameserver/event/EventStats.java | |
| 2770 | =================================================================== | |
| 2771 | --- head-src/com/l2jfrozen/gameserver/event/EventStats.java (revision 0) | |
| 2772 | +++ head-src/com/l2jfrozen/gameserver/event/EventStats.java (revision 0) | |
| 2773 | @@ -0,0 +1,383 @@ | |
| 2774 | +package com.l2jfrozen.gameserver.event; | |
| 2775 | + | |
| 2776 | +import java.sql.Connection; | |
| 2777 | +import java.sql.PreparedStatement; | |
| 2778 | +import java.sql.ResultSet; | |
| 2779 | +import java.util.Map; | |
| 2780 | +import java.util.Set; | |
| 2781 | + | |
| 2782 | +import javolution.text.TextBuilder; | |
| 2783 | +import javolution.util.FastMap; | |
| 2784 | + | |
| 2785 | +import com.l2jfrozen.util.database.L2DatabaseFactory; | |
| 2786 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 2787 | +import com.l2jfrozen.gameserver.network.serverpackets.ShowBoard; | |
| 2788 | + | |
| 2789 | +public class EventStats | |
| 2790 | +{
| |
| 2791 | + | |
| 2792 | + private static class SingletonHolder | |
| 2793 | + {
| |
| 2794 | + protected static final EventStats _instance = new EventStats(); | |
| 2795 | + } | |
| 2796 | + | |
| 2797 | + private class StatModell | |
| 2798 | + {
| |
| 2799 | + protected int num; | |
| 2800 | + protected int wins; | |
| 2801 | + protected int losses; | |
| 2802 | + protected int kills; | |
| 2803 | + protected int deaths; | |
| 2804 | + protected int scores; | |
| 2805 | + | |
| 2806 | + private StatModell(int num, int wins, int losses, int kills, int deaths, int scores) | |
| 2807 | + {
| |
| 2808 | + this.num = num; | |
| 2809 | + this.wins = wins; | |
| 2810 | + this.losses = losses; | |
| 2811 | + this.kills = kills; | |
| 2812 | + this.deaths = deaths; | |
| 2813 | + this.scores = scores; | |
| 2814 | + } | |
| 2815 | + | |
| 2816 | + } | |
| 2817 | + | |
| 2818 | + public static EventStats getInstance() | |
| 2819 | + {
| |
| 2820 | + return SingletonHolder._instance; | |
| 2821 | + } | |
| 2822 | + | |
| 2823 | + private FastMap<Integer, FastMap<Integer, StatModell>> stats; | |
| 2824 | + | |
| 2825 | + protected FastMap<Integer, int[]> tempTable; | |
| 2826 | + | |
| 2827 | + private FastMap<Integer, ShowBoard> htmls; | |
| 2828 | + | |
| 2829 | + private FastMap<Integer, int[]> statSums; | |
| 2830 | + | |
| 2831 | + public EventStats() | |
| 2832 | + {
| |
| 2833 | + stats = new FastMap<Integer, FastMap<Integer, StatModell>>(); | |
| 2834 | + tempTable = new FastMap<Integer, int[]>(); | |
| 2835 | + htmls = new FastMap<Integer, ShowBoard>(); | |
| 2836 | + statSums = new FastMap<Integer, int[]>(); | |
| 2837 | + loadSQL(); | |
| 2838 | + } | |
| 2839 | + | |
| 2840 | + protected void applyChanges() | |
| 2841 | + {
| |
| 2842 | + if (!EventManager.getInstance().getBoolean("statTrackingEnabled"))
| |
| 2843 | + return; | |
| 2844 | + | |
| 2845 | + int eventId = EventManager.getInstance().getCurrentEvent().eventId; | |
| 2846 | + for (L2PcInstance player : EventManager.getInstance().getCurrentEvent().getPlayerList()) | |
| 2847 | + {
| |
| 2848 | + int playerId = player.getObjectId(); | |
| 2849 | + | |
| 2850 | + if (!stats.containsKey(playerId)) | |
| 2851 | + stats.put(playerId, new FastMap<Integer, StatModell>()); | |
| 2852 | + | |
| 2853 | + if (!stats.get(playerId).containsKey(eventId)) | |
| 2854 | + stats.get(playerId).put(eventId, new StatModell(0, 0, 0, 0, 0, 0)); | |
| 2855 | + | |
| 2856 | + if (tempTable.get(playerId)[0] == 1) | |
| 2857 | + stats.get(playerId).get(eventId).wins = stats.get(playerId).get(eventId).wins + 1; | |
| 2858 | + else | |
| 2859 | + stats.get(playerId).get(eventId).losses = stats.get(playerId).get(eventId).losses + 1; | |
| 2860 | + | |
| 2861 | + stats.get(playerId).get(eventId).num = stats.get(playerId).get(eventId).num + 1; | |
| 2862 | + stats.get(playerId).get(eventId).kills = stats.get(playerId).get(eventId).kills + tempTable.get(playerId)[1]; | |
| 2863 | + stats.get(playerId).get(eventId).deaths = stats.get(playerId).get(eventId).deaths + tempTable.get(playerId)[2]; | |
| 2864 | + stats.get(playerId).get(eventId).scores = stats.get(playerId).get(eventId).scores + tempTable.get(playerId)[3]; | |
| 2865 | + } | |
| 2866 | + EventManager.getInstance().debug("applyChanges finished");
| |
| 2867 | + } | |
| 2868 | + | |
| 2869 | + protected void createHtmls() | |
| 2870 | + {
| |
| 2871 | + htmls.clear(); | |
| 2872 | + TextBuilder sb = new TextBuilder(); | |
| 2873 | + Connection con = null; | |
| 2874 | + PreparedStatement statement = null; | |
| 2875 | + try | |
| 2876 | + {
| |
| 2877 | + con = L2DatabaseFactory.getInstance().getConnection(); | |
| 2878 | + statement = con.prepareStatement("SELECT characters.char_name, event_stats_full.* FROM event_stats_full INNER JOIN characters ON characters.obj_Id = event_stats_full.player ORDER BY event_stats_full.wins DESC");
| |
| 2879 | + ResultSet rset = statement.executeQuery(); | |
| 2880 | + rset.last(); | |
| 2881 | + rset.beforeFirst(); | |
| 2882 | + int count = 0; | |
| 2883 | + while (rset.next()) | |
| 2884 | + {
| |
| 2885 | + count++; | |
| 2886 | + if (count % 10 == 1) | |
| 2887 | + sb.append("<html><body><br><br><center><table width=615 bgcolor=5A5A5A><tr><td width=30><center>Rank</td><td width=100><center>Name</td><td width=55><center>Events</td><td width=55><center>Win%</td><td width=55><center>K:D</td><td width=55><center>Wins</td><td width=55><center>Losses</td><td width=55><center>Kills</td><td width=55><center>Deaths</td><td width=100><center>Favourite Event</td></tr></table><br>" + "<center><table width=635>");
| |
| 2888 | + | |
| 2889 | + sb.append("<tr><td width=30><center>" + count + "</td><td width=100>" + rset.getString("char_name") + "</td><td width=55><center>" + rset.getInt("num") + "</td><td width=55><center>" + rset.getInt("winpercent") + "%</td><td width=55><center>" + rset.getDouble("kdratio") + "</td><td width=55><center>" + rset.getInt("wins") + "</td><td width=55><center>" + rset.getInt("losses") + "</td><td width=55><center>" + rset.getInt("kills") + "</td>" + "<td width=55><center>" + rset.getInt("deaths") + "</td><td width=120><center>" + EventManager.getInstance().events.get(rset.getInt("favevent")).getString("eventName") + "</td></tr>");
| |
| 2890 | + | |
| 2891 | + if (count % 10 == 0) | |
| 2892 | + {
| |
| 2893 | + sb.append("</table></body></html>");
| |
| 2894 | + htmls.put(count / 10, new ShowBoard(sb.toString(), "101")); | |
| 2895 | + sb.clear(); | |
| 2896 | + } | |
| 2897 | + } | |
| 2898 | + if (count % 10 != 0 && !htmls.containsKey(count / 10 + 1)) | |
| 2899 | + {
| |
| 2900 | + sb.append("</table></body></html>");
| |
| 2901 | + htmls.put((count / 10 + 1), new ShowBoard(sb.toString(), "101")); | |
| 2902 | + sb.clear(); | |
| 2903 | + } | |
| 2904 | + rset.close(); | |
| 2905 | + statement.close(); | |
| 2906 | + } | |
| 2907 | + catch (Exception e) | |
| 2908 | + {
| |
| 2909 | + System.out.println("create SQL exception.");
| |
| 2910 | + } | |
| 2911 | + finally | |
| 2912 | + {
| |
| 2913 | + try { con.close(); } catch (Exception e) {}
| |
| 2914 | + } | |
| 2915 | + EventManager.getInstance().debug("createHtmls finished");
| |
| 2916 | + } | |
| 2917 | + | |
| 2918 | + private void loadSQL() | |
| 2919 | + {
| |
| 2920 | + if (!EventManager.getInstance().getBoolean("statTrackingEnabled"))
| |
| 2921 | + return; | |
| 2922 | + | |
| 2923 | + Connection con = null; | |
| 2924 | + PreparedStatement statement = null; | |
| 2925 | + try | |
| 2926 | + {
| |
| 2927 | + con = L2DatabaseFactory.getInstance().getConnection(); | |
| 2928 | + statement = con.prepareStatement("SELECT * FROM event_stats");
| |
| 2929 | + ResultSet rset = statement.executeQuery(); | |
| 2930 | + int count = 0; | |
| 2931 | + while (rset.next()) | |
| 2932 | + {
| |
| 2933 | + count++; | |
| 2934 | + if (!stats.containsKey(rset.getInt("player")))
| |
| 2935 | + stats.put(rset.getInt("player"), new FastMap<Integer, StatModell>());
| |
| 2936 | + | |
| 2937 | + stats.get(rset.getInt("player")).put(rset.getInt("event"), new StatModell(rset.getInt("num"), rset.getInt("wins"), rset.getInt("losses"), rset.getInt("kills"), rset.getInt("deaths"), rset.getInt("scores")));
| |
| 2938 | + } | |
| 2939 | + rset.close(); | |
| 2940 | + statement.close(); | |
| 2941 | + | |
| 2942 | + EventManager.getInstance().debug("Stats loaded: " + count + " records.");
| |
| 2943 | + } | |
| 2944 | + catch (Exception e) | |
| 2945 | + {
| |
| 2946 | + System.out.println("EventStats SQL catch");
| |
| 2947 | + } | |
| 2948 | + finally | |
| 2949 | + {
| |
| 2950 | + try { con.close(); } catch (Exception e) {}
| |
| 2951 | + } | |
| 2952 | + createHtmls(); | |
| 2953 | + } | |
| 2954 | + | |
| 2955 | + public void showHtml(int id, L2PcInstance player) | |
| 2956 | + {
| |
| 2957 | + if (!EventManager.getInstance().getBoolean("statTrackingEnabled"))
| |
| 2958 | + {
| |
| 2959 | + player.sendMessage("The stat tracking is disabled.");
| |
| 2960 | + return; | |
| 2961 | + } | |
| 2962 | + player.sendPacket(htmls.get(id)); | |
| 2963 | + player.sendPacket(new ShowBoard(null, "102")); | |
| 2964 | + player.sendPacket(new ShowBoard(null, "103")); | |
| 2965 | + } | |
| 2966 | + | |
| 2967 | + public void showPlayerStats(int playerId, L2PcInstance player) | |
| 2968 | + {
| |
| 2969 | + TextBuilder sb = new TextBuilder(); | |
| 2970 | + sb.append("<html><body><br><br><center><table width=640 bgcolor=5A5A5A><tr><td width=120><center>Event</td><td width=65><center>Count</td><td width=65><center>Win%</td><td width=65><center>K:D</td><td width=65><center>Wins</td><td width=65><center>Losses</td><td width=65><center>Kills</td><td width=65><center>Deaths</td><td width=65><center>Scores</td></tr></table><br>" + "<center><table width=640>");
| |
| 2971 | + | |
| 2972 | + if (stats.containsKey(playerId)) | |
| 2973 | + for (Map.Entry<Integer, StatModell> event : stats.get(playerId).entrySet()) | |
| 2974 | + {
| |
| 2975 | + StatModell stats = event.getValue(); | |
| 2976 | + | |
| 2977 | + if(EventManager.getInstance().events.containsKey(event.getKey())) | |
| 2978 | + sb.append("<tr><td width=120>" + EventManager.getInstance().events.get(event.getKey()).getString("eventName") + "</td><td width=65><center>" + stats.num + "</td><td width=65><center>" + (stats.wins / stats.num) * 100 + "%</td><td width=65><center>" + (stats.deaths == 0 ? (double) stats.kills / stats.num : (double) ((stats.kills / stats.deaths) / stats.num)) + "</td><td width=65><center>" + stats.wins + "</td><td width=65><center>" + stats.losses + "</td><td width=65><center>" + stats.kills / stats.num + "</td><td width=65><center>" + stats.deaths / stats.num + "</td><td width=65><center>" + stats.scores / stats.num + "</td></tr>");
| |
| 2979 | + } | |
| 2980 | + | |
| 2981 | + sb.append("</table></body></html>");
| |
| 2982 | + player.sendPacket(new ShowBoard(sb.toString(), "101")); | |
| 2983 | + player.sendPacket(new ShowBoard(null, "102")); | |
| 2984 | + player.sendPacket(new ShowBoard(null, "103")); | |
| 2985 | + } | |
| 2986 | + | |
| 2987 | + public int getEventKills(int playerId) | |
| 2988 | + {
| |
| 2989 | + int kills = 0; | |
| 2990 | + | |
| 2991 | + if(!stats.containsKey(playerId)) | |
| 2992 | + return 0; | |
| 2993 | + else | |
| 2994 | + for (Map.Entry<Integer, StatModell> statmodell : stats.get(playerId).entrySet()) | |
| 2995 | + kills += statmodell.getValue().kills; | |
| 2996 | + | |
| 2997 | + return kills; | |
| 2998 | + } | |
| 2999 | + | |
| 3000 | + public int getEvents(int playerId) | |
| 3001 | + {
| |
| 3002 | + int num = 0; | |
| 3003 | + | |
| 3004 | + if(!stats.containsKey(playerId)) | |
| 3005 | + return 0; | |
| 3006 | + else | |
| 3007 | + for (Map.Entry<Integer, StatModell> statmodell : stats.get(playerId).entrySet()) | |
| 3008 | + num += statmodell.getValue().num; | |
| 3009 | + | |
| 3010 | + return num; | |
| 3011 | + } | |
| 3012 | + | |
| 3013 | + public int getEventWins(int playerId) | |
| 3014 | + {
| |
| 3015 | + int wins = 0; | |
| 3016 | + | |
| 3017 | + if(!stats.containsKey(playerId)) | |
| 3018 | + return 0; | |
| 3019 | + else | |
| 3020 | + for (Map.Entry<Integer, StatModell> statmodell : stats.get(playerId).entrySet()) | |
| 3021 | + wins += statmodell.getValue().wins; | |
| 3022 | + | |
| 3023 | + return wins; | |
| 3024 | + } | |
| 3025 | + | |
| 3026 | + // num | wins | losses | kills | deaths | fav_event_id | |
| 3027 | + protected void sumPlayerStats() | |
| 3028 | + {
| |
| 3029 | + if (!EventManager.getInstance().getBoolean("statTrackingEnabled"))
| |
| 3030 | + return; | |
| 3031 | + | |
| 3032 | + statSums.clear(); | |
| 3033 | + | |
| 3034 | + for (int playerId : stats.keySet()) | |
| 3035 | + {
| |
| 3036 | + | |
| 3037 | + int num = 0; | |
| 3038 | + int wins = 0; | |
| 3039 | + int losses = 0; | |
| 3040 | + int kills = 0; | |
| 3041 | + int deaths = 0; | |
| 3042 | + int faveventid = 0; | |
| 3043 | + int faveventamm = 0; | |
| 3044 | + | |
| 3045 | + for (Map.Entry<Integer, StatModell> statmodell : stats.get(playerId).entrySet()) | |
| 3046 | + {
| |
| 3047 | + num += statmodell.getValue().num; | |
| 3048 | + wins += statmodell.getValue().wins; | |
| 3049 | + losses += statmodell.getValue().losses; | |
| 3050 | + kills += statmodell.getValue().kills; | |
| 3051 | + deaths += statmodell.getValue().deaths; | |
| 3052 | + | |
| 3053 | + if (statmodell.getValue().num > faveventamm) | |
| 3054 | + {
| |
| 3055 | + faveventamm = statmodell.getValue().num; | |
| 3056 | + faveventid = statmodell.getKey(); | |
| 3057 | + } | |
| 3058 | + } | |
| 3059 | + | |
| 3060 | + statSums.put(playerId, new int[] { num, wins, losses, kills, deaths, faveventid });
| |
| 3061 | + | |
| 3062 | + } | |
| 3063 | + EventManager.getInstance().debug("sumPlayerStats finished");
| |
| 3064 | + } | |
| 3065 | + | |
| 3066 | + protected void updateSQL(Set<L2PcInstance> players, int eventId) | |
| 3067 | + {
| |
| 3068 | + if (!EventManager.getInstance().getBoolean("statTrackingEnabled"))
| |
| 3069 | + return; | |
| 3070 | + | |
| 3071 | + sumPlayerStats(); | |
| 3072 | + Connection con = null; | |
| 3073 | + PreparedStatement statement = null; | |
| 3074 | + try | |
| 3075 | + {
| |
| 3076 | + con = L2DatabaseFactory.getInstance().getConnection(); | |
| 3077 | + | |
| 3078 | + for (L2PcInstance player : players) | |
| 3079 | + {
| |
| 3080 | + int id = player.getObjectId(); | |
| 3081 | + | |
| 3082 | + if (statSums.get(id)[0] != 1) | |
| 3083 | + {
| |
| 3084 | + statement = con.prepareStatement("UPDATE event_stats_full SET num=?, winpercent=?, kdratio=?, wins=?, losses=?, kills=?, deaths=?, favevent=? WHERE player=?");
| |
| 3085 | + statement.setInt(1, statSums.get(id)[0]); | |
| 3086 | + statement.setInt(2, (statSums.get(id)[0] == 0 ? 1 : statSums.get(id)[1] / statSums.get(id)[0]) * 100); | |
| 3087 | + statement.setDouble(3, (statSums.get(id)[4] == 0 ? (double) statSums.get(id)[3] : (double) (statSums.get(id)[3] / statSums.get(id)[4]))); | |
| 3088 | + statement.setInt(4, statSums.get(id)[1]); | |
| 3089 | + statement.setInt(5, statSums.get(id)[2]); | |
| 3090 | + statement.setInt(6, statSums.get(id)[3]); | |
| 3091 | + statement.setInt(7, statSums.get(id)[4]); | |
| 3092 | + statement.setInt(8, statSums.get(id)[5]); | |
| 3093 | + statement.setInt(9, id); | |
| 3094 | + | |
| 3095 | + statement.executeUpdate(); | |
| 3096 | + statement.close(); | |
| 3097 | + } | |
| 3098 | + else | |
| 3099 | + {
| |
| 3100 | + statement = con.prepareStatement("INSERT INTO event_stats_full(player,num,winpercent,kdratio,wins,losses,kills,deaths,favevent) VALUES (?,?,?,?,?,?,?,?,?)");
| |
| 3101 | + statement.setInt(1, id); | |
| 3102 | + statement.setInt(2, statSums.get(id)[0]); | |
| 3103 | + statement.setInt(3, (statSums.get(id)[0] == 0 ? 1 : statSums.get(id)[1] / statSums.get(id)[0]) * 100); | |
| 3104 | + statement.setDouble(4, (statSums.get(id)[4] == 0 ? (double) statSums.get(id)[3] : (double) (statSums.get(id)[3] / statSums.get(id)[4]))); | |
| 3105 | + statement.setInt(5, statSums.get(id)[1]); | |
| 3106 | + statement.setInt(6, statSums.get(id)[2]); | |
| 3107 | + statement.setInt(7, statSums.get(id)[3]); | |
| 3108 | + statement.setInt(8, statSums.get(id)[4]); | |
| 3109 | + statement.setInt(9, statSums.get(id)[5]); | |
| 3110 | + statement.executeUpdate(); | |
| 3111 | + statement.close(); | |
| 3112 | + } | |
| 3113 | + | |
| 3114 | + if (stats.get(id).get(eventId).num != 1) | |
| 3115 | + {
| |
| 3116 | + statement = con.prepareStatement("UPDATE event_stats SET num=?, wins=?, losses=?, kills=?, deaths=?, scores=? WHERE player=? AND event=?");
| |
| 3117 | + statement.setInt(1, stats.get(id).get(eventId).num); | |
| 3118 | + statement.setInt(2, stats.get(id).get(eventId).wins); | |
| 3119 | + statement.setInt(3, stats.get(id).get(eventId).losses); | |
| 3120 | + statement.setInt(4, stats.get(id).get(eventId).kills); | |
| 3121 | + statement.setInt(5, stats.get(id).get(eventId).deaths); | |
| 3122 | + statement.setInt(6, stats.get(id).get(eventId).scores); | |
| 3123 | + statement.setInt(7, id); | |
| 3124 | + statement.setInt(8, eventId); | |
| 3125 | + statement.executeUpdate(); | |
| 3126 | + statement.close(); | |
| 3127 | + } | |
| 3128 | + else | |
| 3129 | + {
| |
| 3130 | + statement = con.prepareStatement("INSERT INTO event_stats(player,event,num,wins,losses,kills,deaths,scores) VALUES (?,?,?,?,?,?,?,?)");
| |
| 3131 | + statement.setInt(1, id); | |
| 3132 | + statement.setInt(2, eventId); | |
| 3133 | + statement.setInt(3, stats.get(id).get(eventId).num); | |
| 3134 | + statement.setInt(4, stats.get(id).get(eventId).wins); | |
| 3135 | + statement.setInt(5, stats.get(id).get(eventId).losses); | |
| 3136 | + statement.setInt(6, stats.get(id).get(eventId).kills); | |
| 3137 | + statement.setInt(7, stats.get(id).get(eventId).deaths); | |
| 3138 | + statement.setInt(8, stats.get(id).get(eventId).scores); | |
| 3139 | + statement.executeUpdate(); | |
| 3140 | + statement.close(); | |
| 3141 | + } | |
| 3142 | + | |
| 3143 | + } | |
| 3144 | + } | |
| 3145 | + catch (Exception e) | |
| 3146 | + {
| |
| 3147 | + System.out.println("EventStats SQL catch");
| |
| 3148 | + } | |
| 3149 | + finally | |
| 3150 | + {
| |
| 3151 | + try { con.close(); } catch (Exception e) {}
| |
| 3152 | + } | |
| 3153 | + EventManager.getInstance().debug("updateSQL finished");
| |
| 3154 | + createHtmls(); | |
| 3155 | + } | |
| 3156 | +} | |
| 3157 | \ No newline at end of file | |
| 3158 | Index: head-src/com/l2jfrozen/gameserver/network/serverpackets/Die.java | |
| 3159 | =================================================================== | |
| 3160 | --- head-src/com/l2jfrozen/gameserver/network/serverpackets/Die.java (revision 936) | |
| 3161 | +++ head-src/com/l2jfrozen/gameserver/network/serverpackets/Die.java (working copy) | |
| 3162 | @@ -18,6 +18,7 @@ | |
| 3163 | */ | |
| 3164 | package com.l2jfrozen.gameserver.network.serverpackets; | |
| 3165 | ||
| 3166 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 3167 | import com.l2jfrozen.gameserver.datatables.AccessLevel; | |
| 3168 | import com.l2jfrozen.gameserver.datatables.sql.AccessLevels; | |
| 3169 | import com.l2jfrozen.gameserver.managers.CastleManager; | |
| 3170 | @@ -46,6 +47,7 @@ | |
| 3171 | private boolean _sweepable; | |
| 3172 | private boolean _canTeleport; | |
| 3173 | private AccessLevel _access = AccessLevels.getInstance()._userAccessLevel; | |
| 3174 | + private boolean _event; | |
| 3175 | private com.l2jfrozen.gameserver.model.L2Clan _clan; | |
| 3176 | L2Character _activeChar; | |
| 3177 | ||
| 3178 | @@ -60,6 +62,7 @@ | |
| 3179 | L2PcInstance player = (L2PcInstance) cha; | |
| 3180 | _access = player.getAccessLevel(); | |
| 3181 | _clan = player.getClan(); | |
| 3182 | + _event = EventManager.getInstance().isRegistered((L2PcInstance)cha); | |
| 3183 | _canTeleport = !((TvT.is_started() && player._inEventTvT) | |
| 3184 | || (DM.is_started() && player._inEventDM) | |
| 3185 | || (CTF.is_started() && player._inEventCTF) | |
| 3186 | @@ -91,45 +94,55 @@ | |
| 3187 | // 6d 03 00 00 00 - to siege HQ | |
| 3188 | // sweepable | |
| 3189 | // 6d 04 00 00 00 - FIXED | |
| 3190 | - | |
| 3191 | - writeD(_canTeleport ? 0x01 : 0); // 6d 00 00 00 00 - to nearest village | |
| 3192 | - | |
| 3193 | - if(_canTeleport && _clan != null) | |
| 3194 | - {
| |
| 3195 | - L2SiegeClan siegeClan = null; | |
| 3196 | - Boolean isInDefense = false; | |
| 3197 | - Castle castle = CastleManager.getInstance().getCastle(_activeChar); | |
| 3198 | - Fort fort = FortManager.getInstance().getFort(_activeChar); | |
| 3199 | - | |
| 3200 | - if(castle != null && castle.getSiege().getIsInProgress()) | |
| 3201 | + | |
| 3202 | + if(_event) | |
| 3203 | + {
| |
| 3204 | + writeD(0x00); | |
| 3205 | + writeD(0x00); // 6d 01 00 00 00 - to hide away | |
| 3206 | + writeD(0x00); // 6d 02 00 00 00 - to castle | |
| 3207 | + writeD(0x00); | |
| 3208 | + } | |
| 3209 | + else | |
| 3210 | + {
| |
| 3211 | + writeD(_canTeleport ? 0x01 : 0); // 6d 00 00 00 00 - to nearest village | |
| 3212 | + | |
| 3213 | + if(_canTeleport && _clan != null) | |
| 3214 | {
| |
| 3215 | - //siege in progress | |
| 3216 | - siegeClan = castle.getSiege().getAttackerClan(_clan); | |
| 3217 | - if(siegeClan == null && castle.getSiege().checkIsDefender(_clan)) | |
| 3218 | + L2SiegeClan siegeClan = null; | |
| 3219 | + Boolean isInDefense = false; | |
| 3220 | + Castle castle = CastleManager.getInstance().getCastle(_activeChar); | |
| 3221 | + Fort fort = FortManager.getInstance().getFort(_activeChar); | |
| 3222 | + | |
| 3223 | + if(castle != null && castle.getSiege().getIsInProgress()) | |
| 3224 | {
| |
| 3225 | - isInDefense = true; | |
| 3226 | + //siege in progress | |
| 3227 | + siegeClan = castle.getSiege().getAttackerClan(_clan); | |
| 3228 | + if(siegeClan == null && castle.getSiege().checkIsDefender(_clan)) | |
| 3229 | + {
| |
| 3230 | + isInDefense = true; | |
| 3231 | + } | |
| 3232 | } | |
| 3233 | - } | |
| 3234 | - else if(fort != null && fort.getSiege().getIsInProgress()) | |
| 3235 | - {
| |
| 3236 | - //siege in progress | |
| 3237 | - siegeClan = fort.getSiege().getAttackerClan(_clan); | |
| 3238 | - if(siegeClan == null && fort.getSiege().checkIsDefender(_clan)) | |
| 3239 | + else if(fort != null && fort.getSiege().getIsInProgress()) | |
| 3240 | {
| |
| 3241 | - isInDefense = true; | |
| 3242 | + //siege in progress | |
| 3243 | + siegeClan = fort.getSiege().getAttackerClan(_clan); | |
| 3244 | + if(siegeClan == null && fort.getSiege().checkIsDefender(_clan)) | |
| 3245 | + {
| |
| 3246 | + isInDefense = true; | |
| 3247 | + } | |
| 3248 | } | |
| 3249 | + | |
| 3250 | + writeD(_clan.getHasHideout() > 0 ? 0x01 : 0x00); // 6d 01 00 00 00 - to hide away | |
| 3251 | + writeD(_clan.getHasCastle() > 0 || _clan.getHasFort() > 0 || isInDefense ? 0x01 : 0x00); // 6d 02 00 00 00 - to castle | |
| 3252 | + writeD(siegeClan != null && !isInDefense && siegeClan.getFlag().size() > 0 ? 0x01 : 0x00); // 6d 03 00 00 00 - to siege HQ | |
| 3253 | } | |
| 3254 | - | |
| 3255 | - writeD(_clan.getHasHideout() > 0 ? 0x01 : 0x00); // 6d 01 00 00 00 - to hide away | |
| 3256 | - writeD(_clan.getHasCastle() > 0 || _clan.getHasFort() > 0 || isInDefense ? 0x01 : 0x00); // 6d 02 00 00 00 - to castle | |
| 3257 | - writeD(siegeClan != null && !isInDefense && siegeClan.getFlag().size() > 0 ? 0x01 : 0x00); // 6d 03 00 00 00 - to siege HQ | |
| 3258 | - } | |
| 3259 | - else | |
| 3260 | - {
| |
| 3261 | - writeD(0x00); // 6d 01 00 00 00 - to hide away | |
| 3262 | - writeD(0x00); // 6d 02 00 00 00 - to castle | |
| 3263 | - writeD(0x00); // 6d 03 00 00 00 - to siege HQ | |
| 3264 | - } | |
| 3265 | + else | |
| 3266 | + {
| |
| 3267 | + writeD(0x00); // 6d 01 00 00 00 - to hide away | |
| 3268 | + writeD(0x00); // 6d 02 00 00 00 - to castle | |
| 3269 | + writeD(0x00); // 6d 03 00 00 00 - to siege HQ | |
| 3270 | + } | |
| 3271 | + } | |
| 3272 | ||
| 3273 | writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow) | |
| 3274 | writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED | |
| 3275 | Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java | |
| 3276 | =================================================================== | |
| 3277 | --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java (revision 936) | |
| 3278 | +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java (working copy) | |
| 3279 | @@ -18,12 +18,18 @@ | |
| 3280 | */ | |
| 3281 | package com.l2jfrozen.gameserver.network.clientpackets; | |
| 3282 | ||
| 3283 | +import java.sql.Connection; | |
| 3284 | +import java.sql.PreparedStatement; | |
| 3285 | +import java.sql.ResultSet; | |
| 3286 | import java.util.logging.Level; | |
| 3287 | import java.util.logging.Logger; | |
| 3288 | ||
| 3289 | import com.l2jfrozen.Config; | |
| 3290 | import com.l2jfrozen.gameserver.ai.CtrlIntention; | |
| 3291 | import com.l2jfrozen.gameserver.communitybbs.CommunityBoard; | |
| 3292 | +import com.l2jfrozen.gameserver.event.EventBuffer; | |
| 3293 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 3294 | +import com.l2jfrozen.gameserver.event.EventStats; | |
| 3295 | import com.l2jfrozen.gameserver.datatables.sql.AdminCommandAccessRights; | |
| 3296 | import com.l2jfrozen.gameserver.handler.AdminCommandHandler; | |
| 3297 | import com.l2jfrozen.gameserver.handler.IAdminCommandHandler; | |
| 3298 | @@ -43,6 +49,7 @@ | |
| 3299 | import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed; | |
| 3300 | import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 3301 | import com.l2jfrozen.gameserver.util.GMAudit; | |
| 3302 | +import com.l2jfrozen.util.database.L2DatabaseFactory; | |
| 3303 | ||
| 3304 | public final class RequestBypassToServer extends L2GameClientPacket | |
| 3305 | {
| |
| 3306 | @@ -116,6 +123,18 @@ | |
| 3307 | ||
| 3308 | ach.useAdminCommand(_command, activeChar); | |
| 3309 | } | |
| 3310 | + else if(_command.startsWith("event_vote"))
| |
| 3311 | + {
| |
| 3312 | + EventManager.getInstance().addVote(activeChar, Integer.parseInt(_command.substring(11))); | |
| 3313 | + } | |
| 3314 | + else if(_command.equals("event_register"))
| |
| 3315 | + {
| |
| 3316 | + EventManager.getInstance().registerPlayer(activeChar); | |
| 3317 | + } | |
| 3318 | + else if(_command.equals("event_unregister"))
| |
| 3319 | + {
| |
| 3320 | + EventManager.getInstance().unregisterPlayer(activeChar); | |
| 3321 | + } | |
| 3322 | else if(_command.equals("come_here") && activeChar.isGM())
| |
| 3323 | {
| |
| 3324 | comeHere(activeChar); | |
| 3325 | @@ -307,7 +326,52 @@ | |
| 3326 | player.processQuestEvent(p.substring(0, idx), p.substring(idx).trim()); | |
| 3327 | } | |
| 3328 | } | |
| 3329 | - | |
| 3330 | + else if (_command.startsWith("eventvote "))
| |
| 3331 | + {
| |
| 3332 | + EventManager.getInstance().addVote(activeChar, Integer.parseInt(_command.substring(10))); | |
| 3333 | + } | |
| 3334 | + else if (_command.startsWith("eventstats "))
| |
| 3335 | + {
| |
| 3336 | + Connection con = null; | |
| 3337 | + PreparedStatement statement = null; | |
| 3338 | + con = L2DatabaseFactory.getInstance().getConnection(); | |
| 3339 | + statement = con.prepareStatement("SELECT characters.char_name, event_stats_full.* FROM event_stats_full INNER JOIN characters ON characters.obj_Id = event_stats_full.player ORDER BY event_stats_full.wins DESC");
| |
| 3340 | + ResultSet rset = statement.executeQuery(); | |
| 3341 | + if (!rset.last()) | |
| 3342 | + {
| |
| 3343 | + rset.close(); | |
| 3344 | + statement.close(); | |
| 3345 | + con.close(); | |
| 3346 | + this.getClient().activeChar.sendMessage("Currently there are no statistics to show.");
| |
| 3347 | + return; | |
| 3348 | + } | |
| 3349 | + rset.close(); | |
| 3350 | + statement.close(); | |
| 3351 | + con.close(); | |
| 3352 | + EventStats.getInstance().showHtml(Integer.parseInt(_command.substring(11)),activeChar); | |
| 3353 | + } | |
| 3354 | + else if (_command.startsWith("eventstats_show "))
| |
| 3355 | + {
| |
| 3356 | + EventStats.getInstance().showPlayerStats(Integer.parseInt(_command.substring(16)),activeChar); | |
| 3357 | + } | |
| 3358 | + else if (_command.equals("eventbuffershow"))
| |
| 3359 | + {
| |
| 3360 | + EventBuffer.getInstance().showHtml(activeChar); | |
| 3361 | + } | |
| 3362 | + else if (_command.startsWith("eventbuffer "))
| |
| 3363 | + {
| |
| 3364 | + EventBuffer.getInstance().changeList(activeChar, Integer.parseInt(_command.substring(12,_command.length()-2)), (Integer.parseInt(_command.substring(_command.length()-1)) == 0 ? false : true)); | |
| 3365 | + EventBuffer.getInstance().showHtml(activeChar); | |
| 3366 | + } | |
| 3367 | + else if (_command.startsWith("eventinfo "))
| |
| 3368 | + {
| |
| 3369 | + int eventId = Integer.valueOf(_command.substring(10)); | |
| 3370 | + | |
| 3371 | + NpcHtmlMessage html = new NpcHtmlMessage(0); | |
| 3372 | + html.setFile("data/html/eventinfo/"+eventId+".htm");
| |
| 3373 | + activeChar.sendPacket(html); | |
| 3374 | + activeChar.sendPacket(ActionFailed.STATIC_PACKET); | |
| 3375 | + } | |
| 3376 | // Jstar's Custom Bypass Caller! | |
| 3377 | else if(_command.startsWith("custom_"))
| |
| 3378 | {
| |
| 3379 | Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java | |
| 3380 | =================================================================== | |
| 3381 | --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java (revision 936) | |
| 3382 | +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java (working copy) | |
| 3383 | @@ -35,6 +35,7 @@ | |
| 3384 | import com.l2jfrozen.gameserver.datatables.sql.HelperBuffTable; | |
| 3385 | import com.l2jfrozen.gameserver.datatables.sql.ItemTable; | |
| 3386 | import com.l2jfrozen.gameserver.datatables.sql.SpawnTable; | |
| 3387 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 3388 | import com.l2jfrozen.gameserver.idfactory.IdFactory; | |
| 3389 | import com.l2jfrozen.gameserver.managers.CastleManager; | |
| 3390 | import com.l2jfrozen.gameserver.managers.CustomNpcInstanceManager; | |
| 3391 | @@ -2961,6 +2962,20 @@ | |
| 3392 | filename = getHtmlPath(npcId, val); | |
| 3393 | break; | |
| 3394 | } | |
| 3395 | + | |
| 3396 | + if(npcId == EventManager.getInstance().getInt("managerNpcId"))
| |
| 3397 | + {
| |
| 3398 | + EventManager.getInstance().showFirstHtml(player,getObjectId()); | |
| 3399 | + player.sendPacket( new ActionFailed() ); | |
| 3400 | + return; | |
| 3401 | + } | |
| 3402 | + | |
| 3403 | + if(EventManager.getInstance().isRunning() && EventManager.getInstance().isRegistered(player)) | |
| 3404 | + if(EventManager.getInstance().getCurrentEvent().onTalkNpc(this,player)) | |
| 3405 | + {
| |
| 3406 | + player.sendPacket( new ActionFailed() ); | |
| 3407 | + return; | |
| 3408 | + } | |
| 3409 | ||
| 3410 | if(this instanceof L2CastleTeleporterInstance){
| |
| 3411 | ((L2CastleTeleporterInstance)this).showChatWindow(player); | |
| 3412 | Index: head-src/com/l2jfrozen/gameserver/event/DoubleDomination.java | |
| 3413 | =================================================================== | |
| 3414 | --- head-src/com/l2jfrozen/gameserver/event/DoubleDomination.java (revision 0) | |
| 3415 | +++ head-src/com/l2jfrozen/gameserver/event/DoubleDomination.java (revision 0) | |
| 3416 | @@ -0,0 +1,280 @@ | |
| 3417 | +/* | |
| 3418 | + * This program is free software: you can redistribute it and/or modify it under | |
| 3419 | + * the terms of the GNU General Public License as published by the Free Software | |
| 3420 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 3421 | + * version. | |
| 3422 | + * | |
| 3423 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 3424 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 3425 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 3426 | + * details. | |
| 3427 | + * | |
| 3428 | + * You should have received a copy of the GNU General Public License along with | |
| 3429 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 3430 | + */ | |
| 3431 | +package com.l2jfrozen.gameserver.event; | |
| 3432 | + | |
| 3433 | +import javolution.text.TextBuilder; | |
| 3434 | +import javolution.util.FastMap; | |
| 3435 | + | |
| 3436 | +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable; | |
| 3437 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 3438 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 3439 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 3440 | + | |
| 3441 | +/** | |
| 3442 | + * @author Rizel | |
| 3443 | + * | |
| 3444 | + */ | |
| 3445 | +public class DoubleDomination extends Event | |
| 3446 | +{
| |
| 3447 | + private class Core implements Runnable | |
| 3448 | + {
| |
| 3449 | + public void run() | |
| 3450 | + {
| |
| 3451 | + try | |
| 3452 | + {
| |
| 3453 | + switch (eventState) | |
| 3454 | + {
| |
| 3455 | + case START: | |
| 3456 | + divideIntoTeams(2); | |
| 3457 | + preparePlayers(); | |
| 3458 | + teleportToTeamPos(); | |
| 3459 | + createPartyOfTeam(1); | |
| 3460 | + createPartyOfTeam(2); | |
| 3461 | + forceSitAll(); | |
| 3462 | + setStatus(EventState.FIGHT); | |
| 3463 | + debug("The event started with " + players.size() + " players");
| |
| 3464 | + schedule(20000); | |
| 3465 | + break; | |
| 3466 | + | |
| 3467 | + case FIGHT: | |
| 3468 | + forceStandAll(); | |
| 3469 | + setStatus(EventState.END); | |
| 3470 | + debug("The fight started");
| |
| 3471 | + clock.startClock(getInt("matchTime"));
| |
| 3472 | + break; | |
| 3473 | + | |
| 3474 | + case END: | |
| 3475 | + clock.setTime(0); | |
| 3476 | + if (winnerTeam == 0) | |
| 3477 | + winnerTeam = getWinnerTeam(); | |
| 3478 | + | |
| 3479 | + giveReward(getPlayersOfTeam(winnerTeam), getInt("rewardId"), getInt("rewardAmmount"));
| |
| 3480 | + unSpawnZones(); | |
| 3481 | + setStatus(EventState.INACTIVE); | |
| 3482 | + debug("The event ended. Winner: " + winnerTeam);
| |
| 3483 | + EventManager.getInstance().end("Congratulation! The " + teams.get(winnerTeam).getName() + " team won the event with " + teams.get(winnerTeam).getScore() + " Domination points!");
| |
| 3484 | + break; | |
| 3485 | + } | |
| 3486 | + } | |
| 3487 | + catch (Throwable e) | |
| 3488 | + {
| |
| 3489 | + e.printStackTrace(); | |
| 3490 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 3491 | + } | |
| 3492 | + } | |
| 3493 | + } | |
| 3494 | + | |
| 3495 | + private enum EventState | |
| 3496 | + {
| |
| 3497 | + START, FIGHT, END, INACTIVE | |
| 3498 | + } | |
| 3499 | + | |
| 3500 | + private EventState eventState; | |
| 3501 | + | |
| 3502 | + private Core task; | |
| 3503 | + | |
| 3504 | + private FastMap<L2Spawn, Integer> zones; | |
| 3505 | + | |
| 3506 | + private int time; | |
| 3507 | + | |
| 3508 | + private int holder; | |
| 3509 | + | |
| 3510 | + public DoubleDomination() | |
| 3511 | + {
| |
| 3512 | + super(); | |
| 3513 | + eventId = 3; | |
| 3514 | + createNewTeam(1, "Blue", getColor("Blue"), getPosition("Blue", 1));
| |
| 3515 | + createNewTeam(2, "Red", getColor("Red"), getPosition("Red", 1));
| |
| 3516 | + task = new Core(); | |
| 3517 | + zones = new FastMap<L2Spawn, Integer>(); | |
| 3518 | + winnerTeam = 0; | |
| 3519 | + time = 0; | |
| 3520 | + holder = 0; | |
| 3521 | + } | |
| 3522 | + | |
| 3523 | + @Override | |
| 3524 | + protected void clockTick() | |
| 3525 | + {
| |
| 3526 | + int team1 = 0; | |
| 3527 | + int team2 = 0; | |
| 3528 | + | |
| 3529 | + for (L2Spawn zone : zones.keySet()) | |
| 3530 | + {
| |
| 3531 | + for (L2PcInstance player : getPlayerList()) | |
| 3532 | + switch (getTeam(player)) | |
| 3533 | + {
| |
| 3534 | + case 1: | |
| 3535 | + if (Math.sqrt(player.getPlanDistanceSq(zone.getLastSpawn())) <= getInt("zoneRadius"))
| |
| 3536 | + team1++; | |
| 3537 | + break; | |
| 3538 | + | |
| 3539 | + case 2: | |
| 3540 | + if (Math.sqrt(player.getPlanDistanceSq(zone.getLastSpawn())) <= getInt("zoneRadius"))
| |
| 3541 | + team2++; | |
| 3542 | + break; | |
| 3543 | + } | |
| 3544 | + | |
| 3545 | + if (team1 > team2) | |
| 3546 | + zones.getEntry(zone).setValue(1); | |
| 3547 | + | |
| 3548 | + if (team2 > team1) | |
| 3549 | + zones.getEntry(zone).setValue(2); | |
| 3550 | + | |
| 3551 | + if (team1 == team2) | |
| 3552 | + zones.getEntry(zone).setValue(0); | |
| 3553 | + | |
| 3554 | + team1 = 0; | |
| 3555 | + team2 = 0; | |
| 3556 | + } | |
| 3557 | + | |
| 3558 | + if (zones.containsValue(1) && (!zones.containsValue(0) && !zones.containsValue(2))) | |
| 3559 | + {
| |
| 3560 | + if (holder != 1) | |
| 3561 | + {
| |
| 3562 | + announce(getPlayerList(), "The " + teams.get(1).getName() + " team captured both zones. Score in 10sec!"); | |
| 3563 | + holder = 1; | |
| 3564 | + time = 0; | |
| 3565 | + } | |
| 3566 | + | |
| 3567 | + if (time == getInt("timeToScore") - 1)
| |
| 3568 | + {
| |
| 3569 | + for (L2PcInstance player : getPlayersOfTeam(1)) | |
| 3570 | + increasePlayersScore(player); | |
| 3571 | + teams.get(1).increaseScore(); | |
| 3572 | + teleportToTeamPos(); | |
| 3573 | + time = 0; | |
| 3574 | + announce(getPlayerList(), "The " + teams.get(1).getName() + " team scored!"); | |
| 3575 | + holder = 0; | |
| 3576 | + } | |
| 3577 | + else | |
| 3578 | + time++; | |
| 3579 | + | |
| 3580 | + } | |
| 3581 | + else if (zones.containsValue(2) && (!zones.containsValue(0) && !zones.containsValue(1))) | |
| 3582 | + {
| |
| 3583 | + if (holder != 2) | |
| 3584 | + {
| |
| 3585 | + announce(getPlayerList(), "The " + teams.get(2).getName() + " team captured both zones. Score in 10sec!"); | |
| 3586 | + holder = 1; | |
| 3587 | + time = 0; | |
| 3588 | + } | |
| 3589 | + | |
| 3590 | + if (time == getInt("timeToScore") - 1)
| |
| 3591 | + {
| |
| 3592 | + for (L2PcInstance player : getPlayersOfTeam(2)) | |
| 3593 | + increasePlayersScore(player); | |
| 3594 | + teams.get(2).increaseScore(); | |
| 3595 | + teleportToTeamPos(); | |
| 3596 | + time = 0; | |
| 3597 | + announce(getPlayerList(), "The " + teams.get(2).getName() + " team scored!"); | |
| 3598 | + holder = 0; | |
| 3599 | + } | |
| 3600 | + else | |
| 3601 | + time++; | |
| 3602 | + } | |
| 3603 | + else | |
| 3604 | + {
| |
| 3605 | + if (holder != 0) | |
| 3606 | + announce(getPlayerList(), "Canceled!"); | |
| 3607 | + | |
| 3608 | + holder = 0; | |
| 3609 | + time = 0; | |
| 3610 | + } | |
| 3611 | + | |
| 3612 | + } | |
| 3613 | + | |
| 3614 | + /** | |
| 3615 | + * @see net.sf.l2j.gameserver.event.Event#endEvent() | |
| 3616 | + */ | |
| 3617 | + @Override | |
| 3618 | + protected void endEvent() | |
| 3619 | + {
| |
| 3620 | + setStatus(EventState.END); | |
| 3621 | + clock.setTime(0); | |
| 3622 | + | |
| 3623 | + } | |
| 3624 | + | |
| 3625 | + @Override | |
| 3626 | + protected String getScorebar() | |
| 3627 | + {
| |
| 3628 | + return "" + teams.get(1).getName() + ": " + teams.get(1).getScore() + " " + teams.get(2).getName() + ": " + teams.get(2).getScore() + " Time: " + clock.getTime(); | |
| 3629 | + } | |
| 3630 | + | |
| 3631 | + @Override | |
| 3632 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 3633 | + {
| |
| 3634 | + super.onDie(victim, killer); | |
| 3635 | + addToResurrector(victim); | |
| 3636 | + } | |
| 3637 | + | |
| 3638 | + @Override | |
| 3639 | + protected void schedule(int time) | |
| 3640 | + {
| |
| 3641 | + tpm.scheduleGeneral(task, time); | |
| 3642 | + } | |
| 3643 | + | |
| 3644 | + private void setStatus(EventState s) | |
| 3645 | + {
| |
| 3646 | + eventState = s; | |
| 3647 | + } | |
| 3648 | + | |
| 3649 | + @Override | |
| 3650 | + protected void showHtml(L2PcInstance player, int obj) | |
| 3651 | + {
| |
| 3652 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 3653 | + TextBuilder sb = new TextBuilder(); | |
| 3654 | + | |
| 3655 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 3656 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 3657 | + sb.append("<table width=270><tr><td><center><font color=" + teams.get(1).getHexaColor() + ">" + teams.get(1).getScore() + "</font> - " + "<font color=" + teams.get(2).getHexaColor() + ">" + teams.get(2).getScore() + "</font></td></tr></table>");
| |
| 3658 | + sb.append("<br><table width=270>");
| |
| 3659 | + int i = 0; | |
| 3660 | + for (EventTeam team : teams.values()) | |
| 3661 | + {
| |
| 3662 | + i++; | |
| 3663 | + sb.append("<tr><td><font color=" + team.getHexaColor() + ">" + team.getName() + "</font> team</td><td></td><td></td><td></td></tr>");
| |
| 3664 | + for (L2PcInstance p : getPlayersOfTeam(i)) | |
| 3665 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 3666 | + } | |
| 3667 | + | |
| 3668 | + sb.append("</table></body></html>");
| |
| 3669 | + html.setHtml(sb.toString()); | |
| 3670 | + player.sendPacket(html); | |
| 3671 | + | |
| 3672 | + } | |
| 3673 | + | |
| 3674 | + @Override | |
| 3675 | + protected void start() | |
| 3676 | + {
| |
| 3677 | + int[] z1pos = getPosition("Zone", 1);
| |
| 3678 | + int[] z2pos = getPosition("Zone", 2);
| |
| 3679 | + zones.put(spawnNPC(z1pos[0], z1pos[1], z1pos[2], getInt("zoneNpcId")), 0);
| |
| 3680 | + zones.put(spawnNPC(z2pos[0], z2pos[1], z2pos[2], getInt("zoneNpcId")), 0);
| |
| 3681 | + setStatus(EventState.START); | |
| 3682 | + schedule(1); | |
| 3683 | + } | |
| 3684 | + | |
| 3685 | + private void unSpawnZones() | |
| 3686 | + {
| |
| 3687 | + for (L2Spawn s : zones.keySet()) | |
| 3688 | + {
| |
| 3689 | + s.getLastSpawn().deleteMe(); | |
| 3690 | + s.stopRespawn(); | |
| 3691 | + SpawnTable.getInstance().deleteSpawn(s, true); | |
| 3692 | + zones.remove(s); | |
| 3693 | + } | |
| 3694 | + } | |
| 3695 | + | |
| 3696 | +} | |
| 3697 | \ No newline at end of file | |
| 3698 | Index: head-src/com/l2jfrozen/gameserver/handler/skillhandlers/Capture.java | |
| 3699 | =================================================================== | |
| 3700 | --- head-src/com/l2jfrozen/gameserver/handler/skillhandlers/Capture.java (revision 0) | |
| 3701 | +++ head-src/com/l2jfrozen/gameserver/handler/skillhandlers/Capture.java (revision 0) | |
| 3702 | @@ -0,0 +1,35 @@ | |
| 3703 | +package com.l2jfrozen.gameserver.handler.skillhandlers; | |
| 3704 | + | |
| 3705 | +import com.l2jfrozen.gameserver.handler.ISkillHandler; | |
| 3706 | +import com.l2jfrozen.gameserver.model.L2Object; | |
| 3707 | +import com.l2jfrozen.gameserver.model.L2Skill; | |
| 3708 | +import com.l2jfrozen.gameserver.model.L2Character; | |
| 3709 | +import com.l2jfrozen.gameserver.model.L2Skill.SkillType; | |
| 3710 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 3711 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 3712 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 3713 | + | |
| 3714 | +public class Capture implements ISkillHandler | |
| 3715 | +{
| |
| 3716 | +private static final SkillType[] SKILL_IDS = | |
| 3717 | +{ SkillType.CAPTURE };
| |
| 3718 | + | |
| 3719 | +public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) | |
| 3720 | +{
| |
| 3721 | +if (!(activeChar instanceof L2PcInstance)) | |
| 3722 | +return; | |
| 3723 | + | |
| 3724 | +if(!(targets[0] instanceof L2NpcInstance)) | |
| 3725 | +return; | |
| 3726 | + | |
| 3727 | +L2PcInstance player = (L2PcInstance) activeChar; | |
| 3728 | +L2NpcInstance target = (L2NpcInstance) targets[0]; | |
| 3729 | + | |
| 3730 | +EventManager.getInstance().getCurrentEvent().useCapture(player, target); | |
| 3731 | +} | |
| 3732 | + | |
| 3733 | +public SkillType[] getSkillIds() | |
| 3734 | +{
| |
| 3735 | +return SKILL_IDS; | |
| 3736 | +} | |
| 3737 | +} | |
| 3738 | \ No newline at end of file | |
| 3739 | Index: head-src/com/l2jfrozen/gameserver/model/L2Character.java | |
| 3740 | =================================================================== | |
| 3741 | --- head-src/com/l2jfrozen/gameserver/model/L2Character.java (revision 936) | |
| 3742 | +++ head-src/com/l2jfrozen/gameserver/model/L2Character.java (working copy) | |
| 3743 | @@ -46,6 +46,7 @@ | |
| 3744 | import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable; | |
| 3745 | import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable.TeleportWhereType; | |
| 3746 | import com.l2jfrozen.gameserver.datatables.sql.NpcTable; | |
| 3747 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 3748 | import com.l2jfrozen.gameserver.geo.GeoData; | |
| 3749 | import com.l2jfrozen.gameserver.geo.pathfinding.Node; | |
| 3750 | import com.l2jfrozen.gameserver.geo.pathfinding.PathFinding; | |
| 3751 | @@ -1107,6 +1108,53 @@ | |
| 3752 | */ | |
| 3753 | protected void doAttack(L2Character target) | |
| 3754 | {
| |
| 3755 | + if (this instanceof L2PcInstance) | |
| 3756 | + if (EventManager.getInstance().isRegistered((L2PcInstance) this)) | |
| 3757 | + {
| |
| 3758 | + | |
| 3759 | + if (target instanceof L2PcInstance) | |
| 3760 | + if (EventManager.getInstance().areTeammates( | |
| 3761 | + (L2PcInstance) this, (L2PcInstance) target) | |
| 3762 | + && !EventManager.getInstance().getBoolean( | |
| 3763 | + "friendlyFireEnabled")) | |
| 3764 | + {
| |
| 3765 | + sendPacket(new ActionFailed()); | |
| 3766 | + return; | |
| 3767 | + } | |
| 3768 | + | |
| 3769 | + if (!EventManager.getInstance().getCurrentEvent() | |
| 3770 | + .canAttack((L2PcInstance) this, target)) | |
| 3771 | + {
| |
| 3772 | + sendPacket(new ActionFailed()); | |
| 3773 | + return; | |
| 3774 | + } | |
| 3775 | + } | |
| 3776 | + | |
| 3777 | + if (this instanceof L2Summon) | |
| 3778 | + {
| |
| 3779 | + if (EventManager.getInstance().isRegistered( | |
| 3780 | + ((L2Summon) this).getOwner())) | |
| 3781 | + {
| |
| 3782 | + if (target instanceof L2PcInstance) | |
| 3783 | + if (EventManager.getInstance() | |
| 3784 | + .areTeammates(((L2Summon) this).getOwner(), | |
| 3785 | + (L2PcInstance) target) | |
| 3786 | + && !EventManager.getInstance().getBoolean( | |
| 3787 | + "friendlyFireEnabled")) | |
| 3788 | + {
| |
| 3789 | + sendPacket(new ActionFailed()); | |
| 3790 | + return; | |
| 3791 | + } | |
| 3792 | + | |
| 3793 | + if (!EventManager.getInstance().getCurrentEvent() | |
| 3794 | + .canAttack(((L2Summon) this).getOwner(), target)) | |
| 3795 | + {
| |
| 3796 | + sendPacket(new ActionFailed()); | |
| 3797 | + return; | |
| 3798 | + } | |
| 3799 | + } | |
| 3800 | + } | |
| 3801 | + | |
| 3802 | if(Config.DEBUG) | |
| 3803 | {
| |
| 3804 | _log.fine(getName() + " doAttack: target=" + target); | |
| 3805 | @@ -1437,6 +1485,10 @@ | |
| 3806 | {
| |
| 3807 | weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_NONE); | |
| 3808 | } | |
| 3809 | + | |
| 3810 | + if(this instanceof L2PcInstance && target instanceof L2PcInstance) | |
| 3811 | + if(EventManager.getInstance().isRegistered((L2PcInstance)this)) | |
| 3812 | + EventManager.getInstance().getCurrentEvent().onHit((L2PcInstance)this,(L2PcInstance)target); | |
| 3813 | ||
| 3814 | if(player != null) | |
| 3815 | {
| |
| 3816 | @@ -1819,6 +1871,75 @@ | |
| 3817 | */ | |
| 3818 | public void doCast(L2Skill skill) | |
| 3819 | {
| |
| 3820 | + try{
| |
| 3821 | + if(getTarget() != null) | |
| 3822 | + {
| |
| 3823 | + if (this instanceof L2PcInstance) | |
| 3824 | + {
| |
| 3825 | + if (EventManager.getInstance().isRegistered((L2PcInstance) this)) | |
| 3826 | + {
| |
| 3827 | + if (!EventManager.getInstance().getCurrentEvent() | |
| 3828 | + .canAttack((L2PcInstance) this, getTarget())) | |
| 3829 | + return; | |
| 3830 | + | |
| 3831 | + if (this.getTarget() instanceof L2PcInstance) | |
| 3832 | + if (EventManager.getInstance().areTeammates( | |
| 3833 | + (L2PcInstance) this, | |
| 3834 | + (L2PcInstance) this.getTarget()) | |
| 3835 | + && !EventManager.getInstance().getBoolean( | |
| 3836 | + "friendlyFireEnabled") | |
| 3837 | + && skill.isOffensive()) | |
| 3838 | + {
| |
| 3839 | + getAI().notifyEvent(CtrlEvent.EVT_CANCEL); | |
| 3840 | + return; | |
| 3841 | + } | |
| 3842 | + | |
| 3843 | + if (!EventManager.getInstance().getCurrentEvent() | |
| 3844 | + .canAttack((L2PcInstance) this, this.getTarget())) | |
| 3845 | + {
| |
| 3846 | + getAI().notifyEvent(CtrlEvent.EVT_CANCEL); | |
| 3847 | + return; | |
| 3848 | + } | |
| 3849 | + } | |
| 3850 | + } | |
| 3851 | + | |
| 3852 | + if (this instanceof L2Summon) | |
| 3853 | + {
| |
| 3854 | + if(((L2Summon) this).getOwner() != null) | |
| 3855 | + if (EventManager.getInstance().isRegistered( | |
| 3856 | + ((L2Summon) this).getOwner())) | |
| 3857 | + {
| |
| 3858 | + if (!EventManager.getInstance().getCurrentEvent() | |
| 3859 | + .canAttack(((L2Summon) this).getOwner(), getTarget())) | |
| 3860 | + return; | |
| 3861 | + | |
| 3862 | + if (this.getTarget() instanceof L2PcInstance) | |
| 3863 | + if (EventManager.getInstance().areTeammates( | |
| 3864 | + ((L2Summon) this).getOwner(), | |
| 3865 | + (L2PcInstance) this.getTarget()) | |
| 3866 | + && !EventManager.getInstance().getBoolean( | |
| 3867 | + "friendlyFireEnabled") | |
| 3868 | + && skill.isOffensive()) | |
| 3869 | + {
| |
| 3870 | + getAI().notifyEvent(CtrlEvent.EVT_CANCEL); | |
| 3871 | + return; | |
| 3872 | + } | |
| 3873 | + | |
| 3874 | + if (!EventManager | |
| 3875 | + .getInstance() | |
| 3876 | + .getCurrentEvent() | |
| 3877 | + .canAttack(((L2Summon) this).getOwner(), | |
| 3878 | + this.getTarget())) | |
| 3879 | + {
| |
| 3880 | + getAI().notifyEvent(CtrlEvent.EVT_CANCEL); | |
| 3881 | + return; | |
| 3882 | + | |
| 3883 | + } | |
| 3884 | + } | |
| 3885 | + } | |
| 3886 | + } | |
| 3887 | + }catch(ClassCastException e){}
| |
| 3888 | + | |
| 3889 | L2Character activeChar = this; | |
| 3890 | ||
| 3891 | if(skill == null) | |
| 3892 | Index: head-src/com/l2jfrozen/gameserver/event/Zombie.java | |
| 3893 | =================================================================== | |
| 3894 | --- head-src/com/l2jfrozen/gameserver/event/Zombie.java (revision 0) | |
| 3895 | +++ head-src/com/l2jfrozen/gameserver/event/Zombie.java (revision 0) | |
| 3896 | @@ -0,0 +1,212 @@ | |
| 3897 | +package com.l2jfrozen.gameserver.event; | |
| 3898 | + | |
| 3899 | +import javolution.text.TextBuilder; | |
| 3900 | + | |
| 3901 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 3902 | +import com.l2jfrozen.gameserver.model.L2Object; | |
| 3903 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 3904 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 3905 | + | |
| 3906 | +/** | |
| 3907 | + * @author Rizel | |
| 3908 | + * | |
| 3909 | + */ | |
| 3910 | +public class Zombie extends Event | |
| 3911 | +{
| |
| 3912 | + private class Core implements Runnable | |
| 3913 | + {
| |
| 3914 | + public void run() | |
| 3915 | + {
| |
| 3916 | + try | |
| 3917 | + {
| |
| 3918 | + switch (eventState) | |
| 3919 | + {
| |
| 3920 | + case START: | |
| 3921 | + divideIntoTeams(1); | |
| 3922 | + preparePlayers(); | |
| 3923 | + teleportToRandom(); | |
| 3924 | + forceSitAll(); | |
| 3925 | + unequip(); | |
| 3926 | + setStatus(EventState.FIGHT); | |
| 3927 | + schedule(20000); | |
| 3928 | + break; | |
| 3929 | + | |
| 3930 | + case FIGHT: | |
| 3931 | + forceStandAll(); | |
| 3932 | + transform(getRandomPlayer()); | |
| 3933 | + setStatus(EventState.END); | |
| 3934 | + clock.startClock(getInt("matchTime"));
| |
| 3935 | + break; | |
| 3936 | + | |
| 3937 | + case END: | |
| 3938 | + setStatus(EventState.INACTIVE); | |
| 3939 | + clock.setTime(0); | |
| 3940 | + | |
| 3941 | + if (getPlayersWithStatus(0).size() != 1) | |
| 3942 | + {
| |
| 3943 | + msgToAll("Tie!");
| |
| 3944 | + EventManager.getInstance().end("The match has ended in a tie!");
| |
| 3945 | + } | |
| 3946 | + | |
| 3947 | + else | |
| 3948 | + {
| |
| 3949 | + L2PcInstance winner = getWinner(); | |
| 3950 | + giveReward(winner, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 3951 | + EventManager.getInstance().end("Congratulation! " + winner.getName() + " won the event!");
| |
| 3952 | + } | |
| 3953 | + | |
| 3954 | + break; | |
| 3955 | + } | |
| 3956 | + } | |
| 3957 | + catch (Throwable e) | |
| 3958 | + {
| |
| 3959 | + e.printStackTrace(); | |
| 3960 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 3961 | + } | |
| 3962 | + } | |
| 3963 | + } | |
| 3964 | + | |
| 3965 | + private enum EventState | |
| 3966 | + {
| |
| 3967 | + START, FIGHT, END, INACTIVE | |
| 3968 | + } | |
| 3969 | + | |
| 3970 | + private EventState eventState; | |
| 3971 | + | |
| 3972 | + private Core task; | |
| 3973 | + | |
| 3974 | + public Zombie() | |
| 3975 | + {
| |
| 3976 | + super(); | |
| 3977 | + eventId = 9; | |
| 3978 | + createNewTeam(1, "All", getColor("All"), getPosition("All", 1));
| |
| 3979 | + task = new Core(); | |
| 3980 | + } | |
| 3981 | + | |
| 3982 | + @Override | |
| 3983 | + public boolean canAttack(L2PcInstance player, L2Object target) | |
| 3984 | + {
| |
| 3985 | + if (target instanceof L2PcInstance) | |
| 3986 | + if (getStatus(player) == 1 && getStatus((L2PcInstance) target) == 0) | |
| 3987 | + return true; | |
| 3988 | + | |
| 3989 | + return false; | |
| 3990 | + } | |
| 3991 | + | |
| 3992 | + @Override | |
| 3993 | + protected void endEvent() | |
| 3994 | + {
| |
| 3995 | + setStatus(EventState.END); | |
| 3996 | + clock.setTime(0); | |
| 3997 | + } | |
| 3998 | + | |
| 3999 | + @Override | |
| 4000 | + protected String getScorebar() | |
| 4001 | + {
| |
| 4002 | + return "Humans: " + getPlayersWithStatus(0).size() + " Time: " + clock.getTime(); | |
| 4003 | + } | |
| 4004 | + | |
| 4005 | + private L2PcInstance getWinner() | |
| 4006 | + {
| |
| 4007 | + return getPlayersWithStatus(0).head().getNext().getValue(); | |
| 4008 | + } | |
| 4009 | + | |
| 4010 | + @Override | |
| 4011 | + public void onHit(L2PcInstance actor, L2PcInstance target) | |
| 4012 | + {
| |
| 4013 | + if (eventState == EventState.END) | |
| 4014 | + {
| |
| 4015 | + if (getStatus(actor) == 1 && getStatus(target) == 0) | |
| 4016 | + {
| |
| 4017 | + transform(target); | |
| 4018 | + increasePlayersScore(actor); | |
| 4019 | + actor.addItem("Event", 6392, 2, actor, true);
| |
| 4020 | + } | |
| 4021 | + | |
| 4022 | + if (getPlayersWithStatus(0).size() == 1) | |
| 4023 | + schedule(1); | |
| 4024 | + } | |
| 4025 | + | |
| 4026 | + } | |
| 4027 | + | |
| 4028 | + @Override | |
| 4029 | + public void onLogout(L2PcInstance player) | |
| 4030 | + {
| |
| 4031 | + if (getStatus(player) == 1 && getPlayersWithStatus(1).size() == 1) | |
| 4032 | + {
| |
| 4033 | + super.onLogout(player); | |
| 4034 | + transform(getRandomPlayer()); | |
| 4035 | + } | |
| 4036 | + else | |
| 4037 | + {
| |
| 4038 | + super.onLogout(player); | |
| 4039 | + } | |
| 4040 | + | |
| 4041 | + } | |
| 4042 | + | |
| 4043 | + @Override | |
| 4044 | + public boolean onUseItem(L2PcInstance player, L2ItemInstance item) | |
| 4045 | + {
| |
| 4046 | + return false; | |
| 4047 | + } | |
| 4048 | + | |
| 4049 | + @Override | |
| 4050 | + protected void schedule(int time) | |
| 4051 | + {
| |
| 4052 | + tpm.scheduleGeneral(task, time); | |
| 4053 | + } | |
| 4054 | + | |
| 4055 | + private void setStatus(EventState s) | |
| 4056 | + {
| |
| 4057 | + eventState = s; | |
| 4058 | + } | |
| 4059 | + | |
| 4060 | + /* (non-Javadoc) | |
| 4061 | + * @see net.sf.l2j.gameserver.event.Event#showHtml(net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, int) | |
| 4062 | + */ | |
| 4063 | + @Override | |
| 4064 | + protected void showHtml(L2PcInstance player, int obj) | |
| 4065 | + {
| |
| 4066 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 4067 | + TextBuilder sb = new TextBuilder(); | |
| 4068 | + | |
| 4069 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 4070 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 4071 | + sb.append("<table width=270><tr><td><center>Players left: " + getPlayersWithStatus(0).size() + "</td></tr></table>");
| |
| 4072 | + sb.append("<br><table width=270>");
| |
| 4073 | + | |
| 4074 | + for (L2PcInstance p : getPlayersOfTeam(1)) | |
| 4075 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + (getStatus(p) == 1 ? "Zombie" : "Human") + "</td></tr>");
| |
| 4076 | + | |
| 4077 | + sb.append("</table></body></html>");
| |
| 4078 | + html.setHtml(sb.toString()); | |
| 4079 | + player.sendPacket(html); | |
| 4080 | + | |
| 4081 | + } | |
| 4082 | + | |
| 4083 | + @Override | |
| 4084 | + protected void start() | |
| 4085 | + {
| |
| 4086 | + setStatus(EventState.START); | |
| 4087 | + schedule(1); | |
| 4088 | + } | |
| 4089 | + | |
| 4090 | + private void teleportToRandom() | |
| 4091 | + {
| |
| 4092 | + for (L2PcInstance player : players.keySet()) | |
| 4093 | + {
| |
| 4094 | + int[] loc = getPosition("All", 0);
| |
| 4095 | + player.teleToLocation(loc[0], loc[1], loc[2]); | |
| 4096 | + } | |
| 4097 | + } | |
| 4098 | + | |
| 4099 | + protected void transform(L2PcInstance player) | |
| 4100 | + {
| |
| 4101 | + setStatus(player, 1); | |
| 4102 | + polymorph(player,25375); | |
| 4103 | + player.getAppearance().setNameColor(255, 0, 0); | |
| 4104 | + player.broadcastUserInfo(); | |
| 4105 | + player.getInventory().unEquipItemInSlot(10); | |
| 4106 | + player.getInventory().unEquipItemInSlot(16); | |
| 4107 | + } | |
| 4108 | +} | |
| 4109 | \ No newline at end of file | |
| 4110 | Index: head-src/com/l2jfrozen/gameserver/network/serverpackets/ExShowScreenMessage.java | |
| 4111 | =================================================================== | |
| 4112 | --- head-src/com/l2jfrozen/gameserver/network/serverpackets/ExShowScreenMessage.java (revision 936) | |
| 4113 | +++ head-src/com/l2jfrozen/gameserver/network/serverpackets/ExShowScreenMessage.java (working copy) | |
| 4114 | @@ -15,45 +15,78 @@ | |
| 4115 | package com.l2jfrozen.gameserver.network.serverpackets; | |
| 4116 | ||
| 4117 | /** | |
| 4118 | - * @author Kerberos | |
| 4119 | + * @author glory to Setekh for IL opcode ;p | |
| 4120 | */ | |
| 4121 | public class ExShowScreenMessage extends L2GameServerPacket | |
| 4122 | {
| |
| 4123 | - private int _type; | |
| 4124 | - private int _sysMessageId; | |
| 4125 | - private int _unk1; | |
| 4126 | - private int _unk2; | |
| 4127 | - private int _unk3; | |
| 4128 | - private int _unk4; | |
| 4129 | - private int _size; | |
| 4130 | - private int _position; | |
| 4131 | - private boolean _effect; | |
| 4132 | - private String _text; | |
| 4133 | - private int _time; | |
| 4134 | - | |
| 4135 | + public static enum SMPOS | |
| 4136 | + {
| |
| 4137 | + DUMMY, | |
| 4138 | + TOP_LEFT, | |
| 4139 | + TOP_CENTER, | |
| 4140 | + TOP_RIGHT, | |
| 4141 | + MIDDLE_LEFT, | |
| 4142 | + MIDDLE_CENTER, | |
| 4143 | + MIDDLE_RIGHT, | |
| 4144 | + BOTTOM_CENTER, | |
| 4145 | + BOTTOM_RIGHT, | |
| 4146 | + } | |
| 4147 | + | |
| 4148 | + private final int _type; | |
| 4149 | + private final int _sysMessageId; | |
| 4150 | + private final boolean _hide; | |
| 4151 | + private final int _unk2; | |
| 4152 | + private final int _unk3; | |
| 4153 | + private final boolean _fade; | |
| 4154 | + private final int _size; | |
| 4155 | + private final int _position; | |
| 4156 | + private final boolean _effect; | |
| 4157 | + private final String _text; | |
| 4158 | + private final int _time; | |
| 4159 | + | |
| 4160 | public ExShowScreenMessage(String text, int time) | |
| 4161 | {
| |
| 4162 | _type = 1; | |
| 4163 | _sysMessageId = -1; | |
| 4164 | - _unk1 = 0; | |
| 4165 | + _hide = false; | |
| 4166 | _unk2 = 0; | |
| 4167 | _unk3 = 0; | |
| 4168 | - _unk4 = 0; | |
| 4169 | + _fade = false; | |
| 4170 | _position = 0x02; | |
| 4171 | _text = text; | |
| 4172 | _time = time; | |
| 4173 | _size = 0; | |
| 4174 | _effect = false; | |
| 4175 | } | |
| 4176 | - | |
| 4177 | - public ExShowScreenMessage(int type, int messageId, int position, int unk1, int size, int unk2, int unk3, boolean showEffect, int time, int unk4, String text) | |
| 4178 | + | |
| 4179 | + public ExShowScreenMessage(String text, int time, SMPOS pos, boolean effect) | |
| 4180 | + {
| |
| 4181 | + this(text, time, pos.ordinal(), effect); | |
| 4182 | + } | |
| 4183 | + | |
| 4184 | + public ExShowScreenMessage(String text, int time, int pos, boolean effect) | |
| 4185 | + {
| |
| 4186 | + _type = 1; | |
| 4187 | + _sysMessageId = -1; | |
| 4188 | + _hide = false; | |
| 4189 | + _unk2 = 0; | |
| 4190 | + _unk3 = 0; | |
| 4191 | + _fade = false; | |
| 4192 | + _position = pos; | |
| 4193 | + _text = text; | |
| 4194 | + _time = time; | |
| 4195 | + _size = 0; | |
| 4196 | + _effect = effect; | |
| 4197 | + } | |
| 4198 | + | |
| 4199 | + public ExShowScreenMessage(int type, int messageId, int position, boolean hide, int size, int unk2, int unk3, boolean showEffect, int time, boolean fade, String text) | |
| 4200 | {
| |
| 4201 | _type = type; | |
| 4202 | _sysMessageId = messageId; | |
| 4203 | - _unk1 = unk1; | |
| 4204 | + _hide = hide; | |
| 4205 | _unk2 = unk2; | |
| 4206 | _unk3 = unk3; | |
| 4207 | - _unk4 = unk4; | |
| 4208 | + _fade = fade; | |
| 4209 | _position = position; | |
| 4210 | _text = text; | |
| 4211 | _time = time; | |
| 4212 | @@ -62,26 +95,26 @@ | |
| 4213 | } | |
| 4214 | ||
| 4215 | @Override | |
| 4216 | - public String getType() | |
| 4217 | - {
| |
| 4218 | - return "[S]FE:39 ExShowScreenMessage"; | |
| 4219 | - } | |
| 4220 | - | |
| 4221 | - @Override | |
| 4222 | protected void writeImpl() | |
| 4223 | {
| |
| 4224 | writeC(0xfe); | |
| 4225 | - writeH(0x39); | |
| 4226 | + writeH(0x38); | |
| 4227 | writeD(_type); // 0 - system messages, 1 - your defined text | |
| 4228 | writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect) | |
| 4229 | writeD(_position); // message position | |
| 4230 | - writeD(_unk1); // ? | |
| 4231 | + writeD(_hide == true ? 1 : 0); // hide | |
| 4232 | writeD(_size); // font size 0 - normal, 1 - small | |
| 4233 | writeD(_unk2); // ? | |
| 4234 | - writeD(_unk3); // ? | |
| 4235 | + writeD(_unk3); // ? | |
| 4236 | writeD(_effect == true ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect | |
| 4237 | writeD(_time); // time | |
| 4238 | - writeD(_unk4); // ? | |
| 4239 | + writeD(_fade == true ? 1 : 0); // fade effect (0 - disabled, 1 enabled) | |
| 4240 | writeS(_text); // your text (_type must be 1, otherwise no effect) | |
| 4241 | } | |
| 4242 | -} | |
| 4243 | + | |
| 4244 | + @Override | |
| 4245 | + public String getType() | |
| 4246 | + {
| |
| 4247 | + return "[S]FE:38 ExShowScreenMessage"; | |
| 4248 | + } | |
| 4249 | +} | |
| 4250 | \ No newline at end of file | |
| 4251 | Index: head-src/com/l2jfrozen/gameserver/Shutdown.java | |
| 4252 | =================================================================== | |
| 4253 | --- head-src/com/l2jfrozen/gameserver/Shutdown.java (revision 936) | |
| 4254 | +++ head-src/com/l2jfrozen/gameserver/Shutdown.java (working copy) | |
| 4255 | @@ -22,6 +22,8 @@ | |
| 4256 | import java.util.logging.Logger; | |
| 4257 | ||
| 4258 | import com.l2jfrozen.Config; | |
| 4259 | +import com.l2jfrozen.gameserver.event.EventBuffer; | |
| 4260 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 4261 | import com.l2jfrozen.gameserver.controllers.GameTimeController; | |
| 4262 | import com.l2jfrozen.gameserver.controllers.TradeController; | |
| 4263 | import com.l2jfrozen.gameserver.datatables.CharSchemesTable; | |
| 4264 | @@ -678,6 +680,9 @@ | |
| 4265 | ||
| 4266 | CharSchemesTable.getInstance().onServerShutdown(); | |
| 4267 | ||
| 4268 | + if(EventManager.getInstance().getBoolean("eventBufferEnabled"))
| |
| 4269 | + EventBuffer.getInstance().updateSQL(); | |
| 4270 | + | |
| 4271 | //Save items on ground before closing | |
| 4272 | if(Config.SAVE_DROPPED_ITEM) | |
| 4273 | {
| |
| 4274 | Index: head-src/com/l2jfrozen/gameserver/event/Russian.java | |
| 4275 | =================================================================== | |
| 4276 | --- head-src/com/l2jfrozen/gameserver/event/Russian.java (revision 0) | |
| 4277 | +++ head-src/com/l2jfrozen/gameserver/event/Russian.java (revision 0) | |
| 4278 | @@ -0,0 +1,289 @@ | |
| 4279 | +package com.l2jfrozen.gameserver.event; | |
| 4280 | + | |
| 4281 | +import java.util.Map; | |
| 4282 | + | |
| 4283 | +import javolution.text.TextBuilder; | |
| 4284 | +import javolution.util.FastList; | |
| 4285 | +import javolution.util.FastMap; | |
| 4286 | + | |
| 4287 | +import com.l2jfrozen.gameserver.model.L2Object; | |
| 4288 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 4289 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 4290 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 4291 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 4292 | +import com.l2jfrozen.util.random.Rnd; | |
| 4293 | + | |
| 4294 | +/** | |
| 4295 | + * @author Rizel | |
| 4296 | + * | |
| 4297 | + */ | |
| 4298 | +public class Russian extends Event | |
| 4299 | +{
| |
| 4300 | + | |
| 4301 | + private class Core implements Runnable | |
| 4302 | + {
| |
| 4303 | + public void run() | |
| 4304 | + {
| |
| 4305 | + try | |
| 4306 | + {
| |
| 4307 | + switch (eventState) | |
| 4308 | + {
| |
| 4309 | + case START: | |
| 4310 | + divideIntoTeams(1); | |
| 4311 | + preparePlayers(); | |
| 4312 | + teleportToTeamPos(); | |
| 4313 | + forceSitAll(); | |
| 4314 | + spawnRussians(); | |
| 4315 | + setStatus(EventState.CHOOSE); | |
| 4316 | + debug("The event started with " + players.size() + " players");
| |
| 4317 | + schedule(30000); | |
| 4318 | + break; | |
| 4319 | + | |
| 4320 | + case CHOOSE: | |
| 4321 | + if (round == 0) | |
| 4322 | + forceStandAll(); | |
| 4323 | + | |
| 4324 | + round++; | |
| 4325 | + setStatus(EventState.CHECK); | |
| 4326 | + debug("Choose phase.");
| |
| 4327 | + schedule(getInt("roundTime") * 1000);
| |
| 4328 | + break; | |
| 4329 | + | |
| 4330 | + case CHECK: | |
| 4331 | + debug("Check phase");
| |
| 4332 | + removeAfkers(); | |
| 4333 | + killRandomRussian(); | |
| 4334 | + | |
| 4335 | + if (countOfPositiveStatus() != 0) | |
| 4336 | + {
| |
| 4337 | + if (russians.size() != 1) | |
| 4338 | + {
| |
| 4339 | + for (L2PcInstance player : getPlayersWithStatus(1)) | |
| 4340 | + {
| |
| 4341 | + setStatus(player, 0); | |
| 4342 | + increasePlayersScore(player); | |
| 4343 | + player.getAppearance().setNameColor(255, 255, 255); | |
| 4344 | + player.broadcastUserInfo(); | |
| 4345 | + } | |
| 4346 | + | |
| 4347 | + for (FastList<L2PcInstance> chose : choses.values()) | |
| 4348 | + chose.reset(); | |
| 4349 | + | |
| 4350 | + setStatus(EventState.CHOOSE); | |
| 4351 | + schedule(getInt("roundTime") * 1000);
| |
| 4352 | + } | |
| 4353 | + else | |
| 4354 | + {
| |
| 4355 | + for (L2PcInstance player : getPlayersWithStatus(1)) | |
| 4356 | + giveReward(player, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 4357 | + | |
| 4358 | + unspawnRussians(); | |
| 4359 | + debug("Event ended. " + countOfPositiveStatus() + " players survived");
| |
| 4360 | + EventManager.getInstance().end("Congratulation! " + countOfPositiveStatus() + " players survived the event!");
| |
| 4361 | + } | |
| 4362 | + | |
| 4363 | + } | |
| 4364 | + else | |
| 4365 | + {
| |
| 4366 | + unspawnRussians(); | |
| 4367 | + debug("Event ended. Noone survived");
| |
| 4368 | + EventManager.getInstance().end("Unfortunatly no-one survived the event!");
| |
| 4369 | + } | |
| 4370 | + break; | |
| 4371 | + } | |
| 4372 | + } | |
| 4373 | + catch (Throwable e) | |
| 4374 | + {
| |
| 4375 | + e.printStackTrace(); | |
| 4376 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 4377 | + } | |
| 4378 | + | |
| 4379 | + } | |
| 4380 | + } | |
| 4381 | + | |
| 4382 | + private enum EventState | |
| 4383 | + {
| |
| 4384 | + START, CHOOSE, CHECK, INACTIVE | |
| 4385 | + } | |
| 4386 | + | |
| 4387 | + private EventState eventState; | |
| 4388 | + | |
| 4389 | + private Core task; | |
| 4390 | + | |
| 4391 | + private int round; | |
| 4392 | + | |
| 4393 | + private FastMap<Integer, L2Spawn> russians; | |
| 4394 | + | |
| 4395 | + private FastMap<Integer, FastList<L2PcInstance>> choses; | |
| 4396 | + | |
| 4397 | + public Russian() | |
| 4398 | + {
| |
| 4399 | + super(); | |
| 4400 | + eventId = 11; | |
| 4401 | + createNewTeam(1, "All", getColor("All"), getPosition("All", 1));
| |
| 4402 | + task = new Core(); | |
| 4403 | + round = 0; | |
| 4404 | + russians = new FastMap<Integer, L2Spawn>(); | |
| 4405 | + choses = new FastMap<Integer, FastList<L2PcInstance>>(); | |
| 4406 | + } | |
| 4407 | + | |
| 4408 | + @Override | |
| 4409 | + public boolean canAttack(L2PcInstance player, L2Object target) | |
| 4410 | + {
| |
| 4411 | + return false; | |
| 4412 | + } | |
| 4413 | + | |
| 4414 | + @Override | |
| 4415 | + protected void endEvent() | |
| 4416 | + {
| |
| 4417 | + L2PcInstance winner = players.head().getNext().getKey(); | |
| 4418 | + giveReward(winner, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 4419 | + | |
| 4420 | + unspawnRussians(); | |
| 4421 | + debug("Event ended. 1 player survived");
| |
| 4422 | + EventManager.getInstance().end("Congratulation! 1 player survived the event!");
| |
| 4423 | + | |
| 4424 | + } | |
| 4425 | + | |
| 4426 | + @Override | |
| 4427 | + protected String getScorebar() | |
| 4428 | + {
| |
| 4429 | + return ""; | |
| 4430 | + } | |
| 4431 | + | |
| 4432 | + private void killRandomRussian() | |
| 4433 | + {
| |
| 4434 | + FastList<Integer> ids = new FastList<Integer>(); | |
| 4435 | + for (int id : russians.keySet()) | |
| 4436 | + ids.add(id); | |
| 4437 | + int russnum = ids.get(Rnd.get(ids.size())); | |
| 4438 | + L2Spawn russian = russians.get(russnum); | |
| 4439 | + unspawnNPC(russian); | |
| 4440 | + announce(getPlayerList(), "The #" + russnum + " russian died."); | |
| 4441 | + | |
| 4442 | + for (L2PcInstance victim : choses.get(russnum)) | |
| 4443 | + {
| |
| 4444 | + setStatus(victim, -1); | |
| 4445 | + victim.stopAllEffects(); | |
| 4446 | + victim.reduceCurrentHp(victim.getMaxHp() + victim.getMaxCp() + 1, victim); | |
| 4447 | + victim.sendMessage("Your russian died!");
| |
| 4448 | + victim.getAppearance().setNameColor(255, 255, 255); | |
| 4449 | + } | |
| 4450 | + debug("Russian #" + russnum + " died");
| |
| 4451 | + russians.remove(russnum); | |
| 4452 | + } | |
| 4453 | + | |
| 4454 | + @Override | |
| 4455 | + public void onLogout(L2PcInstance player) | |
| 4456 | + {
| |
| 4457 | + super.onLogout(player); | |
| 4458 | + | |
| 4459 | + for (FastList<L2PcInstance> list : choses.values()) | |
| 4460 | + if (list.contains(player)) | |
| 4461 | + list.remove(player); | |
| 4462 | + } | |
| 4463 | + | |
| 4464 | + @Override | |
| 4465 | + public boolean onTalkNpc(L2NpcInstance npc, L2PcInstance player) | |
| 4466 | + {
| |
| 4467 | + if (npc.getNpcId() != getInt("russianNpcId"))
| |
| 4468 | + return false; | |
| 4469 | + | |
| 4470 | + if (getStatus(player) != 0) | |
| 4471 | + return true; | |
| 4472 | + | |
| 4473 | + for (Map.Entry<Integer, L2Spawn> russian : russians.entrySet()) | |
| 4474 | + if (russian.getValue().getLastSpawn().getObjectId() == npc.getObjectId()) | |
| 4475 | + {
| |
| 4476 | + choses.get(russian.getKey()).add(player); | |
| 4477 | + player.getAppearance().setNameColor(0, 255, 0); | |
| 4478 | + player.broadcastUserInfo(); | |
| 4479 | + setStatus(player, 1); | |
| 4480 | + } | |
| 4481 | + | |
| 4482 | + return true; | |
| 4483 | + } | |
| 4484 | + | |
| 4485 | + private void removeAfkers() | |
| 4486 | + {
| |
| 4487 | + int c = 0; | |
| 4488 | + for (L2PcInstance player : getPlayerList()) | |
| 4489 | + if (getStatus(player) == 0) | |
| 4490 | + {
| |
| 4491 | + | |
| 4492 | + player.sendMessage("Timeout!");
| |
| 4493 | + player.stopAllEffects(); | |
| 4494 | + player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, player); | |
| 4495 | + setStatus(player, -1); | |
| 4496 | + c++; | |
| 4497 | + } | |
| 4498 | + debug(c + " afkers removed"); | |
| 4499 | + } | |
| 4500 | + | |
| 4501 | + @Override | |
| 4502 | + public void reset() | |
| 4503 | + {
| |
| 4504 | + super.reset(); | |
| 4505 | + round = 0; | |
| 4506 | + russians.clear(); | |
| 4507 | + choses.clear(); | |
| 4508 | + } | |
| 4509 | + | |
| 4510 | + @Override | |
| 4511 | + protected void schedule(int time) | |
| 4512 | + {
| |
| 4513 | + tpm.scheduleGeneral(task, time); | |
| 4514 | + } | |
| 4515 | + | |
| 4516 | + private void setStatus(EventState s) | |
| 4517 | + {
| |
| 4518 | + eventState = s; | |
| 4519 | + } | |
| 4520 | + | |
| 4521 | + @Override | |
| 4522 | + protected void showHtml(L2PcInstance player, int obj) | |
| 4523 | + {
| |
| 4524 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 4525 | + TextBuilder sb = new TextBuilder(); | |
| 4526 | + | |
| 4527 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 4528 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 4529 | + sb.append("<table width=270><tr><td><center>Russians left: " + russians.size() + "</td></tr></table>");
| |
| 4530 | + sb.append("<br><table width=270>");
| |
| 4531 | + | |
| 4532 | + for (L2PcInstance p : getPlayersOfTeam(1)) | |
| 4533 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + (getStatus(p) == 1 ? "Dead" : "Alive") + "</td></tr>");
| |
| 4534 | + | |
| 4535 | + sb.append("</table></body></html>");
| |
| 4536 | + html.setHtml(sb.toString()); | |
| 4537 | + player.sendPacket(html); | |
| 4538 | + | |
| 4539 | + } | |
| 4540 | + | |
| 4541 | + private void spawnRussians() | |
| 4542 | + {
| |
| 4543 | + for (int i = 1; i <= getInt("numberOfRussians"); i++)
| |
| 4544 | + {
| |
| 4545 | + int[] pos = getPosition("Russian", i);
| |
| 4546 | + russians.put(i, spawnNPC(pos[0], pos[1], pos[2], getInt("russianNpcId")));
| |
| 4547 | + choses.put(i, new FastList<L2PcInstance>()); | |
| 4548 | + russians.get(i).getLastSpawn().setTitle("--" + i + "--");
| |
| 4549 | + } | |
| 4550 | + debug("Russians spawned");
| |
| 4551 | + } | |
| 4552 | + | |
| 4553 | + @Override | |
| 4554 | + protected void start() | |
| 4555 | + {
| |
| 4556 | + setStatus(EventState.START); | |
| 4557 | + schedule(1); | |
| 4558 | + } | |
| 4559 | + | |
| 4560 | + private void unspawnRussians() | |
| 4561 | + {
| |
| 4562 | + for (L2Spawn russian : russians.values()) | |
| 4563 | + unspawnNPC(russian); | |
| 4564 | + | |
| 4565 | + debug("Russians unspawned");
| |
| 4566 | + } | |
| 4567 | +} | |
| 4568 | \ No newline at end of file | |
| 4569 | Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java | |
| 4570 | =================================================================== | |
| 4571 | --- head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java (revision 936) | |
| 4572 | +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java (working copy) | |
| 4573 | @@ -22,6 +22,7 @@ | |
| 4574 | import java.util.logging.Logger; | |
| 4575 | ||
| 4576 | import com.l2jfrozen.Config; | |
| 4577 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 4578 | import com.l2jfrozen.gameserver.ai.CtrlIntention; | |
| 4579 | import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 4580 | import com.l2jfrozen.gameserver.handler.IItemHandler; | |
| 4581 | @@ -167,6 +168,10 @@ | |
| 4582 | return; | |
| 4583 | } | |
| 4584 | ||
| 4585 | + if(EventManager.getInstance().isRunning() && EventManager.getInstance().isRegistered(activeChar)) | |
| 4586 | + if(!EventManager.getInstance().getCurrentEvent().onUseItem(activeChar,item)) | |
| 4587 | + return; | |
| 4588 | + | |
| 4589 | if(activeChar.isFishing() && (itemId < 6535 || itemId > 6540)) | |
| 4590 | {
| |
| 4591 | // You cannot do anything else while fishing | |
| 4592 | Index: head-src/com/l2jfrozen/gameserver/handler/SkillHandler.java | |
| 4593 | =================================================================== | |
| 4594 | --- head-src/com/l2jfrozen/gameserver/handler/SkillHandler.java (revision 936) | |
| 4595 | +++ head-src/com/l2jfrozen/gameserver/handler/SkillHandler.java (working copy) | |
| 4596 | @@ -26,6 +26,8 @@ | |
| 4597 | import com.l2jfrozen.gameserver.handler.skillhandlers.BalanceLife; | |
| 4598 | import com.l2jfrozen.gameserver.handler.skillhandlers.BeastFeed; | |
| 4599 | import com.l2jfrozen.gameserver.handler.skillhandlers.Blow; | |
| 4600 | +import com.l2jfrozen.gameserver.handler.skillhandlers.Bomb; | |
| 4601 | +import com.l2jfrozen.gameserver.handler.skillhandlers.Capture; | |
| 4602 | import com.l2jfrozen.gameserver.handler.skillhandlers.Charge; | |
| 4603 | import com.l2jfrozen.gameserver.handler.skillhandlers.ClanGate; | |
| 4604 | import com.l2jfrozen.gameserver.handler.skillhandlers.CombatPointHeal; | |
| 4605 | @@ -120,6 +122,8 @@ | |
| 4606 | registerSkillHandler(new GetPlayer()); | |
| 4607 | registerSkillHandler(new ZakenPlayer()); | |
| 4608 | registerSkillHandler(new ZakenSelf()); | |
| 4609 | + registerSkillHandler(new Bomb()); | |
| 4610 | + registerSkillHandler(new Capture()); | |
| 4611 | _log.config("SkillHandler: Loaded " + _datatable.size() + " handlers.");
| |
| 4612 | ||
| 4613 | } | |
| 4614 | Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestJoinParty.java | |
| 4615 | =================================================================== | |
| 4616 | --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestJoinParty.java (revision 936) | |
| 4617 | +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestJoinParty.java (working copy) | |
| 4618 | @@ -21,6 +21,8 @@ | |
| 4619 | import java.util.logging.Logger; | |
| 4620 | ||
| 4621 | import com.l2jfrozen.Config; | |
| 4622 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 4623 | +import com.l2jfrozen.gameserver.event.LMS; | |
| 4624 | import com.l2jfrozen.gameserver.model.BlockList; | |
| 4625 | import com.l2jfrozen.gameserver.model.L2Party; | |
| 4626 | import com.l2jfrozen.gameserver.model.L2World; | |
| 4627 | @@ -38,6 +40,7 @@ | |
| 4628 | ||
| 4629 | private String _name; | |
| 4630 | private int _itemDistribution; | |
| 4631 | + private boolean _isInLMS; | |
| 4632 | ||
| 4633 | @Override | |
| 4634 | protected void readImpl() | |
| 4635 | @@ -51,10 +54,17 @@ | |
| 4636 | {
| |
| 4637 | L2PcInstance requestor = getClient().getActiveChar(); | |
| 4638 | L2PcInstance target = L2World.getInstance().getPlayer(_name); | |
| 4639 | + _isInLMS = EventManager.getInstance().isRegistered(requestor) && EventManager.getInstance().getCurrentEvent() instanceof LMS; | |
| 4640 | ||
| 4641 | if(requestor == null) | |
| 4642 | return; | |
| 4643 | ||
| 4644 | + if(_isInLMS) | |
| 4645 | + {
| |
| 4646 | + requestor.sendMessage("You cannot make party in LMS");
| |
| 4647 | + return; | |
| 4648 | + } | |
| 4649 | + | |
| 4650 | if (!getClient().getFloodProtectors().getPartyInvitation().tryPerformAction("PartyInvitation"))
| |
| 4651 | {
| |
| 4652 | requestor.sendMessage("You Cannot Invite into Party So Fast!");
| |
| 4653 | Index: head-src/com/l2jfrozen/gameserver/event/LMS.java | |
| 4654 | =================================================================== | |
| 4655 | --- head-src/com/l2jfrozen/gameserver/event/LMS.java (revision 0) | |
| 4656 | +++ head-src/com/l2jfrozen/gameserver/event/LMS.java (revision 0) | |
| 4657 | @@ -0,0 +1,141 @@ | |
| 4658 | +package com.l2jfrozen.gameserver.event; | |
| 4659 | + | |
| 4660 | +import javolution.text.TextBuilder; | |
| 4661 | + | |
| 4662 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 4663 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 4664 | +import com.l2jfrozen.util.random.Rnd; | |
| 4665 | + | |
| 4666 | +/** | |
| 4667 | + * @author Rizel | |
| 4668 | + * | |
| 4669 | + */ | |
| 4670 | +public class LMS extends Event | |
| 4671 | +{
| |
| 4672 | + private class Core implements Runnable | |
| 4673 | + {
| |
| 4674 | + public void run() | |
| 4675 | + {
| |
| 4676 | + try | |
| 4677 | + {
| |
| 4678 | + switch (eventState) | |
| 4679 | + {
| |
| 4680 | + case START: | |
| 4681 | + divideIntoTeams(1); | |
| 4682 | + preparePlayers(); | |
| 4683 | + teleportToTeamPos(); | |
| 4684 | + forceSitAll(); | |
| 4685 | + setStatus(EventState.FIGHT); | |
| 4686 | + debug("The event started with " + players.size() + " players.");
| |
| 4687 | + schedule(20000); | |
| 4688 | + break; | |
| 4689 | + | |
| 4690 | + case FIGHT: | |
| 4691 | + forceStandAll(); | |
| 4692 | + setStatus(EventState.END); | |
| 4693 | + debug("The event started.");
| |
| 4694 | + clock.startClock(getInt("matchTime"));
| |
| 4695 | + break; | |
| 4696 | + | |
| 4697 | + case END: | |
| 4698 | + clock.setTime(0); | |
| 4699 | + debug("The event ended.");
| |
| 4700 | + L2PcInstance winner = getPlayersWithStatus(0).get(Rnd.get(getPlayersWithStatus(0).size())); | |
| 4701 | + giveReward(winner, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 4702 | + setStatus(EventState.INACTIVE); | |
| 4703 | + EventManager.getInstance().end(winner.getName() + " is the Last Man Standing!"); | |
| 4704 | + break; | |
| 4705 | + } | |
| 4706 | + } | |
| 4707 | + catch (Throwable e) | |
| 4708 | + {
| |
| 4709 | + e.printStackTrace(); | |
| 4710 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 4711 | + } | |
| 4712 | + } | |
| 4713 | + } | |
| 4714 | + | |
| 4715 | + private enum EventState | |
| 4716 | + {
| |
| 4717 | + START, FIGHT, END, INACTIVE | |
| 4718 | + } | |
| 4719 | + | |
| 4720 | + private EventState eventState; | |
| 4721 | + | |
| 4722 | + private Core task; | |
| 4723 | + | |
| 4724 | + public LMS() | |
| 4725 | + {
| |
| 4726 | + super(); | |
| 4727 | + eventId = 4; | |
| 4728 | + createNewTeam(1, "All", getColor("All"), getPosition("All", 1));
| |
| 4729 | + task = new Core(); | |
| 4730 | + } | |
| 4731 | + | |
| 4732 | + @Override | |
| 4733 | + protected void endEvent() | |
| 4734 | + {
| |
| 4735 | + setStatus(EventState.END); | |
| 4736 | + clock.setTime(0); | |
| 4737 | + } | |
| 4738 | + | |
| 4739 | + @Override | |
| 4740 | + protected String getScorebar() | |
| 4741 | + {
| |
| 4742 | + return "Players: " + getPlayersWithStatus(0).size() + " Time: " + clock.getTime(); | |
| 4743 | + } | |
| 4744 | + | |
| 4745 | + @Override | |
| 4746 | + public void onKill(L2PcInstance victim, L2PcInstance killer) | |
| 4747 | + {
| |
| 4748 | + super.onKill(victim, killer); | |
| 4749 | + increasePlayersScore(killer); | |
| 4750 | + setStatus(victim, 1); | |
| 4751 | + if (getPlayersWithStatus(0).size() == 1) | |
| 4752 | + {
| |
| 4753 | + setStatus(EventState.END); | |
| 4754 | + clock.setTime(0); | |
| 4755 | + } | |
| 4756 | + } | |
| 4757 | + | |
| 4758 | + @Override | |
| 4759 | + protected void schedule(int time) | |
| 4760 | + {
| |
| 4761 | + tpm.scheduleGeneral(task, time); | |
| 4762 | + } | |
| 4763 | + | |
| 4764 | + private void setStatus(EventState s) | |
| 4765 | + {
| |
| 4766 | + eventState = s; | |
| 4767 | + } | |
| 4768 | + | |
| 4769 | + /* (non-Javadoc) | |
| 4770 | + * @see net.sf.l2j.gameserver.event.Event#showHtml(net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, int) | |
| 4771 | + */ | |
| 4772 | + @Override | |
| 4773 | + protected void showHtml(L2PcInstance player, int obj) | |
| 4774 | + {
| |
| 4775 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 4776 | + TextBuilder sb = new TextBuilder(); | |
| 4777 | + | |
| 4778 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 4779 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 4780 | + sb.append("<table width=270><tr><td><center>Players left: " + getPlayersWithStatus(0).size() + "</td></tr></table>");
| |
| 4781 | + sb.append("<br><table width=270>");
| |
| 4782 | + | |
| 4783 | + for (L2PcInstance p : getPlayersOfTeam(1)) | |
| 4784 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + (getStatus(p) == 1 ? "Dead" : "Alive") + "</td></tr>");
| |
| 4785 | + | |
| 4786 | + sb.append("</table></body></html>");
| |
| 4787 | + html.setHtml(sb.toString()); | |
| 4788 | + player.sendPacket(html); | |
| 4789 | + | |
| 4790 | + } | |
| 4791 | + | |
| 4792 | + @Override | |
| 4793 | + protected void start() | |
| 4794 | + {
| |
| 4795 | + setStatus(EventState.START); | |
| 4796 | + schedule(1); | |
| 4797 | + } | |
| 4798 | +} | |
| 4799 | \ No newline at end of file | |
| 4800 | Index: head-src/com/l2jfrozen/gameserver/event/TvT.java | |
| 4801 | =================================================================== | |
| 4802 | --- head-src/com/l2jfrozen/gameserver/event/TvT.java (revision 0) | |
| 4803 | +++ head-src/com/l2jfrozen/gameserver/event/TvT.java (revision 0) | |
| 4804 | @@ -0,0 +1,151 @@ | |
| 4805 | +package com.l2jfrozen.gameserver.event; | |
| 4806 | + | |
| 4807 | +import javolution.text.TextBuilder; | |
| 4808 | + | |
| 4809 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 4810 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 4811 | + | |
| 4812 | +public class TvT extends Event | |
| 4813 | +{
| |
| 4814 | + private class Core implements Runnable | |
| 4815 | + {
| |
| 4816 | + public void run() | |
| 4817 | + {
| |
| 4818 | + try | |
| 4819 | + {
| |
| 4820 | + switch (eventState) | |
| 4821 | + {
| |
| 4822 | + case START: | |
| 4823 | + divideIntoTeams(2); | |
| 4824 | + preparePlayers(); | |
| 4825 | + teleportToTeamPos(); | |
| 4826 | + createPartyOfTeam(1); | |
| 4827 | + createPartyOfTeam(2); | |
| 4828 | + forceSitAll(); | |
| 4829 | + setStatus(EventState.FIGHT); | |
| 4830 | + schedule(20000); | |
| 4831 | + break; | |
| 4832 | + | |
| 4833 | + case FIGHT: | |
| 4834 | + forceStandAll(); | |
| 4835 | + setStatus(EventState.END); | |
| 4836 | + clock.startClock(getInt("matchTime"));
| |
| 4837 | + break; | |
| 4838 | + | |
| 4839 | + case END: | |
| 4840 | + clock.setTime(0); | |
| 4841 | + if (winnerTeam == 0) | |
| 4842 | + winnerTeam = getWinnerTeam(); | |
| 4843 | + | |
| 4844 | + giveReward(getPlayersOfTeam(winnerTeam), getInt("rewardId"), getInt("rewardAmmount"));
| |
| 4845 | + setStatus(EventState.INACTIVE); | |
| 4846 | + EventManager.getInstance().end("Congratulation! The " + teams.get(winnerTeam).getName() + " team won the event with " + teams.get(winnerTeam).getScore() + " kills!");
| |
| 4847 | + break; | |
| 4848 | + } | |
| 4849 | + } | |
| 4850 | + catch (Throwable e) | |
| 4851 | + {
| |
| 4852 | + e.printStackTrace(); | |
| 4853 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 4854 | + } | |
| 4855 | + } | |
| 4856 | + } | |
| 4857 | + | |
| 4858 | + private enum EventState | |
| 4859 | + {
| |
| 4860 | + START, FIGHT, END, TELEPORT, INACTIVE | |
| 4861 | + } | |
| 4862 | + | |
| 4863 | + private EventState eventState; | |
| 4864 | + | |
| 4865 | + private Core task; | |
| 4866 | + | |
| 4867 | + public TvT() | |
| 4868 | + {
| |
| 4869 | + super(); | |
| 4870 | + eventId = 7; | |
| 4871 | + createNewTeam(1, "Blue", getColor("Blue"), getPosition("Blue", 1));
| |
| 4872 | + createNewTeam(2, "Red", getColor("Red"), getPosition("Red", 1));
| |
| 4873 | + task = new Core(); | |
| 4874 | + winnerTeam = 0; | |
| 4875 | + } | |
| 4876 | + | |
| 4877 | + @Override | |
| 4878 | + protected void endEvent() | |
| 4879 | + {
| |
| 4880 | + winnerTeam = players.head().getNext().getValue()[0]; | |
| 4881 | + | |
| 4882 | + setStatus(EventState.END); | |
| 4883 | + clock.setTime(0); | |
| 4884 | + | |
| 4885 | + } | |
| 4886 | + | |
| 4887 | + @Override | |
| 4888 | + protected String getScorebar() | |
| 4889 | + {
| |
| 4890 | + return "" + teams.get(1).getName() + ": " + teams.get(1).getScore() + " " + teams.get(2).getName() + ": " + teams.get(2).getScore() + " Time: " + clock.getTime(); | |
| 4891 | + } | |
| 4892 | + | |
| 4893 | + @Override | |
| 4894 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 4895 | + {
| |
| 4896 | + super.onDie(victim, killer); | |
| 4897 | + addToResurrector(victim); | |
| 4898 | + } | |
| 4899 | + | |
| 4900 | + @Override | |
| 4901 | + public void onKill(L2PcInstance victim, L2PcInstance killer) | |
| 4902 | + {
| |
| 4903 | + super.onKill(victim, killer); | |
| 4904 | + if (getPlayersTeam(killer) != getPlayersTeam(victim)) | |
| 4905 | + {
| |
| 4906 | + getPlayersTeam(killer).increaseScore(); | |
| 4907 | + killer.addItem("Event", 6392, 1, killer, true);
| |
| 4908 | + increasePlayersScore(killer); | |
| 4909 | + } | |
| 4910 | + | |
| 4911 | + } | |
| 4912 | + | |
| 4913 | + @Override | |
| 4914 | + protected void schedule(int time) | |
| 4915 | + {
| |
| 4916 | + tpm.scheduleGeneral(task, time); | |
| 4917 | + } | |
| 4918 | + | |
| 4919 | + private void setStatus(EventState s) | |
| 4920 | + {
| |
| 4921 | + eventState = s; | |
| 4922 | + } | |
| 4923 | + | |
| 4924 | + @Override | |
| 4925 | + protected void showHtml(L2PcInstance player, int obj) | |
| 4926 | + {
| |
| 4927 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 4928 | + TextBuilder sb = new TextBuilder(); | |
| 4929 | + | |
| 4930 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 4931 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 4932 | + sb.append("<center><table width=270><tr><td><center><font color=" + teams.get(1).getHexaColor() + ">" + teams.get(1).getScore() + "</font> - " + "<font color=" + teams.get(2).getHexaColor() + ">" + teams.get(2).getScore() + "</font></td></tr></table>");
| |
| 4933 | + sb.append("<br><table width=270>");
| |
| 4934 | + int i = 0; | |
| 4935 | + for (EventTeam team : teams.values()) | |
| 4936 | + {
| |
| 4937 | + i++; | |
| 4938 | + sb.append("<tr><td><font color=" + team.getHexaColor() + ">" + team.getName() + "</font> team</td><td></td><td></td><td></td></tr>");
| |
| 4939 | + for (L2PcInstance p : getPlayersOfTeam(i)) | |
| 4940 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 4941 | + } | |
| 4942 | + | |
| 4943 | + sb.append("</table></body></html>");
| |
| 4944 | + html.setHtml(sb.toString()); | |
| 4945 | + player.sendPacket(html); | |
| 4946 | + | |
| 4947 | + } | |
| 4948 | + | |
| 4949 | + @Override | |
| 4950 | + protected void start() | |
| 4951 | + {
| |
| 4952 | + setStatus(EventState.START); | |
| 4953 | + schedule(1); | |
| 4954 | + } | |
| 4955 | +} | |
| 4956 | \ No newline at end of file | |
| 4957 | Index: head-src/com/l2jfrozen/gameserver/handler/skillhandlers/Bomb.java | |
| 4958 | =================================================================== | |
| 4959 | --- head-src/com/l2jfrozen/gameserver/handler/skillhandlers/Bomb.java (revision 0) | |
| 4960 | +++ head-src/com/l2jfrozen/gameserver/handler/skillhandlers/Bomb.java (revision 0) | |
| 4961 | @@ -0,0 +1,30 @@ | |
| 4962 | +package com.l2jfrozen.gameserver.handler.skillhandlers; | |
| 4963 | + | |
| 4964 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 4965 | +import com.l2jfrozen.gameserver.handler.ISkillHandler; | |
| 4966 | +import com.l2jfrozen.gameserver.model.L2Character; | |
| 4967 | +import com.l2jfrozen.gameserver.model.L2Object; | |
| 4968 | +import com.l2jfrozen.gameserver.model.L2Skill; | |
| 4969 | +import com.l2jfrozen.gameserver.model.L2Skill.SkillType; | |
| 4970 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 4971 | + | |
| 4972 | +public class Bomb implements ISkillHandler | |
| 4973 | +{
| |
| 4974 | +private static final SkillType[] SKILL_IDS = | |
| 4975 | +{ SkillType.BOMB };
| |
| 4976 | + | |
| 4977 | +public void useSkill(L2Character activeChar, L2Skill skill, | |
| 4978 | +L2Object[] targets) | |
| 4979 | +{
| |
| 4980 | + | |
| 4981 | +if (!(activeChar instanceof L2PcInstance)) | |
| 4982 | +return; | |
| 4983 | + | |
| 4984 | +EventManager.getInstance().getCurrentEvent().dropBomb((L2PcInstance)activeChar); | |
| 4985 | +} | |
| 4986 | + | |
| 4987 | +public SkillType[] getSkillIds() | |
| 4988 | +{
| |
| 4989 | +return SKILL_IDS; | |
| 4990 | +} | |
| 4991 | +} | |
| 4992 | \ No newline at end of file | |
| 4993 | Index: head-src/com/l2jfrozen/gameserver/event/Mutant.java | |
| 4994 | =================================================================== | |
| 4995 | --- head-src/com/l2jfrozen/gameserver/event/Mutant.java (revision 0) | |
| 4996 | +++ head-src/com/l2jfrozen/gameserver/event/Mutant.java (revision 0) | |
| 4997 | @@ -0,0 +1,212 @@ | |
| 4998 | +/* | |
| 4999 | + * This program is free software: you can redistribute it and/or modify it under | |
| 5000 | + * the terms of the GNU General Public License as published by the Free Software | |
| 5001 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 5002 | + * version. | |
| 5003 | + * | |
| 5004 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 5005 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 5006 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 5007 | + * details. | |
| 5008 | + * | |
| 5009 | + * You should have received a copy of the GNU General Public License along with | |
| 5010 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 5011 | + */ | |
| 5012 | +package com.l2jfrozen.gameserver.event; | |
| 5013 | + | |
| 5014 | +import javolution.text.TextBuilder; | |
| 5015 | + | |
| 5016 | +import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 5017 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 5018 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 5019 | +import com.l2jfrozen.gameserver.model.L2Object; | |
| 5020 | + | |
| 5021 | +/** | |
| 5022 | + * @author Rizel | |
| 5023 | + * | |
| 5024 | + */ | |
| 5025 | +public class Mutant extends Event | |
| 5026 | +{
| |
| 5027 | + | |
| 5028 | + private class Core implements Runnable | |
| 5029 | + {
| |
| 5030 | + public void run() | |
| 5031 | + {
| |
| 5032 | + try | |
| 5033 | + {
| |
| 5034 | + switch (eventState) | |
| 5035 | + {
| |
| 5036 | + case START: | |
| 5037 | + divideIntoTeams(1); | |
| 5038 | + preparePlayers(); | |
| 5039 | + teleportToTeamPos(); | |
| 5040 | + forceSitAll(); | |
| 5041 | + setStatus(EventState.FIGHT); | |
| 5042 | + schedule(20000); | |
| 5043 | + break; | |
| 5044 | + | |
| 5045 | + case FIGHT: | |
| 5046 | + forceStandAll(); | |
| 5047 | + transformMutant(getRandomPlayer()); | |
| 5048 | + setStatus(EventState.END); | |
| 5049 | + clock.startClock(getInt("matchTime"));
| |
| 5050 | + break; | |
| 5051 | + | |
| 5052 | + case END: | |
| 5053 | + clock.setTime(0); | |
| 5054 | + untransformMutant(); | |
| 5055 | + L2PcInstance winner = getPlayerWithMaxScore(); | |
| 5056 | + giveReward(winner, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 5057 | + setStatus(EventState.INACTIVE); | |
| 5058 | + EventManager.getInstance().end("Congratulation! " + winner.getName() + " won the event with " + getScore(winner) + " kills!");
| |
| 5059 | + break; | |
| 5060 | + } | |
| 5061 | + } | |
| 5062 | + catch (Throwable e) | |
| 5063 | + {
| |
| 5064 | + e.printStackTrace(); | |
| 5065 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 5066 | + } | |
| 5067 | + } | |
| 5068 | + } | |
| 5069 | + | |
| 5070 | + private enum EventState | |
| 5071 | + {
| |
| 5072 | + START, FIGHT, END, INACTIVE | |
| 5073 | + } | |
| 5074 | + | |
| 5075 | + private EventState eventState; | |
| 5076 | + | |
| 5077 | + private Core task; | |
| 5078 | + | |
| 5079 | + private L2PcInstance mutant; | |
| 5080 | + | |
| 5081 | + public Mutant() | |
| 5082 | + {
| |
| 5083 | + super(); | |
| 5084 | + eventId = 13; | |
| 5085 | + createNewTeam(1, "All", getColor("All"), getPosition("All", 1));
| |
| 5086 | + task = new Core(); | |
| 5087 | + } | |
| 5088 | + | |
| 5089 | + /** | |
| 5090 | + * @see net.sf.l2j.gameserver.event.Event#endEvent() | |
| 5091 | + */ | |
| 5092 | + @Override | |
| 5093 | + protected void endEvent() | |
| 5094 | + {
| |
| 5095 | + setStatus(EventState.END); | |
| 5096 | + clock.setTime(0); | |
| 5097 | + } | |
| 5098 | + | |
| 5099 | + @Override | |
| 5100 | + protected String getScorebar() | |
| 5101 | + {
| |
| 5102 | + return "Max: " + getScore(getPlayerWithMaxScore()) + " Time: " + clock.getTime() + ""; | |
| 5103 | + } | |
| 5104 | + | |
| 5105 | + @Override | |
| 5106 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 5107 | + {
| |
| 5108 | + super.onDie(victim, killer); | |
| 5109 | + addToResurrector(victim); | |
| 5110 | + } | |
| 5111 | + | |
| 5112 | + @Override | |
| 5113 | + public void onKill(L2PcInstance victim, L2PcInstance killer) | |
| 5114 | + {
| |
| 5115 | + super.onKill(victim, killer); | |
| 5116 | + if (getStatus(killer) == 1) | |
| 5117 | + increasePlayersScore(killer); | |
| 5118 | + if (getStatus(killer) == 0 && getStatus(victim) == 1) | |
| 5119 | + transformMutant(killer); | |
| 5120 | + killer.addItem("Event", 6392, 1, killer, true);
| |
| 5121 | + } | |
| 5122 | + | |
| 5123 | + @Override | |
| 5124 | + public void onLogout(L2PcInstance player) | |
| 5125 | + {
| |
| 5126 | + super.onLogout(player); | |
| 5127 | + | |
| 5128 | + if (mutant == player) | |
| 5129 | + transformMutant(getRandomPlayer()); | |
| 5130 | + } | |
| 5131 | + | |
| 5132 | + @Override | |
| 5133 | + protected void schedule(int time) | |
| 5134 | + {
| |
| 5135 | + tpm.scheduleGeneral(task, time); | |
| 5136 | + } | |
| 5137 | + | |
| 5138 | + private void setStatus(EventState s) | |
| 5139 | + {
| |
| 5140 | + eventState = s; | |
| 5141 | + } | |
| 5142 | + | |
| 5143 | + @Override | |
| 5144 | + protected void showHtml(L2PcInstance player, int obj) | |
| 5145 | + {
| |
| 5146 | + if (players.size() > 0) | |
| 5147 | + {
| |
| 5148 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 5149 | + TextBuilder sb = new TextBuilder(); | |
| 5150 | + | |
| 5151 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 5152 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 5153 | + sb.append("<table width=270><tr><td><center>" + getPlayerWithMaxScore().getName() + " - " + getScore(getPlayerWithMaxScore()) + "</td></tr></table>");
| |
| 5154 | + sb.append("<br><table width=270>");
| |
| 5155 | + | |
| 5156 | + for (L2PcInstance p : getPlayersOfTeam(1)) | |
| 5157 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 5158 | + | |
| 5159 | + sb.append("</table></body></html>");
| |
| 5160 | + html.setHtml(sb.toString()); | |
| 5161 | + player.sendPacket(html); | |
| 5162 | + } | |
| 5163 | + | |
| 5164 | + } | |
| 5165 | + | |
| 5166 | + @Override | |
| 5167 | + protected void start() | |
| 5168 | + {
| |
| 5169 | + setStatus(EventState.START); | |
| 5170 | + schedule(1); | |
| 5171 | + } | |
| 5172 | + | |
| 5173 | + private void transformMutant(L2PcInstance player) | |
| 5174 | + {
| |
| 5175 | + player.addSkill(SkillTable.getInstance().getInfo(getInt("mutantBuffId"), 1), false);
| |
| 5176 | + setStatus(player, 1); | |
| 5177 | + untransformMutant(); | |
| 5178 | + polymorph(player,25286); | |
| 5179 | + player.getAppearance().setNameColor(255, 0, 0); | |
| 5180 | + player.broadcastUserInfo(); | |
| 5181 | + mutant = player; | |
| 5182 | + | |
| 5183 | + } | |
| 5184 | + | |
| 5185 | + private void untransformMutant() | |
| 5186 | + {
| |
| 5187 | + if (mutant != null) | |
| 5188 | + {
| |
| 5189 | + mutant.getAppearance().setNameColor(getColor("All")[0], getColor("All")[1], getColor("All")[2]);
| |
| 5190 | + mutant.removeSkill(SkillTable.getInstance().getInfo(getInt("mutantBuffId"), 1), false);
| |
| 5191 | + setStatus(mutant, 0); | |
| 5192 | + unpolymorph(mutant); | |
| 5193 | + mutant.broadcastUserInfo(); | |
| 5194 | + mutant = null; | |
| 5195 | + } | |
| 5196 | + } | |
| 5197 | + @Override | |
| 5198 | + public boolean canAttack(L2PcInstance player, L2Object target) | |
| 5199 | + {
| |
| 5200 | + if (target instanceof L2PcInstance) | |
| 5201 | + if (getStatus(player) == 0 && getStatus((L2PcInstance) target) == 0) | |
| 5202 | + return false; | |
| 5203 | + else | |
| 5204 | + return true; | |
| 5205 | + | |
| 5206 | + return false; | |
| 5207 | + } | |
| 5208 | + | |
| 5209 | +} | |
| 5210 | \ No newline at end of file | |
| 5211 | Index: head-src/com/l2jfrozen/gameserver/model/L2Skill.java | |
| 5212 | =================================================================== | |
| 5213 | --- head-src/com/l2jfrozen/gameserver/model/L2Skill.java (revision 936) | |
| 5214 | +++ head-src/com/l2jfrozen/gameserver/model/L2Skill.java (working copy) | |
| 5215 | @@ -31,6 +31,7 @@ | |
| 5216 | import com.l2jfrozen.gameserver.datatables.HeroSkillTable; | |
| 5217 | import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 5218 | import com.l2jfrozen.gameserver.datatables.sql.SkillTreeTable; | |
| 5219 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 5220 | import com.l2jfrozen.gameserver.geo.GeoData; | |
| 5221 | import com.l2jfrozen.gameserver.managers.SiegeManager; | |
| 5222 | import com.l2jfrozen.gameserver.model.actor.instance.L2ArtefactInstance; | |
| 5223 | @@ -263,6 +264,8 @@ | |
| 5224 | COREDONE, | |
| 5225 | ZAKENPLAYER, | |
| 5226 | ZAKENSELF, | |
| 5227 | + BOMB, | |
| 5228 | + CAPTURE, | |
| 5229 | ||
| 5230 | // unimplemented | |
| 5231 | NOTDONE; | |
| 5232 | @@ -1968,6 +1971,20 @@ | |
| 5233 | continue; | |
| 5234 | } | |
| 5235 | } | |
| 5236 | + | |
| 5237 | + if(obj instanceof L2PcInstance && activeChar instanceof L2PcInstance) | |
| 5238 | + if(EventManager.getInstance().getCurrentEvent().numberOfTeams() > 1 && | |
| 5239 | + EventManager.getInstance().isRegistered((L2PcInstance)activeChar) && | |
| 5240 | + EventManager.getInstance().isRegistered((L2PcInstance)obj) && | |
| 5241 | + EventManager.getInstance().getCurrentEvent().getTeam((L2PcInstance)obj) == EventManager.getInstance().getCurrentEvent().getTeam((L2PcInstance)activeChar)) | |
| 5242 | + continue; | |
| 5243 | + | |
| 5244 | + if(obj instanceof L2Summon && activeChar instanceof L2PcInstance) | |
| 5245 | + if(EventManager.getInstance().getCurrentEvent().numberOfTeams() > 1 && | |
| 5246 | + EventManager.getInstance().isRegistered((L2PcInstance)activeChar) && | |
| 5247 | + EventManager.getInstance().isRegistered(((L2Summon)obj).getOwner()) && | |
| 5248 | + EventManager.getInstance().getCurrentEvent().getTeam(((L2Summon)obj).getOwner()) == EventManager.getInstance().getCurrentEvent().getTeam((L2PcInstance)activeChar)) | |
| 5249 | + continue; | |
| 5250 | ||
| 5251 | targetList.add((L2Character) obj); | |
| 5252 | } | |
| 5253 | Index: head-src/com/l2jfrozen/gameserver/event/Bomb.java | |
| 5254 | =================================================================== | |
| 5255 | --- head-src/com/l2jfrozen/gameserver/event/Bomb.java (revision 0) | |
| 5256 | +++ head-src/com/l2jfrozen/gameserver/event/Bomb.java (revision 0) | |
| 5257 | @@ -0,0 +1,261 @@ | |
| 5258 | +package com.l2jfrozen.gameserver.event; | |
| 5259 | + | |
| 5260 | +import javolution.text.TextBuilder; | |
| 5261 | +import javolution.util.FastList; | |
| 5262 | +import javolution.util.FastMap; | |
| 5263 | + | |
| 5264 | +import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 5265 | +import com.l2jfrozen.gameserver.model.L2Object; | |
| 5266 | +import com.l2jfrozen.gameserver.model.L2Skill; | |
| 5267 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 5268 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 5269 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 5270 | +import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillLaunched; | |
| 5271 | +import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser; | |
| 5272 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 5273 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcInfo; | |
| 5274 | +import com.l2jfrozen.util.random.Rnd; | |
| 5275 | + | |
| 5276 | +public class Bomb extends Event | |
| 5277 | +{
| |
| 5278 | + private class Bomber implements Runnable | |
| 5279 | + {
| |
| 5280 | + public void run() | |
| 5281 | + {
| |
| 5282 | + explode(bombs.head().getNext().getKey()); | |
| 5283 | + bombs.remove(bombs.head().getNext().getKey()); | |
| 5284 | + } | |
| 5285 | + } | |
| 5286 | + | |
| 5287 | + private class Core implements Runnable | |
| 5288 | + {
| |
| 5289 | + public void run() | |
| 5290 | + {
| |
| 5291 | + try | |
| 5292 | + {
| |
| 5293 | + switch (eventState) | |
| 5294 | + {
| |
| 5295 | + case START: | |
| 5296 | + divideIntoTeams(2); | |
| 5297 | + preparePlayers(); | |
| 5298 | + teleportToTeamPos(); | |
| 5299 | + createPartyOfTeam(1); | |
| 5300 | + createPartyOfTeam(2); | |
| 5301 | + forceSitAll(); | |
| 5302 | + unequip(); | |
| 5303 | + giveSkill(); | |
| 5304 | + debug("The event initialized with " + players.size() + " players");
| |
| 5305 | + setStatus(EventState.FIGHT); | |
| 5306 | + schedule(20000); | |
| 5307 | + break; | |
| 5308 | + | |
| 5309 | + case FIGHT: | |
| 5310 | + forceStandAll(); | |
| 5311 | + setStatus(EventState.END); | |
| 5312 | + debug("The fight started");
| |
| 5313 | + clock.startClock(getInt("matchTime"));
| |
| 5314 | + break; | |
| 5315 | + | |
| 5316 | + case END: | |
| 5317 | + clock.setTime(0); | |
| 5318 | + if (winnerTeam == 0) | |
| 5319 | + winnerTeam = getWinnerTeam(); | |
| 5320 | + | |
| 5321 | + removeSkill(); | |
| 5322 | + giveReward(getPlayersOfTeam(winnerTeam), getInt("rewardId"), getInt("rewardAmmount"));
| |
| 5323 | + debug("The event ended. Winner: " + winnerTeam);
| |
| 5324 | + setStatus(EventState.INACTIVE); | |
| 5325 | + EventManager.getInstance().end("Congratulation! The " + teams.get(winnerTeam).getName() + " team won the event with " + teams.get(winnerTeam).getScore() + " kills!");
| |
| 5326 | + break; | |
| 5327 | + } | |
| 5328 | + } | |
| 5329 | + catch (Throwable e) | |
| 5330 | + {
| |
| 5331 | + e.printStackTrace(); | |
| 5332 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 5333 | + } | |
| 5334 | + } | |
| 5335 | + } | |
| 5336 | + | |
| 5337 | + private enum EventState | |
| 5338 | + {
| |
| 5339 | + START, FIGHT, END, TELEPORT, INACTIVE | |
| 5340 | + } | |
| 5341 | + | |
| 5342 | + private EventState eventState; | |
| 5343 | + | |
| 5344 | + private Core task; | |
| 5345 | + | |
| 5346 | + private FastMap<L2Spawn, L2PcInstance> bombs; | |
| 5347 | + | |
| 5348 | + private Bomber bomber; | |
| 5349 | + | |
| 5350 | + public Bomb() | |
| 5351 | + {
| |
| 5352 | + super(); | |
| 5353 | + eventId = 12; | |
| 5354 | + createNewTeam(1, "Blue", getColor("Blue"), getPosition("Blue", 1));
| |
| 5355 | + createNewTeam(2, "Red", getColor("Red"), getPosition("Red", 1));
| |
| 5356 | + task = new Core(); | |
| 5357 | + bomber = new Bomber(); | |
| 5358 | + bombs = new FastMap<L2Spawn, L2PcInstance>(); | |
| 5359 | + winnerTeam = 0; | |
| 5360 | + } | |
| 5361 | + | |
| 5362 | + @Override | |
| 5363 | + public void dropBomb(L2PcInstance player) | |
| 5364 | + {
| |
| 5365 | + bombs.put(spawnNPC(player.getX(), player.getY(), player.getZ(), getInt("bombNpcId")), player);
| |
| 5366 | + bombs.tail().getPrevious().getKey().getLastSpawn().setTitle((getTeam(player) == 1 ? "Blue" : "Red")); | |
| 5367 | + bombs.tail().getPrevious().getKey().getLastSpawn().broadcastStatusUpdate(); | |
| 5368 | + | |
| 5369 | + for(L2PcInstance p : getPlayerList()) | |
| 5370 | + p.sendPacket(new NpcInfo(bombs.tail().getPrevious().getKey().getLastSpawn(), p)); | |
| 5371 | + | |
| 5372 | + tpm.scheduleGeneral(bomber, 3000); | |
| 5373 | + } | |
| 5374 | + | |
| 5375 | + @Override | |
| 5376 | + protected void endEvent() | |
| 5377 | + {
| |
| 5378 | + winnerTeam = players.head().getNext().getValue()[0]; | |
| 5379 | + | |
| 5380 | + setStatus(EventState.END); | |
| 5381 | + clock.setTime(0); | |
| 5382 | + | |
| 5383 | + } | |
| 5384 | + | |
| 5385 | + private void explode(L2Spawn bomb) | |
| 5386 | + {
| |
| 5387 | + FastList<L2Object> victims = new FastList<L2Object>(); | |
| 5388 | + | |
| 5389 | + for (L2PcInstance player : getPlayerList()) | |
| 5390 | + {
| |
| 5391 | + if(player == null) | |
| 5392 | + continue; | |
| 5393 | + | |
| 5394 | + if(player.isInvul()) | |
| 5395 | + continue; | |
| 5396 | + | |
| 5397 | + if (getTeam(bombs.get(bomb)) != getTeam(player) && Math.sqrt(player.getPlanDistanceSq(bomb.getLastSpawn())) <= getInt("bombRadius"))
| |
| 5398 | + {
| |
| 5399 | + player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, bomb.getLastSpawn()); | |
| 5400 | + increasePlayersScore(bombs.get(bomb)); | |
| 5401 | + EventStats.getInstance().tempTable.get(player.getObjectId())[2] = EventStats.getInstance().tempTable.get(player.getObjectId())[2] + 1; | |
| 5402 | + addToResurrector(player); | |
| 5403 | + | |
| 5404 | + victims.add(player); | |
| 5405 | + | |
| 5406 | + if (getTeam(player) == 1) | |
| 5407 | + teams.get(2).increaseScore(); | |
| 5408 | + if (getTeam(player) == 2) | |
| 5409 | + teams.get(1).increaseScore(); | |
| 5410 | + } | |
| 5411 | + if (victims.size() != 0) | |
| 5412 | + {
| |
| 5413 | + bomb.getLastSpawn().broadcastPacket(new MagicSkillUser(bomb.getLastSpawn(), (L2PcInstance) victims.head().getNext().getValue(), 18, 1, 0, 0)); | |
| 5414 | + bomb.getLastSpawn().broadcastPacket(new MagicSkillLaunched(bomb.getLastSpawn(), 18, 1, victims.toArray(new L2Object[victims.size()]))); | |
| 5415 | + victims.clear(); | |
| 5416 | + } | |
| 5417 | + } | |
| 5418 | + unspawnNPC(bomb); | |
| 5419 | + } | |
| 5420 | + | |
| 5421 | + @Override | |
| 5422 | + protected String getScorebar() | |
| 5423 | + {
| |
| 5424 | + return "" + teams.get(1).getName() + ": " + teams.get(1).getScore() + " " + teams.get(2).getName() + ": " + teams.get(2).getScore() + " Time: " + clock.getTime(); | |
| 5425 | + } | |
| 5426 | + | |
| 5427 | + @Override | |
| 5428 | + protected int getWinnerTeam() | |
| 5429 | + {
| |
| 5430 | + if (teams.get(1).getScore() > teams.get(2).getScore()) | |
| 5431 | + return 1; | |
| 5432 | + if (teams.get(2).getScore() > teams.get(1).getScore()) | |
| 5433 | + return 2; | |
| 5434 | + if (teams.get(1).getScore() == teams.get(2).getScore()) | |
| 5435 | + if (Rnd.nextInt(1) == 1) | |
| 5436 | + return 1; | |
| 5437 | + else | |
| 5438 | + return 2; | |
| 5439 | + | |
| 5440 | + return 1; | |
| 5441 | + } | |
| 5442 | + | |
| 5443 | + private void giveSkill() | |
| 5444 | + {
| |
| 5445 | + for (L2PcInstance player : getPlayerList()) | |
| 5446 | + player.addSkill(SkillTable.getInstance().getInfo(getInt("bombSkillId"), 1), false);
| |
| 5447 | + } | |
| 5448 | + | |
| 5449 | + | |
| 5450 | + @Override | |
| 5451 | + public void onLogout(L2PcInstance player) | |
| 5452 | + {
| |
| 5453 | + player.removeSkill(SkillTable.getInstance().getInfo(getInt("bombSkillId"), 1), false);
| |
| 5454 | + } | |
| 5455 | + | |
| 5456 | + @Override | |
| 5457 | + public boolean onUseMagic(L2Skill skill) | |
| 5458 | + {
| |
| 5459 | + if (skill.getId() == getInt("bombSkillId"))
| |
| 5460 | + return true; | |
| 5461 | + | |
| 5462 | + return false; | |
| 5463 | + | |
| 5464 | + } | |
| 5465 | + | |
| 5466 | + private void removeSkill() | |
| 5467 | + {
| |
| 5468 | + for (L2PcInstance player : getPlayerList()) | |
| 5469 | + player.removeSkill(SkillTable.getInstance().getInfo(getInt("bombSkillId"), 1), false);
| |
| 5470 | + } | |
| 5471 | + | |
| 5472 | + @Override | |
| 5473 | + protected void schedule(int time) | |
| 5474 | + {
| |
| 5475 | + tpm.scheduleGeneral(task, time); | |
| 5476 | + } | |
| 5477 | + | |
| 5478 | + private void setStatus(EventState s) | |
| 5479 | + {
| |
| 5480 | + eventState = s; | |
| 5481 | + } | |
| 5482 | + | |
| 5483 | + @Override | |
| 5484 | + protected void showHtml(L2PcInstance player, int obj) | |
| 5485 | + {
| |
| 5486 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 5487 | + TextBuilder sb = new TextBuilder(); | |
| 5488 | + | |
| 5489 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 5490 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 5491 | + sb.append("<table width=270><tr><td><center><font color=" + teams.get(1).getHexaColor() + ">" + teams.get(1).getScore() + "</font> - " + "<font color=" + teams.get(2).getHexaColor() + ">" + teams.get(2).getScore() + "</font></td></tr></table>");
| |
| 5492 | + sb.append("<br><table width=270>");
| |
| 5493 | + int i = 0; | |
| 5494 | + for (EventTeam team : teams.values()) | |
| 5495 | + {
| |
| 5496 | + i++; | |
| 5497 | + sb.append("<tr><td><font color=" + team.getHexaColor() + ">" + team.getName() + "</font> team</td><td></td><td></td><td></td></tr>");
| |
| 5498 | + for (L2PcInstance p : getPlayersOfTeam(i)) | |
| 5499 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 5500 | + } | |
| 5501 | + | |
| 5502 | + sb.append("</table></body></html>");
| |
| 5503 | + html.setHtml(sb.toString()); | |
| 5504 | + player.sendPacket(html); | |
| 5505 | + | |
| 5506 | + } | |
| 5507 | + | |
| 5508 | + @Override | |
| 5509 | + protected void start() | |
| 5510 | + {
| |
| 5511 | + setStatus(EventState.START); | |
| 5512 | + schedule(1); | |
| 5513 | + } | |
| 5514 | + public boolean onUseItem(L2PcInstance player, L2ItemInstance item) | |
| 5515 | + {
| |
| 5516 | + return false; | |
| 5517 | + } | |
| 5518 | +} | |
| 5519 | \ No newline at end of file | |
| 5520 | Index: head-src/com/l2jfrozen/gameserver/event/FormalLMS.java | |
| 5521 | =================================================================== | |
| 5522 | --- head-src/com/l2jfrozen/gameserver/event/FormalLMS.java (revision 0) | |
| 5523 | +++ head-src/com/l2jfrozen/gameserver/event/FormalLMS.java (revision 0) | |
| 5524 | @@ -0,0 +1,54 @@ | |
| 5525 | +/* | |
| 5526 | + * This program is free software; you can redistribute it and/or modify | |
| 5527 | + * it under the terms of the GNU General Public License as published by | |
| 5528 | + * the Free Software Foundation; either version 2, or (at your option) | |
| 5529 | + * any later version. | |
| 5530 | + * | |
| 5531 | + * This program is distributed in the hope that it will be useful, | |
| 5532 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 5533 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 5534 | + * GNU General Public License for more details. | |
| 5535 | + * | |
| 5536 | + * You should have received a copy of the GNU General Public License | |
| 5537 | + * along with this program; if not, write to the Free Software | |
| 5538 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
| 5539 | + * 02111-1307, USA. | |
| 5540 | + * | |
| 5541 | + * http://www.gnu.org/copyleft/gpl.html | |
| 5542 | + */ | |
| 5543 | +package com.l2jfrozen.gameserver.event; | |
| 5544 | + | |
| 5545 | + | |
| 5546 | +import com.l2jfrozen.gameserver.datatables.sql.ItemTable; | |
| 5547 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 5548 | + | |
| 5549 | +/** | |
| 5550 | + * | |
| 5551 | + * | |
| 5552 | + * @author Rizel | |
| 5553 | + */ | |
| 5554 | +public class FormalLMS | |
| 5555 | +{
| |
| 5556 | + private L2ItemInstance formalWear; | |
| 5557 | + | |
| 5558 | + @SuppressWarnings("synthetic-access")
| |
| 5559 | + private static class SingletonHolder | |
| 5560 | + {
| |
| 5561 | + protected static final FormalLMS _instance = new FormalLMS(); | |
| 5562 | + } | |
| 5563 | + | |
| 5564 | + public static FormalLMS getInstance() | |
| 5565 | + {
| |
| 5566 | + return SingletonHolder._instance; | |
| 5567 | + } | |
| 5568 | + | |
| 5569 | + public FormalLMS() | |
| 5570 | + {
| |
| 5571 | + formalWear = ItemTable.getInstance().createItem("", 6408, 1, null, null);
| |
| 5572 | + } | |
| 5573 | + | |
| 5574 | + public int getOID() | |
| 5575 | + {
| |
| 5576 | + return formalWear.getObjectId(); | |
| 5577 | + } | |
| 5578 | +} | |
| 5579 | Index: head-src/com/l2jfrozen/gameserver/event/EventManager.java | |
| 5580 | =================================================================== | |
| 5581 | --- head-src/com/l2jfrozen/gameserver/event/EventManager.java (revision 0) | |
| 5582 | +++ head-src/com/l2jfrozen/gameserver/event/EventManager.java (revision 0) | |
| 5583 | @@ -0,0 +1,727 @@ | |
| 5584 | +package com.l2jfrozen.gameserver.event; | |
| 5585 | + | |
| 5586 | +import java.io.FileWriter; | |
| 5587 | +import java.io.IOException; | |
| 5588 | +import java.text.SimpleDateFormat; | |
| 5589 | +import java.util.Date; | |
| 5590 | +import java.util.Map; | |
| 5591 | +import java.util.Random; | |
| 5592 | + | |
| 5593 | +import javolution.text.TextBuilder; | |
| 5594 | +import javolution.util.FastList; | |
| 5595 | +import javolution.util.FastMap; | |
| 5596 | + | |
| 5597 | +import com.l2jfrozen.gameserver.thread.ThreadPoolManager; | |
| 5598 | +import com.l2jfrozen.gameserver.model.L2Character; | |
| 5599 | +import com.l2jfrozen.gameserver.model.L2Party; | |
| 5600 | +import com.l2jfrozen.gameserver.model.L2World; | |
| 5601 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 5602 | +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay; | |
| 5603 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 5604 | +import com.l2jfrozen.gameserver.util.Broadcast; | |
| 5605 | + | |
| 5606 | +public final class EventManager | |
| 5607 | +{
| |
| 5608 | + | |
| 5609 | + private class Countdown implements Runnable | |
| 5610 | + {
| |
| 5611 | + protected String getTime() | |
| 5612 | + {
| |
| 5613 | + String mins = "" + counter / 60; | |
| 5614 | + String secs = (counter % 60 < 10 ? "0" + counter % 60 : "" + counter % 60); | |
| 5615 | + return "" + mins + ":" + secs + ""; | |
| 5616 | + } | |
| 5617 | + | |
| 5618 | + @SuppressWarnings("synthetic-access")
| |
| 5619 | + public void run() | |
| 5620 | + {
| |
| 5621 | + if (status == State.REGISTERING) | |
| 5622 | + | |
| 5623 | + switch (counter) | |
| 5624 | + {
| |
| 5625 | + case 300: | |
| 5626 | + case 240: | |
| 5627 | + case 180: | |
| 5628 | + case 120: | |
| 5629 | + case 60: | |
| 5630 | + announce("" + counter / 60 + " min(s) left to register, " + getCurrentEvent().getString("eventName"));
| |
| 5631 | + break; | |
| 5632 | + case 30: | |
| 5633 | + case 10: | |
| 5634 | + announce("" + counter + " seconds left to register!");
| |
| 5635 | + break; | |
| 5636 | + } | |
| 5637 | + | |
| 5638 | + if (status == State.VOTING) | |
| 5639 | + if (counter == getInt("showVotePopupAt") && getBoolean("votePopupEnabled"))
| |
| 5640 | + {
| |
| 5641 | + NpcHtmlMessage html = new NpcHtmlMessage(0); | |
| 5642 | + TextBuilder sb = new TextBuilder(); | |
| 5643 | + int count = 0; | |
| 5644 | + | |
| 5645 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 5646 | + | |
| 5647 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Voting</td><td width=130><center>Time left: " + cdtask.getTime() + "</td><td width=70>Votes: " + votes.size() + "</td></tr></table><br>");
| |
| 5648 | + | |
| 5649 | + for (Map.Entry<Integer, Event> event : events.entrySet()) | |
| 5650 | + {
| |
| 5651 | + count++; | |
| 5652 | + sb.append("<center><table width=270 " + (count % 2 == 1 ? "" : "bgcolor=5A5A5A") + "><tr><td width=180>" + event.getValue().getString("eventName") + "</td><td width=30>Info</td><td width=30>");
| |
| 5653 | + sb.append("<a action=\"bypass -h eventvote " + event.getKey() + "\">Vote</a>");
| |
| 5654 | + sb.append("</td><td width=30><center>" + getVoteCount(event.getKey()) + "</td></tr></table>");
| |
| 5655 | + } | |
| 5656 | + | |
| 5657 | + sb.append("</body></html>");
| |
| 5658 | + html.setHtml(sb.toString()); | |
| 5659 | + | |
| 5660 | + for (L2PcInstance player : L2World.getInstance().getAllPlayers()) | |
| 5661 | + {
| |
| 5662 | + if (votes.containsKey(player) || player.getLevel() < 40) | |
| 5663 | + continue; | |
| 5664 | + | |
| 5665 | + player.sendPacket(html); | |
| 5666 | + } | |
| 5667 | + } | |
| 5668 | + | |
| 5669 | + if (counter == 0) | |
| 5670 | + schedule(1); | |
| 5671 | + else | |
| 5672 | + {
| |
| 5673 | + counter--; | |
| 5674 | + tpm.scheduleGeneral(cdtask, 1000); | |
| 5675 | + } | |
| 5676 | + | |
| 5677 | + } | |
| 5678 | + } | |
| 5679 | + | |
| 5680 | + private class Scheduler implements Runnable | |
| 5681 | + {
| |
| 5682 | + @SuppressWarnings("synthetic-access")
| |
| 5683 | + public void run() | |
| 5684 | + {
| |
| 5685 | + switch (status) | |
| 5686 | + {
| |
| 5687 | + case VOTING: | |
| 5688 | + if (votes.size() > 0) | |
| 5689 | + setCurrentEvent(getVoteWinner()); | |
| 5690 | + else | |
| 5691 | + setCurrentEvent(eventIds.get(rnd.nextInt(eventIds.size()))); | |
| 5692 | + | |
| 5693 | + announce("The next event will be: " + getCurrentEvent().getString("eventName"));
| |
| 5694 | + announce("Registering phase started! You have " + getInt("registerTime") / 60 + " mins to register!");
| |
| 5695 | + announce("Event joinable in giran.");
| |
| 5696 | + setStatus(State.REGISTERING); | |
| 5697 | + debug("Registering phase started.");
| |
| 5698 | + counter = getInt("registerTime") - 1;
| |
| 5699 | + tpm.scheduleGeneral(cdtask, 1); | |
| 5700 | + break; | |
| 5701 | + | |
| 5702 | + case REGISTERING: | |
| 5703 | + announce("Registering phase ended!");
| |
| 5704 | + debug("Registering phase ended.");
| |
| 5705 | + if (countOfRegistered() < getCurrentEvent().getInt("minPlayers"))
| |
| 5706 | + {
| |
| 5707 | + debug("Lack of participants.");
| |
| 5708 | + announce("Theres not enough participants! Next event in " + getInt("betweenEventsTime") / 60 + "mins!");
| |
| 5709 | + players.clear(); | |
| 5710 | + colors.clear(); | |
| 5711 | + positions.clear(); | |
| 5712 | + setStatus(State.VOTING); | |
| 5713 | + counter = getInt("betweenEventsTime") - 1;
| |
| 5714 | + tpm.scheduleGeneral(cdtask, 1); | |
| 5715 | + } | |
| 5716 | + else | |
| 5717 | + {
| |
| 5718 | + debug("Event starts.");
| |
| 5719 | + announce("Event started!");
| |
| 5720 | + setStatus(State.RUNNING); | |
| 5721 | + msgToAll("You'll be teleported to the event in 10 secs");
| |
| 5722 | + schedule(10000); | |
| 5723 | + } | |
| 5724 | + break; | |
| 5725 | + | |
| 5726 | + case RUNNING: | |
| 5727 | + getCurrentEvent().start(); | |
| 5728 | + | |
| 5729 | + for (L2PcInstance player : players) | |
| 5730 | + EventStats.getInstance().tempTable.put(player.getObjectId(), new int[] { 0, 0, 0, 0 });
| |
| 5731 | + | |
| 5732 | + break; | |
| 5733 | + | |
| 5734 | + case TELE_BACK: | |
| 5735 | + msgToAll("You'll be teleported back in 10 secs");
| |
| 5736 | + setStatus(State.END); | |
| 5737 | + debug("Teleporting back.");
| |
| 5738 | + schedule(10000); | |
| 5739 | + break; | |
| 5740 | + | |
| 5741 | + case END: | |
| 5742 | + teleBackEveryone(); | |
| 5743 | + if (getBoolean("statTrackingEnabled"))
| |
| 5744 | + {
| |
| 5745 | + EventStats.getInstance().applyChanges(); | |
| 5746 | + EventStats.getInstance().tempTable.clear(); | |
| 5747 | + EventStats.getInstance().updateSQL(getCurrentEvent().getPlayerList(), getCurrentEvent().eventId); | |
| 5748 | + } | |
| 5749 | + getCurrentEvent().reset(); | |
| 5750 | + setCurrentEvent(0); | |
| 5751 | + players.clear(); | |
| 5752 | + colors.clear(); | |
| 5753 | + positions.clear(); | |
| 5754 | + titles.clear(); | |
| 5755 | + announce("Event ended! Next event in " + getInt("betweenEventsTime") / 60 + "mins!");
| |
| 5756 | + setStatus(State.VOTING); | |
| 5757 | + counter = getInt("betweenEventsTime") - 1;
| |
| 5758 | + debug("Event ended.");
| |
| 5759 | + tpm.scheduleGeneral(cdtask, 1); | |
| 5760 | + break; | |
| 5761 | + | |
| 5762 | + } | |
| 5763 | + } | |
| 5764 | + } | |
| 5765 | + | |
| 5766 | + @SuppressWarnings("synthetic-access")
| |
| 5767 | + private static class SingletonHolder | |
| 5768 | + {
| |
| 5769 | + protected static final EventManager _instance = new EventManager(); | |
| 5770 | + } | |
| 5771 | + | |
| 5772 | + // Manager Statuses | |
| 5773 | + protected enum State | |
| 5774 | + {
| |
| 5775 | + REGISTERING, VOTING, RUNNING, TELE_BACK, END | |
| 5776 | + } | |
| 5777 | + | |
| 5778 | + public static EventManager getInstance() | |
| 5779 | + {
| |
| 5780 | + return SingletonHolder._instance; | |
| 5781 | + } | |
| 5782 | + | |
| 5783 | + private EventConfig config; | |
| 5784 | + // Event instances | |
| 5785 | + public FastMap<Integer, Event> events; | |
| 5786 | + | |
| 5787 | + // The list of registered players | |
| 5788 | + public FastList<L2PcInstance> players; | |
| 5789 | + | |
| 5790 | + // The current event | |
| 5791 | + private Event current; | |
| 5792 | + | |
| 5793 | + // Original name colors | |
| 5794 | + private FastMap<L2PcInstance, Integer> colors; | |
| 5795 | + | |
| 5796 | + //Original titles | |
| 5797 | + protected FastMap<L2PcInstance, String> titles; | |
| 5798 | + | |
| 5799 | + //Original positions | |
| 5800 | + protected FastMap<L2PcInstance, int[]> positions; | |
| 5801 | + | |
| 5802 | + // Votes for the events | |
| 5803 | + private FastMap<L2PcInstance, Integer> votes; | |
| 5804 | + | |
| 5805 | + private State status; | |
| 5806 | + | |
| 5807 | + private int counter; | |
| 5808 | + | |
| 5809 | + private Countdown cdtask; | |
| 5810 | + | |
| 5811 | + // NPC location | |
| 5812 | + public static int[] npcPos = { 82698, 148638, -3473 };
| |
| 5813 | + | |
| 5814 | + // Threadpoolmanager | |
| 5815 | + private ThreadPoolManager tpm; | |
| 5816 | + | |
| 5817 | + // Scheduler | |
| 5818 | + private Scheduler task; | |
| 5819 | + | |
| 5820 | + private Random rnd = new Random(); | |
| 5821 | + | |
| 5822 | + private FileWriter writer; | |
| 5823 | + | |
| 5824 | + private FastList<Integer> eventIds; | |
| 5825 | + | |
| 5826 | + private static final SimpleDateFormat _formatter = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
| |
| 5827 | + | |
| 5828 | + public EventManager() | |
| 5829 | + {
| |
| 5830 | + config = EventConfig.getInstance(); | |
| 5831 | + | |
| 5832 | + events = new FastMap<Integer, Event>(); | |
| 5833 | + players = new FastList<L2PcInstance>(); | |
| 5834 | + votes = new FastMap<L2PcInstance, Integer>(); | |
| 5835 | + titles = new FastMap<L2PcInstance, String>(); | |
| 5836 | + colors = new FastMap<L2PcInstance, Integer>(); | |
| 5837 | + positions = new FastMap<L2PcInstance, int[]>(); | |
| 5838 | + eventIds = new FastList<Integer>(); | |
| 5839 | + status = State.VOTING; | |
| 5840 | + tpm = ThreadPoolManager.getInstance(); | |
| 5841 | + task = new Scheduler(); | |
| 5842 | + cdtask = new Countdown(); | |
| 5843 | + counter = 0; | |
| 5844 | + | |
| 5845 | + // Add the events to the list | |
| 5846 | + events.put(1, new dm()); | |
| 5847 | + events.put(2, new Domination()); | |
| 5848 | + events.put(3, new DoubleDomination()); | |
| 5849 | + events.put(4, new LMS()); | |
| 5850 | + events.put(5, new Lucky()); | |
| 5851 | + events.put(6, new Simon()); | |
| 5852 | + events.put(7, new TvT()); | |
| 5853 | + events.put(8, new VIPTvT()); | |
| 5854 | + events.put(9, new Zombie()); | |
| 5855 | + events.put(10, new CTF()); | |
| 5856 | + events.put(11, new Russian()); | |
| 5857 | + events.put(12, new Bomb()); | |
| 5858 | + events.put(13, new Mutant()); | |
| 5859 | + events.put(14, new Battlefield()); | |
| 5860 | + | |
| 5861 | + for(int eventId : events.keySet()) | |
| 5862 | + eventIds.add(eventId); | |
| 5863 | + | |
| 5864 | + debug(events.size() + " event imported."); | |
| 5865 | + | |
| 5866 | + // Start the scheduler | |
| 5867 | + counter = getInt("firstAfterStartTime") - 1;
| |
| 5868 | + tpm.scheduleGeneral(cdtask, 1); | |
| 5869 | + | |
| 5870 | + System.out.println("Event Engine Started");
| |
| 5871 | + } | |
| 5872 | + | |
| 5873 | + public boolean addVote(L2PcInstance player, int eventId) | |
| 5874 | + {
| |
| 5875 | + if (getStatus() != State.VOTING) | |
| 5876 | + {
| |
| 5877 | + player.sendMessage("You cant vote now!");
| |
| 5878 | + return false; | |
| 5879 | + } | |
| 5880 | + if (votes.containsKey(player)) | |
| 5881 | + {
| |
| 5882 | + player.sendMessage("You already voted for an event!");
| |
| 5883 | + return false; | |
| 5884 | + } | |
| 5885 | + if (player.getLevel() < 40) | |
| 5886 | + {
| |
| 5887 | + player.sendMessage("Your level is too low to vote for events!");
| |
| 5888 | + return false; | |
| 5889 | + } | |
| 5890 | + else | |
| 5891 | + {
| |
| 5892 | + player.sendMessage("You succesfully voted for the event");
| |
| 5893 | + votes.put(player, eventId); | |
| 5894 | + return true; | |
| 5895 | + } | |
| 5896 | + } | |
| 5897 | + | |
| 5898 | + private void announce(String text) | |
| 5899 | + {
| |
| 5900 | + Broadcast.toAllOnlinePlayers(new CreatureSay(0, 18, "", "[Event] " + text)); | |
| 5901 | + } | |
| 5902 | + | |
| 5903 | + private boolean canRegister(L2PcInstance player) | |
| 5904 | + {
| |
| 5905 | + if (players.contains(player)) | |
| 5906 | + {
| |
| 5907 | + player.sendMessage("You already registered to the event!");
| |
| 5908 | + return false; | |
| 5909 | + } | |
| 5910 | + | |
| 5911 | + if (player.isInJail()) | |
| 5912 | + {
| |
| 5913 | + player.sendMessage("You cant register from the jail.");
| |
| 5914 | + return false; | |
| 5915 | + } | |
| 5916 | + | |
| 5917 | + if (player.isInOlympiadMode()) | |
| 5918 | + {
| |
| 5919 | + player.sendMessage("You cant register while youre in the olympiad.");
| |
| 5920 | + return false; | |
| 5921 | + } | |
| 5922 | + | |
| 5923 | + if (player.getLevel() > getCurrentEvent().getInt("maxLvl"))
| |
| 5924 | + {
| |
| 5925 | + player.sendMessage("Youre greater than the max allowed lvl.");
| |
| 5926 | + return false; | |
| 5927 | + } | |
| 5928 | + | |
| 5929 | + if (player.getLevel() < getCurrentEvent().getInt("minLvl"))
| |
| 5930 | + {
| |
| 5931 | + player.sendMessage("Youre lower than the min allowed lvl.");
| |
| 5932 | + return false; | |
| 5933 | + } | |
| 5934 | + | |
| 5935 | + if (player.getKarma() > 0) | |
| 5936 | + {
| |
| 5937 | + player.sendMessage("You cant register if you have karma.");
| |
| 5938 | + return false; | |
| 5939 | + } | |
| 5940 | + | |
| 5941 | + if (player.isCursedWeaponEquiped()) | |
| 5942 | + {
| |
| 5943 | + player.sendMessage("You cant register with a cursed weapon.");
| |
| 5944 | + return false; | |
| 5945 | + } | |
| 5946 | + | |
| 5947 | + if (player.isDead()) | |
| 5948 | + {
| |
| 5949 | + player.sendMessage("You cant register while youre dead.");
| |
| 5950 | + return false; | |
| 5951 | + } | |
| 5952 | + | |
| 5953 | + return true; | |
| 5954 | + } /* | |
| 5955 | + * If theres a running event and | |
| 5956 | + */ | |
| 5957 | + | |
| 5958 | + public boolean canTargetPlayer(L2PcInstance target, L2PcInstance self) | |
| 5959 | + {
| |
| 5960 | + if (getStatus() == State.RUNNING) | |
| 5961 | + {
| |
| 5962 | + if ((isRegistered(target) && isRegistered(self)) || (!isRegistered(target) && !isRegistered(self))) | |
| 5963 | + return true; | |
| 5964 | + else | |
| 5965 | + return false; | |
| 5966 | + } | |
| 5967 | + else | |
| 5968 | + return true; | |
| 5969 | + } | |
| 5970 | + | |
| 5971 | + protected int countOfRegistered() | |
| 5972 | + {
| |
| 5973 | + return players.size(); | |
| 5974 | + } | |
| 5975 | + | |
| 5976 | + protected void debug(String message) | |
| 5977 | + {
| |
| 5978 | + if (!getBoolean("debug"))
| |
| 5979 | + return; | |
| 5980 | + | |
| 5981 | + String today = _formatter.format(new Date()); | |
| 5982 | + | |
| 5983 | + try | |
| 5984 | + {
| |
| 5985 | + writer = new FileWriter("log/EventEngine.log", true);
| |
| 5986 | + writer.write(today + " - " + message + "\r\n"); | |
| 5987 | + } | |
| 5988 | + catch (IOException e) | |
| 5989 | + {
| |
| 5990 | + | |
| 5991 | + } | |
| 5992 | + finally | |
| 5993 | + {
| |
| 5994 | + try | |
| 5995 | + {
| |
| 5996 | + writer.close(); | |
| 5997 | + } | |
| 5998 | + catch (Exception e) | |
| 5999 | + {
| |
| 6000 | + } | |
| 6001 | + } | |
| 6002 | + } | |
| 6003 | + | |
| 6004 | + protected void end(String text) | |
| 6005 | + {
| |
| 6006 | + announce(text); | |
| 6007 | + status = State.TELE_BACK; | |
| 6008 | + schedule(1); | |
| 6009 | + } | |
| 6010 | + | |
| 6011 | + public boolean getBoolean(String propName) | |
| 6012 | + {
| |
| 6013 | + return config.getBoolean(0, propName); | |
| 6014 | + } | |
| 6015 | + | |
| 6016 | + public Event getCurrentEvent() | |
| 6017 | + {
| |
| 6018 | + return current; | |
| 6019 | + } | |
| 6020 | + | |
| 6021 | + public FastList<String> getEventNames() | |
| 6022 | + {
| |
| 6023 | + FastList<String> map = new FastList<String>(); | |
| 6024 | + for (Event event : events.values()) | |
| 6025 | + map.add(event.getString("eventName"));
| |
| 6026 | + return map; | |
| 6027 | + } | |
| 6028 | + | |
| 6029 | + public int getInt(String propName) | |
| 6030 | + {
| |
| 6031 | + return config.getInt(0, propName); | |
| 6032 | + } | |
| 6033 | + | |
| 6034 | + protected int[] getPosition(String owner, int num) | |
| 6035 | + {
| |
| 6036 | + return config.getPosition(0, owner, num); | |
| 6037 | + } | |
| 6038 | + | |
| 6039 | + public FastList<Integer> getRestriction(String type) | |
| 6040 | + {
| |
| 6041 | + return config.getRestriction(0, type); | |
| 6042 | + } | |
| 6043 | + | |
| 6044 | + private State getStatus() | |
| 6045 | + {
| |
| 6046 | + return status; | |
| 6047 | + } | |
| 6048 | + | |
| 6049 | + protected String getString(String propName) | |
| 6050 | + {
| |
| 6051 | + return config.getString(0, propName); | |
| 6052 | + } | |
| 6053 | + | |
| 6054 | + private int getVoteCount(int event) | |
| 6055 | + {
| |
| 6056 | + int count = 0; | |
| 6057 | + for (int e : votes.values()) | |
| 6058 | + if (e == event) | |
| 6059 | + count++; | |
| 6060 | + | |
| 6061 | + return count; | |
| 6062 | + } | |
| 6063 | + | |
| 6064 | + private int getVoteWinner() | |
| 6065 | + {
| |
| 6066 | + int old = 0; | |
| 6067 | + FastMap<Integer, Integer> temp = new FastMap<Integer, Integer>(); | |
| 6068 | + | |
| 6069 | + for (int vote : votes.values()) | |
| 6070 | + if (!temp.containsKey(vote)) | |
| 6071 | + temp.put(vote, 1); | |
| 6072 | + else | |
| 6073 | + {
| |
| 6074 | + old = temp.get(vote); | |
| 6075 | + old++; | |
| 6076 | + temp.getEntry(vote).setValue(old); | |
| 6077 | + } | |
| 6078 | + | |
| 6079 | + int max = temp.head().getNext().getValue(); | |
| 6080 | + int result = temp.head().getNext().getKey(); | |
| 6081 | + | |
| 6082 | + for (Map.Entry<Integer, Integer> entry : temp.entrySet()) | |
| 6083 | + if (entry.getValue() > max) | |
| 6084 | + {
| |
| 6085 | + max = entry.getValue(); | |
| 6086 | + result = entry.getKey(); | |
| 6087 | + } | |
| 6088 | + | |
| 6089 | + votes.clear(); | |
| 6090 | + temp = null; | |
| 6091 | + return result; | |
| 6092 | + | |
| 6093 | + } | |
| 6094 | + | |
| 6095 | + public boolean isRegistered(L2PcInstance player) | |
| 6096 | + {
| |
| 6097 | + if (getCurrentEvent() != null) | |
| 6098 | + return getCurrentEvent().players.containsKey(player); | |
| 6099 | + else | |
| 6100 | + return false; | |
| 6101 | + } | |
| 6102 | + | |
| 6103 | + public boolean isRegistered(L2Character player) | |
| 6104 | + {
| |
| 6105 | + if (getCurrentEvent() != null) | |
| 6106 | + return getCurrentEvent().players.containsKey(player); | |
| 6107 | + else | |
| 6108 | + return false; | |
| 6109 | + } | |
| 6110 | + | |
| 6111 | + public boolean isRunning() | |
| 6112 | + {
| |
| 6113 | + if (getStatus() == State.RUNNING) | |
| 6114 | + return true; | |
| 6115 | + else | |
| 6116 | + return false; | |
| 6117 | + } | |
| 6118 | + | |
| 6119 | + private void msgToAll(String text) | |
| 6120 | + {
| |
| 6121 | + for (L2PcInstance player : players) | |
| 6122 | + player.sendMessage(text); | |
| 6123 | + } | |
| 6124 | + | |
| 6125 | + public void onLogout(L2PcInstance player) | |
| 6126 | + {
| |
| 6127 | + if (votes.containsKey(player)) | |
| 6128 | + votes.remove(player); | |
| 6129 | + if (players.contains(player)) | |
| 6130 | + {
| |
| 6131 | + players.remove(player); | |
| 6132 | + colors.remove(player); | |
| 6133 | + titles.remove(player); | |
| 6134 | + positions.remove(player); | |
| 6135 | + } | |
| 6136 | + } | |
| 6137 | + | |
| 6138 | + public boolean registerPlayer(L2PcInstance player) | |
| 6139 | + {
| |
| 6140 | + if (getStatus() != State.REGISTERING) | |
| 6141 | + {
| |
| 6142 | + player.sendMessage("You can't register now!");
| |
| 6143 | + return false; | |
| 6144 | + } | |
| 6145 | + | |
| 6146 | + if(getBoolean("eventBufferEnabled"))
| |
| 6147 | + if (!EventBuffer.getInstance().playerHaveTemplate(player)) | |
| 6148 | + {
| |
| 6149 | + player.sendMessage("You have to set a buff template first!");
| |
| 6150 | + EventBuffer.getInstance().showHtml(player); | |
| 6151 | + return false; | |
| 6152 | + } | |
| 6153 | + | |
| 6154 | + if (canRegister(player)) | |
| 6155 | + {
| |
| 6156 | + player.sendMessage("You succesfully registered to the event!");
| |
| 6157 | + players.add(player); | |
| 6158 | + titles.put(player, player.getTitle()); | |
| 6159 | + colors.put(player, player.getAppearance().getNameColor()); | |
| 6160 | + positions.put(player, new int[] { player.getX(), player.getY(), player.getZ() });
| |
| 6161 | + return true; | |
| 6162 | + } | |
| 6163 | + else | |
| 6164 | + {
| |
| 6165 | + player.sendMessage("You failed on registering to the event!");
| |
| 6166 | + return false; | |
| 6167 | + } | |
| 6168 | + } | |
| 6169 | + | |
| 6170 | + protected void schedule(int time) | |
| 6171 | + {
| |
| 6172 | + tpm.scheduleGeneral(task, time); | |
| 6173 | + } | |
| 6174 | + | |
| 6175 | + private void setCurrentEvent(int eventId) | |
| 6176 | + {
| |
| 6177 | + if (eventId == 0) | |
| 6178 | + current = null; | |
| 6179 | + else | |
| 6180 | + current = events.get(eventId); | |
| 6181 | + | |
| 6182 | + debug("Changed current event to: " + (current == null ? "null" : current.getString("eventName")));
| |
| 6183 | + } | |
| 6184 | + | |
| 6185 | + protected void setStatus(State s) | |
| 6186 | + {
| |
| 6187 | + status = s; | |
| 6188 | + } | |
| 6189 | + | |
| 6190 | + public void showFirstHtml(L2PcInstance player, int obj) | |
| 6191 | + {
| |
| 6192 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 6193 | + TextBuilder sb = new TextBuilder(); | |
| 6194 | + int count = 0; | |
| 6195 | + | |
| 6196 | + sb.append("<html><body><table width=270><tr><td width=130>Event Engine </td><td width=70>"+(getBoolean("eventBufferEnabled") ? "<a action=\"bypass -h eventbuffershow\">Buffer</a>" : "")+"</td><td width=70><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 6197 | + | |
| 6198 | + if (getStatus() == State.VOTING) | |
| 6199 | + {
| |
| 6200 | + | |
| 6201 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Events</td><td width=130><center>Time left: " + cdtask.getTime() + "</td>"+/*<td width=70>Votes: " + votes.size() + "</td>*/"</tr></table><br>");
| |
| 6202 | + | |
| 6203 | + for (Map.Entry<Integer, Event> event : events.entrySet()) | |
| 6204 | + {
| |
| 6205 | + count++; | |
| 6206 | + sb.append("<center><table width=270 " + (count % 2 == 1 ? "" : "bgcolor=5A5A5A") + "><tr><td width=180>" + event.getValue().getString("eventName") + "</td><td width=30><a action=\"bypass -h eventinfo "+event.getKey()+"\">Info</a></td>"/*<td width=30>*/);
| |
| 6207 | + | |
| 6208 | + /*if (!votes.containsKey(player)) | |
| 6209 | + sb.append("<a action=\"bypass -h npc_" + obj + "_" + event.getKey() + "\">Vote</a>");
| |
| 6210 | + else | |
| 6211 | + sb.append("Vote");*/
| |
| 6212 | + | |
| 6213 | + sb.append(/*</td><td width=30><center>" + getVoteCount(event.getKey()) + "</td>*/"</tr></table>"); | |
| 6214 | + } | |
| 6215 | + sb.append("</body></html>");
| |
| 6216 | + html.setHtml(sb.toString()); | |
| 6217 | + player.sendPacket(html); | |
| 6218 | + } | |
| 6219 | + | |
| 6220 | + if (getStatus() == State.REGISTERING) | |
| 6221 | + {
| |
| 6222 | + | |
| 6223 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>");
| |
| 6224 | + if (players.contains(player)) | |
| 6225 | + sb.append("<a action=\"bypass -h npc_" + obj + "_unreg\">Unregister</a>");
| |
| 6226 | + else | |
| 6227 | + sb.append("<a action=\"bypass -h npc_" + obj + "_reg\">Register</a>");
| |
| 6228 | + | |
| 6229 | + sb.append("</td><td width=130><center><a action=\"bypass -h eventinfo "+getCurrentEvent().getInt("ids")+"\">" + getCurrentEvent().getString("eventName") + "</a></td><td width=70>Time: " + cdtask.getTime() + "</td></tr></table><br>");
| |
| 6230 | + | |
| 6231 | + for (L2PcInstance p : EventManager.getInstance().players) | |
| 6232 | + {
| |
| 6233 | + count++; | |
| 6234 | + sb.append("<center><table width=270 " + (count % 2 == 1 ? "" : "bgcolor=5A5A5A") + "><tr><td width=120>" + p.getName() + "</td><td width=40>lvl " + p.getLevel() + "</td><td width=110>" + p.getTemplate().className + "</td></tr></table>");
| |
| 6235 | + } | |
| 6236 | + | |
| 6237 | + sb.append("</body></html>");
| |
| 6238 | + html.setHtml(sb.toString()); | |
| 6239 | + player.sendPacket(html); | |
| 6240 | + } | |
| 6241 | + if (getStatus() == State.RUNNING) | |
| 6242 | + getCurrentEvent().showHtml(player, obj); | |
| 6243 | + | |
| 6244 | + } | |
| 6245 | + | |
| 6246 | + private void teleBackEveryone() | |
| 6247 | + {
| |
| 6248 | + for (L2PcInstance player : getCurrentEvent().getPlayerList()) | |
| 6249 | + {
| |
| 6250 | + if(player.getPoly().isMorphed()) | |
| 6251 | + {
| |
| 6252 | + player.getPoly().setPolyInfo(null, "1"); | |
| 6253 | + player.decayMe(); | |
| 6254 | + player.spawnMe(player.getX(),player.getY(),player.getZ()); | |
| 6255 | + } | |
| 6256 | + player.teleToLocation(positions.get(player)[0], positions.get(player)[1], positions.get(player)[2]); | |
| 6257 | + player.getAppearance().setNameColor(colors.get(player)); | |
| 6258 | + player.setTitle(titles.get(player)); | |
| 6259 | + if (player.getParty() != null) | |
| 6260 | + {
| |
| 6261 | + L2Party party = player.getParty(); | |
| 6262 | + party.removePartyMember(player); | |
| 6263 | + } | |
| 6264 | + | |
| 6265 | + player.broadcastUserInfo(); | |
| 6266 | + if (player.isDead()) | |
| 6267 | + player.doRevive(); | |
| 6268 | + } | |
| 6269 | + | |
| 6270 | + } | |
| 6271 | + | |
| 6272 | + public boolean unregisterPlayer(L2PcInstance player) | |
| 6273 | + {
| |
| 6274 | + if (!players.contains(player)) | |
| 6275 | + {
| |
| 6276 | + player.sendMessage("You're not registered to the event!");
| |
| 6277 | + return false; | |
| 6278 | + } | |
| 6279 | + if (getStatus() != State.REGISTERING) | |
| 6280 | + {
| |
| 6281 | + player.sendMessage("You can't unregister now!");
| |
| 6282 | + return false; | |
| 6283 | + } | |
| 6284 | + else | |
| 6285 | + {
| |
| 6286 | + player.sendMessage("You succesfully unregistered from the event!");
| |
| 6287 | + players.remove(player); | |
| 6288 | + colors.remove(player); | |
| 6289 | + positions.remove(player); | |
| 6290 | + return true; | |
| 6291 | + } | |
| 6292 | + } | |
| 6293 | + | |
| 6294 | + public boolean areTeammates(L2PcInstance player, L2PcInstance target) | |
| 6295 | + {
| |
| 6296 | + if(getCurrentEvent() == null) | |
| 6297 | + return false; | |
| 6298 | + | |
| 6299 | + if(getCurrentEvent().numberOfTeams() == 1) | |
| 6300 | + return false; | |
| 6301 | + | |
| 6302 | + if(getCurrentEvent().numberOfTeams() > 1) | |
| 6303 | + if(getCurrentEvent().getTeam(player) == getCurrentEvent().getTeam(target)) | |
| 6304 | + return true; | |
| 6305 | + else | |
| 6306 | + return false; | |
| 6307 | + | |
| 6308 | + return false; | |
| 6309 | + } | |
| 6310 | +} | |
| 6311 | \ No newline at end of file | |
| 6312 | Index: config/Events.xml | |
| 6313 | =================================================================== | |
| 6314 | --- config/Events.xml (revision 0) | |
| 6315 | +++ config/Events.xml (revision 0) | |
| 6316 | @@ -0,0 +1,350 @@ | |
| 6317 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 6318 | +<events> | |
| 6319 | + <!-- Core settings --> | |
| 6320 | + <event id="0"> | |
| 6321 | + <property name="registerTime" value="300" /> | |
| 6322 | + <property name="betweenEventsTime" value="10800" /> | |
| 6323 | + <property name="firstAfterStartTime" value="1800" /> | |
| 6324 | + <property name="managerNpcId" value="50001" /> | |
| 6325 | + <property name="showVotePopupAt" value="600" /> | |
| 6326 | + <property name="votePopupEnabled" value="false" /> | |
| 6327 | + <property name="debug" value="false" /> | |
| 6328 | + <property name="statTrackingEnabled" value="true" /> | |
| 6329 | + <property name="eventBufferEnabled" value="false" /> | |
| 6330 | + <property name="allowedBuffsList" value="1068,1085,1086,1087" /> | |
| 6331 | + <property name="maxBuffNum" value="2" /> | |
| 6332 | + <property name="friendlyFireEnabled" value="false" /> | |
| 6333 | + <property name="restartAllowed" value="false" /> | |
| 6334 | + <restriction type="item" ids="" /> | |
| 6335 | + <restriction type="skill" ids="1374,1375,1376,395,396" /> | |
| 6336 | + </event> | |
| 6337 | + | |
| 6338 | + <!-- DeathMatch --> | |
| 6339 | + <event id="1"> | |
| 6340 | + <property name="minLvl" value="70" /> | |
| 6341 | + <property name="maxLvl" value="80" /> | |
| 6342 | + <property name="eventName" value="Deathmatch" /> | |
| 6343 | + <property name="ids" value="1" /> | |
| 6344 | + <property name="matchTime" value="240" /> | |
| 6345 | + <property name="rewardId" value="6392" /> | |
| 6346 | + <property name="rewardAmmount" value="20" /> | |
| 6347 | + <property name="allowPotions" value="false" /> | |
| 6348 | + <property name="allowUseMagic" value="true" /> | |
| 6349 | + <property name="removeBuffs" value="false" /> | |
| 6350 | + <property name="minPlayers" value="8" /> | |
| 6351 | + <color owner="All" r="255" g="255" b="255"/> | |
| 6352 | + <position owner="All" x="106037" y="114816" z="-1560" radius="700" /> | |
| 6353 | + <restriction type="item" ids="" /> | |
| 6354 | + <restriction type="skill" ids="" /> | |
| 6355 | + </event> | |
| 6356 | + | |
| 6357 | + <!-- Domination --> | |
| 6358 | + <event id="2"> | |
| 6359 | + <property name="minLvl" value="70" /> | |
| 6360 | + <property name="maxLvl" value="80" /> | |
| 6361 | + <property name="eventName" value="Domination" /> | |
| 6362 | + <property name="ids" value="2" /> | |
| 6363 | + <property name="matchTime" value="240" /> | |
| 6364 | + <property name="rewardId" value="6392" /> | |
| 6365 | + <property name="rewardAmmount" value="10" /> | |
| 6366 | + <property name="allowPotions" value="false" /> | |
| 6367 | + <property name="allowUseMagic" value="true" /> | |
| 6368 | + <property name="removeBuffs" value="false" /> | |
| 6369 | + <property name="minPlayers" value="8" /> | |
| 6370 | + <property name="zoneRadius" value="170" /> | |
| 6371 | + <property name="zoneNpcId" value="9103" /> | |
| 6372 | + <color owner="Blue" r="0" g="0" b="255"/> | |
| 6373 | + <color owner="Red" r="255" g="0" b="0"/> | |
| 6374 | + <position owner="Blue" x="106679" y="116319" z="-1587" radius="50" /> | |
| 6375 | + <position owner="Red" x="105914" y="113368" z="-1587" radius="50" /> | |
| 6376 | + <position owner="Zone" x="106108" y="114969" z="-1587" radius="0" /> | |
| 6377 | + <restriction type="item" ids="" /> | |
| 6378 | + <restriction type="skill" ids="" /> | |
| 6379 | + </event> | |
| 6380 | + | |
| 6381 | + <!-- Double Domination --> | |
| 6382 | + <event id="3"> | |
| 6383 | + <property name="minLvl" value="70" /> | |
| 6384 | + <property name="maxLvl" value="80" /> | |
| 6385 | + <property name="eventName" value="Double Domination" /> | |
| 6386 | + <property name="ids" value="3" /> | |
| 6387 | + <property name="matchTime" value="240" /> | |
| 6388 | + <property name="rewardId" value="6392" /> | |
| 6389 | + <property name="rewardAmmount" value="10" /> | |
| 6390 | + <property name="allowPotions" value="false" /> | |
| 6391 | + <property name="allowUseMagic" value="true" /> | |
| 6392 | + <property name="removeBuffs" value="false" /> | |
| 6393 | + <property name="minPlayers" value="8" /> | |
| 6394 | + <property name="zoneRadius" value="170" /> | |
| 6395 | + <property name="zoneNpcId" value="9103" /> | |
| 6396 | + <property name="timeToScore" value="10" /> | |
| 6397 | + <color owner="Blue" r="0" g="0" b="255"/> | |
| 6398 | + <color owner="Red" r="255" g="0" b="0"/> | |
| 6399 | + <position owner="Blue" x="106679" y="116319" z="-1587" radius="50" /> | |
| 6400 | + <position owner="Red" x="105914" y="113368" z="-1587" radius="50" /> | |
| 6401 | + <position owner="Zone" x="106995" y="114556" z="-1587" radius="0" /> | |
| 6402 | + <position owner="Zone" x="104823" y="115175" z="-1587" radius="0" /> | |
| 6403 | + <restriction type="item" ids="" /> | |
| 6404 | + <restriction type="skill" ids="" /> | |
| 6405 | + </event> | |
| 6406 | + | |
| 6407 | + <!-- Last Man Standing --> | |
| 6408 | + <event id="4"> | |
| 6409 | + <property name="minLvl" value="70" /> | |
| 6410 | + <property name="maxLvl" value="80" /> | |
| 6411 | + <property name="eventName" value="Last Man Standing" /> | |
| 6412 | + <property name="ids" value="4" /> | |
| 6413 | + <property name="matchTime" value="300" /> | |
| 6414 | + <property name="rewardId" value="6392" /> | |
| 6415 | + <property name="rewardAmmount" value="25" /> | |
| 6416 | + <property name="allowPotions" value="false" /> | |
| 6417 | + <property name="allowUseMagic" value="true" /> | |
| 6418 | + <property name="removeBuffs" value="false" /> | |
| 6419 | + <property name="minPlayers" value="8" /> | |
| 6420 | + <color owner="All" r="255" g="255" b="255"/> | |
| 6421 | + <position owner="All" x="106037" y="114816" z="-1560" radius="700" /> | |
| 6422 | + <restriction type="item" ids="" /> | |
| 6423 | + <restriction type="skill" ids="" /> | |
| 6424 | + </event> | |
| 6425 | + | |
| 6426 | + <!-- Lucky Chests --> | |
| 6427 | + <event id="5"> | |
| 6428 | + <property name="minLvl" value="40" /> | |
| 6429 | + <property name="maxLvl" value="80" /> | |
| 6430 | + <property name="eventName" value="Lucky Chests" /> | |
| 6431 | + <property name="ids" value="5" /> | |
| 6432 | + <property name="matchTime" value="180" /> | |
| 6433 | + <property name="rewardId" value="6392" /> | |
| 6434 | + <property name="rewardAmmount" value="20" /> | |
| 6435 | + <property name="allowPotions" value="false" /> | |
| 6436 | + <property name="allowUseMagic" value="false" /> | |
| 6437 | + <property name="removeBuffs" value="true" /> | |
| 6438 | + <property name="minPlayers" value="8" /> | |
| 6439 | + <property name="chestNpcId" value="9102" /> | |
| 6440 | + <property name="numberOfChests" value="300" /> | |
| 6441 | + <color owner="All" r="255" g="255" b="255"/> | |
| 6442 | + <position owner="All" x="106037" y="114816" z="-1560" radius="100" /> | |
| 6443 | + <position owner="Chests" x="106037" y="114816" z="-1560" radius="700" /> | |
| 6444 | + <restriction type="item" ids="" /> | |
| 6445 | + <restriction type="skill" ids="" /> | |
| 6446 | + </event> | |
| 6447 | + | |
| 6448 | + <!-- Simon Says --> | |
| 6449 | + <event id="6"> | |
| 6450 | + <property name="minLvl" value="40" /> | |
| 6451 | + <property name="maxLvl" value="80" /> | |
| 6452 | + <property name="eventName" value="Simon Says" /> | |
| 6453 | + <property name="ids" value="6" /> | |
| 6454 | + <property name="roundTime" value="10" /> | |
| 6455 | + <property name="rewardId" value="6392" /> | |
| 6456 | + <property name="rewardAmmount" value="25" /> | |
| 6457 | + <property name="allowPotions" value="false" /> | |
| 6458 | + <property name="allowUseMagic" value="false" /> | |
| 6459 | + <property name="removeBuffs" value="false" /> | |
| 6460 | + <property name="minPlayers" value="8" /> | |
| 6461 | + <property name="simonNpcId" value="9101" /> | |
| 6462 | + <property name="lengthOfFirstWord" value="3" /> | |
| 6463 | + <property name="increasePerRound" value="1" /> | |
| 6464 | + <color owner="All" r="255" g="255" b="255"/> | |
| 6465 | + <position owner="All" x="106037" y="114816" z="-1560" radius="100" /> | |
| 6466 | + <position owner="Simon" x="106037" y="114816" z="-1560" radius="0" /> | |
| 6467 | + <restriction type="item" ids="" /> | |
| 6468 | + <restriction type="skill" ids="" /> | |
| 6469 | + </event> | |
| 6470 | + | |
| 6471 | + <!-- Team vs Team --> | |
| 6472 | + <event id="7"> | |
| 6473 | + <property name="minLvl" value="70" /> | |
| 6474 | + <property name="maxLvl" value="80" /> | |
| 6475 | + <property name="eventName" value="Team vs Team" /> | |
| 6476 | + <property name="ids" value="7" /> | |
| 6477 | + <property name="matchTime" value="300" /> | |
| 6478 | + <property name="rewardId" value="6392" /> | |
| 6479 | + <property name="rewardAmmount" value="10" /> | |
| 6480 | + <property name="allowPotions" value="false" /> | |
| 6481 | + <property name="allowUseMagic" value="true" /> | |
| 6482 | + <property name="removeBuffs" value="true" /> | |
| 6483 | + <property name="minPlayers" value="8" /> | |
| 6484 | + <color owner="Blue" r="0" g="0" b="255"/> | |
| 6485 | + <color owner="Red" r="255" g="0" b="0"/> | |
| 6486 | + <position owner="Blue" x="106679" y="116319" z="-1587" radius="50" /> | |
| 6487 | + <position owner="Red" x="105914" y="113368" z="-1587" radius="50" /> | |
| 6488 | + <restriction type="item" ids="" /> | |
| 6489 | + <restriction type="skill" ids="" /> | |
| 6490 | + </event> | |
| 6491 | + | |
| 6492 | + <!-- VIP Team vs Team --> | |
| 6493 | + <event id="8"> | |
| 6494 | + <property name="minLvl" value="70" /> | |
| 6495 | + <property name="maxLvl" value="80" /> | |
| 6496 | + <property name="eventName" value="VIP Team vs Team" /> | |
| 6497 | + <property name="ids" value="8" /> | |
| 6498 | + <property name="matchTime" value="300" /> | |
| 6499 | + <property name="rewardId" value="6392" /> | |
| 6500 | + <property name="rewardAmmount" value="10" /> | |
| 6501 | + <property name="allowPotions" value="false" /> | |
| 6502 | + <property name="allowUseMagic" value="true" /> | |
| 6503 | + <property name="removeBuffs" value="true" /> | |
| 6504 | + <property name="minPlayers" value="8" /> | |
| 6505 | + <color owner="Blue" r="0" g="0" b="255"/> | |
| 6506 | + <color owner="Red" r="255" g="0" b="0"/> | |
| 6507 | + <color owner="BlueVIP" r="0" g="255" b="255"/> | |
| 6508 | + <color owner="RedVIP" r="255" g="155" b="0"/> | |
| 6509 | + <position owner="Blue" x="106679" y="116319" z="-1587" radius="50" /> | |
| 6510 | + <position owner="Red" x="105914" y="113368" z="-1587" radius="50" /> | |
| 6511 | + <restriction type="item" ids="" /> | |
| 6512 | + <restriction type="skill" ids="" /> | |
| 6513 | + </event> | |
| 6514 | + | |
| 6515 | + <!-- Zombie --> | |
| 6516 | + <event id="9"> | |
| 6517 | + <property name="minLvl" value="40" /> | |
| 6518 | + <property name="maxLvl" value="80" /> | |
| 6519 | + <property name="eventName" value="Zombie" /> | |
| 6520 | + <property name="ids" value="9" /> | |
| 6521 | + <property name="matchTime" value="240" /> | |
| 6522 | + <property name="rewardId" value="6392" /> | |
| 6523 | + <property name="rewardAmmount" value="25" /> | |
| 6524 | + <property name="allowPotions" value="false" /> | |
| 6525 | + <property name="allowUseMagic" value="false" /> | |
| 6526 | + <property name="removeBuffs" value="true" /> | |
| 6527 | + <property name="minPlayers" value="8" /> | |
| 6528 | + <color owner="All" r="255" g="255" b="255"/> | |
| 6529 | + <color owner="Zombie" r="255" g="0" b="0"/> | |
| 6530 | + <position owner="All" x="106037" y="114816" z="-1560" radius="50" /> | |
| 6531 | + <position owner="All" x="106037" y="114816" z="-1560" radius="50" /> | |
| 6532 | + <position owner="All" x="106037" y="114816" z="-1560" radius="50" /> | |
| 6533 | + <position owner="All" x="106037" y="114816" z="-1560" radius="50" /> | |
| 6534 | + <restriction type="item" ids="" /> | |
| 6535 | + <restriction type="skill" ids="" /> | |
| 6536 | + </event> | |
| 6537 | + | |
| 6538 | + <!-- Capture the Flag --> | |
| 6539 | + <event id="10"> | |
| 6540 | + <property name="minLvl" value="70" /> | |
| 6541 | + <property name="maxLvl" value="80" /> | |
| 6542 | + <property name="eventName" value="Capture the Flag" /> | |
| 6543 | + <property name="ids" value="10" /> | |
| 6544 | + <property name="matchTime" value="300" /> | |
| 6545 | + <property name="rewardId" value="6392" /> | |
| 6546 | + <property name="rewardAmmount" value="10" /> | |
| 6547 | + <property name="allowPotions" value="false" /> | |
| 6548 | + <property name="allowUseMagic" value="true" /> | |
| 6549 | + <property name="removeBuffs" value="true" /> | |
| 6550 | + <property name="minPlayers" value="8" /> | |
| 6551 | + <property name="blueFlagId" value="9104" /> | |
| 6552 | + <property name="redFlagId" value="9105" /> | |
| 6553 | + <property name="blueFlagHolderId" value="9106" /> | |
| 6554 | + <property name="redFlagHolderId" value="9107" /> | |
| 6555 | + <color owner="Blue" r="0" g="0" b="255"/> | |
| 6556 | + <color owner="Red" r="255" g="0" b="0"/> | |
| 6557 | + <position owner="Blue" x="106679" y="116319" z="-1587" radius="50" /> | |
| 6558 | + <position owner="BlueFlag" x="106391" y="116331" z="-1587" radius="0" /> | |
| 6559 | + <position owner="Red" x="105914" y="113368" z="-1587" radius="50" /> | |
| 6560 | + <position owner="RedFlag" x="105696" y="113522" z="-1587" radius="0" /> | |
| 6561 | + <restriction type="item" ids="" /> | |
| 6562 | + <restriction type="skill" ids="" /> | |
| 6563 | + </event> | |
| 6564 | + | |
| 6565 | + | |
| 6566 | + <!-- Russian Roulette --> | |
| 6567 | + <event id="11"> | |
| 6568 | + <property name="minLvl" value="40" /> | |
| 6569 | + <property name="maxLvl" value="80" /> | |
| 6570 | + <property name="eventName" value="Russian Roulette" /> | |
| 6571 | + <property name="ids" value="11" /> | |
| 6572 | + <property name="matchTime" value="240" /> | |
| 6573 | + <property name="rewardId" value="6392" /> | |
| 6574 | + <property name="rewardAmmount" value="15" /> | |
| 6575 | + <property name="allowPotions" value="false" /> | |
| 6576 | + <property name="allowUseMagic" value="false" /> | |
| 6577 | + <property name="removeBuffs" value="false" /> | |
| 6578 | + <property name="minPlayers" value="8" /> | |
| 6579 | + <property name="russianNpcId" value="9108" /> | |
| 6580 | + <property name="numberOfRussians" value="6" /> | |
| 6581 | + <property name="roundTime" value="10" /> | |
| 6582 | + <color owner="All" r="255" g="255" b="255"/> | |
| 6583 | + <position owner="All" x="106037" y="114816" z="-1560" radius="100" /> | |
| 6584 | + <position owner="Russian" x="106109" y="114947" z="-1587" radius="0" /> | |
| 6585 | + <position owner="Russian" x="106176" y="114792" z="-1587" radius="0" /> | |
| 6586 | + <position owner="Russian" x="106138" y="114658" z="-1587" radius="0" /> | |
| 6587 | + <position owner="Russian" x="106010" y="114607" z="-1587" radius="0" /> | |
| 6588 | + <position owner="Russian" x="105859" y="114672" z="-1587" radius="0" /> | |
| 6589 | + <position owner="Russian" x="105875" y="114837" z="-1587" radius="0" /> | |
| 6590 | + <restriction type="item" ids="" /> | |
| 6591 | + <restriction type="skill" ids="" /> | |
| 6592 | + </event> | |
| 6593 | + | |
| 6594 | + <!-- Bomb Fight --> | |
| 6595 | + <event id="12"> | |
| 6596 | + <property name="minLvl" value="40" /> | |
| 6597 | + <property name="maxLvl" value="80" /> | |
| 6598 | + <property name="eventName" value="Bomb Fight" /> | |
| 6599 | + <property name="ids" value="12" /> | |
| 6600 | + <property name="matchTime" value="300" /> | |
| 6601 | + <property name="rewardId" value="6392" /> | |
| 6602 | + <property name="rewardAmmount" value="10" /> | |
| 6603 | + <property name="allowPotions" value="false" /> | |
| 6604 | + <property name="allowUseMagic" value="true" /> | |
| 6605 | + <property name="removeBuffs" value="true" /> | |
| 6606 | + <property name="minPlayers" value="8" /> | |
| 6607 | + <property name="bombNpcId" value="9109" /> | |
| 6608 | + <property name="bombRadius" value="100" /> | |
| 6609 | + <property name="bombSkillId" value="5220" /> | |
| 6610 | + <color owner="Blue" r="0" g="0" b="255"/> | |
| 6611 | + <color owner="Red" r="255" g="0" b="0"/> | |
| 6612 | + <position owner="Blue" x="11619" y="-49691" z="-3008" radius="50" /> | |
| 6613 | + <position owner="Red" x="12720" y="-48594" z="-3035" radius="50" /> | |
| 6614 | + <restriction type="item" ids="" /> | |
| 6615 | + <restriction type="skill" ids="" /> | |
| 6616 | + </event> | |
| 6617 | + | |
| 6618 | + <!-- Mutant --> | |
| 6619 | + <event id="13"> | |
| 6620 | + <property name="minLvl" value="70" /> | |
| 6621 | + <property name="maxLvl" value="80" /> | |
| 6622 | + <property name="eventName" value="Mutant" /> | |
| 6623 | + <property name="ids" value="13" /> | |
| 6624 | + <property name="matchTime" value="240" /> | |
| 6625 | + <property name="rewardId" value="6392" /> | |
| 6626 | + <property name="rewardAmmount" value="25" /> | |
| 6627 | + <property name="allowPotions" value="false" /> | |
| 6628 | + <property name="allowUseMagic" value="true" /> | |
| 6629 | + <property name="removeBuffs" value="true" /> | |
| 6630 | + <property name="minPlayers" value="8" /> | |
| 6631 | + <property name="mutantBuffId" value="9007" /> | |
| 6632 | + <color owner="All" r="255" g="255" b="255"/> | |
| 6633 | + <position owner="All" x="106037" y="114816" z="-1560" radius="700" /> | |
| 6634 | + <restriction type="item" ids="" /> | |
| 6635 | + <restriction type="skill" ids="" /> | |
| 6636 | + </event> | |
| 6637 | + | |
| 6638 | + <!-- Battlefield --> | |
| 6639 | + <event id="14"> | |
| 6640 | + <property name="minLvl" value="70" /> | |
| 6641 | + <property name="maxLvl" value="80" /> | |
| 6642 | + <property name="eventName" value="Battlefield" /> | |
| 6643 | + <property name="ids" value="14" /> | |
| 6644 | + <property name="matchTime" value="300" /> | |
| 6645 | + <property name="rewardId" value="6392" /> | |
| 6646 | + <property name="rewardAmmount" value="10" /> | |
| 6647 | + <property name="allowPotions" value="false" /> | |
| 6648 | + <property name="allowUseMagic" value="true" /> | |
| 6649 | + <property name="removeBuffs" value="false" /> | |
| 6650 | + <property name="minPlayers" value="8" /> | |
| 6651 | + <property name="numOfBases" value="5" /> | |
| 6652 | + <property name="baseNpcId" value="9110" /> | |
| 6653 | + <property name="captureSkillId" value="5219" /> | |
| 6654 | + <color owner="Blue" r="0" g="0" b="255"/> | |
| 6655 | + <color owner="Red" r="255" g="0" b="0"/> | |
| 6656 | + <position owner="Blue" x="106679" y="116319" z="-1587" radius="50" /> | |
| 6657 | + <position owner="Red" x="105914" y="113368" z="-1587" radius="50" /> | |
| 6658 | + <position owner="Base" x="106037" y="114816" z="-1587" radius="0" /> | |
| 6659 | + <position owner="Base" x="106995" y="114556" z="-1587" radius="0" /> | |
| 6660 | + <position owner="Base" x="104823" y="115175" z="-1587" radius="0" /> | |
| 6661 | + <position owner="Base" x="105752" y="116245" z="-1587" radius="0" /> | |
| 6662 | + <position owner="Base" x="106907" y="113671" z="-1587" radius="0" /> | |
| 6663 | + <restriction type="item" ids="" /> | |
| 6664 | + <restriction type="skill" ids="" /> | |
| 6665 | + </event> | |
| 6666 | +</events> | |
| 6667 | \ No newline at end of file | |
| 6668 | Index: head-src/com/l2jfrozen/gameserver/event/Lucky.java | |
| 6669 | =================================================================== | |
| 6670 | --- head-src/com/l2jfrozen/gameserver/event/Lucky.java (revision 0) | |
| 6671 | +++ head-src/com/l2jfrozen/gameserver/event/Lucky.java (revision 0) | |
| 6672 | @@ -0,0 +1,215 @@ | |
| 6673 | +/* | |
| 6674 | + * This program is free software: you can redistribute it and/or modify it under | |
| 6675 | + * the terms of the GNU General Public License as published by the Free Software | |
| 6676 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 6677 | + * version. | |
| 6678 | + * | |
| 6679 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 6680 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 6681 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 6682 | + * details. | |
| 6683 | + * | |
| 6684 | + * You should have received a copy of the GNU General Public License along with | |
| 6685 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
| 6686 | + */ | |
| 6687 | +package com.l2jfrozen.gameserver.event; | |
| 6688 | + | |
| 6689 | +import javolution.text.TextBuilder; | |
| 6690 | +import javolution.util.FastList; | |
| 6691 | + | |
| 6692 | +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable; | |
| 6693 | +import com.l2jfrozen.gameserver.model.L2Skill; | |
| 6694 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 6695 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 6696 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 6697 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 6698 | +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay; | |
| 6699 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 6700 | +import com.l2jfrozen.util.random.Rnd; | |
| 6701 | + | |
| 6702 | +/** | |
| 6703 | + * @author Rizel | |
| 6704 | + * | |
| 6705 | + */ | |
| 6706 | +public class Lucky extends Event | |
| 6707 | +{
| |
| 6708 | + private class Core implements Runnable | |
| 6709 | + {
| |
| 6710 | + public void run() | |
| 6711 | + {
| |
| 6712 | + try | |
| 6713 | + {
| |
| 6714 | + switch (eventState) | |
| 6715 | + {
| |
| 6716 | + case START: | |
| 6717 | + divideIntoTeams(1); | |
| 6718 | + preparePlayers(); | |
| 6719 | + teleportToTeamPos(); | |
| 6720 | + forceSitAll(); | |
| 6721 | + unequip(); | |
| 6722 | + setStatus(EventState.FIGHT); | |
| 6723 | + schedule(30000); | |
| 6724 | + break; | |
| 6725 | + | |
| 6726 | + case FIGHT: | |
| 6727 | + forceStandAll(); | |
| 6728 | + int[] coor = getPosition("Chests", 1);
| |
| 6729 | + for (int i = 0; i < getInt("numberOfChests"); i++)
| |
| 6730 | + chests.add(spawnNPC(coor[0] + (Rnd.get(coor[3] * 2) - coor[3]), coor[1] + (Rnd.get(coor[3] * 2) - coor[3]), coor[2], getInt("chestNpcId")));
| |
| 6731 | + setStatus(EventState.END); | |
| 6732 | + clock.startClock(getInt("matchTime"));
| |
| 6733 | + break; | |
| 6734 | + | |
| 6735 | + case END: | |
| 6736 | + clock.setTime(0); | |
| 6737 | + unSpawnChests(); | |
| 6738 | + L2PcInstance winner = getPlayerWithMaxScore(); | |
| 6739 | + giveReward(winner, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 6740 | + setStatus(EventState.INACTIVE); | |
| 6741 | + EventManager.getInstance().end("Congratulation! " + winner.getName() + " won the event with " + getScore(winner) + " opened chests!");
| |
| 6742 | + break; | |
| 6743 | + } | |
| 6744 | + } | |
| 6745 | + catch (Throwable e) | |
| 6746 | + {
| |
| 6747 | + e.printStackTrace(); | |
| 6748 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 6749 | + } | |
| 6750 | + } | |
| 6751 | + } | |
| 6752 | + | |
| 6753 | + private enum EventState | |
| 6754 | + {
| |
| 6755 | + START, FIGHT, END, INACTIVE | |
| 6756 | + } | |
| 6757 | + | |
| 6758 | + private EventState eventState; | |
| 6759 | + | |
| 6760 | + private Core task; | |
| 6761 | + | |
| 6762 | + private FastList<L2Spawn> chests; | |
| 6763 | + | |
| 6764 | + public Lucky() | |
| 6765 | + {
| |
| 6766 | + super(); | |
| 6767 | + eventId = 5; | |
| 6768 | + createNewTeam(1, "All", getColor("All"), getPosition("All", 1));
| |
| 6769 | + task = new Core(); | |
| 6770 | + chests = new FastList<L2Spawn>(); | |
| 6771 | + } | |
| 6772 | + | |
| 6773 | + /** | |
| 6774 | + * @see net.sf.l2j.gameserver.event.Event#endEvent() | |
| 6775 | + */ | |
| 6776 | + @Override | |
| 6777 | + protected void endEvent() | |
| 6778 | + {
| |
| 6779 | + | |
| 6780 | + setStatus(EventState.END); | |
| 6781 | + clock.setTime(0); | |
| 6782 | + | |
| 6783 | + } | |
| 6784 | + | |
| 6785 | + @Override | |
| 6786 | + protected String getScorebar() | |
| 6787 | + {
| |
| 6788 | + return "Max: " + getScore(getPlayerWithMaxScore()) + " Time: " + clock.getTime() + ""; | |
| 6789 | + } | |
| 6790 | + | |
| 6791 | + @Override | |
| 6792 | + public boolean onTalkNpc(L2NpcInstance npc, L2PcInstance player) | |
| 6793 | + {
| |
| 6794 | + if (npc.getNpcId() != getInt("chestNpcId"))
| |
| 6795 | + return false; | |
| 6796 | + | |
| 6797 | + if (Rnd.get(3) == 0) | |
| 6798 | + {
| |
| 6799 | + player.sendPacket(new CreatureSay(npc.getObjectId(), 0, "Chest", "BoOoOoMm!")); | |
| 6800 | + player.stopAllEffects(); | |
| 6801 | + player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, player); | |
| 6802 | + EventStats.getInstance().tempTable.get(player.getObjectId())[2] = EventStats.getInstance().tempTable.get(player.getObjectId())[2] + 1; | |
| 6803 | + addToResurrector(player); | |
| 6804 | + } | |
| 6805 | + else | |
| 6806 | + {
| |
| 6807 | + npc.doDie(npc); | |
| 6808 | + player.addItem("Event", 6392, 1, player, true);
| |
| 6809 | + increasePlayersScore(player); | |
| 6810 | + } | |
| 6811 | + | |
| 6812 | + npc.deleteMe(); | |
| 6813 | + npc.getSpawn().stopRespawn(); | |
| 6814 | + SpawnTable.getInstance().deleteSpawn(npc.getSpawn(), true); | |
| 6815 | + chests.remove(npc.getSpawn()); | |
| 6816 | + | |
| 6817 | + if (chests.size() == 0) | |
| 6818 | + clock.setTime(0); | |
| 6819 | + | |
| 6820 | + return true; | |
| 6821 | + } | |
| 6822 | + | |
| 6823 | + @Override | |
| 6824 | + protected void schedule(int time) | |
| 6825 | + {
| |
| 6826 | + tpm.scheduleGeneral(task, time); | |
| 6827 | + } | |
| 6828 | + | |
| 6829 | + private void setStatus(EventState s) | |
| 6830 | + {
| |
| 6831 | + eventState = s; | |
| 6832 | + } | |
| 6833 | + public boolean onUseMagic(L2Skill skill) | |
| 6834 | + {
| |
| 6835 | + return false; | |
| 6836 | + } | |
| 6837 | + | |
| 6838 | + @Override | |
| 6839 | + protected void showHtml(L2PcInstance player, int obj) | |
| 6840 | + {
| |
| 6841 | + if (players.size() > 0) | |
| 6842 | + {
| |
| 6843 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 6844 | + TextBuilder sb = new TextBuilder(); | |
| 6845 | + | |
| 6846 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 6847 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 6848 | + sb.append("<table width=270><tr><td><center>" + getPlayerWithMaxScore().getName() + " - " + getScore(getPlayerWithMaxScore()) + "</td></tr></table>");
| |
| 6849 | + sb.append("<br><table width=270>");
| |
| 6850 | + | |
| 6851 | + for (L2PcInstance p : getPlayersOfTeam(1)) | |
| 6852 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 6853 | + | |
| 6854 | + sb.append("</table></body></html>");
| |
| 6855 | + html.setHtml(sb.toString()); | |
| 6856 | + player.sendPacket(html); | |
| 6857 | + | |
| 6858 | + } | |
| 6859 | + | |
| 6860 | + } | |
| 6861 | + | |
| 6862 | + /* (non-Javadoc) | |
| 6863 | + * @see net.sf.l2j.gameserver.event.Event#start() | |
| 6864 | + */ | |
| 6865 | + @Override | |
| 6866 | + protected void start() | |
| 6867 | + {
| |
| 6868 | + setStatus(EventState.START); | |
| 6869 | + schedule(1); | |
| 6870 | + } | |
| 6871 | + | |
| 6872 | + private void unSpawnChests() | |
| 6873 | + {
| |
| 6874 | + for (L2Spawn s : chests) | |
| 6875 | + {
| |
| 6876 | + s.getLastSpawn().deleteMe(); | |
| 6877 | + s.stopRespawn(); | |
| 6878 | + SpawnTable.getInstance().deleteSpawn(s, true); | |
| 6879 | + chests.remove(s); | |
| 6880 | + } | |
| 6881 | + } | |
| 6882 | + public boolean onUseItem(L2PcInstance player, L2ItemInstance item) | |
| 6883 | + {
| |
| 6884 | + return false; | |
| 6885 | + } | |
| 6886 | + | |
| 6887 | +} | |
| 6888 | \ No newline at end of file | |
| 6889 | Index: head-src/com/l2jfrozen/gameserver/event/Simon.java | |
| 6890 | =================================================================== | |
| 6891 | --- head-src/com/l2jfrozen/gameserver/event/Simon.java (revision 0) | |
| 6892 | +++ head-src/com/l2jfrozen/gameserver/event/Simon.java (revision 0) | |
| 6893 | @@ -0,0 +1,308 @@ | |
| 6894 | +package com.l2jfrozen.gameserver.event; | |
| 6895 | + | |
| 6896 | +import javolution.text.TextBuilder; | |
| 6897 | + | |
| 6898 | +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable; | |
| 6899 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 6900 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 6901 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 6902 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 6903 | +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay; | |
| 6904 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 6905 | +import com.l2jfrozen.util.random.Rnd; | |
| 6906 | + | |
| 6907 | +/** | |
| 6908 | + * @author Rizel | |
| 6909 | + * | |
| 6910 | + */ | |
| 6911 | +public class Simon extends Event | |
| 6912 | +{
| |
| 6913 | + | |
| 6914 | + private class Core implements Runnable | |
| 6915 | + {
| |
| 6916 | + public void run() | |
| 6917 | + {
| |
| 6918 | + try | |
| 6919 | + {
| |
| 6920 | + switch (eventState) | |
| 6921 | + {
| |
| 6922 | + case START: | |
| 6923 | + divideIntoTeams(1); | |
| 6924 | + preparePlayers(); | |
| 6925 | + teleportToTeamPos(); | |
| 6926 | + forceSitAll(); | |
| 6927 | + unequip(); | |
| 6928 | + setStatus(EventState.SAY); | |
| 6929 | + schedule(30000); | |
| 6930 | + break; | |
| 6931 | + | |
| 6932 | + case SAY: | |
| 6933 | + round++; | |
| 6934 | + say = createNewRandomString(getInt("lengthOfFirstWord") + getInt("increasePerRound") * round);
| |
| 6935 | + sendToPlayers(say.toUpperCase()); | |
| 6936 | + setStatus(EventState.CHECK); | |
| 6937 | + schedule(getInt("roundTime") * 1000);
| |
| 6938 | + break; | |
| 6939 | + | |
| 6940 | + case CHECK: | |
| 6941 | + if (removeAfkers()) | |
| 6942 | + {
| |
| 6943 | + setAllToFalse(); | |
| 6944 | + setStatus(EventState.SAY); | |
| 6945 | + schedule(getInt("roundTime") * 1000);
| |
| 6946 | + } | |
| 6947 | + break; | |
| 6948 | + | |
| 6949 | + case END: | |
| 6950 | + setStatus(EventState.INACTIVE); | |
| 6951 | + forceStandAll(); | |
| 6952 | + | |
| 6953 | + if (winner != null) | |
| 6954 | + {
| |
| 6955 | + giveReward(winner, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 6956 | + EventManager.getInstance().end("Congratulation! " + winner.getName() + " won the event!");
| |
| 6957 | + } | |
| 6958 | + else | |
| 6959 | + EventManager.getInstance().end("The match ended in a tie!");
| |
| 6960 | + break; | |
| 6961 | + } | |
| 6962 | + } | |
| 6963 | + catch (Throwable e) | |
| 6964 | + {
| |
| 6965 | + e.printStackTrace(); | |
| 6966 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 6967 | + } | |
| 6968 | + } | |
| 6969 | + } | |
| 6970 | + | |
| 6971 | + private enum EventState | |
| 6972 | + {
| |
| 6973 | + START, SAY, CHECK, END, INACTIVE | |
| 6974 | + } | |
| 6975 | + | |
| 6976 | + private EventState eventState; | |
| 6977 | + | |
| 6978 | + private Core task; | |
| 6979 | + | |
| 6980 | + private int round; | |
| 6981 | + | |
| 6982 | + private String say; | |
| 6983 | + | |
| 6984 | + private L2NpcInstance npc; | |
| 6985 | + | |
| 6986 | + private L2Spawn spawn; | |
| 6987 | + | |
| 6988 | + private CreatureSay message; | |
| 6989 | + | |
| 6990 | + private L2PcInstance winner; | |
| 6991 | + | |
| 6992 | + public Simon() | |
| 6993 | + {
| |
| 6994 | + super(); | |
| 6995 | + eventId = 6; | |
| 6996 | + createNewTeam(1, "All", getColor("All"), getPosition("All", 1));
| |
| 6997 | + task = new Core(); | |
| 6998 | + round = 0; | |
| 6999 | + spawn = null; | |
| 7000 | + npc = null; | |
| 7001 | + winner = null; | |
| 7002 | + } | |
| 7003 | + | |
| 7004 | + private String createNewRandomString(int size) | |
| 7005 | + {
| |
| 7006 | + String str = ""; | |
| 7007 | + | |
| 7008 | + for (int i = 0; i < size; i++) | |
| 7009 | + str = str + (char) (Rnd.nextInt(26) + 97); | |
| 7010 | + | |
| 7011 | + return str; | |
| 7012 | + } | |
| 7013 | + | |
| 7014 | + @Override | |
| 7015 | + protected void endEvent() | |
| 7016 | + {
| |
| 7017 | + winner = players.head().getNext().getKey(); | |
| 7018 | + setStatus(EventState.END); | |
| 7019 | + schedule(1); | |
| 7020 | + | |
| 7021 | + } | |
| 7022 | + | |
| 7023 | + @Override | |
| 7024 | + protected String getScorebar() | |
| 7025 | + {
| |
| 7026 | + return ""; | |
| 7027 | + } | |
| 7028 | + | |
| 7029 | + @Override | |
| 7030 | + public void onSay(int type, L2PcInstance player, String text) | |
| 7031 | + {
| |
| 7032 | + if (eventState == EventState.CHECK && getStatus(player) != -1) | |
| 7033 | + {
| |
| 7034 | + if (text.equalsIgnoreCase(say)) | |
| 7035 | + {
| |
| 7036 | + setStatus(player, 1); | |
| 7037 | + player.sendMessage("Correct!");
| |
| 7038 | + increasePlayersScore(player); | |
| 7039 | + player.getAppearance().setNameColor(0, 255, 0); | |
| 7040 | + player.broadcastUserInfo(); | |
| 7041 | + } | |
| 7042 | + | |
| 7043 | + else | |
| 7044 | + {
| |
| 7045 | + setStatus(player, -1); | |
| 7046 | + player.sendMessage("Wrong!");
| |
| 7047 | + player.getAppearance().setNameColor(255, 0, 0); | |
| 7048 | + player.broadcastUserInfo(); | |
| 7049 | + } | |
| 7050 | + | |
| 7051 | + int falses = 0; | |
| 7052 | + L2PcInstance falsed = null; | |
| 7053 | + for (L2PcInstance p : getPlayerList()) | |
| 7054 | + if (getStatus(p) == 0) | |
| 7055 | + {
| |
| 7056 | + falses++; | |
| 7057 | + falsed = p; | |
| 7058 | + } | |
| 7059 | + | |
| 7060 | + if (falses == 1) | |
| 7061 | + {
| |
| 7062 | + int count = 0; | |
| 7063 | + for (L2PcInstance pla : getPlayerList()) | |
| 7064 | + if (getStatus(pla) == 1) | |
| 7065 | + count++; | |
| 7066 | + | |
| 7067 | + if (count >= 1) | |
| 7068 | + {
| |
| 7069 | + falsed.sendMessage("Last one!");
| |
| 7070 | + falsed.getAppearance().setNameColor(255, 0, 0); | |
| 7071 | + falsed.broadcastUserInfo(); | |
| 7072 | + setStatus(falsed, -1); | |
| 7073 | + } | |
| 7074 | + | |
| 7075 | + if (count == 0) | |
| 7076 | + {
| |
| 7077 | + winner = getPlayersWithStatus(0).head().getNext().getValue(); | |
| 7078 | + setStatus(EventState.END); | |
| 7079 | + schedule(1); | |
| 7080 | + } | |
| 7081 | + | |
| 7082 | + } | |
| 7083 | + | |
| 7084 | + if (countOfPositiveStatus() == 1) | |
| 7085 | + {
| |
| 7086 | + winner = getPlayersWithStatus(1).head().getNext().getValue(); | |
| 7087 | + setStatus(EventState.END); | |
| 7088 | + schedule(1); | |
| 7089 | + } | |
| 7090 | + | |
| 7091 | + } | |
| 7092 | + | |
| 7093 | + } | |
| 7094 | + | |
| 7095 | + private boolean removeAfkers() | |
| 7096 | + {
| |
| 7097 | + | |
| 7098 | + for (L2PcInstance player : getPlayerList()) | |
| 7099 | + {
| |
| 7100 | + if (getStatus(player) == 0) | |
| 7101 | + {
| |
| 7102 | + | |
| 7103 | + player.sendMessage("Timeout!");
| |
| 7104 | + player.getAppearance().setNameColor(255, 0, 0); | |
| 7105 | + player.broadcastUserInfo(); | |
| 7106 | + setStatus(player, -1); | |
| 7107 | + } | |
| 7108 | + | |
| 7109 | + if (countOfPositiveStatus() == 1) | |
| 7110 | + {
| |
| 7111 | + if (getPlayersWithStatus(1).size() == 1) | |
| 7112 | + winner = getPlayersWithStatus(1).head().getNext().getValue(); | |
| 7113 | + else | |
| 7114 | + winner = null; | |
| 7115 | + | |
| 7116 | + setStatus(EventState.END); | |
| 7117 | + schedule(1); | |
| 7118 | + return false; | |
| 7119 | + } | |
| 7120 | + } | |
| 7121 | + return true; | |
| 7122 | + } | |
| 7123 | + | |
| 7124 | + @Override | |
| 7125 | + public void reset() | |
| 7126 | + {
| |
| 7127 | + super.reset(); | |
| 7128 | + round = 0; | |
| 7129 | + players.clear(); | |
| 7130 | + say = ""; | |
| 7131 | + npc.deleteMe(); | |
| 7132 | + spawn.stopRespawn(); | |
| 7133 | + SpawnTable.getInstance().deleteSpawn(spawn, true); | |
| 7134 | + npc = null; | |
| 7135 | + spawn = null; | |
| 7136 | + } | |
| 7137 | + | |
| 7138 | + @Override | |
| 7139 | + protected void schedule(int time) | |
| 7140 | + {
| |
| 7141 | + tpm.scheduleGeneral(task, time); | |
| 7142 | + } | |
| 7143 | + | |
| 7144 | + private void sendToPlayers(String text) | |
| 7145 | + {
| |
| 7146 | + message = new CreatureSay(npc.getObjectId(), 1, "Simon", text); | |
| 7147 | + for (L2PcInstance player : getPlayerList()) | |
| 7148 | + player.sendPacket(message); | |
| 7149 | + } | |
| 7150 | + | |
| 7151 | + private void setAllToFalse() | |
| 7152 | + {
| |
| 7153 | + for (L2PcInstance player : getPlayerList()) | |
| 7154 | + if (getStatus(player) != -1) | |
| 7155 | + {
| |
| 7156 | + setStatus(player, 0); | |
| 7157 | + player.getAppearance().setNameColor(255, 255, 255); | |
| 7158 | + player.broadcastUserInfo(); | |
| 7159 | + } | |
| 7160 | + } | |
| 7161 | + | |
| 7162 | + private void setStatus(EventState s) | |
| 7163 | + {
| |
| 7164 | + eventState = s; | |
| 7165 | + } | |
| 7166 | + | |
| 7167 | + @Override | |
| 7168 | + protected void showHtml(L2PcInstance player, int obj) | |
| 7169 | + {
| |
| 7170 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 7171 | + TextBuilder sb = new TextBuilder(); | |
| 7172 | + | |
| 7173 | + sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 7174 | + sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: ?</td></tr></table>");
| |
| 7175 | + sb.append("<table width=270><tr><td><center>Players left: " + getPlayersWithStatus(0).size() + "</td></tr></table>");
| |
| 7176 | + sb.append("<br><table width=270>");
| |
| 7177 | + | |
| 7178 | + for (L2PcInstance p : getPlayersOfTeam(1)) | |
| 7179 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 7180 | + | |
| 7181 | + sb.append("</table></body></html>");
| |
| 7182 | + html.setHtml(sb.toString()); | |
| 7183 | + player.sendPacket(html); | |
| 7184 | + } | |
| 7185 | + | |
| 7186 | + @Override | |
| 7187 | + protected void start() | |
| 7188 | + {
| |
| 7189 | + int[] npcpos = getPosition("Simon", 1);
| |
| 7190 | + spawn = spawnNPC(npcpos[0], npcpos[1], npcpos[2], getInt("simonNpcId"));
| |
| 7191 | + npc = spawn.getLastSpawn(); | |
| 7192 | + setStatus(EventState.START); | |
| 7193 | + schedule(1); | |
| 7194 | + } | |
| 7195 | + | |
| 7196 | + @Override | |
| 7197 | + public boolean onUseItem(L2PcInstance player, L2ItemInstance item) | |
| 7198 | + {
| |
| 7199 | + return false; | |
| 7200 | + } | |
| 7201 | +} | |
| 7202 | \ No newline at end of file | |
| 7203 | Index: head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java | |
| 7204 | =================================================================== | |
| 7205 | --- head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java (revision 936) | |
| 7206 | +++ head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java (working copy) | |
| 7207 | @@ -47,6 +47,7 @@ | |
| 7208 | import com.l2jfrozen.Config; | |
| 7209 | import com.l2jfrozen.crypt.nProtect; | |
| 7210 | import com.l2jfrozen.crypt.nProtect.RestrictionType; | |
| 7211 | +import com.l2jfrozen.gameserver.event.EventManager; | |
| 7212 | import com.l2jfrozen.gameserver.managers.OlympiadStadiaManager; | |
| 7213 | import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 7214 | import com.l2jfrozen.gameserver.model.entity.Announcements; | |
| 7215 | @@ -485,6 +486,12 @@ | |
| 7216 | return false; | |
| 7217 | } | |
| 7218 | ||
| 7219 | + if(EventManager.getInstance().players.contains(noble)) | |
| 7220 | + {
| |
| 7221 | + noble.sendMessage("You can't join olympiad while participating on an Event.");
| |
| 7222 | + return false; | |
| 7223 | + } | |
| 7224 | + | |
| 7225 | if(!noble.isNoble()) | |
| 7226 | {
| |
| 7227 | sm = new SystemMessage(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD); | |
| 7228 | @@ -1114,6 +1121,12 @@ | |
| 7229 | spectator.sendPacket(new SystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS)); | |
| 7230 | return; | |
| 7231 | } | |
| 7232 | + | |
| 7233 | + if(EventManager.getInstance().players.contains(spectator)) | |
| 7234 | + {
| |
| 7235 | + spectator.sendMessage("You can not observe games while registered for an event!");
| |
| 7236 | + return; | |
| 7237 | + } | |
| 7238 | ||
| 7239 | L2PcInstance[] players = _manager.getOlympiadInstance(id).getPlayers(); | |
| 7240 | ||
| 7241 | Index: head-src/com/l2jfrozen/gameserver/event/Battlefield.java | |
| 7242 | =================================================================== | |
| 7243 | --- head-src/com/l2jfrozen/gameserver/event/Battlefield.java (revision 0) | |
| 7244 | +++ head-src/com/l2jfrozen/gameserver/event/Battlefield.java (revision 0) | |
| 7245 | @@ -0,0 +1,238 @@ | |
| 7246 | +package com.l2jfrozen.gameserver.event; | |
| 7247 | + | |
| 7248 | +import java.util.Map; | |
| 7249 | + | |
| 7250 | +import javolution.text.TextBuilder; | |
| 7251 | +import javolution.util.FastMap; | |
| 7252 | + | |
| 7253 | +import com.l2jfrozen.gameserver.datatables.SkillTable; | |
| 7254 | +import com.l2jfrozen.gameserver.model.spawn.L2Spawn; | |
| 7255 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 7256 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 7257 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcInfo; | |
| 7258 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 7259 | +import com.l2jfrozen.util.random.Rnd; | |
| 7260 | + | |
| 7261 | +public class Battlefield extends Event | |
| 7262 | +{
| |
| 7263 | + private class Core implements Runnable | |
| 7264 | + {
| |
| 7265 | + | |
| 7266 | + public void run() | |
| 7267 | + {
| |
| 7268 | + try{
| |
| 7269 | + switch (eventState) | |
| 7270 | + {
| |
| 7271 | + case START: | |
| 7272 | + divideIntoTeams(2); | |
| 7273 | + preparePlayers(); | |
| 7274 | + teleportToTeamPos(); | |
| 7275 | + createPartyOfTeam(1); | |
| 7276 | + createPartyOfTeam(2); | |
| 7277 | + forceSitAll(); | |
| 7278 | + giveSkill(); | |
| 7279 | + spawnBases(); | |
| 7280 | + setStatus(EventState.FIGHT); | |
| 7281 | + schedule(20000); | |
| 7282 | + break; | |
| 7283 | + | |
| 7284 | + case FIGHT: | |
| 7285 | + forceStandAll(); | |
| 7286 | + setStatus(EventState.END); | |
| 7287 | + clock.startClock(getInt("matchTime"));
| |
| 7288 | + break; | |
| 7289 | + | |
| 7290 | + case END: | |
| 7291 | + clock.setTime(0); | |
| 7292 | + if (winnerTeam == 0) | |
| 7293 | + winnerTeam = getWinnerTeam(); | |
| 7294 | + | |
| 7295 | + giveReward(getPlayersOfTeam(winnerTeam), getInt("rewardId"), getInt("rewardAmmount"));
| |
| 7296 | + unspawnBases(); | |
| 7297 | + removeSkill(); | |
| 7298 | + setStatus(EventState.INACTIVE); | |
| 7299 | + EventManager.getInstance().end("Congratulation! The " + teams.get(winnerTeam).getName() + " team won the event with " + teams.get(winnerTeam).getScore() + " points!");
| |
| 7300 | + break; | |
| 7301 | + } | |
| 7302 | + } | |
| 7303 | + catch (Throwable e) | |
| 7304 | + {
| |
| 7305 | + e.printStackTrace(); | |
| 7306 | + EventManager.getInstance().end("Error! Event ended.");
| |
| 7307 | + } | |
| 7308 | + } | |
| 7309 | + | |
| 7310 | + } | |
| 7311 | + | |
| 7312 | + private enum EventState | |
| 7313 | + {
| |
| 7314 | + START, FIGHT, END, TELEPORT, INACTIVE | |
| 7315 | + } | |
| 7316 | + | |
| 7317 | + private EventState eventState; | |
| 7318 | + | |
| 7319 | + private Core task; | |
| 7320 | + | |
| 7321 | + private int winnerTeam; | |
| 7322 | + | |
| 7323 | + private FastMap<Integer,L2Spawn> bases; | |
| 7324 | + | |
| 7325 | + private FastMap<Integer,Integer> owners; | |
| 7326 | + | |
| 7327 | + public Battlefield() | |
| 7328 | + {
| |
| 7329 | + super(); | |
| 7330 | + eventId = 14; | |
| 7331 | + createNewTeam(1, "Blue", getColor("Blue"), getPosition("Blue", 1));
| |
| 7332 | + createNewTeam(2, "Red", getColor("Red"), getPosition("Red", 1));
| |
| 7333 | + bases = new FastMap<Integer,L2Spawn>(); | |
| 7334 | + owners = new FastMap<Integer,Integer>(); | |
| 7335 | + task = new Core(); | |
| 7336 | + winnerTeam = 0; | |
| 7337 | + } | |
| 7338 | + | |
| 7339 | + @Override | |
| 7340 | + protected void endEvent() | |
| 7341 | + {
| |
| 7342 | + winnerTeam = players.head().getNext().getValue()[0]; | |
| 7343 | + | |
| 7344 | + setStatus(EventState.END); | |
| 7345 | + schedule(1); | |
| 7346 | + } | |
| 7347 | + | |
| 7348 | + @Override | |
| 7349 | + protected String getScorebar() | |
| 7350 | + {
| |
| 7351 | + return "" + teams.get(1).getName() + ": " + teams.get(1).getScore() + " " + teams.get(2).getName() + ": " + teams.get(2).getScore() + " Time: " + clock.getTime(); | |
| 7352 | + } | |
| 7353 | + | |
| 7354 | + @Override | |
| 7355 | + protected int getWinnerTeam() | |
| 7356 | + {
| |
| 7357 | + if (teams.get(1).getScore() > teams.get(2).getScore()) | |
| 7358 | + return 1; | |
| 7359 | + if (teams.get(2).getScore() > teams.get(1).getScore()) | |
| 7360 | + return 2; | |
| 7361 | + if (teams.get(1).getScore() == teams.get(2).getScore()) | |
| 7362 | + if (Rnd.nextInt(1) == 1) | |
| 7363 | + return 1; | |
| 7364 | + else | |
| 7365 | + return 2; | |
| 7366 | + | |
| 7367 | + return 1; | |
| 7368 | + } | |
| 7369 | + | |
| 7370 | + @Override | |
| 7371 | + public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 7372 | + {
| |
| 7373 | + super.onDie(victim, killer); | |
| 7374 | + addToResurrector(victim); | |
| 7375 | + } | |
| 7376 | + | |
| 7377 | + @Override | |
| 7378 | + protected void schedule(int time) | |
| 7379 | + {
| |
| 7380 | + tpm.scheduleGeneral(task, time); | |
| 7381 | + } | |
| 7382 | + | |
| 7383 | + private void setStatus(EventState s) | |
| 7384 | + {
| |
| 7385 | + eventState = s; | |
| 7386 | + } | |
| 7387 | + | |
| 7388 | + @Override | |
| 7389 | + protected void showHtml(L2PcInstance player, int obj) | |
| 7390 | + {
| |
| 7391 | + NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 7392 | + TextBuilder sb = new TextBuilder(); | |
| 7393 | + sb.append("<html><body><table width=300>" + "<tr><td><center>Event phase</td></tr>" + "<tr><td><center>" + getString("eventName") + " - " + clock.getTime() + "</td></tr>" + "<tr><td><center><font color=" + teams.get(1).getHexaColor() + ">" + teams.get(1).getScore() + "</font> - " + "<font color=" + teams.get(2).getHexaColor() + ">" + teams.get(2).getScore() + "</font></td></tr>" + "</table><br><table width=300>");
| |
| 7394 | + | |
| 7395 | + int i = 0; | |
| 7396 | + for (EventTeam team : teams.values()) | |
| 7397 | + {
| |
| 7398 | + i++; | |
| 7399 | + sb.append("<tr><td><font color=" + team.getHexaColor() + ">" + team.getName() + "</font> team</td><td></td><td></td><td></td></tr>");
| |
| 7400 | + for (L2PcInstance p : getPlayersOfTeam(i)) | |
| 7401 | + sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 7402 | + } | |
| 7403 | + | |
| 7404 | + sb.append("</table><br></body></html>");
| |
| 7405 | + html.setHtml(sb.toString()); | |
| 7406 | + player.sendPacket(html); | |
| 7407 | + | |
| 7408 | + } | |
| 7409 | + | |
| 7410 | + @Override | |
| 7411 | + protected void start() | |
| 7412 | + {
| |
| 7413 | + setStatus(EventState.START); | |
| 7414 | + schedule(1); | |
| 7415 | + } | |
| 7416 | + | |
| 7417 | + private void spawnBases() | |
| 7418 | + {
| |
| 7419 | + for(int i = 1; i <= getInt("numOfBases"); i++)
| |
| 7420 | + {
| |
| 7421 | + bases.put(i, spawnNPC(getPosition("Base",i)[0],getPosition("Base",i)[1],getPosition("Base",i)[2],getInt("baseNpcId")));
| |
| 7422 | + bases.get(i).getLastSpawn().setTitle("- Neutral -");
| |
| 7423 | + owners.put(i, 0); | |
| 7424 | + } | |
| 7425 | + } | |
| 7426 | + | |
| 7427 | + private void unspawnBases() | |
| 7428 | + {
| |
| 7429 | + for(L2Spawn base: bases.values()) | |
| 7430 | + unspawnNPC(base); | |
| 7431 | + } | |
| 7432 | + | |
| 7433 | + @Override | |
| 7434 | + public void reset() | |
| 7435 | + {
| |
| 7436 | + super.reset(); | |
| 7437 | + bases.clear(); | |
| 7438 | + owners.clear(); | |
| 7439 | + } | |
| 7440 | + | |
| 7441 | + @Override | |
| 7442 | + protected void clockTick() | |
| 7443 | + {
| |
| 7444 | + for(int owner : owners.values()) | |
| 7445 | + if(owner != 0) | |
| 7446 | + teams.get(owner).increaseScore(1); | |
| 7447 | + } | |
| 7448 | + | |
| 7449 | + @Override | |
| 7450 | + public void useCapture(L2PcInstance player, L2NpcInstance base) | |
| 7451 | + {
| |
| 7452 | + if(base.getNpcId() != getInt("baseNpcId"))
| |
| 7453 | + return; | |
| 7454 | + | |
| 7455 | + for(Map.Entry<Integer, L2Spawn> baseSpawn: bases.entrySet()) | |
| 7456 | + if(baseSpawn.getValue().getLastSpawn().getObjectId() == base.getObjectId()) | |
| 7457 | + {
| |
| 7458 | + if(owners.get(baseSpawn.getKey()) == getTeam(player)) | |
| 7459 | + return; | |
| 7460 | + | |
| 7461 | + owners.getEntry(baseSpawn.getKey()).setValue(getTeam(player)); | |
| 7462 | + baseSpawn.getValue().getLastSpawn().setTitle("- "+teams.get(getTeam(player)).getName()+" -");
| |
| 7463 | + for(L2PcInstance p : getPlayerList()) | |
| 7464 | + p.sendPacket(new NpcInfo(baseSpawn.getValue().getLastSpawn(), p)); | |
| 7465 | + | |
| 7466 | + announce(getPlayerList(),"The "+teams.get(getTeam(player)).getName()+" team captured a base!"); | |
| 7467 | + increasePlayersScore(player); | |
| 7468 | + player.addItem("Event", 6392, 2, player, true);
| |
| 7469 | + } | |
| 7470 | + } | |
| 7471 | + | |
| 7472 | + private void removeSkill() | |
| 7473 | + {
| |
| 7474 | + for (L2PcInstance player : getPlayerList()) | |
| 7475 | + player.removeSkill(SkillTable.getInstance().getInfo(getInt("captureSkillId"), 1), false);
| |
| 7476 | + } | |
| 7477 | + | |
| 7478 | + private void giveSkill() | |
| 7479 | + {
| |
| 7480 | + for (L2PcInstance player : getPlayerList()) | |
| 7481 | + player.addSkill(SkillTable.getInstance().getInfo(getInt("captureSkillId"), 1), false);
| |
| 7482 | + } | |
| 7483 | +} | |
| 7484 | \ No newline at end of file | |
| 7485 | Index: head-src/com/l2jfrozen/gameserver/event/dm.java | |
| 7486 | =================================================================== | |
| 7487 | --- head-src/com/l2jfrozen/gameserver/event/dm.java (revision 0) | |
| 7488 | +++ head-src/com/l2jfrozen/gameserver/event/dm.java (revision 0) | |
| 7489 | @@ -0,0 +1,139 @@ | |
| 7490 | +package com.l2jfrozen.gameserver.event; | |
| 7491 | + | |
| 7492 | +import javolution.text.TextBuilder; | |
| 7493 | + | |
| 7494 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 7495 | +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage; | |
| 7496 | + | |
| 7497 | +public class dm extends Event | |
| 7498 | +{
| |
| 7499 | +private class Core implements Runnable | |
| 7500 | +{
| |
| 7501 | +public void run() | |
| 7502 | +{
| |
| 7503 | +try | |
| 7504 | +{
| |
| 7505 | +switch (eventState) | |
| 7506 | +{
| |
| 7507 | +case START: | |
| 7508 | +divideIntoTeams(1); | |
| 7509 | +preparePlayers(); | |
| 7510 | +teleportToTeamPos(); | |
| 7511 | +forceSitAll(); | |
| 7512 | +setStatus(EventState.FIGHT); | |
| 7513 | +debug("The event started with " + players.size() + " player");
| |
| 7514 | +schedule(20000); | |
| 7515 | +break; | |
| 7516 | + | |
| 7517 | +case FIGHT: | |
| 7518 | +forceStandAll(); | |
| 7519 | +setStatus(EventState.END); | |
| 7520 | +debug("The fight started");
| |
| 7521 | +clock.startClock(getInt("matchTime"));
| |
| 7522 | +break; | |
| 7523 | + | |
| 7524 | +case END: | |
| 7525 | +clock.setTime(0); | |
| 7526 | +L2PcInstance winner = getPlayerWithMaxScore(); | |
| 7527 | +giveReward(winner, getInt("rewardId"), getInt("rewardAmmount"));
| |
| 7528 | +setStatus(EventState.INACTIVE); | |
| 7529 | +debug("The event ended. Winner: " + winner.getName());
| |
| 7530 | +EventManager.getInstance().end("Congratulation! " + winner.getName() + " won the event with " + getScore(winner) + " kills!");
| |
| 7531 | +break; | |
| 7532 | +} | |
| 7533 | +} | |
| 7534 | +catch (Throwable e) | |
| 7535 | +{
| |
| 7536 | +e.printStackTrace(); | |
| 7537 | +EventManager.getInstance().end("Error! Event ended.");
| |
| 7538 | +} | |
| 7539 | +} | |
| 7540 | +} | |
| 7541 | + | |
| 7542 | +private enum EventState | |
| 7543 | +{
| |
| 7544 | +START, FIGHT, END, INACTIVE | |
| 7545 | +} | |
| 7546 | + | |
| 7547 | +private EventState eventState; | |
| 7548 | + | |
| 7549 | +private Core task; | |
| 7550 | + | |
| 7551 | +public dm() | |
| 7552 | +{
| |
| 7553 | +super(); | |
| 7554 | +eventId = 1; | |
| 7555 | +createNewTeam(1, "All", getColor("All"), getPosition("All", 1));
| |
| 7556 | +task = new Core(); | |
| 7557 | +} | |
| 7558 | + | |
| 7559 | +@Override | |
| 7560 | +protected void endEvent() | |
| 7561 | +{
| |
| 7562 | +setStatus(EventState.END); | |
| 7563 | +clock.setTime(0); | |
| 7564 | + | |
| 7565 | +} | |
| 7566 | + | |
| 7567 | +@Override | |
| 7568 | +protected String getScorebar() | |
| 7569 | +{
| |
| 7570 | +return "Max: " + getScore(getPlayerWithMaxScore()) + " Time: " + clock.getTime() + ""; | |
| 7571 | +} | |
| 7572 | + | |
| 7573 | +@Override | |
| 7574 | +public void onDie(L2PcInstance victim, L2PcInstance killer) | |
| 7575 | +{
| |
| 7576 | +super.onDie(victim, killer); | |
| 7577 | +addToResurrector(victim); | |
| 7578 | +} | |
| 7579 | + | |
| 7580 | +@Override | |
| 7581 | +public void onKill(L2PcInstance victim, L2PcInstance killer) | |
| 7582 | +{
| |
| 7583 | +super.onKill(victim, killer); | |
| 7584 | +killer.addItem("Event", 6392, 1, killer, true);
| |
| 7585 | +increasePlayersScore(killer); | |
| 7586 | +} | |
| 7587 | + | |
| 7588 | +@Override | |
| 7589 | +protected void schedule(int time) | |
| 7590 | +{
| |
| 7591 | +tpm.scheduleGeneral(task, time); | |
| 7592 | +} | |
| 7593 | + | |
| 7594 | +private void setStatus(EventState s) | |
| 7595 | +{
| |
| 7596 | +eventState = s; | |
| 7597 | +} | |
| 7598 | + | |
| 7599 | +@Override | |
| 7600 | +protected void showHtml(L2PcInstance player, int obj) | |
| 7601 | +{
| |
| 7602 | +if (players.size() > 0) | |
| 7603 | +{
| |
| 7604 | +NpcHtmlMessage html = new NpcHtmlMessage(obj); | |
| 7605 | +TextBuilder sb = new TextBuilder(); | |
| 7606 | + | |
| 7607 | +sb.append("<html><body><table width=270><tr><td width=200>Event Engine </td><td><a action=\"bypass -h eventstats 1\">Statistics</a></td></tr></table><br>");
| |
| 7608 | +sb.append("<center><table width=270 bgcolor=5A5A5A><tr><td width=70>Running</td><td width=130><center>" + getString("eventName") + "</td><td width=70>Time: " + clock.getTime() + "</td></tr></table>");
| |
| 7609 | +sb.append("<table width=270><tr><td><center>" + getPlayerWithMaxScore().getName() + " - " + getScore(getPlayerWithMaxScore()) + "</td></tr></table>");
| |
| 7610 | +sb.append("<br><table width=270>");
| |
| 7611 | + | |
| 7612 | +for (L2PcInstance p : getPlayersOfTeam(1)) | |
| 7613 | +sb.append("<tr><td>" + p.getName() + "</td><td>lvl " + p.getLevel() + "</td><td>" + p.getTemplate().className + "</td><td>" + getScore(p) + "</td></tr>");
| |
| 7614 | + | |
| 7615 | +sb.append("</table></body></html>");
| |
| 7616 | +html.setHtml(sb.toString()); | |
| 7617 | +player.sendPacket(html); | |
| 7618 | +} | |
| 7619 | +} | |
| 7620 | + | |
| 7621 | +@Override | |
| 7622 | +protected void start() | |
| 7623 | +{
| |
| 7624 | +setStatus(EventState.START); | |
| 7625 | +schedule(1); | |
| 7626 | +} | |
| 7627 | + | |
| 7628 | +} | |
| 7629 | \ No newline at end of file |