diff --git a/gradle.properties b/gradle.properties index 3f7769ea7e..dbf57649ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.warning.mode=all org.gradle.parallel=true org.gradle.console=rich org.gradle.configureondemand=true -org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 diff --git a/injected-client/src/main/java/Placeholder.java b/injected-client/src/main/java/Placeholder.java deleted file mode 100644 index 8486c0fc90..0000000000 --- a/injected-client/src/main/java/Placeholder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019 ThatGamerBlue - * 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. - */ - -/** - * @author ThatGamerBlue - * - * This file exists to force gradle to execute the compileJava task - * so we can hijack it and run the injector-plugin - */ -public class Placeholder -{ -} \ No newline at end of file diff --git a/injector-plugin/src/main/java/net/runelite/injector/raw/RasterizerAlpha.java b/injector-plugin/src/main/java/net/runelite/injector/raw/RasterizerAlpha.java deleted file mode 100644 index 724d5769eb..0000000000 --- a/injector-plugin/src/main/java/net/runelite/injector/raw/RasterizerAlpha.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (c) 2018, Lucas - * 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.injector.raw; - -import com.google.common.collect.Lists; -import net.runelite.asm.ClassFile; -import net.runelite.asm.Field; -import net.runelite.asm.Method; -import net.runelite.asm.attributes.Code; -import net.runelite.asm.attributes.code.Instruction; -import net.runelite.asm.attributes.code.InstructionType; -import net.runelite.asm.attributes.code.Instructions; -import net.runelite.asm.attributes.code.instruction.types.FieldInstruction; -import net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction; -import net.runelite.asm.attributes.code.instruction.types.LVTInstruction; -import net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction; -import net.runelite.asm.attributes.code.instructions.GetStatic; -import net.runelite.asm.attributes.code.instructions.IALoad; -import net.runelite.asm.attributes.code.instructions.IAStore; -import net.runelite.asm.attributes.code.instructions.IAdd; -import net.runelite.asm.attributes.code.instructions.ILoad; -import net.runelite.asm.attributes.code.instructions.IOr; -import net.runelite.asm.attributes.code.instructions.IShR; -import net.runelite.asm.attributes.code.instructions.ISub; -import net.runelite.asm.attributes.code.instructions.IUShR; -import net.runelite.asm.attributes.code.instructions.InvokeStatic; -import net.runelite.asm.attributes.code.instructions.LDC; -import net.runelite.asm.attributes.code.instructions.SiPush; -import net.runelite.asm.execution.Execution; -import net.runelite.asm.execution.InstructionContext; -import net.runelite.asm.execution.MethodContext; -import net.runelite.asm.execution.StackContext; -import net.runelite.asm.execution.VariableContext; -import net.runelite.asm.pool.Class; -import net.runelite.asm.signature.Signature; -import net.runelite.injector.Inject; -import net.runelite.injector.InjectUtil; -import net.runelite.injector.InjectionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RasterizerAlpha -{ - private static final Logger logger = LoggerFactory.getLogger(RasterizerAlpha.class); - private static final net.runelite.asm.pool.Method DRAWALPHA = new net.runelite.asm.pool.Method( - new Class("client"), - "drawAlpha", - new Signature("([IIII)V") - ); - private static final int ALPHA = 0xff000000; - - private final Inject inject; - - public RasterizerAlpha(Inject inject) - { - this.inject = inject; - } - - /* - * This class exists cause of removing colour banding. - * - * Push array on stack - * Push array index on stack - * Push colour on stack -> we're interested in where the colour comes from - * Put colour in array, popping array, index and colour - * - * - * - */ - public void inject() throws InjectionException - { - final Field r2dPx = InjectUtil.findDeobField(inject, "Rasterizer2D_pixels", "Rasterizer2D"); - final Method draw = InjectUtil.findMethod(inject, "draw", "Client"); - final ClassFile rasterizer2D = r2dPx.getClassFile(); - final Execution ex = new Execution(rasterizer2D.getGroup()); - ex.staticStep = false; - ex.step = false; - ex.addMethod(draw); - - int[] counts = new int[2]; - - ex.addMethodContextVisitor((MethodContext mc) -> - { - Instructions instrs = getInstrs(mc); - if (instrs == null) - return; - - int count = 0; - int orCount = 0; - - for (InstructionContext ic : mc.getInstructionContexts()) - { - Instruction instruction = ic.getInstruction(); - if (!(instruction instanceof IAStore)) - continue; - - // Field field = astore.getMyField(ic); - // doesn't track into methods so doing it here - StackContext array = ic.getPops().get(2); - - if (!isSameField(r2dPx, array)) - continue; - - // This is the colour that's being set - StackContext colour = ic.getPops().get(0); - - // resolve gets the original value pusher - InstructionContext colPusher = colour.getPushed().resolve(colour); - Instruction colPushI = colPusher.getInstruction(); - - // If it's not a >> or a | we're not interested - if (colPushI instanceof LVTInstruction // when called from a method we didn't execute - || colPushI instanceof PushConstantInstruction && - !((PushConstantInstruction) colPushI).getConstant().equals(0) - || colPushI instanceof IALoad) - { - // OR with 0xFF000000, unless 0 - int storeIdx = instrs.getInstructions().indexOf(instruction); - - instrs.addInstruction(storeIdx++, new LDC(instrs, ALPHA)); - instrs.addInstruction(storeIdx, new IOr(instrs, InstructionType.IOR)); - ++orCount; - continue; - } - else if (!( - colPushI instanceof IShR || - colPushI instanceof IUShR || - colPushI instanceof IAdd)) - { - continue; - } - - // So we know we're dealing with alpha here, now we need the alpha value - // earlier on in the method there's been a 256 - XXX, where xxx is alpha - - for (InstructionContext ins : mc.getInstructionContexts()) - { - if (!(ins.getInstruction() instanceof SiPush)) - continue; - - SiPush pci = (SiPush) ins.getInstruction(); - if ((short) pci.getConstant() != (short) 256) - continue; - - InstructionContext isub = ins.getPushes().get(0).getPopped().get(0); - if (!(isub.getInstruction() instanceof ISub)) - continue; - - StackContext alphaPop = isub.getPops().get(0); - InstructionContext alphaPusher = alphaPop.getPushed().resolve(alphaPop); - InstructionContext isubResult = isub.getPushes().get(0).getPopped().get(0); - - if (pushesToSameField(isubResult, alphaPusher)) - { - alphaPusher = resolveFieldThroughInvokes(alphaPop); - - if (alphaPusher == null) - throw new RuntimeException("Alpha var is overwritten and we don't know what pushed it"); // cheeky unchecked - } - - int storeIdx = instrs.getInstructions().indexOf(instruction); - - Instruction alphaPushI = alphaPusher.getInstruction(); - if (alphaPushI instanceof GetStatic) - { - instrs.addInstruction(storeIdx++, new LDC(instrs, 255)); - instrs.addInstruction(storeIdx++, new GetStatic(instrs, ((GetStatic) alphaPushI).getField())); - instrs.addInstruction(storeIdx++, new ISub(instrs, InstructionType.ISUB)); - } - else if (alphaPushI instanceof LVTInstruction) - { - instrs.addInstruction(storeIdx++, new ILoad(instrs, ((LVTInstruction) alphaPushI).getVariableIndex())); - } - - instrs.getInstructions().set(storeIdx, new InvokeStatic(instrs, DRAWALPHA)); - ++count; - break; - } - } - - if (orCount != 0) - { - counts[0] += orCount; - logger.info("Added {} OR's into {}", orCount, mc.getMethod()); - } - if (count != 0) - { - counts[1] += count; - logger.info("Injected {} DrawAlpha invokes into {}", count, mc.getMethod()); - } - }); - - ex.run(); - logger.info("Injected {} DrawAlpha invokes and {} ors", counts[1], counts[0]); - } - - private static boolean pushesToSameField(InstructionContext cA, InstructionContext cB) - { - if (cA.getInstruction() instanceof FieldInstruction && cB instanceof FieldInstruction) - { - Field a = ((FieldInstruction) cA.getInstruction()).getMyField(); - Field b = ((FieldInstruction) cB.getInstruction()).getMyField(); - - return a == b; - } - - return false; - } - - private static Instructions getInstrs(MethodContext mc) - { - Code c = mc.getMethod().getCode(); - if (c == null) - return null; - - return c.getInstructions(); - } - - private static InstructionContext resolveFieldThroughInvokes(StackContext stackContext) - { - InstructionContext pusher = stackContext.getPushed().resolve(stackContext); - if (pusher.getInstruction() instanceof GetFieldInstruction) - return pusher; - - // No field I wanna trace, rn at least - if (!(pusher.getInstruction() instanceof LVTInstruction)) - return null; - - int vidx = ((LVTInstruction) pusher.getInstruction()).getVariableIndex(); - - VariableContext vc = pusher.getVariables().get(vidx); - stackContext = Lists.reverse(vc.getInstructionWhichStored().getPops()).get(vidx); - - return resolveFieldThroughInvokes(stackContext); - } - - private static boolean isSameField(Field f, StackContext array) - { - InstructionContext ic = resolveFieldThroughInvokes(array); - - if (ic == null) - return false; - - return ((GetFieldInstruction) ic.getInstruction()).getMyField() == f; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java index 59370602da..7eda31a71d 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java @@ -1,341 +1,340 @@ -/* - * Copyright (c) 2018, 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.client.game; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ListMultimap; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.inject.Inject; -import javax.inject.Singleton; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.AnimationID; -import net.runelite.api.Client; -import net.runelite.api.TileItem; -import net.runelite.api.ItemID; -import net.runelite.api.NPC; -import net.runelite.api.NpcID; -import net.runelite.api.Player; -import net.runelite.api.Tile; -import net.runelite.api.coords.LocalPoint; -import net.runelite.api.coords.WorldPoint; -import net.runelite.api.events.AnimationChanged; -import net.runelite.api.events.GameTick; -import net.runelite.api.events.ItemDespawned; -import net.runelite.api.events.ItemQuantityChanged; -import net.runelite.api.events.ItemSpawned; -import net.runelite.api.events.NpcDespawned; -import net.runelite.api.events.PlayerDespawned; -import net.runelite.client.eventbus.EventBus; -import net.runelite.client.events.NpcLootReceived; -import net.runelite.client.events.PlayerLootReceived; - -@Singleton -@Slf4j -public class LootManager -{ - private static final Map NPC_DEATH_ANIMATIONS = ImmutableMap.builder() - .put(NpcID.CAVE_KRAKEN, AnimationID.CAVE_KRAKEN_DEATH) - .put(NpcID.CRYSTALLINE_BAT, AnimationID.CRYSTALLINE_BAT_DEATH) - .put(NpcID.CRYSTALLINE_RAT, AnimationID.CRYSTALLINE_RAT_DEATH) - .put(NpcID.CRYSTALLINE_SPIDER, AnimationID.CRYSTALLINE_SPIDER_DEATH) - .put(NpcID.CRYSTALLINE_WOLF, AnimationID.CRYSTALLINE_WOLF_DEATH) - .put(NpcID.CRYSTALLINE_UNICORN, AnimationID.CRYSTALLINE_UNICORN_DEATH) - .put(NpcID.CRYSTALLINE_SCORPION, AnimationID.CORRUPTED_SCORPION_DEATH) - .put(NpcID.CRYSTALLINE_DRAGON, AnimationID.CRYSTALLINE_DRAGON_DEATH) - .put(NpcID.CRYSTALLINE_DARK_BEAST, AnimationID.CRYSTALLINE_DARK_BEAST_DEATH) - .put(NpcID.CRYSTALLINE_BEAR, AnimationID.CRYSTALLINE_BEAR_DEATH) - .put(NpcID.CORRUPTED_BAT, AnimationID.CRYSTALLINE_BAT_DEATH) - .put(NpcID.CORRUPTED_RAT, AnimationID.CRYSTALLINE_RAT_DEATH) - .put(NpcID.CORRUPTED_SPIDER, AnimationID.CRYSTALLINE_SPIDER_DEATH) - .put(NpcID.CORRUPTED_WOLF, AnimationID.CRYSTALLINE_WOLF_DEATH) - .put(NpcID.CORRUPTED_UNICORN, AnimationID.CRYSTALLINE_UNICORN_DEATH) - .put(NpcID.CORRUPTED_SCORPION, AnimationID.CORRUPTED_SCORPION_DEATH) - .put(NpcID.CORRUPTED_DRAGON, AnimationID.CRYSTALLINE_DRAGON_DEATH) - .put(NpcID.CORRUPTED_DARK_BEAST, AnimationID.CRYSTALLINE_DARK_BEAST_DEATH) - .put(NpcID.CORRUPTED_BEAR, AnimationID.CRYSTALLINE_BEAR_DEATH) - .build(); - - private final EventBus eventBus; - private final Client client; - private final ListMultimap itemSpawns = ArrayListMultimap.create(); - private final Set killPoints = new HashSet<>(); - private WorldPoint playerLocationLastTick; - private WorldPoint krakenPlayerLocation; - - @Inject - private LootManager( - final EventBus eventBus, - final Client client - ) - { - this.eventBus = eventBus; - this.client = client; - - eventBus.subscribe(GameTick.class, this, this::onGameTick); - eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); - eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned); - eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned); - eventBus.subscribe(ItemDespawned.class, this, this::onItemDespawned); - eventBus.subscribe(ItemQuantityChanged.class, this, this::onItemQuantityChanged); - eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged); - } - - private void onNpcDespawned(NpcDespawned npcDespawned) - { - final NPC npc = npcDespawned.getNpc(); - if (!npc.isDead()) - { - int id = npc.getId(); - switch (id) - { - case NpcID.GARGOYLE: - case NpcID.GARGOYLE_413: - case NpcID.GARGOYLE_1543: - case NpcID.MARBLE_GARGOYLE: - case NpcID.MARBLE_GARGOYLE_7408: - case NpcID.DUSK_7888: - case NpcID.DUSK_7889: - - case NpcID.ROCKSLUG: - case NpcID.ROCKSLUG_422: - case NpcID.GIANT_ROCKSLUG: - - case NpcID.SMALL_LIZARD: - case NpcID.SMALL_LIZARD_463: - case NpcID.DESERT_LIZARD: - case NpcID.DESERT_LIZARD_460: - case NpcID.DESERT_LIZARD_461: - case NpcID.LIZARD: - - case NpcID.ZYGOMITE: - case NpcID.ZYGOMITE_1024: - case NpcID.ANCIENT_ZYGOMITE: - - // these monsters die with >0 hp, so we just look for coincident - // item spawn with despawn - break; - default: - return; - } - } - - processNpcLoot(npc); - } - - private void onPlayerDespawned(PlayerDespawned playerDespawned) - { - final Player player = playerDespawned.getPlayer(); - // Only care about dead Players - if (player.getHealthRatio() != 0) - { - return; - } - - final LocalPoint location = LocalPoint.fromWorld(client, player.getWorldLocation()); - if (location == null || killPoints.contains(location)) - { - return; - } - - final int x = location.getSceneX(); - final int y = location.getSceneY(); - final int packed = x << 8 | y; - final Collection items = itemSpawns.get(packed); - - if (items.isEmpty()) - { - return; - } - - killPoints.add(location); - eventBus.post(PlayerLootReceived.class, new PlayerLootReceived(player, items)); - } - - private void onItemSpawned(ItemSpawned itemSpawned) - { - final TileItem item = itemSpawned.getItem(); - final Tile tile = itemSpawned.getTile(); - final LocalPoint location = tile.getLocalLocation(); - final int packed = location.getSceneX() << 8 | location.getSceneY(); - log.debug("storing items in {}", packed); - itemSpawns.put(packed, new ItemStack(item.getId(), item.getQuantity(), location)); - log.debug("Item spawn {} ({}) location {}", item.getId(), item.getQuantity(), location); - } - - private void onItemDespawned(ItemDespawned itemDespawned) - { - final TileItem item = itemDespawned.getItem(); - final LocalPoint location = itemDespawned.getTile().getLocalLocation(); - log.debug("Item despawn {} ({}) location {}", item.getId(), item.getQuantity(), location); - } - - private void onItemQuantityChanged(ItemQuantityChanged itemQuantityChanged) - { - final TileItem item = itemQuantityChanged.getItem(); - final Tile tile = itemQuantityChanged.getTile(); - final LocalPoint location = tile.getLocalLocation(); - final int packed = location.getSceneX() << 8 | location.getSceneY(); - final int diff = itemQuantityChanged.getNewQuantity() - itemQuantityChanged.getOldQuantity(); - - if (diff <= 0) - { - return; - } - - itemSpawns.put(packed, new ItemStack(item.getId(), diff, location)); - } - - private void onAnimationChanged(AnimationChanged e) - { - if (!(e.getActor() instanceof NPC)) - { - return; - } - - final NPC npc = (NPC) e.getActor(); - int id = npc.getId(); - - // We only care about certain NPCs - final Integer deathAnim = NPC_DEATH_ANIMATIONS.get(id); - - // Current animation is death animation? - if (deathAnim != null && deathAnim == npc.getAnimation()) - { - if (id == NpcID.CAVE_KRAKEN) - { - // Big Kraken drops loot wherever player is standing when animation starts. - krakenPlayerLocation = client.getLocalPlayer().getWorldLocation(); - } - else - { - // These NPCs drop loot on death animation, which is right now. - processNpcLoot(npc); - } - } - } - - private void onGameTick(GameTick gameTick) - { - playerLocationLastTick = client.getLocalPlayer().getWorldLocation(); - itemSpawns.clear(); - killPoints.clear(); - } - - private void processNpcLoot(NPC npc) - { - final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation())); - if (location == null || killPoints.contains(location)) - { - return; - } - - final int x = location.getSceneX(); - final int y = location.getSceneY(); - final int size = npc.getDefinition().getSize(); - - // Some NPCs drop items onto multiple tiles - final List allItems = new ArrayList<>(); - for (int i = 0; i < size; ++i) - { - for (int j = 0; j < size; ++j) - { - final int packed = (x + i) << 8 | (y + j); - final Collection items = itemSpawns.get(packed); - allItems.addAll(items); - } - } - - if (allItems.isEmpty()) - { - return; - } - - killPoints.add(location); - eventBus.post(NpcLootReceived.class, new NpcLootReceived(npc, allItems)); - } - - private WorldPoint getDropLocation(NPC npc, WorldPoint worldLocation) - { - switch (npc.getId()) - { - case NpcID.KRAKEN: - case NpcID.KRAKEN_6640: - case NpcID.KRAKEN_6656: - worldLocation = playerLocationLastTick; - break; - case NpcID.CAVE_KRAKEN: - worldLocation = krakenPlayerLocation; - break; - case NpcID.ZULRAH: // Green - case NpcID.ZULRAH_2043: // Red - case NpcID.ZULRAH_2044: // Blue - for (Map.Entry entry : itemSpawns.entries()) - { - if (entry.getValue().getId() == ItemID.ZULRAHS_SCALES) - { - int packed = entry.getKey(); - int unpackedX = packed >> 8; - int unpackedY = packed & 0xFF; - worldLocation = WorldPoint.fromScene(client, unpackedX, unpackedY, worldLocation.getPlane()); - break; - } - } - break; - case NpcID.VORKATH: - case NpcID.VORKATH_8058: - case NpcID.VORKATH_8059: - case NpcID.VORKATH_8060: - case NpcID.VORKATH_8061: - int x = worldLocation.getX() + 3; - int y = worldLocation.getY() + 3; - if (playerLocationLastTick.getX() < x) - { - x -= 4; - } - else if (playerLocationLastTick.getX() > x) - { - x += 4; - } - if (playerLocationLastTick.getY() < y) - { - y -= 4; - } - else if (playerLocationLastTick.getY() > y) - { - y += 4; - } - worldLocation = new WorldPoint(x, y, worldLocation.getPlane()); - break; - } - - return worldLocation; - } -} +/* + * Copyright (c) 2018, 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.client.game; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ListMultimap; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.AnimationID; +import net.runelite.api.Client; +import net.runelite.api.TileItem; +import net.runelite.api.ItemID; +import net.runelite.api.NPC; +import net.runelite.api.NpcID; +import net.runelite.api.Player; +import net.runelite.api.Tile; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.AnimationChanged; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.ItemDespawned; +import net.runelite.api.events.ItemQuantityChanged; +import net.runelite.api.events.ItemSpawned; +import net.runelite.api.events.NpcDespawned; +import net.runelite.api.events.PlayerDespawned; +import net.runelite.client.eventbus.EventBus; +import net.runelite.client.events.NpcLootReceived; +import net.runelite.client.events.PlayerLootReceived; + +@Singleton +@Slf4j +public class LootManager +{ + private static final Map NPC_DEATH_ANIMATIONS = ImmutableMap.builder() + .put(NpcID.CAVE_KRAKEN, AnimationID.CAVE_KRAKEN_DEATH) + .put(NpcID.CRYSTALLINE_BAT, AnimationID.CRYSTALLINE_BAT_DEATH) + .put(NpcID.CRYSTALLINE_RAT, AnimationID.CRYSTALLINE_RAT_DEATH) + .put(NpcID.CRYSTALLINE_SPIDER, AnimationID.CRYSTALLINE_SPIDER_DEATH) + .put(NpcID.CRYSTALLINE_WOLF, AnimationID.CRYSTALLINE_WOLF_DEATH) + .put(NpcID.CRYSTALLINE_UNICORN, AnimationID.CRYSTALLINE_UNICORN_DEATH) + .put(NpcID.CRYSTALLINE_SCORPION, AnimationID.CORRUPTED_SCORPION_DEATH) + .put(NpcID.CRYSTALLINE_DRAGON, AnimationID.CRYSTALLINE_DRAGON_DEATH) + .put(NpcID.CRYSTALLINE_DARK_BEAST, AnimationID.CRYSTALLINE_DARK_BEAST_DEATH) + .put(NpcID.CRYSTALLINE_BEAR, AnimationID.CRYSTALLINE_BEAR_DEATH) + .put(NpcID.CORRUPTED_BAT, AnimationID.CRYSTALLINE_BAT_DEATH) + .put(NpcID.CORRUPTED_RAT, AnimationID.CRYSTALLINE_RAT_DEATH) + .put(NpcID.CORRUPTED_SPIDER, AnimationID.CRYSTALLINE_SPIDER_DEATH) + .put(NpcID.CORRUPTED_WOLF, AnimationID.CRYSTALLINE_WOLF_DEATH) + .put(NpcID.CORRUPTED_UNICORN, AnimationID.CRYSTALLINE_UNICORN_DEATH) + .put(NpcID.CORRUPTED_SCORPION, AnimationID.CORRUPTED_SCORPION_DEATH) + .put(NpcID.CORRUPTED_DRAGON, AnimationID.CRYSTALLINE_DRAGON_DEATH) + .put(NpcID.CORRUPTED_DARK_BEAST, AnimationID.CRYSTALLINE_DARK_BEAST_DEATH) + .put(NpcID.CORRUPTED_BEAR, AnimationID.CRYSTALLINE_BEAR_DEATH) + .build(); + + private final EventBus eventBus; + private final Client client; + private final ListMultimap itemSpawns = ArrayListMultimap.create(); + private final Set killPoints = new HashSet<>(); + private WorldPoint playerLocationLastTick; + private WorldPoint krakenPlayerLocation; + + @Inject + private LootManager( + final EventBus eventBus, + final Client client + ) + { + this.eventBus = eventBus; + this.client = client; + + eventBus.subscribe(GameTick.class, this, this::onGameTick); + eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); + eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned); + eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned); + eventBus.subscribe(ItemDespawned.class, this, this::onItemDespawned); + eventBus.subscribe(ItemQuantityChanged.class, this, this::onItemQuantityChanged); + eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged); + } + + private void onNpcDespawned(NpcDespawned npcDespawned) + { + final NPC npc = npcDespawned.getNpc(); + if (!npc.isDead()) + { + int id = npc.getId(); + switch (id) + { + case NpcID.GARGOYLE: + case NpcID.GARGOYLE_413: + case NpcID.GARGOYLE_1543: + case NpcID.MARBLE_GARGOYLE: + case NpcID.MARBLE_GARGOYLE_7408: + case NpcID.DUSK_7888: + case NpcID.DUSK_7889: + + case NpcID.ROCKSLUG: + case NpcID.ROCKSLUG_422: + case NpcID.GIANT_ROCKSLUG: + + case NpcID.SMALL_LIZARD: + case NpcID.SMALL_LIZARD_463: + case NpcID.DESERT_LIZARD: + case NpcID.DESERT_LIZARD_460: + case NpcID.DESERT_LIZARD_461: + case NpcID.LIZARD: + + case NpcID.ZYGOMITE: + case NpcID.ZYGOMITE_1024: + case NpcID.ANCIENT_ZYGOMITE: + + // these monsters die with >0 hp, so we just look for coincident + // item spawn with despawn + break; + default: + return; + } + } + + processNpcLoot(npc); + } + + private void onPlayerDespawned(PlayerDespawned playerDespawned) + { + final Player player = playerDespawned.getPlayer(); + // Only care about dead Players + if (player.getHealthRatio() != 0) + { + return; + } + + final LocalPoint location = LocalPoint.fromWorld(client, player.getWorldLocation()); + if (location == null || killPoints.contains(location)) + { + return; + } + + final int x = location.getSceneX(); + final int y = location.getSceneY(); + final int packed = x << 8 | y; + final Collection items = itemSpawns.get(packed); + + if (items.isEmpty()) + { + return; + } + + killPoints.add(location); + eventBus.post(PlayerLootReceived.class, new PlayerLootReceived(player, items)); + } + + private void onItemSpawned(ItemSpawned itemSpawned) + { + final TileItem item = itemSpawned.getItem(); + final Tile tile = itemSpawned.getTile(); + final LocalPoint location = tile.getLocalLocation(); + final int packed = location.getSceneX() << 8 | location.getSceneY(); + itemSpawns.put(packed, new ItemStack(item.getId(), item.getQuantity(), location)); + log.debug("Item spawn {} ({}) location {}", item.getId(), item.getQuantity(), location); + } + + private void onItemDespawned(ItemDespawned itemDespawned) + { + final TileItem item = itemDespawned.getItem(); + final LocalPoint location = itemDespawned.getTile().getLocalLocation(); + log.debug("Item despawn {} ({}) location {}", item.getId(), item.getQuantity(), location); + } + + private void onItemQuantityChanged(ItemQuantityChanged itemQuantityChanged) + { + final TileItem item = itemQuantityChanged.getItem(); + final Tile tile = itemQuantityChanged.getTile(); + final LocalPoint location = tile.getLocalLocation(); + final int packed = location.getSceneX() << 8 | location.getSceneY(); + final int diff = itemQuantityChanged.getNewQuantity() - itemQuantityChanged.getOldQuantity(); + + if (diff <= 0) + { + return; + } + + itemSpawns.put(packed, new ItemStack(item.getId(), diff, location)); + } + + private void onAnimationChanged(AnimationChanged e) + { + if (!(e.getActor() instanceof NPC)) + { + return; + } + + final NPC npc = (NPC) e.getActor(); + int id = npc.getId(); + + // We only care about certain NPCs + final Integer deathAnim = NPC_DEATH_ANIMATIONS.get(id); + + // Current animation is death animation? + if (deathAnim != null && deathAnim == npc.getAnimation()) + { + if (id == NpcID.CAVE_KRAKEN) + { + // Big Kraken drops loot wherever player is standing when animation starts. + krakenPlayerLocation = client.getLocalPlayer().getWorldLocation(); + } + else + { + // These NPCs drop loot on death animation, which is right now. + processNpcLoot(npc); + } + } + } + + private void onGameTick(GameTick gameTick) + { + playerLocationLastTick = client.getLocalPlayer().getWorldLocation(); + itemSpawns.clear(); + killPoints.clear(); + } + + private void processNpcLoot(NPC npc) + { + final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation())); + if (location == null || killPoints.contains(location)) + { + return; + } + + final int x = location.getSceneX(); + final int y = location.getSceneY(); + final int size = npc.getDefinition().getSize(); + + // Some NPCs drop items onto multiple tiles + final List allItems = new ArrayList<>(); + for (int i = 0; i < size; ++i) + { + for (int j = 0; j < size; ++j) + { + final int packed = (x + i) << 8 | (y + j); + final Collection items = itemSpawns.get(packed); + allItems.addAll(items); + } + } + + if (allItems.isEmpty()) + { + return; + } + + killPoints.add(location); + eventBus.post(NpcLootReceived.class, new NpcLootReceived(npc, allItems)); + } + + private WorldPoint getDropLocation(NPC npc, WorldPoint worldLocation) + { + switch (npc.getId()) + { + case NpcID.KRAKEN: + case NpcID.KRAKEN_6640: + case NpcID.KRAKEN_6656: + worldLocation = playerLocationLastTick; + break; + case NpcID.CAVE_KRAKEN: + worldLocation = krakenPlayerLocation; + break; + case NpcID.ZULRAH: // Green + case NpcID.ZULRAH_2043: // Red + case NpcID.ZULRAH_2044: // Blue + for (Map.Entry entry : itemSpawns.entries()) + { + if (entry.getValue().getId() == ItemID.ZULRAHS_SCALES) + { + int packed = entry.getKey(); + int unpackedX = packed >> 8; + int unpackedY = packed & 0xFF; + worldLocation = WorldPoint.fromScene(client, unpackedX, unpackedY, worldLocation.getPlane()); + break; + } + } + break; + case NpcID.VORKATH: + case NpcID.VORKATH_8058: + case NpcID.VORKATH_8059: + case NpcID.VORKATH_8060: + case NpcID.VORKATH_8061: + int x = worldLocation.getX() + 3; + int y = worldLocation.getY() + 3; + if (playerLocationLastTick.getX() < x) + { + x -= 4; + } + else if (playerLocationLastTick.getX() > x) + { + x += 4; + } + if (playerLocationLastTick.getY() < y) + { + y -= 4; + } + else if (playerLocationLastTick.getY() > y) + { + y += 4; + } + worldLocation = new WorldPoint(x, y, worldLocation.getPlane()); + break; + } + + return worldLocation; + } +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index c0f8542430..baaf96c2da 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -1,1148 +1,1148 @@ -/* - * BSD 2-Clause License - * - * Copyright (c) 2019, ThatGamerBlue - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 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 HOLDER 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.rs.api; - -import java.math.BigInteger; -import java.util.Map; -import net.runelite.api.Client; -import net.runelite.api.Sprite; -import net.runelite.api.World; -import net.runelite.api.widgets.Widget; -import net.runelite.mapping.Construct; -import net.runelite.mapping.Import; - -public interface RSClient extends RSGameShell, Client -{ - @Import("cameraX") - @Override - int getCameraX(); - - @Import("cameraZ") // <--- This is correct! - @Override - int getCameraY(); - - @Import("cameraY") // <--- This is correct! - @Override - int getCameraZ(); - - @Import("Scene_cameraX") - @Override - int getCameraX2(); - - @Import("Scene_cameraY") - @Override - int getCameraY2(); - - @Import("Scene_cameraZ") - @Override - int getCameraZ2(); - - @Import("Client_plane") - @Override - int getPlane(); - - @Import("cameraPitch") - @Override - int getCameraPitch(); - - @Import("cameraPitch") - void setCameraPitch(int cameraPitch); - - @Import("cameraYaw") - @Override - int getCameraYaw(); - - @Import("worldId") - int getWorld(); - - @Import("fps") - @Override - int getFPS(); - - @Import("camAngleY") - @Override - int getMapAngle(); - - @Import("Tiles_heights") - @Override - int[][][] getTileHeights(); - - @Import("Tiles_renderFlags") - @Override - byte[][][] getTileSettings(); - - @Import("Varps_main") - @Override - int[] getVarps(); - - @Import("varcs") - RSVarcs getVarcs(); - - @Import("runEnergy") - @Override - int getEnergy(); - - @Import("weight") - @Override - int getWeight(); - - @Import("baseX") - @Override - int getBaseX(); - - @Import("baseY") - @Override - int getBaseY(); - - @Import("currentLevels") - @Override - int[] getBoostedSkillLevels(); - - @Import("levels") - @Override - int[] getRealSkillLevels(); - - @Import("experience") - @Override - int[] getSkillExperiences(); - - @Import("changedSkills") - int[] getChangedSkills(); - - @Import("changedSkillsCount") - int getChangedSkillsCount(); - - @Import("changedSkillsCount") - void setChangedSkillsCount(int i); - - @Import("gameState") - int getRSGameState(); - - @Import("updateGameState") - void setGameState(int gameState); - - @Import("checkClick") - void setCheckClick(boolean checkClick); - - @Import("Scene_selectedScreenX") - void setMouseCanvasHoverPositionX(int x); - - @Import("Scene_selectedScreenY") - void setMouseCanvasHoverPositionY(int y); - - @Import("MouseHandler_currentButton") - @Override - int getMouseCurrentButton(); - - @Import("Scene_selectedX") - int getSelectedSceneTileX(); - - @Import("Scene_selectedX") - void setSelectedSceneTileX(int selectedSceneTileX); - - @Import("Scene_selectedY") - int getSelectedSceneTileY(); - - @Import("Scene_selectedY") - void setSelectedSceneTileY(int selectedSceneTileY); - - @Import("isDraggingWidget") - @Override - boolean isDraggingWidget(); - - @Import("clickedWidget") - @Override - RSWidget getDraggedWidget(); - - @Import("draggedOnWidget") - @Override - RSWidget getDraggedOnWidget(); - - @Import("draggedOnWidget") - @Override - void setDraggedOnWidget(Widget widget); - - @Import("Widget_interfaceComponents") - RSWidget[][] getWidgets(); - - /** - * Gets an array of widgets that correspond to the passed group ID. - * - * @param groupId the group ID - * @return the widget group - * @see net.runelite.api.widgets.WidgetID - */ - RSWidget[] getGroup(int groupId); - - @Import("scene") - @Override - RSScene getScene(); - - @Import("localPlayer") - @Override - RSPlayer getLocalPlayer(); - - @Import("localPlayerIndex") - @Override - int getLocalPlayerIndex(); - - @Import("npcCount") - int getNpcIndexesCount(); - - @Import("npcIndices") - int[] getNpcIndices(); - - @Import("npcs") - @Override - RSNPC[] getCachedNPCs(); - - @Import("collisionMaps") - RSCollisionMap[] getCollisionMaps(); - - @Import("Players_count") - int getPlayerIndexesCount(); - - @Import("Players_indices") - int[] getPlayerIndices(); - - @Import("players") - @Override - RSPlayer[] getCachedPlayers(); - - @Import("combatTargetPlayerIndex") - int getLocalInteractingIndex(); - - @Import("groundItems") - RSNodeDeque[][][] getGroundItemDeque(); - - @Import("projectiles") - RSNodeDeque getProjectilesDeque(); - - @Import("graphicsObjects") - RSNodeDeque getGraphicsObjectDeque(); - - @Import("Login_username") - @Override - String getUsername(); - - @Import("Login_username") - @Override - void setUsername(String username); - - @Import("Login_password") - @Override - void setPassword(String password); - - @Import("otp") - @Override - void setOtp(String otp); - - @Import("currentLoginField") - @Override - int getCurrentLoginField(); - - @Import("loginIndex") - @Override - int getLoginIndex(); - - @Import("playerMenuActions") - @Override - String[] getPlayerOptions(); - - @Import("playerOptionsPriorities") - @Override - boolean[] getPlayerOptionsPriorities(); - - @Import("playerMenuOpcodes") - @Override - int[] getPlayerMenuTypes(); - - @Import("MouseHandler_xVolatile") - int getMouseX(); - - @Import("MouseHandler_yVolatile") - int getMouseY(); - - @Import("Scene_selectedScreenX") - int getMouseX2(); - - @Import("Scene_selectedScreenY") - int getMouseY2(); - - @Import("containsBounds") - boolean containsBounds(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7); - - @Import("checkClick") - boolean isCheckClick(); - - @Import("menuOptionsCount") - @Override - int getMenuOptionCount(); - - @Import("menuOptionsCount") - @Override - void setMenuOptionCount(int menuOptionCount); - - @Import("menuActions") - String[] getMenuOptions(); - - @Import("menuTargets") - String[] getMenuTargets(); - - @Import("menuIdentifiers") - int[] getMenuIdentifiers(); - - @Import("menuOpcodes") - int[] getMenuOpcodes(); - - @Import("menuArguments1") - int[] getMenuArguments1(); - - @Import("menuArguments2") - int[] getMenuArguments2(); - - @Import("menuShiftClick") - boolean[] getMenuForceLeftClick(); - - @Import("World_worlds") - @Override - RSWorld[] getWorldList(); - - @Import("addChatMessage") - void addChatMessage(int type, String name, String message, String sender); - - @Override - @Import("getObjectDefinition") - RSObjectDefinition getObjectDefinition(int objectId); - - @Override - @Import("getNpcDefinition") - RSNPCDefinition getNpcDefinition(int npcId); - - @Import("viewportZoom") - @Override - int getScale(); - - @Import("canvasHeight") - @Override - int getCanvasHeight(); - - @Import("canvasWidth") - @Override - int getCanvasWidth(); - - @Import("viewportHeight") - @Override - int getViewportHeight(); - - @Import("viewportWidth") - @Override - int getViewportWidth(); - - @Import("viewportOffsetX") - @Override - int getViewportXOffset(); - - @Import("viewportOffsetY") - @Override - int getViewportYOffset(); - - @Import("isResizable") - @Override - boolean isResized(); - - @Import("rootWidgetXs") - @Override - int[] getWidgetPositionsX(); - - @Import("rootWidgetYs") - @Override - int[] getWidgetPositionsY(); - - @Import("itemContainers") - RSNodeHashTable getItemContainers(); - - @Import("ItemDefinition_get") - @Override - RSItemDefinition getItemDefinition(int itemId); - - @Import("getItemSprite") - RSSprite createItemSprite(int itemId, int quantity, int thickness, int borderColor, int stackable, boolean noted); - - @Import("menuAction") - void sendMenuAction(int n2, int n3, int n4, int n5, String string, String string2, int n6, int n7); - - @Import("tempMenuAction") - RSMenuAction getTempMenuAction(); - - @Import("SpriteBuffer_decode") - void decodeSprite(byte[] data); - - @Import("SpriteBuffer_spriteCount") - int getIndexedSpriteCount(); - - @Import("SpriteBuffer_spriteWidth") - int getIndexedSpriteWidth(); - - @Import("SpriteBuffer_spriteHeight") - int getIndexedSpriteHeight(); - - @Import("SpriteBuffer_xOffsets") - int[] getIndexedSpriteOffsetXs(); - - @Import("SpriteBuffer_xOffsets") - void setIndexedSpriteOffsetXs(int[] indexedSpriteOffsetXs); - - @Import("SpriteBuffer_yOffsets") - int[] getIndexedSpriteOffsetYs(); - - @Import("SpriteBuffer_yOffsets") - void setIndexedSpriteOffsetYs(int[] indexedSpriteOffsetYs); - - @Import("SpriteBuffer_spriteWidths") - int[] getIndexedSpriteWidths(); - - @Import("SpriteBuffer_spriteWidths") - void setIndexedSpriteWidths(int[] indexedSpriteWidths); - - @Import("SpriteBuffer_spriteHeights") - int[] getIndexedSpriteHeights(); - - @Import("SpriteBuffer_spriteHeights") - void setIndexedSpriteHeights(int[] indexedSpriteHeights); - - @Import("SpriteBuffer_pixels") - byte[][] getSpritePixels(); - - @Import("SpriteBuffer_pixels") - void setSpritePixels(byte[][] spritePixels); - - @Import("SpriteBuffer_spritePalette") - int[] getIndexedSpritePalette(); - - @Import("SpriteBuffer_spritePalette") - void setIndexedSpritePalette(int[] indexedSpritePalette); - - @Import("archive6") - RSAbstractArchive getMusicTracks(); - - @Import("archive8") - @Override - RSArchive getIndexSprites(); - - @Import("archive12") - @Override - RSArchive getIndexScripts(); - - @Import("widgetClickMasks") - @Override - RSNodeHashTable getWidgetFlags(); - - @Import("interfaceParents") - @Override - RSNodeHashTable getComponentTable(); - - @Import("grandExchangeOffers") - RSGrandExchangeOffer[] getGrandExchangeOffers(); - - @Import("isMenuOpen") - @Override - boolean isMenuOpen(); - - @Import("cycle") - @Override - int getGameCycle(); - - // unused - //@Import("packetHandler") - //void packetHandler(); - - @Import("Messages_channels") - @Override - Map getChatLineMap(); - - @Import("Messages_hashTable") - @Override - RSIterableNodeHashTable getMessages(); - - @Import("RunException_revision") - @Override - int getRevision(); - - @Import("regions") - @Override - int[] getMapRegions(); - - @Import("instanceChunkTemplates") - @Override - int[][][] getInstanceTemplateChunks(); - - @Import("xteaKeys") - @Override - int[][] getXteaKeys(); - - @Import("gameDrawingMode") - @Override - int getGameDrawingMode(); - - @Import("gameDrawingMode") - @Override - void setGameDrawingMode(int gameDrawingMode); - - @Import("cycleCntr") - int getCycleCntr(); - - @Import("chatCycle") - void setChatCycle(int value); - - /** - * Get the widget top group. widgets[topGroup] contains widgets with - * parentId -1, which are the widget roots. - */ - @Import("rootInterface") - int getWidgetRoot(); - - @Import("WorldMapElement_cached") - @Override - RSWorldMapElement[] getMapElementConfigs(); - - @Import("mapSceneSprites") - @Override - RSIndexedSprite[] getMapScene(); - - @Import("mapIcons") - @Override - RSSprite[] getMapIcons(); - - @Import("mapDotSprites") - RSSprite[] getMapDots(); - - @Import("AbstractFont_modIconSprites") - @Override - RSIndexedSprite[] getModIcons(); - - @Import("AbstractFont_modIconSprites") - void setRSModIcons(RSIndexedSprite[] modIcons); - - @Construct - @Override - RSIndexedSprite createIndexedSprite(); - - @Construct - @Override - RSSprite createSprite(int[] pixels, int width, int height); - - @Import("destinationX") - int getDestinationX(); - - @Import("destinationY") - int getDestinationY(); - - @Import("soundEffects") - RSSoundEffect[] getAudioEffects(); - - @Import("soundEffectIds") - int[] getQueuedSoundEffectIDs(); - - @Import("soundLocations") - int[] getSoundLocations(); - - @Import("queuedSoundEffectLoops") - int[] getQueuedSoundEffectLoops(); - - @Import("queuedSoundEffectDelays") - int[] getQueuedSoundEffectDelays(); - - @Import("soundEffectCount") - int getQueuedSoundEffectCount(); - - @Import("soundEffectCount") - void setQueuedSoundEffectCount(int queuedSoundEffectCount); - - @Import("queueSoundEffect") - void queueSoundEffect(int id, int numLoops, int delay); - - @Import("rasterProvider") - @Override - RSAbstractRasterProvider getBufferProvider(); - - @Import("MouseHandler_idleCycles") - @Override - int getMouseIdleTicks(); - - @Import("MouseHandler_lastPressedTimeMillis") - @Override - long getMouseLastPressedMillis(); - - @Import("KeyHandler_idleCycles") - @Override - int getKeyboardIdleTicks(); - - @Import("KeyHandler_pressedKeys") - @Override - boolean[] getPressedKeys(); - - @Import("isLowDetail") - void setLowMemory(boolean lowMemory); - - @Import("Scene_isLowDetail") - void setSceneLowMemory(boolean lowMemory); - - @Import("PcmPlayer_stereo") - void setAudioHighMemory(boolean highMemory); - - @Import("ObjectDefinition_isLowDetail") - void setObjectDefinitionLowDetail(boolean lowDetail); - - @Import("Interpreter_intStackSize") - @Override - int getIntStackSize(); - - @Import("Interpreter_intStackSize") - @Override - void setIntStackSize(int stackSize); - - @Import("Interpreter_intStack") - @Override - int[] getIntStack(); - - @Import("Interpreter_stringStackSize") - @Override - int getStringStackSize(); - - @Import("Interpreter_stringStackSize") - @Override - void setStringStackSize(int stackSize); - - @Import("Interpreter_stringStack") - @Override - String[] getStringStack(); - - @Import("friendSystem") - RSFriendSystem getFriendManager(); - - @Import("clanChat") - RSClanChat getClanMemberManager(); - - @Import("loginType") - RSLoginType getLoginType(); - - @Construct - RSUsername createName(String name, RSLoginType type); - - @Import("getVarbit") - int getVarbit(int varbitId); - - @Import("VarbitDefinition_cached") - RSEvictingDualNodeHashTable getVarbitCache(); - - @Import("clientPreferences") - @Override - RSClientPreferences getPreferences(); - - /** - * This is the pitch the user has set the camera to. - * It should be between 128 and (pitchUnlimiter?512:383) JAUs(1). - * The difference between this and cameraPitch is that cameraPitch has a lower limit, imposed by the surrounding - * terrain. - * - * (1) JAU - Jagex Angle Unit; 1/1024 of a revolution - */ - @Import("camAngleX") - int getCameraPitchTarget(); - - @Import("camAngleX") - void setCameraPitchTarget(int pitch); - - @Import("Scene_cameraPitchSine") - void setPitchSin(int v); - - @Import("Scene_cameraPitchCosine") - void setPitchCos(int v); - - @Import("Scene_cameraYawSine") - void setYawSin(int v); - - @Import("Scene_cameraYawCosine") - void setYawCos(int v); - - @Import("Rasterizer3D_zoom") - @Override - int get3dZoom(); - - @Import("Rasterizer3D_zoom") - void set3dZoom(int zoom); - - @Import("Rasterizer3D_clipMidX2") - @Override - int getRasterizer3D_clipMidX2(); - - @Import("Rasterizer3D_clipNegativeMidX") - @Override - int getRasterizer3D_clipNegativeMidX(); - - @Import("Rasterizer3D_clipNegativeMidY") - @Override - int getRasterizer3D_clipNegativeMidY(); - - @Import("Rasterizer3D_clipMidY2") - @Override - int getRasterizer3D_clipMidY2(); - - @Import("Rasterizer3D_clipMidX") - @Override - int getCenterX(); - - @Import("Rasterizer3D_clipMidY") - @Override - int getCenterY(); - - @Import("getWorldMap") - RSWorldMap getRenderOverview(); - - @Import("changeWorld") - @Override - void changeWorld(World world); - - @Construct - @Override - RSWorld createWorld(); - - @Import("Model_transformTempX") - void setAnimOffsetX(int animOffsetX); - - @Import("Model_transformTempY") - void setAnimOffsetY(int animOffsetY); - - @Import("Model_transformTempZ") - void setAnimOffsetZ(int animOffsetZ); - - @Import("getFrames") - RSFrames getFrames(int frameId); - - @Import("sceneMinimapSprite") - RSSprite getMinimapSprite(); - - @Import("sceneMinimapSprite") - void setMinimapSprite(Sprite spritePixels); - - @Import("drawObject") - void drawObject(int z, int x, int y, int randomColor1, int randomColor2); - - @Construct - RSScriptEvent createScriptEvent(); - - @Import("runScript") - void runScript(RSScriptEvent ev, int ex); - - @Import("hintArrowType") - void setHintArrowTargetType(int value); - - @Import("hintArrowType") - int getHintArrowTargetType(); - - @Import("hintArrowX") - void setHintArrowX(int value); - - @Import("hintArrowX") - int getHintArrowX(); - - @Import("hintArrowY") - void setHintArrowY(int value); - - @Import("hintArrowY") - int getHintArrowY(); - - @Import("hintArrowSubX") - void setHintArrowOffsetX(int value); - - @Import("hintArrowSubY") - void setHintArrowOffsetY(int value); - - @Import("hintArrowNpcIndex") - void setHintArrowNpcTargetIdx(int value); - - @Import("hintArrowNpcIndex") - int getHintArrowNpcTargetIdx(); - - @Import("hintArrowPlayerIndex") - void setHintArrowPlayerTargetIdx(int value); - - @Import("hintArrowPlayerIndex") - int getHintArrowPlayerTargetIdx(); - - @Import("isInInstance") - @Override - boolean isInInstancedRegion(); - - @Import("itemDragDuration") - @Override - int getItemPressedDuration(); - - @Import("itemDragDuration") - void setItemPressedDuration(int duration); - - @Import("worldProperties") - int getFlags(); - - @Import("compass") - void setCompass(Sprite spritePixels); - - @Import("Widget_cachedSprites") - @Override - RSEvictingDualNodeHashTable getWidgetSpriteCache(); - - @Import("ItemDefinition_cached") - @Override - RSEvictingDualNodeHashTable getItemDefinitionCache(); - - @Import("oculusOrbState") - @Override - int getOculusOrbState(); - - @Import("oculusOrbState") - @Override - void setOculusOrbState(int state); - - @Import("oculusOrbNormalSpeed") - @Override - void setOculusOrbNormalSpeed(int state); - - @Import("oculusOrbFocalPointX") - @Override - int getOculusOrbFocalPointX(); - - @Import("oculusOrbFocalPointY") - @Override - int getOculusOrbFocalPointY(); - - RSTileItem getLastItemDespawn(); - - void setLastItemDespawn(RSTileItem lastItemDespawn); - - @Construct - RSWidget createWidget(); - - @Import("alignWidget") - void revalidateWidget(Widget w); - - @Import("revalidateWidgetScroll") - void revalidateWidgetScroll(Widget[] group, Widget w, boolean postEvent); - - @Import("ViewportMouse_entityCount") - int getEntitiesAtMouseCount(); - - @Import("ViewportMouse_entityCount") - void setEntitiesAtMouseCount(int i); - - @Import("ViewportMouse_entityTags") - long[] getEntitiesAtMouse(); - - @Import("ViewportMouse_x") - int getViewportMouseX(); - - @Import("ViewportMouse_y") - int getViewportMouseY(); - - @Import("textureProvider") - @Override - RSTextureProvider getTextureProvider(); - - @Import("tileLastDrawnActor") - int[][] getOccupiedTilesTick(); - - @Import("ObjectDefinition_cachedModels") - RSEvictingDualNodeHashTable getCachedModels2(); - - @Import("Scene_drawnCount") - int getCycle(); - - @Import("Scene_drawnCount") - void setCycle(int cycle); - - @Import("visibilityMap") - boolean[][][][] getVisibilityMaps(); - - @Import("visibleTiles") - void setRenderArea(boolean[][] renderArea); - - @Import("Scene_cameraX") - void setCameraX2(int cameraX2); - - @Import("Scene_cameraY") - void setCameraY2(int cameraY2); - - @Import("Scene_cameraZ") - void setCameraZ2(int cameraZ2); - - @Import("Scene_cameraXTile") - void setScreenCenterX(int screenCenterX); - - @Import("Scene_cameraYTile") - void setScreenCenterZ(int screenCenterZ); // <-- This is correct! - - @Import("Scene_plane") - void setScenePlane(int scenePlane); - - @Import("Scene_cameraXTileMin") - void setMinTileX(int i); - - @Import("Scene_cameraYTileMin") - void setMinTileZ(int i); // <-- This is correct! - - @Import("Scene_cameraXTileMax") - void setMaxTileX(int i); - - @Import("Scene_cameraYTileMax") - void setMaxTileZ(int i); // <-- This is correct! - - @Import("tileUpdateCount") - int getTileUpdateCount(); - - @Import("tileUpdateCount") - void setTileUpdateCount(int tileUpdateCount); - - @Import("ViewportMouse_isInViewport") - boolean getViewportContainsMouse(); - - @Import("Rasterizer2D_pixels") - int[] getGraphicsPixels(); - - @Import("Rasterizer2D_width") - int getGraphicsPixelsWidth(); - - @Import("Rasterizer2D_height") - int getGraphicsPixelsHeight(); - - @Import("Rasterizer2D_fillRectangle") - void rasterizerFillRectangle(int x, int y, int w, int h, int rgb); - - @Import("Rasterizer2D_xClipStart") - int getStartX(); - - @Import("Rasterizer2D_yClipStart") - int getStartY(); - - @Import("Rasterizer2D_xClipEnd") - int getEndX(); - - @Import("Rasterizer2D_yClipEnd") - int getEndY(); - - @Import("dragInventoryWidget") - @Override - RSWidget getIf1DraggedWidget(); - - @Import("dragItemSlotSource") - @Override - int getIf1DraggedItemIndex(); - - @Import("isSpellSelected") - @Override - void setSpellSelected(boolean selected); - - @Import("getEnum") - RSEnumDefinition getRsEnum(int id); - - @Import("menuX") - int getMenuX(); - - @Import("menuY") - int getMenuY(); - - @Import("menuHeight") - int getMenuHeight(); - - @Import("menuWidth") - int getMenuWidth(); - - @Import("fontBold12") - RSFont getFontBold12(); - - @Import("Rasterizer2D_drawHorizontalLine") - void rasterizerDrawHorizontalLine(int x, int y, int w, int rgb); - - @Import("Rasterizer2D_drawVerticalLine") - void rasterizerDrawVerticalLine(int x, int y, int h, int rgb); - - @Import("Rasterizer2D_fillRectangleGradient") - void rasterizerDrawGradient(int x, int y, int w, int h, int rgbTop, int rgbBottom); - - @Import("Rasterizer2D_fillRectangleAlpha") - void rasterizerFillRectangleAlpha(int x, int y, int w, int h, int rgb, int a); - - @Import("Rasterizer2D_drawRectangle") - void rasterizerDrawRectangle(int x, int y, int w, int h, int rgb); - - @Import("drawCircle") - void rasterizerDrawCircle(int x, int y, int r, int rgb); - - @Import("HealthBarDefinition_cached") - RSEvictingDualNodeHashTable getHealthBarCache(); - - @Import("HealthBarDefinition_cachedSprites") - RSEvictingDualNodeHashTable getHealthBarSpriteCache(); - - @Import("renderSelf") - @Override - boolean getRenderSelf(); - - @Import("renderSelf") - @Override - void setRenderSelf(boolean enabled); - - @Import("mouseRecorder") - RSMouseRecorder getMouseRecorder(); - - @Import("selectedSpellName") - String getSelectedSpellName(); - - @Import("selectedSpellName") - @Override - void setSelectedSpellName(String name); - - @Import("isSpellSelected") - boolean isSpellSelected(); - - @Import("readSoundEffect") - RSSoundEffect getTrack(RSAbstractArchive indexData, int id, int var0); - - @Import("createRawPcmStream") - RSRawPcmStream createRawPcmStream(RSRawSound audioNode, int var0, int volume); - - @Import("pcmStreamMixer") - RSPcmStreamMixer getSoundEffectAudioQueue(); - - @Import("archive4") - RSArchive getIndexCache4(); - - @Import("decimator") - RSDecimator getSoundEffectResampler(); - - @Import("musicVolume") - @Override - int getMusicVolume(); - - @Import("musicVolume") - void setClientMusicVolume(int volume); - - @Import("areaSoundEffectVolume") - @Override - int getAreaSoundEffectVolume(); - - @Import("areaSoundEffectVolume") - @Override - void setAreaSoundEffectVolume(int volume); - - @Import("soundEffectVolume") - @Override - int getSoundEffectVolume(); - - @Import("soundEffectVolume") - @Override - void setSoundEffectVolume(int volume); - - @Import("musicTrackVolume") - void setMusicTrackVolume(int volume); - - @Import("viewportWalking") - void setViewportWalking(boolean viewportWalking); - - @Import("playMusicTrack") - void playMusicTrack(RSAbstractArchive var0, int var1, int var2, int var3, boolean var4); - - @Import("midiPcmStream") - RSMidiPcmStream getMidiPcmStream(); - - @Import("currentTrackGroupId") - int getCurrentTrackGroupId(); - - @Import("crossSprites") - @Override - RSSprite[] getCrossSprites(); - - void setModulus(BigInteger modulus); - - @Import("ItemDefinition_fileCount") - int getItemCount(); - - @Import("insertMenuItem") - @Override - void insertMenuItem(String action, String target, int opcode, int identifier, int argument1, int argument2, boolean forceLeftClick); - - @Import("selectedItemId") - @Override - void setSelectedItemID(int id); - - @Import("selectedItemSlot") - @Override - void setSelectedItemSlot(int index); - - @Import("selectedItemWidget") - @Override - void setSelectedItemWidget(int widgetID); - - @Import("selectedSpellWidget") - @Override - int getSelectedSpellWidget(); - - @Import("selectedSpellChildIndex") - @Override - int getSelectedSpellChildIndex(); - - @Import("selectedSpellWidget") - @Override - void setSelectedSpellWidget(int widgetID); - - @Import("selectedSpellChildIndex") - @Override - void setSelectedSpellChildIndex(int index); - - @Import("Sprite_drawScaled") - @Override - void scaleSprite(int[] canvas, int[] pixels, int color, int pixelX, int pixelY, int canvasIdx, int canvasOffset, int newWidth, int newHeight, int pixelWidth, int pixelHeight, int oldWidth); - - /** - * This sets the login screen to where it asks for username/pass - */ - @Import("Login_promptCredentials") - void promptCredentials(boolean clearPass); - - @Import("VarpDefinition_get") - RSVarpDefinition getVarpDefinition(int id); - - @Construct - RSTileItem newTileItem(); - - @Construct - RSNodeDeque newNodeDeque(); - - @Import("updateItemPile") - void updateItemPile(int localX, int localY); -} +/* + * BSD 2-Clause License + * + * Copyright (c) 2019, ThatGamerBlue + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 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 HOLDER 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.rs.api; + +import java.math.BigInteger; +import java.util.Map; +import net.runelite.api.Client; +import net.runelite.api.Sprite; +import net.runelite.api.World; +import net.runelite.api.widgets.Widget; +import net.runelite.mapping.Construct; +import net.runelite.mapping.Import; + +public interface RSClient extends RSGameShell, Client +{ + @Import("cameraX") + @Override + int getCameraX(); + + @Import("cameraZ") // <--- This is correct! + @Override + int getCameraY(); + + @Import("cameraY") // <--- This is correct! + @Override + int getCameraZ(); + + @Import("Scene_cameraX") + @Override + int getCameraX2(); + + @Import("Scene_cameraY") + @Override + int getCameraY2(); + + @Import("Scene_cameraZ") + @Override + int getCameraZ2(); + + @Import("Client_plane") + @Override + int getPlane(); + + @Import("cameraPitch") + @Override + int getCameraPitch(); + + @Import("cameraPitch") + void setCameraPitch(int cameraPitch); + + @Import("cameraYaw") + @Override + int getCameraYaw(); + + @Import("worldId") + int getWorld(); + + @Import("fps") + @Override + int getFPS(); + + @Import("camAngleY") + @Override + int getMapAngle(); + + @Import("Tiles_heights") + @Override + int[][][] getTileHeights(); + + @Import("Tiles_renderFlags") + @Override + byte[][][] getTileSettings(); + + @Import("Varps_main") + @Override + int[] getVarps(); + + @Import("varcs") + RSVarcs getVarcs(); + + @Import("runEnergy") + @Override + int getEnergy(); + + @Import("weight") + @Override + int getWeight(); + + @Import("baseX") + @Override + int getBaseX(); + + @Import("baseY") + @Override + int getBaseY(); + + @Import("currentLevels") + @Override + int[] getBoostedSkillLevels(); + + @Import("levels") + @Override + int[] getRealSkillLevels(); + + @Import("experience") + @Override + int[] getSkillExperiences(); + + @Import("changedSkills") + int[] getChangedSkills(); + + @Import("changedSkillsCount") + int getChangedSkillsCount(); + + @Import("changedSkillsCount") + void setChangedSkillsCount(int i); + + @Import("gameState") + int getRSGameState(); + + @Import("updateGameState") + void setGameState(int gameState); + + @Import("checkClick") + void setCheckClick(boolean checkClick); + + @Import("Scene_selectedScreenX") + void setMouseCanvasHoverPositionX(int x); + + @Import("Scene_selectedScreenY") + void setMouseCanvasHoverPositionY(int y); + + @Import("MouseHandler_currentButton") + @Override + int getMouseCurrentButton(); + + @Import("Scene_selectedX") + int getSelectedSceneTileX(); + + @Import("Scene_selectedX") + void setSelectedSceneTileX(int selectedSceneTileX); + + @Import("Scene_selectedY") + int getSelectedSceneTileY(); + + @Import("Scene_selectedY") + void setSelectedSceneTileY(int selectedSceneTileY); + + @Import("isDraggingWidget") + @Override + boolean isDraggingWidget(); + + @Import("clickedWidget") + @Override + RSWidget getDraggedWidget(); + + @Import("draggedOnWidget") + @Override + RSWidget getDraggedOnWidget(); + + @Import("draggedOnWidget") + @Override + void setDraggedOnWidget(Widget widget); + + @Import("Widget_interfaceComponents") + RSWidget[][] getWidgets(); + + /** + * Gets an array of widgets that correspond to the passed group ID. + * + * @param groupId the group ID + * @return the widget group + * @see net.runelite.api.widgets.WidgetID + */ + RSWidget[] getGroup(int groupId); + + @Import("scene") + @Override + RSScene getScene(); + + @Import("localPlayer") + @Override + RSPlayer getLocalPlayer(); + + @Import("localPlayerIndex") + @Override + int getLocalPlayerIndex(); + + @Import("npcCount") + int getNpcIndexesCount(); + + @Import("npcIndices") + int[] getNpcIndices(); + + @Import("npcs") + @Override + RSNPC[] getCachedNPCs(); + + @Import("collisionMaps") + RSCollisionMap[] getCollisionMaps(); + + @Import("Players_count") + int getPlayerIndexesCount(); + + @Import("Players_indices") + int[] getPlayerIndices(); + + @Import("players") + @Override + RSPlayer[] getCachedPlayers(); + + @Import("combatTargetPlayerIndex") + int getLocalInteractingIndex(); + + @Import("groundItems") + RSNodeDeque[][][] getGroundItemDeque(); + + @Import("projectiles") + RSNodeDeque getProjectilesDeque(); + + @Import("graphicsObjects") + RSNodeDeque getGraphicsObjectDeque(); + + @Import("Login_username") + @Override + String getUsername(); + + @Import("Login_username") + @Override + void setUsername(String username); + + @Import("Login_password") + @Override + void setPassword(String password); + + @Import("otp") + @Override + void setOtp(String otp); + + @Import("currentLoginField") + @Override + int getCurrentLoginField(); + + @Import("loginIndex") + @Override + int getLoginIndex(); + + @Import("playerMenuActions") + @Override + String[] getPlayerOptions(); + + @Import("playerOptionsPriorities") + @Override + boolean[] getPlayerOptionsPriorities(); + + @Import("playerMenuOpcodes") + @Override + int[] getPlayerMenuTypes(); + + @Import("MouseHandler_xVolatile") + int getMouseX(); + + @Import("MouseHandler_yVolatile") + int getMouseY(); + + @Import("Scene_selectedScreenX") + int getMouseX2(); + + @Import("Scene_selectedScreenY") + int getMouseY2(); + + @Import("containsBounds") + boolean containsBounds(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7); + + @Import("checkClick") + boolean isCheckClick(); + + @Import("menuOptionsCount") + @Override + int getMenuOptionCount(); + + @Import("menuOptionsCount") + @Override + void setMenuOptionCount(int menuOptionCount); + + @Import("menuActions") + String[] getMenuOptions(); + + @Import("menuTargets") + String[] getMenuTargets(); + + @Import("menuIdentifiers") + int[] getMenuIdentifiers(); + + @Import("menuOpcodes") + int[] getMenuOpcodes(); + + @Import("menuArguments1") + int[] getMenuArguments1(); + + @Import("menuArguments2") + int[] getMenuArguments2(); + + @Import("menuShiftClick") + boolean[] getMenuForceLeftClick(); + + @Import("World_worlds") + @Override + RSWorld[] getWorldList(); + + @Import("addChatMessage") + void addChatMessage(int type, String name, String message, String sender); + + @Override + @Import("getObjectDefinition") + RSObjectDefinition getObjectDefinition(int objectId); + + @Override + @Import("getNpcDefinition") + RSNPCDefinition getNpcDefinition(int npcId); + + @Import("viewportZoom") + @Override + int getScale(); + + @Import("canvasHeight") + @Override + int getCanvasHeight(); + + @Import("canvasWidth") + @Override + int getCanvasWidth(); + + @Import("viewportHeight") + @Override + int getViewportHeight(); + + @Import("viewportWidth") + @Override + int getViewportWidth(); + + @Import("viewportOffsetX") + @Override + int getViewportXOffset(); + + @Import("viewportOffsetY") + @Override + int getViewportYOffset(); + + @Import("isResizable") + @Override + boolean isResized(); + + @Import("rootWidgetXs") + @Override + int[] getWidgetPositionsX(); + + @Import("rootWidgetYs") + @Override + int[] getWidgetPositionsY(); + + @Import("itemContainers") + RSNodeHashTable getItemContainers(); + + @Import("ItemDefinition_get") + @Override + RSItemDefinition getItemDefinition(int itemId); + + @Import("getItemSprite") + RSSprite createItemSprite(int itemId, int quantity, int thickness, int borderColor, int stackable, boolean noted); + + @Import("menuAction") + void sendMenuAction(int n2, int n3, int n4, int n5, String string, String string2, int n6, int n7); + + @Import("tempMenuAction") + RSMenuAction getTempMenuAction(); + + @Import("SpriteBuffer_decode") + void decodeSprite(byte[] data); + + @Import("SpriteBuffer_spriteCount") + int getIndexedSpriteCount(); + + @Import("SpriteBuffer_spriteWidth") + int getIndexedSpriteWidth(); + + @Import("SpriteBuffer_spriteHeight") + int getIndexedSpriteHeight(); + + @Import("SpriteBuffer_xOffsets") + int[] getIndexedSpriteOffsetXs(); + + @Import("SpriteBuffer_xOffsets") + void setIndexedSpriteOffsetXs(int[] indexedSpriteOffsetXs); + + @Import("SpriteBuffer_yOffsets") + int[] getIndexedSpriteOffsetYs(); + + @Import("SpriteBuffer_yOffsets") + void setIndexedSpriteOffsetYs(int[] indexedSpriteOffsetYs); + + @Import("SpriteBuffer_spriteWidths") + int[] getIndexedSpriteWidths(); + + @Import("SpriteBuffer_spriteWidths") + void setIndexedSpriteWidths(int[] indexedSpriteWidths); + + @Import("SpriteBuffer_spriteHeights") + int[] getIndexedSpriteHeights(); + + @Import("SpriteBuffer_spriteHeights") + void setIndexedSpriteHeights(int[] indexedSpriteHeights); + + @Import("SpriteBuffer_pixels") + byte[][] getSpritePixels(); + + @Import("SpriteBuffer_pixels") + void setSpritePixels(byte[][] spritePixels); + + @Import("SpriteBuffer_spritePalette") + int[] getIndexedSpritePalette(); + + @Import("SpriteBuffer_spritePalette") + void setIndexedSpritePalette(int[] indexedSpritePalette); + + @Import("archive6") + RSArchive getMusicTracks(); + + @Import("archive8") + @Override + RSArchive getIndexSprites(); + + @Import("archive12") + @Override + RSArchive getIndexScripts(); + + @Import("widgetClickMasks") + @Override + RSNodeHashTable getWidgetFlags(); + + @Import("interfaceParents") + @Override + RSNodeHashTable getComponentTable(); + + @Import("grandExchangeOffers") + RSGrandExchangeOffer[] getGrandExchangeOffers(); + + @Import("isMenuOpen") + @Override + boolean isMenuOpen(); + + @Import("cycle") + @Override + int getGameCycle(); + + // unused + //@Import("packetHandler") + //void packetHandler(); + + @Import("Messages_channels") + @Override + Map getChatLineMap(); + + @Import("Messages_hashTable") + @Override + RSIterableNodeHashTable getMessages(); + + @Import("RunException_revision") + @Override + int getRevision(); + + @Import("regions") + @Override + int[] getMapRegions(); + + @Import("instanceChunkTemplates") + @Override + int[][][] getInstanceTemplateChunks(); + + @Import("xteaKeys") + @Override + int[][] getXteaKeys(); + + @Import("gameDrawingMode") + @Override + int getGameDrawingMode(); + + @Import("gameDrawingMode") + @Override + void setGameDrawingMode(int gameDrawingMode); + + @Import("cycleCntr") + int getCycleCntr(); + + @Import("chatCycle") + void setChatCycle(int value); + + /** + * Get the widget top group. widgets[topGroup] contains widgets with + * parentId -1, which are the widget roots. + */ + @Import("rootInterface") + int getWidgetRoot(); + + @Import("WorldMapElement_cached") + @Override + RSWorldMapElement[] getMapElementConfigs(); + + @Import("mapSceneSprites") + @Override + RSIndexedSprite[] getMapScene(); + + @Import("mapIcons") + @Override + RSSprite[] getMapIcons(); + + @Import("mapDotSprites") + RSSprite[] getMapDots(); + + @Import("AbstractFont_modIconSprites") + @Override + RSIndexedSprite[] getModIcons(); + + @Import("AbstractFont_modIconSprites") + void setRSModIcons(RSIndexedSprite[] modIcons); + + @Construct + @Override + RSIndexedSprite createIndexedSprite(); + + @Construct + @Override + RSSprite createSprite(int[] pixels, int width, int height); + + @Import("destinationX") + int getDestinationX(); + + @Import("destinationY") + int getDestinationY(); + + @Import("soundEffects") + RSSoundEffect[] getAudioEffects(); + + @Import("soundEffectIds") + int[] getQueuedSoundEffectIDs(); + + @Import("soundLocations") + int[] getSoundLocations(); + + @Import("queuedSoundEffectLoops") + int[] getQueuedSoundEffectLoops(); + + @Import("queuedSoundEffectDelays") + int[] getQueuedSoundEffectDelays(); + + @Import("soundEffectCount") + int getQueuedSoundEffectCount(); + + @Import("soundEffectCount") + void setQueuedSoundEffectCount(int queuedSoundEffectCount); + + @Import("queueSoundEffect") + void queueSoundEffect(int id, int numLoops, int delay); + + @Import("rasterProvider") + @Override + RSAbstractRasterProvider getBufferProvider(); + + @Import("MouseHandler_idleCycles") + @Override + int getMouseIdleTicks(); + + @Import("MouseHandler_lastPressedTimeMillis") + @Override + long getMouseLastPressedMillis(); + + @Import("KeyHandler_idleCycles") + @Override + int getKeyboardIdleTicks(); + + @Import("KeyHandler_pressedKeys") + @Override + boolean[] getPressedKeys(); + + @Import("isLowDetail") + void setLowMemory(boolean lowMemory); + + @Import("Scene_isLowDetail") + void setSceneLowMemory(boolean lowMemory); + + @Import("PcmPlayer_stereo") + void setAudioHighMemory(boolean highMemory); + + @Import("ObjectDefinition_isLowDetail") + void setObjectDefinitionLowDetail(boolean lowDetail); + + @Import("Interpreter_intStackSize") + @Override + int getIntStackSize(); + + @Import("Interpreter_intStackSize") + @Override + void setIntStackSize(int stackSize); + + @Import("Interpreter_intStack") + @Override + int[] getIntStack(); + + @Import("Interpreter_stringStackSize") + @Override + int getStringStackSize(); + + @Import("Interpreter_stringStackSize") + @Override + void setStringStackSize(int stackSize); + + @Import("Interpreter_stringStack") + @Override + String[] getStringStack(); + + @Import("friendSystem") + RSFriendSystem getFriendManager(); + + @Import("clanChat") + RSClanChat getClanMemberManager(); + + @Import("loginType") + RSLoginType getLoginType(); + + @Construct + RSUsername createName(String name, RSLoginType type); + + @Import("getVarbit") + int getVarbit(int varbitId); + + @Import("VarbitDefinition_cached") + RSEvictingDualNodeHashTable getVarbitCache(); + + @Import("clientPreferences") + @Override + RSClientPreferences getPreferences(); + + /** + * This is the pitch the user has set the camera to. + * It should be between 128 and (pitchUnlimiter?512:383) JAUs(1). + * The difference between this and cameraPitch is that cameraPitch has a lower limit, imposed by the surrounding + * terrain. + * + * (1) JAU - Jagex Angle Unit; 1/1024 of a revolution + */ + @Import("camAngleX") + int getCameraPitchTarget(); + + @Import("camAngleX") + void setCameraPitchTarget(int pitch); + + @Import("Scene_cameraPitchSine") + void setPitchSin(int v); + + @Import("Scene_cameraPitchCosine") + void setPitchCos(int v); + + @Import("Scene_cameraYawSine") + void setYawSin(int v); + + @Import("Scene_cameraYawCosine") + void setYawCos(int v); + + @Import("Rasterizer3D_zoom") + @Override + int get3dZoom(); + + @Import("Rasterizer3D_zoom") + void set3dZoom(int zoom); + + @Import("Rasterizer3D_clipMidX2") + @Override + int getRasterizer3D_clipMidX2(); + + @Import("Rasterizer3D_clipNegativeMidX") + @Override + int getRasterizer3D_clipNegativeMidX(); + + @Import("Rasterizer3D_clipNegativeMidY") + @Override + int getRasterizer3D_clipNegativeMidY(); + + @Import("Rasterizer3D_clipMidY2") + @Override + int getRasterizer3D_clipMidY2(); + + @Import("Rasterizer3D_clipMidX") + @Override + int getCenterX(); + + @Import("Rasterizer3D_clipMidY") + @Override + int getCenterY(); + + @Import("getWorldMap") + RSWorldMap getRenderOverview(); + + @Import("changeWorld") + @Override + void changeWorld(World world); + + @Construct + @Override + RSWorld createWorld(); + + @Import("Model_transformTempX") + void setAnimOffsetX(int animOffsetX); + + @Import("Model_transformTempY") + void setAnimOffsetY(int animOffsetY); + + @Import("Model_transformTempZ") + void setAnimOffsetZ(int animOffsetZ); + + @Import("getFrames") + RSFrames getFrames(int frameId); + + @Import("sceneMinimapSprite") + RSSprite getMinimapSprite(); + + @Import("sceneMinimapSprite") + void setMinimapSprite(Sprite spritePixels); + + @Import("drawObject") + void drawObject(int z, int x, int y, int randomColor1, int randomColor2); + + @Construct + RSScriptEvent createScriptEvent(); + + @Import("runScript") + void runScript(RSScriptEvent ev, int ex); + + @Import("hintArrowType") + void setHintArrowTargetType(int value); + + @Import("hintArrowType") + int getHintArrowTargetType(); + + @Import("hintArrowX") + void setHintArrowX(int value); + + @Import("hintArrowX") + int getHintArrowX(); + + @Import("hintArrowY") + void setHintArrowY(int value); + + @Import("hintArrowY") + int getHintArrowY(); + + @Import("hintArrowSubX") + void setHintArrowOffsetX(int value); + + @Import("hintArrowSubY") + void setHintArrowOffsetY(int value); + + @Import("hintArrowNpcIndex") + void setHintArrowNpcTargetIdx(int value); + + @Import("hintArrowNpcIndex") + int getHintArrowNpcTargetIdx(); + + @Import("hintArrowPlayerIndex") + void setHintArrowPlayerTargetIdx(int value); + + @Import("hintArrowPlayerIndex") + int getHintArrowPlayerTargetIdx(); + + @Import("isInInstance") + @Override + boolean isInInstancedRegion(); + + @Import("itemDragDuration") + @Override + int getItemPressedDuration(); + + @Import("itemDragDuration") + void setItemPressedDuration(int duration); + + @Import("worldProperties") + int getFlags(); + + @Import("compass") + void setCompass(Sprite spritePixels); + + @Import("Widget_cachedSprites") + @Override + RSEvictingDualNodeHashTable getWidgetSpriteCache(); + + @Import("ItemDefinition_cached") + @Override + RSEvictingDualNodeHashTable getItemDefinitionCache(); + + @Import("oculusOrbState") + @Override + int getOculusOrbState(); + + @Import("oculusOrbState") + @Override + void setOculusOrbState(int state); + + @Import("oculusOrbNormalSpeed") + @Override + void setOculusOrbNormalSpeed(int state); + + @Import("oculusOrbFocalPointX") + @Override + int getOculusOrbFocalPointX(); + + @Import("oculusOrbFocalPointY") + @Override + int getOculusOrbFocalPointY(); + + RSTileItem getLastItemDespawn(); + + void setLastItemDespawn(RSTileItem lastItemDespawn); + + @Construct + RSWidget createWidget(); + + @Import("alignWidget") + void revalidateWidget(Widget w); + + @Import("revalidateWidgetScroll") + void revalidateWidgetScroll(Widget[] group, Widget w, boolean postEvent); + + @Import("ViewportMouse_entityCount") + int getEntitiesAtMouseCount(); + + @Import("ViewportMouse_entityCount") + void setEntitiesAtMouseCount(int i); + + @Import("ViewportMouse_entityTags") + long[] getEntitiesAtMouse(); + + @Import("ViewportMouse_x") + int getViewportMouseX(); + + @Import("ViewportMouse_y") + int getViewportMouseY(); + + @Import("textureProvider") + @Override + RSTextureProvider getTextureProvider(); + + @Import("tileLastDrawnActor") + int[][] getOccupiedTilesTick(); + + @Import("ObjectDefinition_cachedModels") + RSEvictingDualNodeHashTable getCachedModels2(); + + @Import("Scene_drawnCount") + int getCycle(); + + @Import("Scene_drawnCount") + void setCycle(int cycle); + + @Import("visibilityMap") + boolean[][][][] getVisibilityMaps(); + + @Import("visibleTiles") + void setRenderArea(boolean[][] renderArea); + + @Import("Scene_cameraX") + void setCameraX2(int cameraX2); + + @Import("Scene_cameraY") + void setCameraY2(int cameraY2); + + @Import("Scene_cameraZ") + void setCameraZ2(int cameraZ2); + + @Import("Scene_cameraXTile") + void setScreenCenterX(int screenCenterX); + + @Import("Scene_cameraYTile") + void setScreenCenterZ(int screenCenterZ); // <-- This is correct! + + @Import("Scene_plane") + void setScenePlane(int scenePlane); + + @Import("Scene_cameraXTileMin") + void setMinTileX(int i); + + @Import("Scene_cameraYTileMin") + void setMinTileZ(int i); // <-- This is correct! + + @Import("Scene_cameraXTileMax") + void setMaxTileX(int i); + + @Import("Scene_cameraYTileMax") + void setMaxTileZ(int i); // <-- This is correct! + + @Import("tileUpdateCount") + int getTileUpdateCount(); + + @Import("tileUpdateCount") + void setTileUpdateCount(int tileUpdateCount); + + @Import("ViewportMouse_isInViewport") + boolean getViewportContainsMouse(); + + @Import("Rasterizer2D_pixels") + int[] getGraphicsPixels(); + + @Import("Rasterizer2D_width") + int getGraphicsPixelsWidth(); + + @Import("Rasterizer2D_height") + int getGraphicsPixelsHeight(); + + @Import("Rasterizer2D_fillRectangle") + void rasterizerFillRectangle(int x, int y, int w, int h, int rgb); + + @Import("Rasterizer2D_xClipStart") + int getStartX(); + + @Import("Rasterizer2D_yClipStart") + int getStartY(); + + @Import("Rasterizer2D_xClipEnd") + int getEndX(); + + @Import("Rasterizer2D_yClipEnd") + int getEndY(); + + @Import("dragInventoryWidget") + @Override + RSWidget getIf1DraggedWidget(); + + @Import("dragItemSlotSource") + @Override + int getIf1DraggedItemIndex(); + + @Import("isSpellSelected") + @Override + void setSpellSelected(boolean selected); + + @Import("getEnum") + RSEnumDefinition getRsEnum(int id); + + @Import("menuX") + int getMenuX(); + + @Import("menuY") + int getMenuY(); + + @Import("menuHeight") + int getMenuHeight(); + + @Import("menuWidth") + int getMenuWidth(); + + @Import("fontBold12") + RSFont getFontBold12(); + + @Import("Rasterizer2D_drawHorizontalLine") + void rasterizerDrawHorizontalLine(int x, int y, int w, int rgb); + + @Import("Rasterizer2D_drawVerticalLine") + void rasterizerDrawVerticalLine(int x, int y, int h, int rgb); + + @Import("Rasterizer2D_fillRectangleGradient") + void rasterizerDrawGradient(int x, int y, int w, int h, int rgbTop, int rgbBottom); + + @Import("Rasterizer2D_fillRectangleAlpha") + void rasterizerFillRectangleAlpha(int x, int y, int w, int h, int rgb, int a); + + @Import("Rasterizer2D_drawRectangle") + void rasterizerDrawRectangle(int x, int y, int w, int h, int rgb); + + @Import("drawCircle") + void rasterizerDrawCircle(int x, int y, int r, int rgb); + + @Import("HealthBarDefinition_cached") + RSEvictingDualNodeHashTable getHealthBarCache(); + + @Import("HealthBarDefinition_cachedSprites") + RSEvictingDualNodeHashTable getHealthBarSpriteCache(); + + @Import("renderSelf") + @Override + boolean getRenderSelf(); + + @Import("renderSelf") + @Override + void setRenderSelf(boolean enabled); + + @Import("mouseRecorder") + RSMouseRecorder getMouseRecorder(); + + @Import("selectedSpellName") + String getSelectedSpellName(); + + @Import("selectedSpellName") + @Override + void setSelectedSpellName(String name); + + @Import("isSpellSelected") + boolean isSpellSelected(); + + @Import("readSoundEffect") + RSSoundEffect getTrack(RSAbstractArchive indexData, int id, int var0); + + @Import("createRawPcmStream") + RSRawPcmStream createRawPcmStream(RSRawSound audioNode, int var0, int volume); + + @Import("pcmStreamMixer") + RSPcmStreamMixer getSoundEffectAudioQueue(); + + @Import("archive4") + RSArchive getIndexCache4(); + + @Import("decimator") + RSDecimator getSoundEffectResampler(); + + @Import("musicVolume") + @Override + int getMusicVolume(); + + @Import("musicVolume") + void setClientMusicVolume(int volume); + + @Import("areaSoundEffectVolume") + @Override + int getAreaSoundEffectVolume(); + + @Import("areaSoundEffectVolume") + @Override + void setAreaSoundEffectVolume(int volume); + + @Import("soundEffectVolume") + @Override + int getSoundEffectVolume(); + + @Import("soundEffectVolume") + @Override + void setSoundEffectVolume(int volume); + + @Import("musicTrackVolume") + void setMusicTrackVolume(int volume); + + @Import("viewportWalking") + void setViewportWalking(boolean viewportWalking); + + @Import("playMusicTrack") + void playMusicTrack(RSAbstractArchive var0, int var1, int var2, int var3, boolean var4); + + @Import("midiPcmStream") + RSMidiPcmStream getMidiPcmStream(); + + @Import("currentTrackGroupId") + int getCurrentTrackGroupId(); + + @Import("crossSprites") + @Override + RSSprite[] getCrossSprites(); + + void setModulus(BigInteger modulus); + + @Import("ItemDefinition_fileCount") + int getItemCount(); + + @Import("insertMenuItem") + @Override + void insertMenuItem(String action, String target, int opcode, int identifier, int argument1, int argument2, boolean forceLeftClick); + + @Import("selectedItemId") + @Override + void setSelectedItemID(int id); + + @Import("selectedItemSlot") + @Override + void setSelectedItemSlot(int index); + + @Import("selectedItemWidget") + @Override + void setSelectedItemWidget(int widgetID); + + @Import("selectedSpellWidget") + @Override + int getSelectedSpellWidget(); + + @Import("selectedSpellChildIndex") + @Override + int getSelectedSpellChildIndex(); + + @Import("selectedSpellWidget") + @Override + void setSelectedSpellWidget(int widgetID); + + @Import("selectedSpellChildIndex") + @Override + void setSelectedSpellChildIndex(int index); + + @Import("Sprite_drawScaled") + @Override + void scaleSprite(int[] canvas, int[] pixels, int color, int pixelX, int pixelY, int canvasIdx, int canvasOffset, int newWidth, int newHeight, int pixelWidth, int pixelHeight, int oldWidth); + + /** + * This sets the login screen to where it asks for username/pass + */ + @Import("Login_promptCredentials") + void promptCredentials(boolean clearPass); + + @Import("VarpDefinition_get") + RSVarpDefinition getVarpDefinition(int id); + + @Construct + RSTileItem newTileItem(); + + @Construct + RSNodeDeque newNodeDeque(); + + @Import("updateItemPile") + void updateItemPile(int localX, int localY); +}