From 21acfea48fac948e358d24cda61f0e1e7d02ead0 Mon Sep 17 00:00:00 2001 From: Zealar <Zealar@users.noreply.github.com> Date: Mon, 4 Aug 2014 21:35:35 +0000 Subject: [PATCH] BETA: Observation fix/update: * Fix TvT problem * Missing check for summon + retail message * Some protections add * Performance improvements Reported by: momo61 Tested by: Pandragon, Konstantinos Reviewed by: UnAfraid --- .../game/data/html/observation/31031-1.htm | 4 +- .../game/data/html/observation/31031-10.htm | 6 +- .../game/data/html/observation/31031-2.htm | 4 +- .../game/data/html/observation/31031-3.htm | 4 +- .../game/data/html/observation/31031-4.htm | 4 +- .../game/data/html/observation/31031-5.htm | 4 +- .../game/data/html/observation/31031-6.htm | 4 +- .../game/data/html/observation/31031-7.htm | 4 +- .../game/data/html/observation/31031-8.htm | 4 +- .../game/data/html/observation/31031-9.htm | 4 +- .../data/html/observation/31031-Oracle-1.htm | 10 +- .../data/html/observation/31031-Oracle-2.htm | 10 +- .../handlers/bypasshandlers/Observation.java | 122 +++++++++++++----- 13 files changed, 123 insertions(+), 61 deletions(-) diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-1.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-1.htm index 290be57f63..d65d3774e8 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-1.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-1.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 -18347 114000 -2360">&$620; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 -18347 113255 -2447">&$621; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 0">&$620; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 1">&$621; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-10.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-10.htm index e8b1a82b6a..0cb9cefdb1 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-10.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-10.htm @@ -1,5 +1,5 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observe 80 148416 46724 -3000">&$634; - 80 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observe 80 149500 46724 -3000">&$635; - 80 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observe 80 150511 46724 -3000">&$636; - 80 &$469;</a> +<a action="bypass -h npc_%objectId%_observe 18">&$634; - 80 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observe 19">&$635; - 80 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observe 20">&$636; - 80 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-2.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-2.htm index 93b72569cc..8ad7196898 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-2.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-2.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 22321 155785 -2604">&$622; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 22321 156492 -2627">&$623; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 2">&$622; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 3">&$623; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-3.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-3.htm index 29f55d0e1a..7693c29731 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-3.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-3.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 112000 144864 -2445">&$624; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 112657 144864 -2525">&$625; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 4">&$624; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 5">&$625; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-4.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-4.htm index bcfd56f254..fce6056d27 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-4.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-4.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 116260 244600 -775">&$626; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 116260 245264 -721">&$627; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 6">&$626; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 7">&$627; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-5.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-5.htm index 56f623fbbf..428446f40e 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-5.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-5.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 78100 36950 -2242">&$628; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 78744 36950 -2244">&$629; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 8">&$628; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 9">&$629; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-6.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-6.htm index 548ca215c3..af609fbc86 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-6.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-6.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 147457 9601 -233">&$630; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 147457 8720 -252">&$631; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 10">&$630; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 11">&$631; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-7.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-7.htm index 5cafc274a0..dff9606f7f 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-7.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-7.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 147542 -43543 -1328">&$1244; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 147465 -45259 -1328">&$1245; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 12">&$1244; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 13">&$1245; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-8.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-8.htm index 11c8faaa57..573bbc6f0c 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-8.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-8.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 20598 -49113 -300">&$1421; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 18702 -49150 -600">&$1422; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 14">&$1421; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 15">&$1422; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-9.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-9.htm index a7b0ea7f86..7215d5ed50 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-9.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-9.htm @@ -1,4 +1,4 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeSiege 500 77541 -147447 353">&$1424; - 500 &$469;</a><br1> -<a action="bypass -h npc_%objectId%_observeSiege 500 77541 -149245 353">&$1425; - 500 &$469;</a> +<a action="bypass -h npc_%objectId%_observeSiege 16">&$1424; - 500 &$469;</a><br1> +<a action="bypass -h npc_%objectId%_observeSiege 17">&$1425; - 500 &$469;</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-1.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-1.htm index bdaf978e34..adc78f2836 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-1.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-1.htm @@ -1,7 +1,7 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeOracle 500 -80210 87400 -4800">Level 31 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -77200 88500 -4800">Level 42 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -75320 87135 -4800">Level 53 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -76840 85770 -4800">Level 64 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -79950 85165 -4800">No Level Limit - 500 Adena</a> +<a action="bypass -h npc_%objectId%_observeOracle 21">Level 31 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 22">Level 42 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 23">Level 53 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 24">Level 64 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 25">No Level Limit - 500 Adena</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-2.htm b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-2.htm index 05b257ef2e..9d74df88c1 100644 --- a/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-2.htm +++ b/L2J_DataPack_BETA/dist/game/data/html/observation/31031-Oracle-2.htm @@ -1,7 +1,7 @@ <html><body>&$650;<br><br> -<a action="bypass -h npc_%objectId%_observeOracle 500 -79185 112725 -4300">Level 31 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -76175 113330 -4300">Level 42 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -74305 111965 -4300">Level 53 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -75915 110600 -4300">Level 64 and Below - 500 Adena</a><br1> -<a action="bypass -h npc_%objectId%_observeOracle 500 -78930 110005 -4300">No Level Limit - 500 Adena</a> +<a action="bypass -h npc_%objectId%_observeOracle 26">Level 31 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 27">Level 42 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 28">Level 53 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 29">Level 64 and Below - 500 Adena</a><br1> +<a action="bypass -h npc_%objectId%_observeOracle 30">No Level Limit - 500 Adena</a> </body></html> \ No newline at end of file diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/Observation.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/Observation.java index 345aa0c300..61c48dcdc9 100644 --- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/Observation.java +++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/Observation.java @@ -18,7 +18,6 @@ */ package handlers.bypasshandlers; -import java.util.StringTokenizer; import java.util.logging.Level; import com.l2jserver.gameserver.handler.IBypassHandler; @@ -26,6 +25,7 @@ import com.l2jserver.gameserver.instancemanager.SiegeManager; import com.l2jserver.gameserver.model.Location; import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.actor.instance.L2ObservationInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.network.SystemMessageId; import com.l2jserver.gameserver.network.serverpackets.ActionFailed; @@ -40,25 +40,102 @@ public class Observation implements IBypassHandler "observe" }; + private static final int[][] LOCATIONS = new int[][] + { + //@formatter:off + // Gludio + {-18347, 114000, -2360, 500}, + {-18347, 113255, -2447, 500}, + // Dion + {22321, 155785, -2604, 500}, + {22321, 156492, -2627, 500}, + // Giran + {112000, 144864, -2445, 500}, + {112657, 144864, -2525, 500}, + // Innadril + {116260, 244600, -775, 500}, + {116260, 245264, -721, 500}, + // Oren + {78100, 36950, -2242, 500}, + {78744, 36950, -2244, 500}, + // Aden + {147457, 9601, -233, 500}, + {147457, 8720, -252, 500}, + // Goddard + {147542, -43543, -1328, 500}, + {147465, -45259, -1328, 500}, + // Rune + {20598, -49113, -300, 500}, + {18702, -49150, -600, 500}, + // Schuttgart + {77541, -147447, 353, 500}, + {77541, -149245, 353, 500}, + // Coliseum + {148416, 46724, -3000, 80}, + {149500, 46724, -3000, 80}, + {150511, 46724, -3000, 80}, + // Dusk + {-77200, 88500, -4800, 500}, + {-75320, 87135, -4800, 500}, + {-76840, 85770, -4800, 500}, + {-76840, 85770, -4800, 500}, + {-79950, 85165, -4800, 500}, + // Dawn + {-79185, 112725, -4300, 500}, + {-76175, 113330, -4300, 500}, + {-74305, 111965, -4300, 500}, + {-75915, 110600, -4300, 500}, + {-78930, 110005, -4300, 500} + //@formatter:on + }; + @Override public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) { - if (!target.isNpc()) + if (!(target instanceof L2ObservationInstance)) { return false; } + if (activeChar.hasSummon()) + { + activeChar.sendPacket(SystemMessageId.NO_OBSERVE_WITH_PET); + return false; + } + if (activeChar.isOnEvent()) + { + activeChar.sendMessage("Cannot use while current Event"); + return false; + } + + String _command = command.split(" ")[0].toLowerCase(); + final int param; try { - if (command.toLowerCase().startsWith(COMMANDS[0])) // siege + param = Integer.parseInt(command.split(" ")[1]); + } + catch (NumberFormatException nfe) + { + _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), nfe); + return false; + } + + if ((param < 0) || (param > (LOCATIONS.length - 1))) + { + return false; + } + final int[] locCost = LOCATIONS[param]; + + Location loc = new Location(locCost[0], locCost[1], locCost[2]); + final long cost = locCost[3]; + + switch (_command) + { + case "observesiege": { - String val = command.substring(13); - StringTokenizer st = new StringTokenizer(val); - st.nextToken(); // Bypass cost - - if (SiegeManager.getInstance().getSiege(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())) != null) + if (SiegeManager.getInstance().getSiege(loc) != null) { - doObserve(activeChar, (L2Npc) target, val); + doObserve(activeChar, (L2Npc) target, loc, cost); } else { @@ -66,41 +143,26 @@ public class Observation implements IBypassHandler } return true; } - else if (command.toLowerCase().startsWith(COMMANDS[1])) // oracle + case "observeoracle": // Oracle Dusk/Dawn { - String val = command.substring(13); - StringTokenizer st = new StringTokenizer(val); - st.nextToken(); // Bypass cost - doObserve(activeChar, (L2Npc) target, val); + doObserve(activeChar, (L2Npc) target, loc, cost); return true; } - else if (command.toLowerCase().startsWith(COMMANDS[2])) // observe + case "observe": // Observe { - doObserve(activeChar, (L2Npc) target, command.substring(8)); + doObserve(activeChar, (L2Npc) target, loc, cost); return true; } - - return false; - } - catch (Exception e) - { - _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e); } return false; } - private static final void doObserve(L2PcInstance player, L2Npc npc, String val) + private static final void doObserve(final L2PcInstance player, final L2Npc npc, final Location pos, final long cost) { - StringTokenizer st = new StringTokenizer(val); - long cost = Long.parseLong(st.nextToken()); - int x = Integer.parseInt(st.nextToken()); - int y = Integer.parseInt(st.nextToken()); - int z = Integer.parseInt(st.nextToken()); - if (player.reduceAdena("Broadcast", cost, npc, true)) { // enter mode - player.enterObserverMode(new Location(x, y, z)); + player.enterObserverMode(pos); player.sendPacket(new ItemList(player, false)); } player.sendPacket(ActionFailed.STATIC_PACKET); -- GitLab