Class GameEngine

java.lang.Object
com.valhalla.sdk.api.GameEngine

public final class GameEngine extends Object
Compile-time API surface. Implementations are supplied by the Android payload.
  • Method Details

    • getLocalPlayer

      public static LocalPlayer getLocalPlayer()
      Returns the current local-player snapshot.
      Returns:
      the current local-player snapshot
    • getLocalSceneHeight

      public static OptionalInt getLocalSceneHeight()
      Returns the local player's interpolated terrain height.
      Returns:
      scene height, or empty when the active adapter cannot validate the renderer grid for this snapshot
    • getCapabilities

      public static Set<String> getCapabilities()
      Returns immutable names of features supported by the active native adapter.
      Returns:
      immutable names of features supported by the active native adapter
    • getCurrentWorld

      public static int getCurrentWorld()
      Returns the active world number, or -1 when unavailable.
      Returns:
      the active world number, or -1 when unavailable
    • getVarp

      public static OptionalInt getVarp(int varpId)
      Reads one client varp from the revision-validated native adapter.
      Parameters:
      varpId - non-negative client varp identifier
      Returns:
      the current value, or empty when varp state is unavailable
    • getPlayers

      public static List<Player> getPlayers()
      Returns visible player snapshots.
      Returns:
      visible player snapshots
    • getNpcs

      public static List<Npc> getNpcs()
      Returns visible NPC snapshots.
      Returns:
      visible NPC snapshots
    • getCurrentSkillLevel

      public static int getCurrentSkillLevel(int skillId)
      Reads a boost-aware skill level.
      Parameters:
      skillId - stable client skill identifier
      Returns:
      the current level
    • getRealSkillLevel

      public static int getRealSkillLevel(int skillId)
      Reads an unboosted skill level.
      Parameters:
      skillId - stable client skill identifier
      Returns:
      the real level
    • getSkillExperience

      public static int getSkillExperience(int skillId)
      Reads accumulated skill experience.
      Parameters:
      skillId - stable client skill identifier
      Returns:
      experience points
    • getGameObjects

      public static List<SceneObject> getGameObjects()
      Returns typed objects in the loaded scene.
      Returns:
      typed objects in the loaded scene
    • getGroundItems

      public static List<GroundItem> getGroundItems()
      Returns ground items in the loaded scene.
      Returns:
      ground items in the loaded scene
    • getInventoryItems

      public static List<Item> getInventoryItems()
      Returns items in occupied inventory slots.
      Returns:
      items in occupied inventory slots
    • getEquipmentItems

      public static List<Item> getEquipmentItems()
      Returns items in occupied equipment slots.
      Returns:
      items in occupied equipment slots
    • getWidgets

      public static List<Widget> getWidgets()
      Returns live widgets decoded by the active revision-pinned adapter.
      Returns:
      live widgets decoded by the active revision-pinned adapter
    • getWidgetSnapshots

      public static List<WidgetSnapshot> getWidgetSnapshots()
      Returns complete live-widget observations.

      Absent geometry stays absent and absent visibility stays unknown, and the adapter's ordered action slots and dynamic child index are retained.

      Returns:
      immutable snapshots in native enumeration order
    • getGameMessages

      public static List<GameMessage> getGameMessages()
      Returns game-message lines retained locally by the client.
      Throws:
      SecurityException - when the active package did not request game:read-messages
    • getCollisionMap

      public static Optional<CollisionMap> getCollisionMap()
      Returns the live collision map, or an empty value when it is unavailable.
      Returns:
      the live collision map, or an empty value when it is unavailable
    • getBankSnapshot

      public static BankSnapshot getBankSnapshot()
      Returns the most recent bank state and item snapshot.
      Returns:
      the most recent bank state and item snapshot
      Throws:
      SecurityException - when game:read-bank is not granted
    • bankAction

      public static boolean bankAction(String operation, int id, int amount, int slot, String text)
      Dispatches a bank operation.
      Parameters:
      operation - runtime bank-operation name
      id - target item identifier, or -1
      amount - requested amount
      slot - target slot, or -1
      text - optional operation text
      Returns:
      true when the runtime accepted the request
    • bankPinDigit

      public static boolean bankPinDigit(int digit)
      Queues one bank-PIN digit for native client-thread resolution.
      Parameters:
      digit - one decimal digit from 0 through 9
      Returns:
      true when the runtime accepted the bounded request
    • getSceneBase

      public static Tile getSceneBase()
      Returns the southwest tile of the loaded scene.
      Returns:
      the southwest tile of the loaded scene
    • isLoggedIn

      public static boolean isLoggedIn()
      Returns true when the native client reports an active game session.
      Returns:
      true when the native client reports an active game session
    • isInCombat

      public static boolean isInCombat()
      Returns whether the local player currently has a live combat target; false when the adapter cannot determine combat state.
      Returns:
      whether the local player currently has a live combat target; false when the adapter cannot determine combat state
    • getGameTickSequence

      public static long getGameTickSequence()
      Returns the latest 600 ms tick sequence emitted by the native client hook.
      Returns:
      the latest 600 ms tick sequence emitted by the native client hook
    • waitForNextTick

      public static long waitForNextTick(long afterSequence, long timeoutMs)
      Blocks the script thread until a later native 600 ms tick or a bounded timeout.
    • isActionReady

      public static boolean isActionReady()
      Returns true when the runtime can accept another native action.
      Returns:
      true when the runtime can accept another native action
    • isTileLoaded

      public static boolean isTileLoaded(Tile tile)
      Tests whether a tile is represented by the loaded scene.
      Parameters:
      tile - world tile to test
      Returns:
      true when the tile is loaded
    • interactObject

      public static boolean interactObject(int id, Tile tile, int action)
      Invokes a scene-object action.
      Parameters:
      id - object identifier
      tile - exact object tile
      action - zero-based menu-action index
      Returns:
      true when the runtime accepted the action
    • interactGroundItem

      public static boolean interactGroundItem(int id, Tile tile, int action)
      Invokes a ground-item action.
      Parameters:
      id - item identifier
      tile - exact item tile
      action - zero-based menu-action index
      Returns:
      true when the runtime accepted the action
    • interactNpc

      public static boolean interactNpc(int index, int action)
      Invokes an NPC action.
      Parameters:
      index - NPC scene index
      action - zero-based menu-action index
      Returns:
      true when the runtime accepted the action
    • walk

      public static boolean walk(Tile tile)
      Requests native movement toward a loaded tile.
      Parameters:
      tile - target world tile
      Returns:
      true when the runtime accepted the request
    • cancelWalk

      public static boolean cancelWalk()
      Cancels script-owned walking and replaces any active client route with a semantic native stop at the local player's current tile.
      Returns:
      true when the runtime accepted the cancellation
    • useFairyRing

      public static boolean useFairyRing(String code)
      Configures and activates a loaded fairy ring using semantic object and widget hooks. The player must already be beside a ring and must have a dramen/lunar staff equipped unless staffless travel is unlocked.
      Parameters:
      code - three-letter destination code, case-insensitive
      Returns:
      true when the runtime accepted the journey request
    • hopWorld

      public static boolean hopWorld(int world)
      Requests a world hop.
      Parameters:
      world - destination world number
      Returns:
      true when the runtime accepted the request
    • logout

      public static boolean logout()
      Returns true when the runtime accepted the logout request.
      Returns:
      true when the runtime accepted the logout request
    • openTab

      public static boolean openTab(int tab)
      Opens a top-level game tab.
      Parameters:
      tab - native tab code
      Returns:
      true when the runtime accepted the request
    • interactInventorySlot

      public static boolean interactInventorySlot(int slot)
      Invokes the default action for an inventory slot.
      Parameters:
      slot - zero-based inventory slot
      Returns:
      true when the runtime accepted the action
    • interactInventoryItem

      public static boolean interactInventoryItem(int itemId, int slot, int action)
      Invokes an action on an inventory item.
      Parameters:
      itemId - expected item identifier
      slot - zero-based inventory slot
      action - zero-based menu-action index
      Returns:
      true when the runtime accepted the action
    • interactInventoryItemAction

      public static boolean interactInventoryItemAction(int itemId, int slot, String action)
      Dispatches an exact live inventory menu action on the hooked client thread.
    • interactInventoryItemOnItem

      public static boolean interactInventoryItemOnItem(int sourceItemId, int sourceSlot, int targetItemId, int targetSlot)
      Atomically selects one exact inventory item and applies it to another.
    • interactInventoryItemOnObject

      public static boolean interactInventoryItemOnObject(int sourceItemId, int sourceSlot, int objectId, int worldX, int worldY, int plane)
      Atomically selects one exact inventory item and uses it on one exact scene object.
    • interactInventoryItemOnNpc

      public static boolean interactInventoryItemOnNpc(int sourceItemId, int sourceSlot, int npcId, int npcIndex)
      Atomically selects one exact inventory item and uses it on one exact NPC.
    • interactEquipmentSlot

      public static boolean interactEquipmentSlot(int slot)
      Invokes the default action for an equipment slot.
      Parameters:
      slot - native equipment-slot index
      Returns:
      true when the runtime accepted the action
    • cameraNorth

      public static boolean cameraNorth()
      Returns true when north-alignment was accepted.
      Returns:
      true when north-alignment was accepted
    • interactInventoryItemPrimaryAction

      public static boolean interactInventoryItemPrimaryAction(int itemId, int slot, String expectedAction)
      Dispatches an item's live primary option, validated against an expected label.
      Parameters:
      itemId - inventory item identifier
      slot - inventory slot
      expectedAction - label the primary option must carry
      Returns:
      true when the native queue accepted the request
    • interactComponent

      public static boolean interactComponent(int packedId, int childIndex, int operation, String target)
      Dispatches one component operation on an exact widget.
      Parameters:
      packedId - group << 16 | child
      childIndex - dynamic child index, or -1 for the component itself
      operation - 1-based operation slot of the component
      target - optional target text; may be empty
      Returns:
      true when the native queue accepted the request
    • interactWidget

      public static boolean interactWidget(WidgetSnapshot snapshot, String exactAction)
      Queues one exact label from a visible, fresh WidgetSnapshot. Native code re-resolves the widget and derives its action slot; callers cannot provide an opcode, coordinates, sprite identity, or slot.
    • castSpellOnNpc

      public static boolean castSpellOnNpc(WidgetSnapshot spell, Npc target)
      Queues one revision-pinned target spell on one current NPC. Native code revalidates the spell widget, its coherent live panel, and the NPC's exact index/definition/tile before owning the measured two-leg action. Callers cannot supply an opcode, slot, coordinate, sprite, or holder. Acceptance is not a hit or damage confirmation.
    • setRunEnabled

      public static boolean setRunEnabled(boolean enabled)
      Requests the enabled or disabled player run state.