Search in sources :

Example 26 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class ScriptVMMixin method runScript.

@Inject
@Override
public void runScript(int id, Object... args) {
    assert isClientThread();
    Object[] cargs = new Object[args.length + 1];
    cargs[0] = id;
    System.arraycopy(args, 0, cargs, 1, args.length);
    RSScriptEvent se = createScriptEvent();
    se.setArguments(cargs);
    runScript(se, 200000);
}
Also used : RSScriptEvent(net.runelite.rs.api.RSScriptEvent) Inject(net.runelite.api.mixins.Inject)

Example 27 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class ScriptVMMixin method vmExecuteOpcode.

// Call is injected into runScript by the ScriptVM raw injector
@Inject
static boolean vmExecuteOpcode(int opcode) {
    if (opcode == RUNELITE_EXECUTE) {
        assert currentScript.getInstructions()[currentScriptPC] == RUNELITE_EXECUTE;
        int stringStackSize = client.getStringStackSize();
        String stringOp = client.getStringStack()[--stringStackSize];
        client.setStringStackSize(stringStackSize);
        if ("debug".equals(stringOp)) {
            int intStackSize = client.getIntStackSize();
            String fmt = client.getStringStack()[--stringStackSize];
            StringBuffer out = new StringBuffer();
            Matcher m = Pattern.compile("%(.)").matcher(fmt);
            for (; m.find(); ) {
                m.appendReplacement(out, "");
                switch(m.group(1).charAt(0)) {
                    case 'i':
                    case 'd':
                        out.append(client.getIntStack()[--intStackSize]);
                        break;
                    case 's':
                        out.append(client.getStringStack()[--stringStackSize]);
                        break;
                    default:
                        out.append(m.group(0)).append("=unknown");
                }
            }
            m.appendTail(out);
            Hooks.log.debug(out.toString());
            client.setStringStackSize(stringStackSize);
            client.setIntStackSize(intStackSize);
            return true;
        }
        ScriptCallbackEvent event = new ScriptCallbackEvent();
        event.setScript(currentScript);
        event.setEventName(stringOp);
        Hooks.eventBus.post(event);
        return true;
    }
    return false;
}
Also used : Matcher(java.util.regex.Matcher) ScriptCallbackEvent(net.runelite.api.events.ScriptCallbackEvent) Inject(net.runelite.api.mixins.Inject)

Example 28 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSActorMixin method getInteracting.

@Inject
@Override
public Actor getInteracting() {
    int i = getRSInteracting();
    if (i == -1) {
        return null;
    }
    if (i < 0x8000) {
        NPC[] npcs = client.getCachedNPCs();
        return npcs[i];
    }
    i -= 0x8000;
    Player[] players = client.getCachedPlayers();
    return players[i];
}
Also used : NPC(net.runelite.api.NPC) Player(net.runelite.api.Player) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) WorldPoint(net.runelite.api.coords.WorldPoint) Inject(net.runelite.api.mixins.Inject)

Example 29 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSActorMixin method graphicChanged.

@FieldHook("graphic")
@Inject
public void graphicChanged(int idx) {
    GraphicChanged graphicChanged = new GraphicChanged();
    graphicChanged.setActor(this);
    eventBus.post(graphicChanged);
}
Also used : GraphicChanged(net.runelite.api.events.GraphicChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 30 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSPlayerMixin method getName.

@Inject
@Override
public String getName() {
    final RSName rsName = getRsName();
    if (rsName == null) {
        return null;
    }
    String name = rsName.getName();
    if (name == null) {
        return null;
    }
    return name.replace('\u00A0', ' ');
}
Also used : RSName(net.runelite.rs.api.RSName) Inject(net.runelite.api.mixins.Inject)

Aggregations

Inject (net.runelite.api.mixins.Inject)57 Point (net.runelite.api.Point)20 FieldHook (net.runelite.api.mixins.FieldHook)20 ArrayList (java.util.ArrayList)14 LocalPoint (net.runelite.api.coords.LocalPoint)10 RSWidget (net.runelite.rs.api.RSWidget)6 Vertex (net.runelite.api.model.Vertex)5 Widget (net.runelite.api.widgets.Widget)5 Node (net.runelite.api.Node)4 RSNode (net.runelite.rs.api.RSNode)4 WidgetNode (net.runelite.api.WidgetNode)3 Triangle (net.runelite.api.model.Triangle)3 Polygon (java.awt.Polygon)2 MenuEntry (net.runelite.api.MenuEntry)2 Model (net.runelite.api.Model)2 NPC (net.runelite.api.NPC)2 Player (net.runelite.api.Player)2 Skill (net.runelite.api.Skill)2 WidgetItem (net.runelite.api.widgets.WidgetItem)2 RSCombatInfoList (net.runelite.rs.api.RSCombatInfoList)2