From 3775bdacabe35a6cc369053aae98667604bfc02e Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 8 Nov 2019 10:34:06 -0500 Subject: [PATCH] api: add fake xp drop event --- .../net/runelite/api/events/FakeXpDrop.java | 35 +++ .../net/runelite/client/callback/Hooks.java | 25 ++ .../src/main/scripts/FakeXpDrop.hash | 1 + .../src/main/scripts/FakeXpDrop.rs2asm | 256 ++++++++++++++++++ 4 files changed, 317 insertions(+) create mode 100644 runelite-api/src/main/java/net/runelite/api/events/FakeXpDrop.java create mode 100644 runelite-client/src/main/scripts/FakeXpDrop.hash create mode 100644 runelite-client/src/main/scripts/FakeXpDrop.rs2asm diff --git a/runelite-api/src/main/java/net/runelite/api/events/FakeXpDrop.java b/runelite-api/src/main/java/net/runelite/api/events/FakeXpDrop.java new file mode 100644 index 0000000000..67cbeea22d --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/FakeXpDrop.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.events; + +import lombok.Value; +import net.runelite.api.Skill; + +@Value +public class FakeXpDrop +{ + private final Skill skill; + private final int xp; +} diff --git a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java index ca2053e446..9954f322dc 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java @@ -47,11 +47,14 @@ import net.runelite.api.MainBufferProvider; import net.runelite.api.NullItemID; import net.runelite.api.RenderOverview; import net.runelite.api.Renderable; +import net.runelite.api.Skill; import net.runelite.api.WorldMapManager; import net.runelite.api.events.BeforeMenuRender; import net.runelite.api.events.BeforeRender; +import net.runelite.api.events.FakeXpDrop; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; +import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.hooks.Callbacks; import net.runelite.api.hooks.DrawCallbacks; import net.runelite.api.widgets.Widget; @@ -550,4 +553,26 @@ public class Hooks implements Callbacks client.getCallbacks().post(event); return event.isConsumed(); } + + @Subscribe + public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent) + { + if (!scriptCallbackEvent.getEventName().equals("fakeXpDrop")) + { + return; + } + + final int[] intStack = client.getIntStack(); + final int intStackSize = client.getIntStackSize(); + + final int statId = intStack[intStackSize - 2]; + final int xp = intStack[intStackSize - 1]; + + Skill skill = Skill.values()[statId]; + FakeXpDrop fakeXpDrop = new FakeXpDrop( + skill, + xp + ); + eventBus.post(fakeXpDrop); + } } diff --git a/runelite-client/src/main/scripts/FakeXpDrop.hash b/runelite-client/src/main/scripts/FakeXpDrop.hash new file mode 100644 index 0000000000..cf5e37e931 --- /dev/null +++ b/runelite-client/src/main/scripts/FakeXpDrop.hash @@ -0,0 +1 @@ +32FBC48F8C6D8E62E02BCF09F444BA036F76133B6596396F0AB9E474687D9F3F \ No newline at end of file diff --git a/runelite-client/src/main/scripts/FakeXpDrop.rs2asm b/runelite-client/src/main/scripts/FakeXpDrop.rs2asm new file mode 100644 index 0000000000..93ac905034 --- /dev/null +++ b/runelite-client/src/main/scripts/FakeXpDrop.rs2asm @@ -0,0 +1,256 @@ +.id 2091 +.int_stack_count 2 +.string_stack_count 0 +.int_var_count 2 +.string_var_count 0 + iload 0 ; stat + iload 1 ; xp + sconst "fakeXpDrop" + runelite_callback + pop_int + pop_int + iconst 105 + iconst 83 + iconst 681 + get_varc_int 207 + coordx + enum + iload 0 + if_icmpeq LABEL9 + jump LABEL16 +LABEL9: + get_varc_int 207 + iconst 0 + iconst 0 + iload 1 + movecoord + set_varc_int 207 + jump LABEL216 +LABEL16: + iconst 105 + iconst 83 + iconst 681 + get_varc_int 208 + coordx + enum + iload 0 + if_icmpeq LABEL25 + jump LABEL32 +LABEL25: + get_varc_int 208 + iconst 0 + iconst 0 + iload 1 + movecoord + set_varc_int 208 + jump LABEL216 +LABEL32: + iconst 105 + iconst 83 + iconst 681 + get_varc_int 209 + coordx + enum + iload 0 + if_icmpeq LABEL41 + jump LABEL48 +LABEL41: + get_varc_int 209 + iconst 0 + iconst 0 + iload 1 + movecoord + set_varc_int 209 + jump LABEL216 +LABEL48: + iconst 105 + iconst 83 + iconst 681 + get_varc_int 210 + coordx + enum + iload 0 + if_icmpeq LABEL57 + jump LABEL64 +LABEL57: + get_varc_int 210 + iconst 0 + iconst 0 + iload 1 + movecoord + set_varc_int 210 + jump LABEL216 +LABEL64: + iconst 105 + iconst 83 + iconst 681 + get_varc_int 211 + coordx + enum + iload 0 + if_icmpeq LABEL73 + jump LABEL80 +LABEL73: + get_varc_int 211 + iconst 0 + iconst 0 + iload 1 + movecoord + set_varc_int 211 + jump LABEL216 +LABEL80: + iconst 105 + iconst 83 + iconst 681 + get_varc_int 212 + coordx + enum + iload 0 + if_icmpeq LABEL89 + jump LABEL96 +LABEL89: + get_varc_int 212 + iconst 0 + iconst 0 + iload 1 + movecoord + set_varc_int 212 + jump LABEL216 +LABEL96: + iconst 105 + iconst 83 + iconst 681 + get_varc_int 213 + coordx + enum + iload 0 + if_icmpeq LABEL105 + jump LABEL112 +LABEL105: + get_varc_int 213 + iconst 0 + iconst 0 + iload 1 + movecoord + set_varc_int 213 + jump LABEL216 +LABEL112: + get_varc_int 207 + iconst -1 + if_icmpeq LABEL116 + jump LABEL127 +LABEL116: + iconst 0 + iconst 83 + iconst 105 + iconst 81 + iload 0 + enum + iconst 0 + iload 1 + movecoord + set_varc_int 207 + jump LABEL216 +LABEL127: + get_varc_int 208 + iconst -1 + if_icmpeq LABEL131 + jump LABEL142 +LABEL131: + iconst 0 + iconst 83 + iconst 105 + iconst 81 + iload 0 + enum + iconst 0 + iload 1 + movecoord + set_varc_int 208 + jump LABEL216 +LABEL142: + get_varc_int 209 + iconst -1 + if_icmpeq LABEL146 + jump LABEL157 +LABEL146: + iconst 0 + iconst 83 + iconst 105 + iconst 81 + iload 0 + enum + iconst 0 + iload 1 + movecoord + set_varc_int 209 + jump LABEL216 +LABEL157: + get_varc_int 210 + iconst -1 + if_icmpeq LABEL161 + jump LABEL172 +LABEL161: + iconst 0 + iconst 83 + iconst 105 + iconst 81 + iload 0 + enum + iconst 0 + iload 1 + movecoord + set_varc_int 210 + jump LABEL216 +LABEL172: + get_varc_int 211 + iconst -1 + if_icmpeq LABEL176 + jump LABEL187 +LABEL176: + iconst 0 + iconst 83 + iconst 105 + iconst 81 + iload 0 + enum + iconst 0 + iload 1 + movecoord + set_varc_int 211 + jump LABEL216 +LABEL187: + get_varc_int 212 + iconst -1 + if_icmpeq LABEL191 + jump LABEL202 +LABEL191: + iconst 0 + iconst 83 + iconst 105 + iconst 81 + iload 0 + enum + iconst 0 + iload 1 + movecoord + set_varc_int 212 + jump LABEL216 +LABEL202: + get_varc_int 213 + iconst -1 + if_icmpeq LABEL206 + jump LABEL216 +LABEL206: + iconst 0 + iconst 83 + iconst 105 + iconst 81 + iload 0 + enum + iconst 0 + iload 1 + movecoord + set_varc_int 213 +LABEL216: + return